Graphite  Version 3
An experimental 3D geometry processing program
callable.h
1 /*
2  * 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_GOM_TYPES_CALLABLE_H
38 #define H_OGF_GOM_TYPES_CALLABLE_H
39 
40 #include <OGF/gom/common/common.h>
42 
43 namespace OGF {
44 
49  gom_attribute(abstract,"true")
50  gom_class GOM_API Callable : public Object {
51  public:
52 
57 
61  ~Callable() override;
62 
71  virtual bool invoke(const ArgList& args, Any& ret_val) = 0;
72 
80  bool invoke(const ArgList& args) {
81  Any ret_val;
82  return invoke(args, ret_val);
83  }
84 
92  bool invoke() {
93  ArgList args;
94  Any ret_val;
95  return invoke(args, ret_val);
96  }
97  };
98 
103 
104  /**********************************************************************/
105 
110  gom_class GOM_API Request : public Callable {
111  public:
120  Object* o, MetaMethod* m, bool managed = true
121  );
122 
126  ~Request() override;
127 
131  bool invoke(const ArgList& args, Any& ret_val) override;
132 
133 
137  std::string get_doc() const override;
138 
139  gom_slots:
140 
145  Object* object() const {
146  return object_;
147  }
148 
154  MetaMethod* method() const {
155  return method_;
156  }
157 
158  private:
162  Request(const Request& rhs);
163 
167  Request& operator=(const Request& rhs);
168 
169  private:
170  Object* object_;
171  MetaMethod* method_;
172  bool managed_;
173  };
174 
175 
180 
181  /**********************************************************************/
182 
183 }
184 
185 #endif
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
Callable()
Callable constructor.
virtual bool invoke(const ArgList &args, Any &ret_val)=0
Invokes a method with an argument list, and gets the return value.
bool invoke(const ArgList &args)
Invokes a method by method name and argument list.
Definition: callable.h:80
~Callable() override
Callable destructor.
bool invoke()
Invokes a method by method name.
Definition: callable.h:92
The representation of a method in the Meta repository.
Definition: meta_method.h:72
Base class for all objects in the GOM system.
Definition: object.h:65
A pointer to an object and to a meta-method of that object (a very limited notion of "closure").
Definition: callable.h:110
bool invoke(const ArgList &args, Any &ret_val) override
Invokes a method by method name.
~Request() override
Request destructor.
MetaMethod * method() const
Gets the method to be invoked.
Definition: callable.h:154
std::string get_doc() const override
Gets the documentation.
Request(Object *o, MetaMethod *m, bool managed=true)
Request constructor.
MetaType for classes.
Global Graphite namespace.
Definition: common.h:76
SmartPointer< Callable > Callable_var
A reference-counted pointer to a Callable.
Definition: callable.h:102
SmartPointer< Request > Request_var
A reference-counted pointer to a Request.
Definition: callable.h:179
Definitions common to all include files in the gom library.