Orxonox  0.0.5 Codename: Arcturus
TclBind.h
Go to the documentation of this file.
1 /*
2  * ORXONOX - the hottest 3D action shooter ever to exist
3  * > www.orxonox.net <
4  *
5  *
6  * License notice:
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  * Author:
23  * Fabian 'x3n' Landau
24  * Co-authors:
25  * ...
26  *
27  */
28 
78 #ifndef _TclBind_H__
79 #define _TclBind_H__
80 
81 #include "core/CorePrereqs.h"
82 
83 #include <cassert>
84 #include <string>
85 #include "util/Singleton.h"
86 
87 namespace orxonox
88 {
98  class _CoreExport TclBind : public Singleton<TclBind>
99  {
100  friend class Singleton<TclBind>;
101  public:
102  TclBind(const std::string& datapath);
103  ~TclBind();
104 
105  static std::string tcl(const std::string& tclcode);
106  static void bgerror(const std::string& error);
107 
108  void setDataPath(const std::string& datapath);
109  static std::string getTclLibraryPath();
111  inline const std::string& getTclDataPath() const
112  { return this->tclDataPath_; }
113 
114  void initializeTclInterpreter();
115  static Tcl::interpreter* createTclInterpreter();
117  inline Tcl::interpreter* getTclInterpreter() const
118  { return this->interpreter_; }
119 
120  static std::string tcl_query(Tcl::object const &args);
121  static void tcl_execute(Tcl::object const &args);
122 
123  static std::string eval(const std::string& tclcode, int* error = nullptr);
124 
125  private:
126  // non-copyable:
127  TclBind(const TclBind&) = delete;
128  TclBind& operator=(const TclBind&) = delete;
129 
130  static std::string tcl_helper(Tcl::object const &args, bool bQuery);
131 
132  Tcl::interpreter* interpreter_;
135 
137  };
138 }
139 
140 #endif /* _TclBind_H__ */
Tcl::interpreter * interpreter_
The wrapped Tcl interpreter.
Definition: TclBind.h:132
void error(const std::string &text)
Prints output with error level.
Definition: ConsoleCommandCompilation.cc:145
Tcl::interpreter * getTclInterpreter() const
Returns the Tcl-interpreter.
Definition: TclBind.h:117
Shared library macros, enums, constants and forward declarations for the core library ...
::std::string string
Definition: gtest-port.h:756
std::string tclDataPath_
The path to the directory that contains the Orxonox-specific Tcl-files.
Definition: TclBind.h:133
const std::string & getTclDataPath() const
Returns the path to the Orxonox-specific Tcl-files.
Definition: TclBind.h:111
static TclBind * singletonPtr_s
The singleton pointer.
Definition: TclBind.h:136
Base for singleton classes.
Definition: Singleton.h:114
A wrapper class for a Tcl interpreter.
Definition: TclBind.h:98
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
#define _CoreExport
Definition: CorePrereqs.h:61
Definition of the Singleton template that is used as base class for classes that allow only one insta...
bool bSetTclDataPath_
True if tclDataPath_ was defined (after a call to setDataPath())
Definition: TclBind.h:134