Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Sep 27, 2006, 11:39:47 PM (18 years ago)
Author:
bensch
Message:

new_class_id: dynamic loading works completely

try the shell with:
ResourceManger load Texture some-pic-from-data

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

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/shell/some_shell_commands.cc

    r9836 r9848  
    5353
    5454#include "loading/resource_manager.h"
    55 namespace Resources
    56 {SHELL_COMMAND(debug, ResourceManager, debug);}
     55namespace Resources {
     56  SHELL_COMMAND(debug, ResourceManager, debug);
     57  SHELL_COMMAND(load, ResourceManager, loadFromLoadString);
     58}
    5759
    5860#include "loading/load_param_class_description.h"
  • branches/new_class_id/src/lib/util/loading/resource.h

    r9847 r9848  
    4242
    4343
    44 
     44  ///////////////////
     45  // STORE POINTER //
     46  ///////////////////
    4547  //! Stores a Resource-Pointer, the LoadString and it's keepLevel.
    4648  class StorePointer
     
    7072
    7173
    72 
     74  ///////////////////
     75  // RESOURCE TYPE //
     76  ///////////////////
    7377  //! A Type of Resources.
    7478  /**
     
    122126  };
    123127
     128  /**
     129   * @brief A Type Definition Class for any Object that is resourceable.
     130   *
     131   * This Class's main reason of Existence is, that resources can be dynamically
     132   * created over a loadString. For this the Type of Resource is required, and the Resource must
     133   * itself support the 'void createFromString(const std::string&)' function.
     134   */
    124135  template<class T> class tType : public Type
    125136  {
    126137  public:
     138    /** Create the ResourceType @see Type(const std::string&) */
    127139    tType(const std::string& typeName) : Type(typeName) {};
     140    /** @param loadString the String to load a Resource with @brief tries to create a Resource of Type T with a loadString */
    128141    virtual void createFromString(const std::string& loadString) { T::createFromString(loadString); }
    129142  };
     
    131144
    132145
     146  /////////////////////
     147  // RESOURCE ITSELF //
     148  /////////////////////
    133149
    134150  //! A Resource is an Object, that can be loaded from Disk
  • branches/new_class_id/src/lib/util/loading/resource_manager.cc

    r9845 r9848  
    144144  }
    145145
     146  void ResourceManager::loadFromLoadString(const std::string& resourceTypeName, const std::string& loadString)
     147  {
     148    std::vector<Resources::Type*>::const_iterator it;
     149    for (it = this->_resourceTypes.begin(); it != this->_resourceTypes.end(); ++it)
     150    {
     151      if (*(*it) == resourceTypeName)
     152      {
     153        (*it)->createFromString(loadString);
     154        /// TODO check if the resource was allocated!!
     155        return ;
     156      }
     157    }
     158    return ;
     159  }
     160
    146161
    147162  void ResourceManager::unloadAllBelowKeepLevel(const Resources::KeepLevel& keepLevel)
  • branches/new_class_id/src/lib/util/loading/resource_manager.h

    r9845 r9848  
    4747
    4848    void unloadAllBelowKeepLevel(const Resources::KeepLevel& keepLevel);
     49    void loadFromLoadString(const std::string& resourceTypeName, const std::string& loadString);
    4950
    5051    void debug() const;
     
    5859
    5960  private:
    60     static ResourceManager*         _singletonRef;       //!< singleton Reference
     61    static ResourceManager*            _singletonRef;       //!< singleton Reference
    6162
    6263    Directory                          _mainGlobalPath;     //!< The main include directory (default at "./")
Note: See TracChangeset for help on using the changeset viewer.