Graphite  Version 3
An experimental 3D geometry processing program
meta_property.h
Go to the documentation of this file.
1 /*
2  * GXML/Graphite: Geometry and Graphics Programming Library + Utilities
3  * Copyright (C) 2000 Bruno Levy
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  *
19  * If you modify this software, you should include a notice giving the
20  * name of the person performing the modification, the date of modification,
21  * and the reason for such modification.
22  *
23  * Contact: Bruno Levy
24  *
25  * levy@loria.fr
26  *
27  * ISA Project
28  * LORIA, INRIA Lorraine,
29  * Campus Scientifique, BP 239
30  * 54506 VANDOEUVRE LES NANCY CEDEX
31  * FRANCE
32  *
33  * Note that the GNU General Public License does not permit incorporating
34  * the Software into proprietary programs.
35  */
36 
37 #ifndef H_OGF_META_MEMBERS_META_PROPERTY_H
38 #define H_OGF_META_MEMBERS_META_PROPERTY_H
39 
40 #include <OGF/gom/common/common.h>
43 
49 namespace OGF {
50 
51  class Object ;
52  class MetaProperty ;
53 
58  gom_class GOM_API MetaMethodSetProperty : public MetaMethod {
59  public:
60 
67  const std::string& name, MetaProperty* property
68  ) ;
69 
74 
81  virtual bool invoke(
82  Object* target, const ArgList& args, Any& return_value
83  ) ;
84 
90  return property_ ;
91  }
92 
93  private:
94  MetaProperty* property_ ;
95  } ;
96 
101  gom_class GOM_API MetaMethodGetProperty : public MetaMethod {
102  public:
103 
110  const std::string& name, MetaProperty* property
111  ) ;
112 
117 
124  virtual bool invoke(
125  Object* target, const ArgList& args, Any& return_value
126  ) ;
127 
133  return property_ ;
134  }
135 
136  private:
137  MetaProperty* property_ ;
138  } ;
139 
140 /****************************************************************/
141 
145  gom_class GOM_API MetaProperty : public MetaMember {
146  public:
147 
156  const std::string& name, MetaClass* container,
157  const std::string& type_name,
158  bool read_only = false
159  ) ;
160 
169  const std::string& name, MetaClass* container,
170  MetaType* meta_type,
171  bool read_only = false
172  ) ;
173 
177  virtual ~MetaProperty() ;
178 
179  gom_slots:
180 
186  bool read_only() const {
187  return read_only_ ;
188  }
189 
194  const std::string& type_name() const {
195  return type_name_ ;
196  }
197 
202  MetaType* type() const ;
203 
209  virtual bool set_value(Object* target, const std::string& value) ;
210 
216  virtual bool get_value(const Object* target, std::string& value) ;
217 
218  public:
219 
225  virtual bool set_value(Object* target, const Any& value) ;
226 
232  virtual bool get_value(const Object* target, Any& value) ;
233 
234 
240  void set_read_only(bool x) ;
241 
242 
248  return meta_method_get_ ;
249  }
250 
256  return meta_method_set_ ;
257  }
258 
265  meta_method_get_ = getter ;
266  }
267 
274  meta_method_set_ = setter ;
275  }
276 
277  protected:
283  void set_type_name(const std::string& type_name_in) {
284  type_name_ = type_name_in ;
285  }
286 
287  private:
288  std::string type_name_ ;
289  bool read_only_ ;
290  MetaMethod_var meta_method_get_ ;
291  MetaMethod_var meta_method_set_ ;
292  } ;
293 
298 
299 //______________________________________________________
300 
301 }
302 #endif
303 
A class that stores a variable of arbitrary type.
Definition: any.h:62
Represents a list of name-value pairs.
Definition: arg_list.h:65
The representation of a class in the Meta repository.
Definition: meta_class.h:64
The base class for class members in the Meta repository.
Definition: meta_member.h:56
A MetaMethod that corresponds to the getter of a property.
virtual ~MetaMethodGetProperty()
MetaMethodGetProperty destructor.
MetaMethodGetProperty(const std::string &name, MetaProperty *property)
MetaMethodGetProperty constructor.
MetaProperty * property() const
Gets the MetaProperty.
virtual bool invoke(Object *target, const ArgList &args, Any &return_value)
Invokes the getter on a target object.
A MetaMethod that corresponds to the setter of a property.
Definition: meta_property.h:58
virtual bool invoke(Object *target, const ArgList &args, Any &return_value)
Invokes the setter on a target object.
MetaProperty * property() const
Gets the MetaProperty.
Definition: meta_property.h:89
virtual ~MetaMethodSetProperty()
MetaMethodSetProperty destructor.
MetaMethodSetProperty(const std::string &name, MetaProperty *property)
MetaMethodSetProperty constructor.
The representation of a method in the Meta repository.
Definition: meta_method.h:72
The representation of a property in the Meta repository.
void set_read_only(bool x)
Specify whether this MetaProperty is read only.
MetaProperty(const std::string &name, MetaClass *container, MetaType *meta_type, bool read_only=false)
MetaProperty constructor.
const std::string & type_name() const
Gets the type name.
MetaType * type() const
Gets the type.
MetaMethod * meta_method_set()
Gets the setter.
MetaProperty(const std::string &name, MetaClass *container, const std::string &type_name, bool read_only=false)
MetaProperty constructor.
virtual ~MetaProperty()
MetaProperty destructor.
virtual bool get_value(const Object *target, Any &value)
Gets the value of this property from a target object.
virtual bool set_value(Object *target, const Any &value)
Sets the value of this property in a target object.
void set_type_name(const std::string &type_name_in)
Sets the type name of this property.
virtual bool get_value(const Object *target, std::string &value)
Gets the value of this property from a target object.
virtual bool set_value(Object *target, const std::string &value)
Sets the value of this property in a target object.
MetaMethod * meta_method_get()
Gets the getter.
void set_meta_method_get(MetaMethod *getter)
Sets the getter.
void set_meta_method_set(MetaMethod *setter)
Sets the setter.
The representation of a type in the Meta repository.
Definition: meta_type.h:221
Base class for all objects in the GOM system.
Definition: object.h:65
Meta-information attached to class members.
Meta-information attached to class methods.
Global Graphite namespace.
Definition: common.h:76
SmartPointer< MetaProperty > MetaProperty_var
Automatic reference-counted pointer to a MetaProperty.
Definitions common to all include files in the gom library.