Graphite  Version 3
An experimental 3D geometry processing program
dynamic_object.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_TYPES_DYNAMIC_OBJECT_H
38 #define H_OGF_META_TYPES_DYNAMIC_OBJECT_H
39 
40 #include <OGF/gom/common/common.h>
42 #include <OGF/gom/types/callable.h>
43 
49 namespace OGF {
50 
55  gom_class GOM_API DynamicObject : public Object {
56  public:
61  const std::string& name, const Any& value
62  ) override;
63 
68  const std::string& prop_name, Any& prop_value
69  ) const override;
70 
71  private:
72  mutable std::map<std::string, Any> properties_;
73  };
74 
75  /******************************************************************/
76 
77  class GOM_API DynamicFactoryMetaClass : public FactoryMetaClass {
78  public:
83  DynamicFactoryMetaClass(MetaClass* mclass, Callable* action = nullptr) :
84  FactoryMetaClass(mclass), action_(action) {
85  }
86 
90  Object* create(const ArgList& args) override;
91 
92  private:
93  Callable_var action_;
94  };
95 
96  /******************************************************************/
97 
101  gom_class GOM_API DynamicMetaSlot : public MetaSlot {
102  public:
113  const std::string& name, MetaClass* container,
114  Callable* action,
115  const std::string& return_type_name = "void"
116  );
117 
118  gom_slots:
125  void add_arg(
126  const std::string& name, MetaType* type,
127  const std::string& default_value = ""
128  );
129 
137  const std::string& name, const std::string& default_value
138  );
139 
148  const std::string& arg_name,
149  const std::string& name, const std::string& value
150  );
151 
159  const std::string& arg_name,
160  const std::string& name, const std::string& value
161  );
162 
163  public:
164  void pre_delete() override;
165 
166  protected:
167  Callable_var action_;
168  };
169 
174  gom_class GOM_API DynamicMetaClass : public MetaClass {
175  public:
185  const std::string& class_name,
186  const std::string& super_class_name,
187  bool is_abstract = false
188  );
189 
190  gom_slots:
191 
200  MetaConstructor* add_constructor(Callable* action=nullptr);
201 
212  const std::string& name, Callable* action,
213  const std::string& return_type="void"
214  );
215  };
216 
217 }
218 
219 #endif
220 
221 
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
A Callable object.
Definition: callable.h:50
DynamicFactoryMetaClass(MetaClass *mclass, Callable *action=nullptr)
FactoryMetaClass constructor.
Object * create(const ArgList &args) override
Creates an objet.
A MetaClass that can be created in Lua.
DynamicMetaClass(const std::string &class_name, const std::string &super_class_name, bool is_abstract=false)
Constructs a new DynamicMetaClass.
DynamicMetaSlot * add_slot(const std::string &name, Callable *action, const std::string &return_type="void")
Creates a new slot.
A slot in a dynamically-created class.
void pre_delete() override
Removes all variables that use the meta type system before deleting.
void set_arg_default_value(const std::string &name, const std::string &default_value)
Sets the default value for an arg.
void set_arg_custom_attribute(const std::string &arg_name, const std::string &name, const std::string &value)
Sets a custom attribute.
DynamicMetaSlot(const std::string &name, MetaClass *container, Callable *action, const std::string &return_type_name="void")
DynamicMetaSlot constructor.
void create_arg_custom_attribute(const std::string &arg_name, const std::string &name, const std::string &value)
Creates a new custom attribute.
An object with a class that can be created in Lua.
bool set_property(const std::string &name, const Any &value) override
Sets an individual property.
bool get_property(const std::string &prop_name, Any &prop_value) const override
Gets a property.
A Factory that uses a MetaClass.
Definition: meta_class.h:538
The representation of a class in the Meta repository.
Definition: meta_class.h:64
The representation of a constructor in the Meta repository.
The representation of a slot in the Meta repository.
Definition: meta_slot.h:55
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
MetaType for classes.
Global Graphite namespace.
Definition: common.h:76
Definitions common to all include files in the gom library.