Changeset 1276 for code/branches/console/src
- Timestamp:
- May 15, 2008, 1:05:58 AM (17 years ago)
- Location:
- code/branches/console/src
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/core/CMakeLists.txt
r1230 r1276 28 28 TclBind.cc 29 29 TclThreadManager.cc 30 IRC.cc 30 31 ) 31 32 -
code/branches/console/src/core/CommandExecutor.cc
r1269 r1276 100 100 { 101 101 if (newline) 102 std::cout<< text << std::endl;102 COUT(0) << text << std::endl; 103 103 else 104 std::cout<< text;104 COUT(0) << text; 105 105 } 106 106 … … 412 412 if (evaluation.bEvaluatedParams_ && evaluation.evaluatedExecutor_) 413 413 { 414 std::cout<< "CE_execute (evaluation): " << evaluation.evaluatedExecutor_->getName() << " " << evaluation.param_[0] << " " << evaluation.param_[1] << " " << evaluation.param_[2] << " " << evaluation.param_[3] << " " << evaluation.param_[4] << std::endl;414 COUT(4) << "CE_execute (evaluation): " << evaluation.evaluatedExecutor_->getName() << " " << evaluation.param_[0] << " " << evaluation.param_[1] << " " << evaluation.param_[2] << " " << evaluation.param_[3] << " " << evaluation.param_[4] << std::endl; 415 415 (*evaluation.evaluatedExecutor_)(evaluation.param_[0], evaluation.param_[1], evaluation.param_[2], evaluation.param_[3], evaluation.param_[4]); 416 416 return true; 417 417 } 418 418 419 std::cout<< "CE_execute: " << evaluation.processedCommand_ << "\n";419 COUT(4) << "CE_execute: " << evaluation.processedCommand_ << "\n"; 420 420 switch (evaluation.state_) 421 421 { -
code/branches/console/src/core/CorePrereqs.h
r1198 r1276 119 119 class InputHandlerGUI; 120 120 class InputManager; 121 class IRC; 121 122 template <class T> 122 123 class Iterator; … … 135 136 class ObjectListElement; 136 137 class OrxonoxClass; 138 class OutputBuffer; 137 139 class OutputHandler; 138 140 class Shell; … … 140 142 class SubclassIdentifier; 141 143 class TclBind; 144 struct TclInterpreterBundle; 142 145 class Tickable; 143 146 template <class T, class O> -
code/branches/console/src/core/TclBind.cc
r1267 r1276 35 35 #include "TclThreadManager.h" 36 36 #include "TclBind.h" 37 #include "util/String.h" 37 38 38 39 namespace orxonox … … 104 105 std::string TclBind::tcl_query(Tcl::object const &args) 105 106 { 106 std::cout << "Tcl_query: args: " << args.get() << std::endl; 107 std::string command = args.get(); 107 COUT(4) << "Tcl_query: " << args.get() << std::endl; 108 108 109 while (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}') 110 command = command.substr(1, command.size() - 2); 109 std::string command = stripEnclosingBraces(args.get()); 111 110 112 111 if (!CommandExecutor::execute(command, false)) … … 121 120 void TclBind::tcl_execute(Tcl::object const &args) 122 121 { 123 std::cout << "Tcl_execute: args: " << args.get() << std::endl; 124 std::string command = args.get(); 125 126 while (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}') 127 command = command.substr(1, command.size() - 2); 122 COUT(4) << "Tcl_execute: " << args.get() << std::endl; 123 std::string command = stripEnclosingBraces(args.get()); 128 124 129 125 if (!CommandExecutor::execute(command, false)) … … 150 146 void TclBind::bgerror(std::string error) 151 147 { 152 while (error.size() >= 2 && error[0] == '{' && error[error.size() - 1] == '}') 153 error = error.substr(1, error.size() - 2); 154 155 COUT(1) << "Tcl background error: " << error << std::endl; 148 COUT(1) << "Tcl background error: " << stripEnclosingBraces(error) << std::endl; 156 149 } 157 150 -
code/branches/console/src/core/TclThreadManager.cc
r1269 r1276 58 58 ConsoleCommand(TclThreadManager, flush, AccessLevel::None, false); 59 59 60 TclThreadManager* instance = &TclThreadManager::getInstance();60 TclThreadManager* instance_tclthreadmanager = &TclThreadManager::getInstance(); 61 61 62 62 TclThreadManager::TclThreadManager() … … 92 92 COUT(0) << "Created new Tcl-interpreter with ID " << TclThreadManager::getInstance().threadCounter_ << std::endl; 93 93 return TclThreadManager::getInstance().threadCounter_; 94 } 95 96 unsigned int TclThreadManager::createID(unsigned int threadID) 97 { 98 unsigned int temp = TclThreadManager::getInstance().threadCounter_; 99 TclThreadManager::getInstance().threadCounter_ = threadID - 1; 100 TclThreadManager::create(); 101 TclThreadManager::getInstance().threadCounter_ = temp; 102 return threadID; 94 103 } 95 104 … … 136 145 void TclThreadManager::execute(unsigned int threadID, const std::string& _command) 137 146 { 138 std::string command = _command; 139 while (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}') 140 command = command.substr(1, command.size() - 2); 141 147 std::string command = stripEnclosingBraces(_command); 142 148 143 149 if (threadID == 0) … … 237 243 void TclThreadManager::tcl_execute(Tcl::object const &args) 238 244 { 239 std::string command = args.get(); 240 while (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}') 241 command = command.substr(1, command.size() - 2); 242 243 TclThreadManager::getInstance().pushCommandToQueue(command); 245 TclThreadManager::getInstance().pushCommandToQueue(stripEnclosingBraces(args.get())); 244 246 } 245 247 246 248 std::string TclThreadManager::tcl_query(int querierID, Tcl::object const &args) 247 249 { 248 std::string command = args.get(); 249 while (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}') 250 command = command.substr(1, command.size() - 2); 251 252 return TclThreadManager::getInstance().evalQuery((unsigned int)querierID, command); 250 return TclThreadManager::getInstance().evalQuery((unsigned int)querierID, stripEnclosingBraces(args.get())); 253 251 } 254 252 255 253 std::string TclThreadManager::tcl_crossquery(int querierID, int threadID, Tcl::object const &args) 256 254 { 257 std::string command = args.get(); 258 while (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}') 259 command = command.substr(1, command.size() - 2); 260 261 return TclThreadManager::getInstance().evalQuery((unsigned int)querierID, (unsigned int)threadID, command); 255 return TclThreadManager::getInstance().evalQuery((unsigned int)querierID, (unsigned int)threadID, stripEnclosingBraces(args.get())); 262 256 } 263 257 … … 349 343 350 344 this->forceCommandToFrontOfQueue("error " + error); 345 } 346 347 void TclThreadManager::debug(const std::string& error) 348 { 349 if (boost::this_thread::get_id() != this->threadID_) 350 { 351 boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_); 352 if (this->orxonoxInterpreterBundle_.queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH) 353 { 354 boost::this_thread::yield(); 355 return; 356 } 357 } 358 359 this->forceCommandToFrontOfQueue("debug " + error); 351 360 } 352 361 … … 506 515 if (successfullyLocked) 507 516 { 517 this->debug("TclThread_query: " + command); 508 518 try 509 519 { output = (std::string)target->interpreter_->eval(command); } … … 566 576 void tclThread(TclInterpreterBundle* interpreterBundle, std::string command) 567 577 { 568 std::cout << "tclthreadm executes " << command << std::endl;578 TclThreadManager::getInstance().debug("TclThread_execute: " + command); 569 579 boost::mutex::scoped_lock interpreter_lock(interpreterBundle->interpreterMutex_); 570 580 try -
code/branches/console/src/core/TclThreadManager.h
r1269 r1276 73 73 74 74 static unsigned int create(); 75 static unsigned int createID(unsigned int threadID); 75 76 static void destroy(unsigned int threadID); 76 77 static void execute(unsigned int threadID, const std::string& command); … … 89 90 std::string dumpList(const std::list<unsigned int>& list); 90 91 void error(const std::string& error); 92 void debug(const std::string& error); 91 93 92 94 void pushCommandToQueue(const std::string& command); -
code/branches/console/src/util/String.cc
r1149 r1276 185 185 else 186 186 return str; 187 } 188 189 /** 190 @brief Removes enclosing {braces}. 191 @param str The string to strip 192 @return The striped string 193 */ 194 std::string stripEnclosingBraces(const std::string& str) 195 { 196 std::string output = str; 197 198 while (output.size() >= 2 && output[0] == '{' && output[output.size() - 1] == '}') 199 output = output.substr(1, output.size() - 2); 200 201 return output; 187 202 } 188 203 -
code/branches/console/src/util/String.h
r1062 r1276 47 47 48 48 _UtilExport std::string stripEnclosingQuotes(const std::string& str); 49 _UtilExport std::string stripEnclosingBraces(const std::string& str); 49 50 50 51 _UtilExport bool isEmpty(const std::string& str);
Note: See TracChangeset
for help on using the changeset viewer.