Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9692 in orxonox.OLD for branches/new_class_id/src/lib


Ignore:
Timestamp:
Aug 23, 2006, 12:43:25 AM (18 years ago)
Author:
bensch
Message:

orxonox/new_class_id: some thoughts on a BaseIterator class, that can travers through ObejectLists without knowing the Polymorph type.
This is all virtual, and since templated virutal functions are not allowed, quite hard to implements…
hpe it will work

Location:
branches/new_class_id/src/lib
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/lang/new_object_list.h

    r9691 r9692  
    3636    NewObjectListDefinitionID(ClassName, -1)
    3737
    38 
     38class BaseObject;
    3939//! The superclass that all NewObjectLists follow.
    4040/**
     
    4444{
    4545public:
    46   //! An iterator Base-Class, for iterator-casting and storing.
     46  class base_iterator
     47  {
     48  public:
     49    virtual base_iterator operator++() = 0;
     50    virtual base_iterator operator--() = 0;
     51    virtual BaseObject* operator*() = 0;
     52    virtual base_iterator& operator=(const base_iterator& iterator) = 0;
     53    virtual bool operator==(const base_iterator& iterator) = 0;
     54  protected:
     55    void* _it;
     56  };
     57
     58  virtual base_iterator& base_begin() = 0;
     59  virtual base_iterator& base_end() = 0;
     60
     61  //! A fast iterator Base-Class, for iterator-casting and storing.
     62  /**
     63   * @note This Iterator is explicitely used only for storage purposes
     64   */
    4765  class IteratorBase { };
    4866
     
    7694
    7795protected:
    78   typedef std::map<int, NewObjectListBase*> classIDMap;    //!< The Generic Map.
    79   typedef std::map<std::string, NewObjectListBase*> classNameMap;//!< The Generic Map.
     96  typedef std::map<int, NewObjectListBase*>         classIDMap;   //!< The Generic Map.
     97  typedef std::map<std::string, NewObjectListBase*> classNameMap; //!< The Generic Map.
    8098
    8199  NewClassID                    _identity;          //!< The Identity of the Class (ID and Name).
     
    108126  typedef typename list::const_iterator  const_iterator;
    109127
     128  virtual base_iterator& base_begin() { };
     129  virtual base_iterator& base_end() { };
     130
     131
    110132class Iterator : public NewObjectListBase::IteratorBase
    111133  {
  • branches/new_class_id/src/lib/script_engine/script.cc

    r9298 r9692  
    2424
    2525#include "class_list.h"
    26 CREATE_SCRIPTABLE_CLASS(Script, CL_SCRIPT,
     26CREATE_SCRIPTABLE_CLASS(Script, Script::classID(),
    2727                    addMethod("addObject", ExecutorLua2<Script,const std::string&, const std::string& >(&Script::addObject))
    2828                    ->addMethod("registerClass", ExecutorLua1<Script,const std::string&>(&Script::registerClass))
     
    3131                     );
    3232
     33NewObjectListDefinition(Script);
     34
    3335Script::Script(const TiXmlElement* root)
    3436{
    35   this->setClassID(CL_SCRIPT, "Script");
     37  this->registerObject(this, Script::_objectList);
    3638
    3739  returnCount = argumentCount = 0;
     
    6466  luaopen_math(luaState);
    6567  luaopen_debug(luaState);
    66  
     68
    6769  this->loadFile(filename);
    6870
     
    100102   std::string filedest(ResourceManager::getInstance()->getDataDir());
    101103   filedest += "scripts/" + filename;
    102    
     104
    103105   this->addThisScript();
    104106   this->registerStandartClasses();
    105    
     107
    106108   if(currentFile.length() != 0)
    107109   {
     
    295297       lua_remove(luaState,-1*returnCount);
    296298       returnCount--;
    297        
     299
    298300     }
    299301   }
     
    375377 {
    376378   bool success = false;
    377    
     379
    378380   //this->registerClass(std::string("Vector"));
    379381    this->registerClass("ScriptTrigger");
     
    382384   return success;
    383385 }
    384  
    385  
     386
     387
    386388 void Script::registerClass( const std::string& className)
    387389 {
     
    400402     }
    401403   }
    402  
     404
    403405 }
    404406
  • branches/new_class_id/src/lib/script_engine/script.h

    r9298 r9692  
    2222class Script : public BaseObject
    2323{
     24  NewObjectListDeclaration(Script);
    2425  public:
    2526    Script(const TiXmlElement* root = NULL);
     
    3334    bool loadFile(const std::string& filename);
    3435    void addObject( const std::string& className,const std::string& objectName);
    35     void registerClass(const std::string& className);                           //!< Register a class but dont add any instances 
     36    void registerClass(const std::string& className);                           //!< Register a class but dont add any instances
    3637
    3738    /// QUERRYING
  • branches/new_class_id/src/lib/script_engine/script_class.cc

    r8711 r9692  
    1919#include <cassert>
    2020
     21NewObjectListDefinition(ScriptClass);
    2122/**
    2223 * @brief standard constructor
     
    2728{
    2829  assert(scriptMethods != NULL);
    29   this->setClassID(CL_SCRIPT_CLASS, "ScriptClass");
     30  this->registerObject(this, Shell::_objectList);
    3031
    3132  this->_classID = classID;
  • branches/new_class_id/src/lib/shell/shell.cc

    r8362 r9692  
    5454  ->completionPlugin(0, OrxShell::CompletorFileSystem(".ttf", "fonts/"));
    5555
     56  NewObjectListDefinition(Shell);
    5657
    5758  /**
     
    6061  Shell::Shell ()
    6162  {
    62     this->setClassID(CL_SHELL, "Shell");
     63    this->registerObject(this, Shell::_objectList);
     64
    6365    this->setName("Shell");
    6466
  • branches/new_class_id/src/lib/shell/shell.h

    r7762 r9692  
    4848  class Shell : public Element2D, public EventListener
    4949  {
    50 
     50    NewObjectListDeclaration(Shell);
    5151  public:
    5252    Shell();
  • branches/new_class_id/src/lib/shell/shell_buffer.h

    r8145 r9692  
    2424  class ShellBuffer
    2525  {
    26 
    2726  public:
    2827    virtual ~ShellBuffer();
  • branches/new_class_id/src/lib/shell/shell_command.cc

    r9406 r9692  
    2121#include "compiler.h"
    2222#include "debug.h"
    23 #include "class_list.h"
    2423
    2524#include "key_names.h"
     
    2827{
    2928  SHELL_COMMAND(debug, ShellCommandClass, help);
     29  NewObjectListDefinition(ShellCommand);
    3030
    3131
     
    3838  ShellCommand::ShellCommand(const std::string& commandName, const std::string& className, Executor* executor)
    3939  {
    40     this->setClassID(CL_SHELL_COMMAND, "ShellCommand");
     40    this->registerObject(this, ShellCommand::_objectList);
    4141    PRINTF(4)("create shellcommand '%s' for class '%s'\n", commandName.c_str(), className.c_str());
    4242    this->setName(commandName);
     
    9494  void ShellCommand::unregisterCommand(const std::string& commandName, const std::string& className)
    9595  {
    96 
    9796    ShellCommandClass* cmdClass = ShellCommandClass::acquireCommandClass(className);
    9897    if (cmdClass != NULL)
    9998    {
    10099      CmdList::iterator cmd;
    101       for (cmd = cmdClass->commandList.begin(); cmd != cmdClass->commandList.end(); cmd++)
     100      for (cmd = cmdClass->_commandList.begin(); cmd != cmdClass->_commandList.end(); cmd++)
    102101        if (commandName == (*cmd)->getName())
    103102        {
     
    119118
    120119    CmdList::const_iterator elem;
    121     for (unsigned int i = 0; i < cmdClass->commandList.size(); i++)
    122     {
    123       if (commandName == cmdClass->commandList[i]->getName())
    124         return (cmdClass->commandList[i]);
     120    for (unsigned int i = 0; i < cmdClass->_commandList.size(); i++)
     121    {
     122      if (commandName == cmdClass->_commandList[i]->getName())
     123        return (cmdClass->_commandList[i]);
    125124    }
    126125    return NULL;
  • branches/new_class_id/src/lib/shell/shell_command.h

    r8145 r9692  
    5858  class ShellCommand : public BaseObject
    5959  {
     60    NewObjectListDeclaration(ShellCommand);
     61
    6062    friend class ShellCommandClass;
    6163  public:
  • branches/new_class_id/src/lib/shell/shell_command_class.cc

    r9406 r9692  
    2121
    2222#include "debug.h"
    23 #include "class_list.h"
    2423#include "compiler.h"
    2524
     
    2827namespace OrxShell
    2928{
     29  NewObjectListDefinition(ShellCommandClass);
     30
    3031  CmdClassList* ShellCommandClass::commandClassList = NULL;
    3132
     
    3536   */
    3637  ShellCommandClass::ShellCommandClass(const std::string& className)
    37       : className(className)
    38   {
    39     this->setClassID(CL_SHELL_COMMAND_CLASS, "ShellCommandClass");
     38      : _className(className)
     39  {
     40    this->registerObject(this, ShellCommandClass::_objectList);
    4041    this->setName(className);
    4142
  • branches/new_class_id/src/lib/shell/shell_command_class.h

    r8362 r9692  
    2525  class ShellCommandClass : public BaseObject
    2626  {
     27    NewObjectListDeclaration(ShellCommandClass);
     28
    2729    friend class ShellCommand;
    2830  public:
    2931    /** @returns the CommandClassList */
    30     static const CmdClassList& getCommandClassList() { return *ShellCommandClass::commandClassList; };
     32    static const CmdClassList& getCommandClassList() { return *ShellCommandClass::_commandClassList; };
    3133
    3234    static bool getCommandListOfClass(const std::string& className, std::list<std::string>& stringList);
     
    3436    static void unregisterAllCommands();
    3537    static ShellCommandClass* getCommandClass(const std::string& className);
    36     ClassID getClassID();
     38    NewClassID getClassID();
    3739    static bool exists(const std::string& className);
    3840
     
    5153
    5254  private:
    53     const std::string                      className;                 //!< The Name of the Class. This should match the ClassName of the Commands Class.
    54     ClassID                                classID;                   //!< The classID of this Class
    55     CmdList                                commandList;               //!< A list of Commands from this Class
     55    const std::string                      _className;                 //!< The Name of the Class. This should match the ClassName of the Commands Class.
     56    NewClassID                             _classID;                   //!< The classID of this Class
     57    CmdList                                _commandList;               //!< A list of Commands from this Class
    5658
    57     static CmdClassList*                   commandClassList;          //!< A list of Classes
     59    static CmdClassList*                   _commandClassList;          //!< A list of Classes
    5860  };
    5961}
  • branches/new_class_id/src/lib/shell/shell_input.cc

    r8339 r9692  
    2424#include "compiler.h"
    2525#include "key_names.h"
     26
    2627
    2728namespace OrxShell
     
    3132  ->setAlias("help");
    3233
     34  NewObjectListDefinition(ShellInput);
    3335
    3436  /**
     
    3941      : Text ("")
    4042  {
     43    this->registerObject(this, ShellInput::_objectList);
     44
    4145    this->pressedKey = SDLK_FIRST;
    42     this->setClassID(CL_SHELL_INPUT, "ShellInput");
    4346
    4447    this->inputLine = "";
  • branches/new_class_id/src/lib/shell/shell_input.h

    r7858 r9692  
    3030  class ShellInput : public Text,  public EventListener
    3131  {
     32    NewObjectListDeclaration(ShellInput);
    3233
    3334  public:
Note: See TracChangeset for help on using the changeset viewer.