- Timestamp:
- Sep 16, 2008, 8:45:13 PM (16 years ago)
- Location:
- code/trunk/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/core/IRC.cc
r1784 r1792 27 27 */ 28 28 29 #include "IRC.h" 30 29 31 #include <boost/thread/thread.hpp> 30 31 #include "IRC.h"32 32 #include "ConsoleCommand.h" 33 33 #include "TclThreadManager.h" -
code/trunk/src/core/Shell.cc
r1755 r1792 50 50 SetConsoleCommandShortcut(OutputHandler, debug); 51 51 52 Shell* Shell::singletonRef_s = 0; 53 52 54 Shell::Shell() 53 55 { 56 assert(singletonRef_s == 0); 57 singletonRef_s = this; 58 59 int level = Core::getSoftDebugLevel(OutputHandler::LD_Shell); 60 Core::setSoftDebugLevel(OutputHandler::LD_Shell, -1); 61 54 62 RegisterRootObject(Shell); 55 63 … … 70 78 71 79 this->setConfigValues(); 80 81 Core::setSoftDebugLevel(OutputHandler::LD_Shell, level); 72 82 } 73 83 … … 76 86 if (this->inputBuffer_) 77 87 delete this->inputBuffer_; 78 } 79 80 Shell& Shell::createShell() 81 { 82 int level = Core::getSoftDebugLevel(OutputHandler::LD_Shell); 83 Core::setSoftDebugLevel(OutputHandler::LD_Shell, -1); 84 static Shell instance; 85 Core::setSoftDebugLevel(OutputHandler::LD_Shell, level); 86 return instance; 87 } 88 89 Shell& Shell::getInstance() 90 { 91 static Shell& instance = createShell(); 92 return instance; 88 singletonRef_s = 0; 93 89 } 94 90 -
code/trunk/src/core/Shell.h
r1755 r1792 30 30 #define _Shell_H__ 31 31 32 #include "CorePrereqs.h" 33 32 34 #include <list> 33 35 #include <vector> 34 35 #include "CorePrereqs.h"36 36 37 37 #include "OrxonoxClass.h" … … 60 60 { 61 61 public: 62 static Shell& getInstance(); 63 static Shell& createShell(); 62 Shell(); 63 virtual ~Shell(); 64 65 static Shell& getInstance() { assert(singletonRef_s); return *singletonRef_s; } 64 66 65 67 static void clearShell(); … … 104 106 105 107 private: 106 Shell();107 108 Shell(const Shell& other); 108 virtual ~Shell();109 109 110 110 void configureInputBuffer(); … … 142 142 unsigned int historyOffset_; 143 143 bool bAddOutputLevel_; 144 145 static Shell* singletonRef_s; 144 146 }; 145 147 } -
code/trunk/src/core/TclBind.cc
r1747 r1792 27 27 */ 28 28 29 #include "TclBind.h" 30 29 31 #include <iostream> 30 32 #include <string> 31 32 33 #include "ConsoleCommand.h" 33 34 #include "CommandExecutor.h" 34 35 #include "TclThreadManager.h" 35 #include "TclBind.h"36 36 #include "util/Debug.h" 37 37 #include "util/String.h" … … 42 42 SetConsoleCommandShortcut(TclBind, bgerror); 43 43 44 TclBind::TclBind() 44 TclBind* TclBind::singletonRef_s = 0; 45 46 TclBind::TclBind(const std::string& datapath) 45 47 { 48 assert(singletonRef_s == 0); 49 singletonRef_s = this; 46 50 this->interpreter_ = 0; 47 51 this->bSetTclLibPath_ = false; 52 this->setDataPath(datapath); 48 53 } 49 54 … … 52 57 if (this->interpreter_) 53 58 delete this->interpreter_; 54 } 55 56 TclBind& TclBind::getInstance() 57 { 58 static TclBind instance; 59 return instance; 59 singletonRef_s = 0; 60 60 } 61 61 -
code/trunk/src/core/TclBind.h
r1505 r1792 39 39 { 40 40 public: 41 static TclBind& getInstance(); 41 TclBind(const std::string& datapath); 42 ~TclBind(); 43 44 static TclBind& getInstance() { assert(singletonRef_s); return *singletonRef_s; } 42 45 43 46 static std::string tcl(const std::string& tclcode); … … 56 59 57 60 private: 58 TclBind();59 61 TclBind(const TclBind& other); 60 ~TclBind();61 62 62 63 Tcl::interpreter* interpreter_; 63 64 std::string tclLibPath_; 64 65 bool bSetTclLibPath_; 66 67 static TclBind* singletonRef_s; 65 68 }; 66 69 } -
code/trunk/src/core/TclThreadManager.cc
r1786 r1792 27 27 */ 28 28 29 #include "TclThreadManager.h" 30 29 31 #include <iostream> 30 32 #include <string> 31 32 33 #include <boost/thread/thread.hpp> 33 34 #include <boost/bind.hpp> 34 35 35 #include <OgreTimer.h> 36 36 … … 39 39 #include "CommandExecutor.h" 40 40 #include "TclBind.h" 41 #include "TclThreadManager.h"42 41 #include "util/Debug.h" 43 42 #include "util/Convert.h" … … 59 58 SetConsoleCommand(TclThreadManager, flush, false).argumentCompleter(0, autocompletion::tclthreads()); 60 59 61 TclThreadManager::TclThreadManager() 60 TclThreadManager* TclThreadManager::singletonRef_s = 0; 61 62 TclThreadManager::TclThreadManager(Tcl::interpreter* interpreter) 62 63 { 63 64 RegisterRootObject(TclThreadManager); 65 66 assert(singletonRef_s == 0); 67 singletonRef_s = this; 64 68 65 69 this->threadCounter_ = 0; 66 70 this->orxonoxInterpreterBundle_.id_ = 0; 67 this->orxonoxInterpreterBundle_.interpreter_ = TclBind::getInstance().getTclInterpreter();71 this->orxonoxInterpreterBundle_.interpreter_ = interpreter; 68 72 #if (BOOST_VERSION >= 103500) 69 73 this->threadID_ = boost::this_thread::get_id(); … … 84 88 } 85 89 this->destroy(threadID); 86 } 87 88 TclThreadManager& TclThreadManager::getInstance() 89 { 90 static TclThreadManager instance; 91 return instance; 90 91 singletonRef_s = 0; 92 92 } 93 93 -
code/trunk/src/core/TclThreadManager.h
r1747 r1792 73 73 74 74 public: 75 static TclThreadManager& getInstance(); 75 TclThreadManager(Tcl::interpreter* interpreter); 76 ~TclThreadManager(); 77 78 static TclThreadManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; } 76 79 77 80 static unsigned int create(); … … 92 95 93 96 private: 94 TclThreadManager();95 97 TclThreadManager(const TclThreadManager& other); 96 ~TclThreadManager();97 98 98 99 static void tcl_execute(Tcl::object const &args); … … 130 131 boost::thread threadID_; 131 132 #endif 133 134 static TclThreadManager* singletonRef_s; 132 135 }; 133 136 -
code/trunk/src/orxonox/gamestates/GSRoot.cc
r1764 r1792 33 33 #include <OgreRoot.h> 34 34 35 //#include "util/SubString.h"36 35 #include "util/Exception.h" 37 36 #include "util/Debug.h" … … 42 41 #include "core/ConsoleCommand.h" 43 42 #include "core/CommandLine.h" 43 #include "core/Shell.h" 44 44 #include "core/TclBind.h" 45 45 #include "core/TclThreadManager.h" … … 73 73 , ogreLogger_(0) 74 74 , graphicsEngine_(0) 75 , tclBind_(0) 76 , tclThreadManager_(0) 77 , shell_(0) 75 78 { 76 79 RegisterRootObject(GSRoot); … … 120 123 121 124 // initialise TCL 122 TclBind::getInstance().setDataPath(Settings::getDataPath()); 123 TclThreadManager::getInstance(); 125 this->tclBind_ = new TclBind(Settings::getDataPath()); 126 this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter()); 127 128 // create a shell 129 this->shell_ = new Shell(); 124 130 125 131 setupOgre(); … … 149 155 void GSRoot::leave() 150 156 { 157 // TODO: remove and destroy console commands 158 151 159 delete graphicsEngine_; 152 160 … … 160 168 #endif 161 169 170 delete this->shell_; 171 delete this->tclThreadManager_; 172 delete this->tclBind_; 173 162 174 delete settings_; 163 175 164 // TODO: remove and destroy console commands165 176 } 166 177 -
code/trunk/src/orxonox/gamestates/GSRoot.h
r1755 r1792 65 65 Ogre::LogManager* ogreLogger_; 66 66 GraphicsEngine* graphicsEngine_; //!< Interface to Ogre 67 TclBind* tclBind_; 68 TclThreadManager* tclThreadManager_; 69 Shell* shell_; 67 70 68 71 std::string ogreConfigFile_; //!< ogre config file name
Note: See TracChangeset
for help on using the changeset viewer.