Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1276


Ignore:
Timestamp:
May 15, 2008, 1:05:58 AM (16 years ago)
Author:
landauf
Message:

someone likes to chat? well, I do. here's a new IRC client. it connects directly into our irc.datacore.ch / #orxonox channel with a random nickname. use the "say text" command to write text into the channel. there are some more commands without a shortcut, type "IRC" and tab.
please update your media directory.

for some reason, irc-client and telnet-remote don't work together. please use only one feature at the same time. I'm not sure if it's a bug in TCL or in my TclThreadManager class. The problem also occurs with irc or telnet in parallel with another busy tcl-thread… strange thing.

Location:
code/branches/console
Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/core/CMakeLists.txt

    r1230 r1276  
    2828  TclBind.cc
    2929  TclThreadManager.cc
     30  IRC.cc
    3031)
    3132
  • code/branches/console/src/core/CommandExecutor.cc

    r1269 r1276  
    100100    {
    101101        if (newline)
    102             std::cout << text << std::endl;
     102            COUT(0) << text << std::endl;
    103103        else
    104             std::cout << text;
     104            COUT(0) << text;
    105105    }
    106106
     
    412412        if (evaluation.bEvaluatedParams_ && evaluation.evaluatedExecutor_)
    413413        {
    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;
    415415            (*evaluation.evaluatedExecutor_)(evaluation.param_[0], evaluation.param_[1], evaluation.param_[2], evaluation.param_[3], evaluation.param_[4]);
    416416            return true;
    417417        }
    418418
    419 std::cout << "CE_execute: " << evaluation.processedCommand_ << "\n";
     419        COUT(4) << "CE_execute: " << evaluation.processedCommand_ << "\n";
    420420        switch (evaluation.state_)
    421421        {
  • code/branches/console/src/core/CorePrereqs.h

    r1198 r1276  
    119119  class InputHandlerGUI;
    120120  class InputManager;
     121  class IRC;
    121122  template <class T>
    122123  class Iterator;
     
    135136  class ObjectListElement;
    136137  class OrxonoxClass;
     138  class OutputBuffer;
    137139  class OutputHandler;
    138140  class Shell;
     
    140142  class SubclassIdentifier;
    141143  class TclBind;
     144  struct TclInterpreterBundle;
    142145  class Tickable;
    143146  template <class T, class O>
  • code/branches/console/src/core/TclBind.cc

    r1267 r1276  
    3535#include "TclThreadManager.h"
    3636#include "TclBind.h"
     37#include "util/String.h"
    3738
    3839namespace orxonox
     
    104105    std::string TclBind::tcl_query(Tcl::object const &args)
    105106    {
    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;
    108108
    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());
    111110
    112111        if (!CommandExecutor::execute(command, false))
     
    121120    void TclBind::tcl_execute(Tcl::object const &args)
    122121    {
    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());
    128124
    129125        if (!CommandExecutor::execute(command, false))
     
    150146    void TclBind::bgerror(std::string error)
    151147    {
    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;
    156149    }
    157150
  • code/branches/console/src/core/TclThreadManager.cc

    r1269 r1276  
    5858    ConsoleCommand(TclThreadManager, flush,     AccessLevel::None, false);
    5959
    60     TclThreadManager* instance = &TclThreadManager::getInstance();
     60    TclThreadManager* instance_tclthreadmanager = &TclThreadManager::getInstance();
    6161
    6262    TclThreadManager::TclThreadManager()
     
    9292        COUT(0) << "Created new Tcl-interpreter with ID " << TclThreadManager::getInstance().threadCounter_ << std::endl;
    9393        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;
    94103    }
    95104
     
    136145    void TclThreadManager::execute(unsigned int threadID, const std::string& _command)
    137146    {
    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);
    142148
    143149        if (threadID == 0)
     
    237243    void TclThreadManager::tcl_execute(Tcl::object const &args)
    238244    {
    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()));
    244246    }
    245247
    246248    std::string TclThreadManager::tcl_query(int querierID, Tcl::object const &args)
    247249    {
    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()));
    253251    }
    254252
    255253    std::string TclThreadManager::tcl_crossquery(int querierID, int threadID, Tcl::object const &args)
    256254    {
    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()));
    262256    }
    263257
     
    349343
    350344        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);
    351360    }
    352361
     
    506515                    if (successfullyLocked)
    507516                    {
     517                        this->debug("TclThread_query: " + command);
    508518                        try
    509519                        {   output = (std::string)target->interpreter_->eval(command);   }
     
    566576    void tclThread(TclInterpreterBundle* interpreterBundle, std::string command)
    567577    {
    568 std::cout << "tclthreadm executes " << command << std::endl;
     578        TclThreadManager::getInstance().debug("TclThread_execute: " + command);
    569579        boost::mutex::scoped_lock interpreter_lock(interpreterBundle->interpreterMutex_);
    570580        try
  • code/branches/console/src/core/TclThreadManager.h

    r1269 r1276  
    7373
    7474            static unsigned int create();
     75            static unsigned int createID(unsigned int threadID);
    7576            static void destroy(unsigned int threadID);
    7677            static void execute(unsigned int threadID, const std::string& command);
     
    8990            std::string dumpList(const std::list<unsigned int>& list);
    9091            void error(const std::string& error);
     92            void debug(const std::string& error);
    9193
    9294            void pushCommandToQueue(const std::string& command);
  • code/branches/console/src/util/String.cc

    r1149 r1276  
    185185    else
    186186        return str;
     187}
     188
     189/**
     190    @brief Removes enclosing {braces}.
     191    @param str The string to strip
     192    @return The striped string
     193*/
     194std::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;
    187202}
    188203
  • code/branches/console/src/util/String.h

    r1062 r1276  
    4747
    4848_UtilExport std::string  stripEnclosingQuotes(const std::string& str);
     49_UtilExport std::string  stripEnclosingBraces(const std::string& str);
    4950
    5051_UtilExport bool         isEmpty(const std::string& str);
Note: See TracChangeset for help on using the changeset viewer.