aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcommon/metapropertyt.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llcommon/metapropertyt.h
parentREADME.txt (diff)
downloadmeta-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.h184
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
36template<class TProperty>
37class LLMetaPropertyT : public LLMetaProperty
38{
39public:
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
63protected:
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
70template <>
71inline const LLReflective* LLMetaPropertyT<S32>::get(const LLReflective* object) const
72{
73 checkObjectClass(object);
74 return NULL;
75}
76
77template <>
78inline const LLReflective* LLMetaPropertyT<std::string>::get(const LLReflective* object) const
79{
80 checkObjectClass(object);
81 return NULL;
82}
83
84template <>
85inline const LLReflective* LLMetaPropertyT<LLString>::get(const LLReflective* object) const
86{
87 checkObjectClass(object);
88 return NULL;
89}
90
91template <>
92inline const LLReflective* LLMetaPropertyT<LLUUID>::get(const LLReflective* object) const
93{
94 checkObjectClass(object);
95 return NULL;
96}
97
98template <>
99inline LLSD LLMetaPropertyT<S32>::getLLSD(const LLReflective* object) const
100{
101 return *(getProperty(object));
102}
103
104template <>
105inline LLSD LLMetaPropertyT<std::string>::getLLSD(const LLReflective* object) const
106{
107 return *(getProperty(object));
108}
109
110template <>
111inline LLSD LLMetaPropertyT<LLString>::getLLSD(const LLReflective* object) const
112{
113 return *(getProperty(object));
114}
115
116template <>
117inline LLSD LLMetaPropertyT<LLUUID>::getLLSD(const LLReflective* object) const
118{
119 return *(getProperty(object));
120}
121
122template<class TObject, class TProperty>
123class LLMetaPropertyTT : public LLMetaPropertyT<TProperty>
124{
125public:
126
127 LLMetaPropertyTT(const std::string& name, const LLMetaClass& object_class, TProperty (TObject::*property)) :
128 LLMetaPropertyT<TProperty>(name, object_class), mProperty(property) {;}
129
130protected:
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
139private:
140
141 TProperty (TObject::*mProperty);
142};
143
144template<class TObject, class TProperty>
145class LLMetaPropertyPtrTT : public LLMetaPropertyT<TProperty>
146{
147public:
148
149 LLMetaPropertyPtrTT(const std::string& name, const LLMetaClass& object_class, TProperty* (TObject::*property)) :
150 LLMetaPropertyT<TProperty>(name, object_class), mProperty(property) {;}
151
152protected:
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
161private:
162
163 TProperty* (TObject::*mProperty);
164};
165
166// Utility function to simplify the registration of members.
167template<class TObject, class TProperty>
168void 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.
176template<class TObject, class TProperty>
177void 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