diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llcommon/metapropertyt.h | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llcommon/metapropertyt.h')
-rw-r--r-- | linden/indra/llcommon/metapropertyt.h | 184 |
1 files changed, 184 insertions, 0 deletions
diff --git a/linden/indra/llcommon/metapropertyt.h b/linden/indra/llcommon/metapropertyt.h new file mode 100644 index 0000000..6633975 --- /dev/null +++ b/linden/indra/llcommon/metapropertyt.h | |||
@@ -0,0 +1,184 @@ | |||
1 | /** | ||
2 | * @file metapropertyt.h | ||
3 | * | ||
4 | * Copyright (c) 2006-2007, Linden Research, Inc. | ||
5 | * | ||
6 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
7 | * to you under the terms of the GNU General Public License, version 2.0 | ||
8 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
9 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
10 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
11 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
12 | * | ||
13 | * There are special exceptions to the terms and conditions of the GPL as | ||
14 | * it is applied to this Source Code. View the full text of the exception | ||
15 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
16 | * online at http://secondlife.com/developers/opensource/flossexception | ||
17 | * | ||
18 | * By copying, modifying or distributing this software, you acknowledge | ||
19 | * that you have read and understood your obligations described above, | ||
20 | * and agree to abide by those obligations. | ||
21 | * | ||
22 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
23 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
24 | * COMPLETENESS OR PERFORMANCE. | ||
25 | */ | ||
26 | |||
27 | #ifndef LL_METAPROPERTYT_H | ||
28 | #define LL_METAPROPERTYT_H | ||
29 | |||
30 | #include "llsd.h" | ||
31 | #include "llstring.h" | ||
32 | #include "metaclasst.h" | ||
33 | #include "metaproperty.h" | ||
34 | #include "reflectivet.h" | ||
35 | |||
36 | template<class TProperty> | ||
37 | class LLMetaPropertyT : public LLMetaProperty | ||
38 | { | ||
39 | public: | ||
40 | |||
41 | virtual ~LLMetaPropertyT() {;} | ||
42 | |||
43 | // Get value of this property. Gives ownership of returned value. | ||
44 | virtual const LLReflective* get(const LLReflective* object) const | ||
45 | { | ||
46 | checkObjectClass(object); | ||
47 | return getProperty(object); | ||
48 | } | ||
49 | |||
50 | // Set value of this property. | ||
51 | /*virtual void set(LLReflective* object, const LLReflective* value) | ||
52 | { | ||
53 | // TODO: Babbage: Check types. | ||
54 | ref(object) = static_cast<const LLReflectiveT<TProperty>* >(value)->getValue(); | ||
55 | }*/ | ||
56 | |||
57 | // Get value of this property as LLSD. | ||
58 | virtual LLSD getLLSD(const LLReflective* object) const | ||
59 | { | ||
60 | return LLSD(); | ||
61 | } | ||
62 | |||
63 | protected: | ||
64 | |||
65 | LLMetaPropertyT(const std::string& name, const LLMetaClass& object_class) : LLMetaProperty(name, object_class) {;} | ||
66 | |||
67 | virtual const TProperty* getProperty(const LLReflective* object) const = 0; | ||
68 | }; | ||
69 | |||
70 | template <> | ||
71 | inline const LLReflective* LLMetaPropertyT<S32>::get(const LLReflective* object) const | ||
72 | { | ||
73 | checkObjectClass(object); | ||
74 | return NULL; | ||
75 | } | ||
76 | |||
77 | template <> | ||
78 | inline const LLReflective* LLMetaPropertyT<std::string>::get(const LLReflective* object) const | ||
79 | { | ||
80 | checkObjectClass(object); | ||
81 | return NULL; | ||
82 | } | ||
83 | |||
84 | template <> | ||
85 | inline const LLReflective* LLMetaPropertyT<LLString>::get(const LLReflective* object) const | ||
86 | { | ||
87 | checkObjectClass(object); | ||
88 | return NULL; | ||
89 | } | ||
90 | |||
91 | template <> | ||
92 | inline const LLReflective* LLMetaPropertyT<LLUUID>::get(const LLReflective* object) const | ||
93 | { | ||
94 | checkObjectClass(object); | ||
95 | return NULL; | ||
96 | } | ||
97 | |||
98 | template <> | ||
99 | inline LLSD LLMetaPropertyT<S32>::getLLSD(const LLReflective* object) const | ||
100 | { | ||
101 | return *(getProperty(object)); | ||
102 | } | ||
103 | |||
104 | template <> | ||
105 | inline LLSD LLMetaPropertyT<std::string>::getLLSD(const LLReflective* object) const | ||
106 | { | ||
107 | return *(getProperty(object)); | ||
108 | } | ||
109 | |||
110 | template <> | ||
111 | inline LLSD LLMetaPropertyT<LLString>::getLLSD(const LLReflective* object) const | ||
112 | { | ||
113 | return *(getProperty(object)); | ||
114 | } | ||
115 | |||
116 | template <> | ||
117 | inline LLSD LLMetaPropertyT<LLUUID>::getLLSD(const LLReflective* object) const | ||
118 | { | ||
119 | return *(getProperty(object)); | ||
120 | } | ||
121 | |||
122 | template<class TObject, class TProperty> | ||
123 | class LLMetaPropertyTT : public LLMetaPropertyT<TProperty> | ||
124 | { | ||
125 | public: | ||
126 | |||
127 | LLMetaPropertyTT(const std::string& name, const LLMetaClass& object_class, TProperty (TObject::*property)) : | ||
128 | LLMetaPropertyT<TProperty>(name, object_class), mProperty(property) {;} | ||
129 | |||
130 | protected: | ||
131 | |||
132 | // Get void* to property. | ||
133 | virtual const TProperty* getProperty(const LLReflective* object) const | ||
134 | { | ||
135 | const TObject* typed_object = static_cast<const TObject*>(object); | ||
136 | return &(typed_object->*mProperty); | ||
137 | }; | ||
138 | |||
139 | private: | ||
140 | |||
141 | TProperty (TObject::*mProperty); | ||
142 | }; | ||
143 | |||
144 | template<class TObject, class TProperty> | ||
145 | class LLMetaPropertyPtrTT : public LLMetaPropertyT<TProperty> | ||
146 | { | ||
147 | public: | ||
148 | |||
149 | LLMetaPropertyPtrTT(const std::string& name, const LLMetaClass& object_class, TProperty* (TObject::*property)) : | ||
150 | LLMetaPropertyT<TProperty>(name, object_class), mProperty(property) {;} | ||
151 | |||
152 | protected: | ||
153 | |||
154 | // Get void* to property. | ||
155 | virtual const TProperty* getProperty(const LLReflective* object) const | ||
156 | { | ||
157 | const TObject* typed_object = static_cast<const TObject*>(object); | ||
158 | return typed_object->*mProperty; | ||
159 | }; | ||
160 | |||
161 | private: | ||
162 | |||
163 | TProperty* (TObject::*mProperty); | ||
164 | }; | ||
165 | |||
166 | // Utility function to simplify the registration of members. | ||
167 | template<class TObject, class TProperty> | ||
168 | void reflectProperty(LLMetaClass& meta_class, const std::string& name, TProperty (TObject::*property)) | ||
169 | { | ||
170 | typedef LLMetaPropertyTT<TObject, TProperty> PropertyType; | ||
171 | const LLMetaProperty* meta_property = new PropertyType(name, meta_class, property); | ||
172 | meta_class.addProperty(meta_property); | ||
173 | } | ||
174 | |||
175 | // Utility function to simplify the registration of ptr properties. | ||
176 | template<class TObject, class TProperty> | ||
177 | void reflectPtrProperty(LLMetaClass& meta_class, const std::string& name, TProperty* (TObject::*property)) | ||
178 | { | ||
179 | typedef LLMetaPropertyPtrTT<TObject, TProperty> PropertyType; | ||
180 | const LLMetaProperty* meta_property = new PropertyType(name, meta_class, property); | ||
181 | meta_class.addProperty(meta_property); | ||
182 | } | ||
183 | |||
184 | #endif // LL_METAPROPERTYT_H | ||