Free Electron
LuaIterate.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __lua_LuaIterate_h__
8 #define __lua_LuaIterate_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 /** lua execution component. Can also operate as a handler.
16 
17  @copydoc LuaIterate_info
18  */
19 class LuaIterate : public Initialize<LuaIterate>,
20  virtual public Dispatch,
21  virtual public HandlerI,
22  virtual public LuaI,
23  virtual public Config
24 {
25  public:
26  LuaIterate(void);
27 virtual ~LuaIterate(void);
28 
29  void initialize(void);
30 
31  // AS LuaI
32 virtual bool preloadString(const String &text) { return false; }
33 virtual Result loadFile(const String &filename);
34 virtual Result loadString(const String &text);
35 
36 virtual void set(const String &key, Record r_value);
37 virtual void set(const String &key, sp<RecordArray> ra_value);
38 virtual void set(const String &key, sp<RecordGroup> rg_value);
39 virtual void set(const String &key, const String &value);
40 virtual void set(const String &key, const Real &value) {}
41 virtual void set(const String &key, Vector2 &value) {}
42 virtual void set(const String &key, Vector3 &value) {}
43 virtual void set(const String &key, Vector4f &value) {}
44 virtual void set(const String &key, sp<Layout> l_value);
45 virtual void set(const String &key, sp<Component> spValue);
46 virtual void set(const String &key, sp<Scope> spValue);
47 virtual void set(const String &key, sp<StateCatalog> spValue) {}
48 
49  //*TODO
50 virtual Record getRecord(const String &key) { return Record(); }
51 virtual String getString(const String &key) { return String(); }
52 virtual Real getReal(const String &key) { return 0.0; }
53 virtual Vector2 getVector2(const String &key)
54  { return Vector2(0,0); }
55 virtual Vector3 getVector3(const String &key)
56  { return Vector3(0,0,0); }
57 virtual Vector4 getVector4(const String &key)
58  { return Vector4(0,0,0,0); }
59 virtual Vector4f getVector4f(const String &key)
60  { return Vector4f(0,0,0,0); }
61 
62 virtual bool execute(void);
63 virtual bool execute(const String &a_fnName) { return false; };
64 virtual void flush(void);
65 virtual void alias(String a_aliasName,String a_trueName) {}
66 
67  // AS HandlerI
68 virtual void handle(Record& r_sig);
69 
70  using Dispatch::call;
71 
72  // AS DispatchI
73 virtual bool call(const String &a_name, Array<Instance>& a_argv);
74 
75  private:
76  Result compile(void);
77  lua_State *m_pLuaState;
78  String m_chunk;
79  sp<LuaContext> m_spContext;
80  String m_name;
81 #if FE_COUNTED_TRACK
82  Array<void*> m_trackArray;
83 #endif
84 };
85 
86 } /* namespace ext */
87 } /* namespace fe */
88 
89 
90 #endif /* __lua_LuaIterate_h__ */
91 
Convienience base class for specification and use of path accessors.
Definition: Config.h:19
kernel
Definition: namespace.dox:3
lua execution component.
Definition: LuaIterate.h:19
Per-class participation in the Initialized <> mechanism.
Definition: Initialized.h:117
Interface to handle signals from an SignalerI.
Definition: HandlerI.h:22
Automatically reference-counted string container.
Definition: String.h:128
lua execution interface
Definition: LuaI.h:16
Wrapper for std::vector.
Definition: Array.h:21
Result
Generalized return value indicating success or failure, and why.
Definition: Result.h:24
Reference to an instance of a Layout.
Definition: RecordSB.h:35
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
virtual bool call(const String &a_name, Array< Instance > &a_argv)
Execute the call.
Definition: LuaIterate.cc:231