aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llplugin/llpluginsharedmemory.h
diff options
context:
space:
mode:
authorArmin Weatherwax2010-06-14 12:04:49 +0200
committerArmin Weatherwax2010-09-23 15:38:25 +0200
commit35df5441d3e2789663532c948731aff3a1e04728 (patch)
treeac7674289784a5f96106ea507637055a8dada78a /linden/indra/llplugin/llpluginsharedmemory.h
parentChanged version to Experimental 2010.09.18 (diff)
downloadmeta-impy-35df5441d3e2789663532c948731aff3a1e04728.zip
meta-impy-35df5441d3e2789663532c948731aff3a1e04728.tar.gz
meta-impy-35df5441d3e2789663532c948731aff3a1e04728.tar.bz2
meta-impy-35df5441d3e2789663532c948731aff3a1e04728.tar.xz
llmediaplugins first step
Diffstat (limited to 'linden/indra/llplugin/llpluginsharedmemory.h')
-rw-r--r--linden/indra/llplugin/llpluginsharedmemory.h130
1 files changed, 130 insertions, 0 deletions
diff --git a/linden/indra/llplugin/llpluginsharedmemory.h b/linden/indra/llplugin/llpluginsharedmemory.h
new file mode 100644
index 0000000..2dc550e
--- /dev/null
+++ b/linden/indra/llplugin/llpluginsharedmemory.h
@@ -0,0 +1,130 @@
1/**
2 * @file llpluginsharedmemory.h
3 * @brief LLPluginSharedMemory manages a shared memory segment for use by the LLPlugin API.
4 *
5 * $LicenseInfo:firstyear=2008&license=viewergpl$
6 *
7 * Copyright (c) 2008-2009, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
22 *
23 * By copying, modifying or distributing this software, you acknowledge
24 * that you have read and understood your obligations described above,
25 * and agree to abide by those obligations.
26 *
27 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
28 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
29 * COMPLETENESS OR PERFORMANCE.
30 * $/LicenseInfo$
31 */
32
33#ifndef LL_LLPLUGINSHAREDMEMORY_H
34#define LL_LLPLUGINSHAREDMEMORY_H
35
36class LLPluginSharedMemoryPlatformImpl;
37
38/**
39 * @brief LLPluginSharedMemory manages a shared memory segment for use by the LLPlugin API.
40 *
41 */
42class LLPluginSharedMemory
43{
44 LOG_CLASS(LLPluginSharedMemory);
45public:
46 LLPluginSharedMemory();
47 ~LLPluginSharedMemory();
48
49 // Parent will use create/destroy, child will use attach/detach.
50 // Message transactions will ensure child attaches after parent creates and detaches before parent destroys.
51
52 /**
53 * Creates a shared memory segment, with a name which is guaranteed to be unique on the host at the current time. Used by parent.
54 * Message transactions will (? TODO:DOC - should? must?) ensure child attaches after parent creates and detaches before parent destroys.
55 *
56 * @param[in] size Shared memory size in TODO:DOC units = bytes?.
57 *
58 * @return False for failure, true for success.
59 */
60 bool create(size_t size);
61 /**
62 * Destroys a shared memory segment. Used by parent.
63 * Message transactions will (? TODO:DOC - should? must?) ensure child attaches after parent creates and detaches before parent destroys.
64 *
65 * @return True. TODO:DOC - always returns true. Is this the intended behavior?
66 */
67 bool destroy(void);
68
69 /**
70 * Creates and attaches a name to a shared memory segment. TODO:DOC what's the difference between attach() and create()?
71 *
72 * @param[in] name Name to attach to memory segment
73 * @param[in] size Size of memory segment TODO:DOC in bytes?
74 *
75 * @return False on failure, true otherwise.
76 */
77 bool attach(const std::string &name, size_t size);
78 /**
79 * Detaches shared memory segment.
80 *
81 * @return False on failure, true otherwise.
82 */
83 bool detach(void);
84
85 /**
86 * Checks if shared memory is mapped to a non-null address.
87 *
88 * @return True if memory address is non-null, false otherwise.
89 */
90 bool isMapped(void) const { return (mMappedAddress != NULL); };
91 /**
92 * Get pointer to shared memory.
93 *
94 * @return Pointer to shared memory.
95 */
96 void *getMappedAddress(void) const { return mMappedAddress; };
97 /**
98 * Get size of shared memory.
99 *
100 * @return Size of shared memory in bytes. TODO:DOC are bytes the correct unit?
101 */
102 size_t getSize(void) const { return mSize; };
103 /**
104 * Get name of shared memory.
105 *
106 * @return Name of shared memory.
107 */
108 std::string getName() const { return mName; };
109
110private:
111 bool map(void);
112 bool unmap(void);
113 bool close(void);
114 bool unlink(void);
115
116 std::string mName;
117 size_t mSize;
118 void *mMappedAddress;
119 bool mNeedsDestroy;
120
121 LLPluginSharedMemoryPlatformImpl *mImpl;
122
123 static int sSegmentNumber;
124 static std::string createName();
125
126};
127
128
129
130#endif // LL_LLPLUGINSHAREDMEMORY_H