guit  0.1
 All Classes Functions Variables Typedefs Enumerations Friends
gobjectbase.hpp
1 //
2 // Base of GObjects (useful for srcipts among other things)
3 // Guit GUI Toolkit
4 // Copyright © 2019/2020 Eric Lecolinet. All rights reserved.
5 // http://www.telecom-paris.fr/~elc
6 //
7 
8 #ifndef Guit_ObjectBase_hpp
9 #define Guit_ObjectBase_hpp
10 #include <map>
11 #include <gobject.hpp>
12 #include <gptr.hpp>
13 namespace guit {
14 
15 class GObjectBase {
16 public:
17  enum Status{InvalidName = -1, NameExists = 0, OK = 1};
18 
19  GObjectBase();
20  ~GObjectBase();
21 
23  static void loadGadgetClasses();
24 
30  Status add(GString const& name, GObject&);
32 
37  Status add(GString const& name, GFunction const& function);
38 
41  GObject* getObject(GString const& name);
42  Gadget* getGadget(GString const& name);
43  GBox* getBox(GString const& name);
44  GProp* getProp(GString const& name);
46 
47  void printObjects(std::ostream&);
48 
51  using Map = std::map<GString,gptr<GObject>>;
52  Map map_;
54 };
55 
56 
58 class GFunctionWrapper : public GObject {
59 public:
60  GFunctionWrapper(GFunction const& fun) : fun(fun) {}
61  virtual GString typeName() const override;
62  GFunction fun;
63 };
64 
65 }
66 #endif