Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/netp6/src/core/TclThreadManager.h @ 3825

Last change on this file since 3825 was 3264, checked in by rgrieder, 15 years ago

Moved boost headers from TclThreadmanager.h to the source file.
Also removed the old boost 1.34 commands since Oli requires 1.35 anyway and there have been about three or four new releases of boost since the writing of the code.

  • Property svn:eol-style set to native
File size: 3.9 KB
Line 
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
29#ifndef _TclThreadManager_H__
30#define _TclThreadManager_H__
31
32#include "CorePrereqs.h"
33
34#include <list>
35#include <map>
36#include <string>
37#include "core/OrxonoxClass.h"
38
39namespace orxonox
40{
41    // Internal struct
42    struct TclInterpreterBundle;
43
44    class _CoreExport TclThreadManager : public OrxonoxClass
45    {
46        friend class IRC;
47        friend class TclBind;
48
49        public:
50            TclThreadManager(Tcl::interpreter* interpreter);
51            ~TclThreadManager();
52
53            static TclThreadManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
54
55            static unsigned int create();
56            static unsigned int createID(unsigned int threadID);
57            static void destroy(unsigned int threadID);
58            static void execute(unsigned int threadID, const std::string& command);
59            static std::string query(unsigned int threadID, const std::string& command);
60            static void status();
61            static void dump(unsigned int threadID);
62            static void flush(unsigned int threadID);
63
64            void error(const std::string& error);
65            void debug(const std::string& error);
66
67            void update(const Clock& time);
68
69            std::list<unsigned int> getThreadList() const;
70
71        private:
72            TclThreadManager(const TclThreadManager& other);
73
74            static void tcl_execute(Tcl::object const &args);
75            static std::string tcl_query(int querierID, Tcl::object const &args);
76            static std::string tcl_crossquery(int querierID, int threadID, Tcl::object const &args);
77            static bool tcl_running(int threadID);
78
79            Tcl::interpreter* createNewTclInterpreter(const std::string& threadID);
80            Tcl::interpreter* getTclInterpreter(unsigned int threadID);
81            TclInterpreterBundle* getInterpreterBundle(unsigned int threadID);
82            std::string dumpList(const std::list<unsigned int>& list);
83
84            void pushCommandToQueue(const std::string& command);
85            void forceCommandToFrontOfQueue(const std::string& command);
86            std::string popCommandFromQueue();
87            bool queueIsEmpty();
88
89            void pushCommandToQueue(unsigned int threadID, const std::string& command);
90            std::string popCommandFromQueue(unsigned int threadID);
91            bool queueIsEmpty(unsigned int threadID);
92
93            bool updateQueriersList(TclInterpreterBundle* querier, TclInterpreterBundle* target);
94
95            std::string evalQuery(unsigned int querierID, const std::string& command);
96            std::string evalQuery(unsigned int querierID, unsigned int threadID, const std::string& command);
97
98            unsigned int threadCounter_;
99            TclInterpreterBundle* orxonoxInterpreterBundle_;
100            std::map<unsigned int, TclInterpreterBundle*> interpreterBundles_;
101
102            static TclThreadManager* singletonRef_s;
103    };
104
105    _CoreExport void tclThread(TclInterpreterBundle* interpreterBundle, std::string command);
106}
107
108#endif /* _TclThreadManager_H__ */
Note: See TracBrowser for help on using the repository browser.