Free Electron
LuaExec.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_LuaExec_h__
8 #define __lua_LuaExec_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 /** lua execution component. Can also operate as a handler.
16 
17  @copydoc LuaExec_info
18  */
19 class LuaExec : public Initialize<LuaExec>,
20  virtual public Dispatch,
21  virtual public HandlerI,
22  virtual public LuaI
23 {
24  public:
25  LuaExec(void);
26 virtual ~LuaExec(void);
27 
28  void initialize(void);
29 
30  // AS LuaI
31 virtual Result loadFile(const String &filename);
32 virtual Result loadString(const String &text);
33 
34 virtual void set(const String &key, Record r_value);
35 virtual void set(const String &key, sp<RecordArray> ra_value) {}
36 virtual void set(const String &key, const String &value);
37 virtual void set(const String &key, const Real &value) {}
38 virtual void set(const String &key, Vector2 &value) {}
39 virtual void set(const String &key, Vector3 &value) {}
40 virtual void set(const String &key, Vector4f &value) {}
41 virtual void set(const String &key, sp<Layout> l_value);
42 virtual void set(const String &key, sp<Component> spValue);
43 virtual void set(const String &key, sp<Scope> spValue);
44 virtual void set(const String &key, sp<StateCatalog> spValue) {}
45 
46 virtual Record get(const String &key) { return Record(); } //* TODO
47 
48 virtual bool execute(void);
49 virtual bool execute(const String &a_fnName) { return false; };
50 virtual void flush(void);
51 virtual void alias(String a_aliasName,String a_trueName) {}
52 
53  // AS HandlerI
54 virtual void handle(Record& r_sig);
55 
56  using Dispatch::call;
57 
58  // AS DispatchI
59 virtual bool call(const String &a_name, Array<Instance> a_argv);
60 
61  private:
62  Result compile(void);
63  lua_State *m_pLuaState;
64  String m_chunk;
65  sp<LuaContext> m_spContext;
66  String m_name;
67 #if FE_COUNTED_TRACK
68  Array<void*> m_trackArray;
69 #endif
70 };
71 
72 } /* namespace ext */
73 } /* namespace fe */
74 
75 
76 #endif /* __lua_LuaExec_h__ */
77 
kernel
Definition: namespace.dox:3
lua execution component.
Definition: LuaExec.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