Cafu Engine
ConFunc.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_CONSOLE_FUNCTIONS_HPP_INCLUDED
8 #define CAFU_CONSOLE_FUNCTIONS_HPP_INCLUDED
9 
10 extern "C"
11 {
12  #include <lua.h>
13 }
14 
15 #include <string>
16 
17 
18 class ConFuncT
19 {
20  public:
21 
22  enum FlagT
23  {
24  FLAG_ALL = -1,
25 
26  FLAG_MAIN_EXE = 0x0001,
27  FLAG_MATSYS = 0x0002,
28  FLAG_SOUNDSYS = 0x0004,
29  FLAG_GAMEDLL = 0x0008,
30 
31  FLAG_CHEAT = 0x0080 ///< Use of this function is considered a cheat.
32  };
33 
34 
35  /// The constructor.
36  ConFuncT(const std::string& Name_, lua_CFunction ExecCallback_, const unsigned long Flags_, const std::string& Description_);
37 
38  /// The destructor.
39  ~ConFuncT();
40 
41  // Get methods.
42  const std::string& GetName() const { return Name; }
43  const std::string& GetDescription() const { return Description; }
44  unsigned long GetFlags() const { return Flags; }
45 
46 
47  /// Registers all convars in the StaticList with the ConsoleInterpreter and invalidates the StaticList.
48  /// This has to be called after the ConsoleInterpreter pointer is set when the dll is first initialized!
49  /// The ctors of all convars that are instantiated after this call (those that are declared as local (static) variables)
50  /// then automatically register themselves with the ConsoleInterpreter rather than with the StaticList.
51  static void RegisterStaticList();
52 
53 
54  private:
55 
56  /// Give the implementation of the console interpreter full access.
58 
59  const std::string Name; ///< The name of this console variable.
60  const std::string Description; ///< The description (i.e. user help text) for this console variable.
61  const int Flags; ///< The flags for this convar.
62  lua_CFunction LuaCFunction; ///< The actual C function that is registered with (made available to) Lua.
63 };
64 
65 #endif
FlagT
Definition: ConFunc.hpp:22
This class provides an implementation for the ConsoleInterpreterI interface.
Definition: ConsoleInterpreterImpl.hpp:33
Use of this function is considered a cheat.
Definition: ConFunc.hpp:31
static void RegisterStaticList()
Registers all convars in the StaticList with the ConsoleInterpreter and invalidates the StaticList...
Definition: ConFunc.cpp:29
~ConFuncT()
The destructor.
Definition: ConFunc.cpp:64
Definition: ConFunc.hpp:18
ConFuncT(const std::string &Name_, lua_CFunction ExecCallback_, const unsigned long Flags_, const std::string &Description_)
The constructor.
Definition: ConFunc.cpp:43