Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9771 in orxonox.OLD


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

first step in the direction of parameter descriptions… again

Location:
branches/new_class_id/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/util/loading/load_param.cc

    r9770 r9771  
    4949  classID.name().c_str(), classID.id(), paramName.c_str(), descriptionText.c_str());
    5050
    51 //  LoadParamDescription
    52 
    53   /// TODO REIMPLEMENT
    54   /*  if (LoadParamClassDescription::parametersDescription && this->paramDesc && this->paramDesc->getDescription().empty())
    55   {
    56     this->paramDesc->setDescription(descriptionText);
    57   }*/
     51  LoadParamClassDescription::describeClass(classID, paramName, descriptionText);
    5852}
    5953
    60 
    61 
     54/**
     55 * @brief sets the Values of the Description to a usefull text.
     56 */
     57void LoadParamBase::setDescriptionValues(const ClassID& classID, unsigned int paramCount, const MultiType* const defaultValues, bool retVal)
     58{
     59  LoadParamClassDescription::setValuesOf(classID, paramName, paramCount, defaultValues, retVal);
     60}
    6261
    6362
     
    7069 * @returns the Value of the parameter if found, NULL otherwise
    7170*/
    72 const std::string& LoadParamBase::grabParameter(const TiXmlElement* root, const std::string& parameterName)
     71std::string LoadParamBase::grabParameter(const TiXmlElement* root, const std::string& parameterName)
    7372{
    7473  const TiXmlElement* const element = grabParameterElement(root, parameterName);
  • branches/new_class_id/src/lib/util/loading/load_param.h

    r9770 r9771  
    9292
    9393protected:
    94   void describe(const ClassID& id, const std::string& descriptionText);
     94  void describe(const ClassID& classID, const std::string& descriptionText);
     95  void setDescriptionValues(const ClassID& classID, unsigned int paramCount, const MultiType* const defaultValues, bool retVal = false);
    9596
    96 private:
    97   const std::string& grabParameter(const TiXmlElement* root, const std::string& parameterName);
    98   const TiXmlElement* grabParameterElement(const TiXmlElement* root, const std::string& parameterName);
    99 
     97public:
     98  static std::string grabParameter(const TiXmlElement* root, const std::string& parameterName);
     99  static const TiXmlElement* grabParameterElement(const TiXmlElement* root, const std::string& parameterName);
    100100
    101101protected:
     
    112112public:
    113113  /**
    114    * @brief generates a LoadParam based on
    115    * @param root the Root Element to load onto the object.
    116    * @param paramName the Parameter name that is loaded.
    117    * @param object the Object to apply the changes on.
    118    * @param executor the Functional Object, that actually executes the function Call.
     114   * @brief generates a LoadParam based on:
     115   * @param root the Root Element to load onto the object. @param paramName the Parameter name that is loaded.
     116   * @param object the Object to apply the changes on. @param executor the Functional Object, that actually executes the function Call.
    119117   * @param inLoadCycle If we are inside of a loading cycle. (Loading will be different here)
    120118   */
     
    139137      }
    140138    }
     139    this->setDescriptionValues(OperateClass::staticClassID(), executor->getParamCount(), executor->getDefaultValues(), executor->hasRetVal());
    141140    delete this->executor;
    142141  }
     
    159158};
    160159
    161 // helper function
    162 
    163 
    164160#endif /* _LOAD_PARAM_H */
  • branches/new_class_id/src/lib/util/loading/load_param_class_description.cc

    r9768 r9771  
    2222 *  A list, that holds all the classes that are loadable (classes not objects!!)
    2323 */
    24 LoadParamClassDescription::ClassDescriptionSet LoadParamClassDescription::_classList;
     24LoadParamClassDescription::ClassDescriptionMap LoadParamClassDescription::_classList;
    2525
    2626/**
     
    4848
    4949
     50
     51void LoadParamClassDescription::describeClass(const ClassID& classID,
     52    const std::string& paramName,
     53    const std::string& descriptionText)
     54{
     55  ParamDescriptionMap::iterator it = LoadParamClassDescription::getParamDescription(classID, paramName);
     56
     57}
     58
     59
     60void LoadParamClassDescription::setValuesOf(const ClassID& classID,
     61    const std::string& paramName,
     62    unsigned int paramCount,
     63    const MultiType* const defaultValues,
     64    bool retVal)
     65{
     66  ParamDescriptionMap::iterator it = LoadParamClassDescription::getParamDescription(classID, paramName);
     67
     68}
     69
     70
    5071/**
    51  *  prints out all loadable Classes, and their parameters
     72 * @brief finds the Iterator to the ParameterDescription paramName matching classID
     73 * @param classID the ClassID to match.
     74 * @param paramName the name of the parameter in the Class.
     75 * @returns the iterator on match.
     76 *
     77 * @note this function creates the Element classID.name()::paramName on the go if it does not exist.
     78 */
     79LoadParamClassDescription::ParamDescriptionMap::iterator
     80LoadParamClassDescription::getParamDescription(const ClassID& classID, const std::string& paramName)
     81{
     82  /// Locate the ClassDescription first
     83  ClassDescriptionMap::iterator classIt = LoadParamClassDescription::_classList.find(classID);
     84  if (classIt == LoadParamClassDescription::_classList.end())
     85  {
     86    LoadParamClassDescription::_classList[classID] = LoadParamClassDescription(classID.name());
     87    classIt = LoadParamClassDescription::_classList.find(classID);
     88    printf("Inserted %s\n", classID.name().c_str());
     89    printAll("");
     90  }
     91  // At this position the class-iterator should point to a valid usefull position.
     92  assert(classIt != LoadParamClassDescription::_classList.end());
     93
     94  /// Now locate the description with paramName.
     95  ParamDescriptionMap::iterator paramIt = (*classIt).second._parameters.find(paramName);
     96  if (paramIt == (*classIt).second._parameters.end())
     97  {
     98    (*classIt).second._parameters[paramName] = LoadParamDescription(paramName);
     99    paramIt = (*classIt).second._parameters.find(paramName);
     100  }
     101  // at this position the param-iterator should
     102  assert (paramIt != (*classIt).second._parameters.end());
     103
     104  return (paramIt);
     105}
     106
     107
     108
     109
     110/**
     111 * @brief prints out all loadable Classes, and their parameters
    52112 * @param fileName prints the output to a File
    53113 * @todo implement it
     
    55115void LoadParamClassDescription::printAll(const std::string& fileName)
    56116{
    57   PRINT(3)("===============================================================\n");
    58   PRINT(3)(" Listing all the Loadable Options (loaded since Game started).\n\n");
    59   for (ClassDescriptionSet::const_iterator classIt = LoadParamClassDescription::_classList.begin();
    60        classIt != LoadParamClassDescription::_classList.begin();
     117  PRINT(0)("===============================================================\n");
     118  PRINT(0)(" Listing all the Loadable Options (loaded since Game started).\n\n");
     119  for (ClassDescriptionMap::const_iterator classIt = LoadParamClassDescription::_classList.begin();
     120       classIt != LoadParamClassDescription::_classList.end();
    61121       classIt ++)
    62122  {
    63     PRINT(3)("<%s>\n", (*classIt)._className.c_str());
    64     for (ParamDescriptionSet::const_iterator param = (*classIt)._parameters.begin();
    65          param != (*classIt)._parameters.end();
     123    PRINT(0)("<%s>\n", (*classIt).second._className.c_str());
     124    for (ParamDescriptionMap::const_iterator param = (*classIt).second._parameters.begin();
     125         param != (*classIt).second._parameters.end();
    66126         ++param)
    67127    {
    68       (*param).print();
     128    ///  (*param).second.print();
    69129    }
    70     PRINT(3)("</%s>\n\n", (*classIt)._className.c_str());
     130    PRINT(0)("</%s>\n\n", (*classIt).second._className.c_str());
    71131  }
    72   PRINT(3)("===============================================================\n");
     132  PRINT(0)("===============================================================\n");
    73133}
  • branches/new_class_id/src/lib/util/loading/load_param_class_description.h

    r9768 r9771  
    2323
    2424#include "load_param_description.h"
     25#include "class_id.h"
     26#include <map>
    2527#include <set>
    26 
    2728// Forward Declaration //
    2829class MultiType;
     
    3233{
    3334public:
    34   LoadParamClassDescription(const std::string& className);
     35  LoadParamClassDescription(const std::string& className = "");
    3536  ~LoadParamClassDescription();
    3637
     
    3940  bool operator<(const LoadParamClassDescription& classDescr) const { return this->_className < classDescr._className; }
    4041
     42
     43  static void describeClass(const ClassID& classID,
     44                            const std::string& paramName,
     45                            const std::string& descriptionText);
     46  static void setValuesOf(const ClassID& classID,
     47                          const std::string& paramName,
     48                          unsigned int paramCount,
     49                          const MultiType* const defaultValues,
     50                          bool retVal = false);
     51
    4152  static void deleteAllDescriptions();
    42 
    43 
    4453
    4554  static void printAll(const std::string& fileName = "");
    4655
    4756private:
    48   typedef std::set<LoadParamClassDescription>  ClassDescriptionSet;
    49   typedef std::set<LoadParamDescription>       ParamDescriptionSet;
     57  typedef std::map<ClassID, LoadParamClassDescription>  ClassDescriptionMap;
     58  typedef std::map<std::string, LoadParamDescription>   ParamDescriptionMap;
     59
     60private:
     61  static ParamDescriptionMap::iterator getParamDescription(const ClassID& classID, const std::string& paramName);
     62
     63private:
    5064
    5165  static bool                                  _parametersDescription;  //!< if parameter-description should be enabled globally.
    5266
    53   static ClassDescriptionSet                   _classList;              //!< a list, that stores all the loadable classes. (after one instance has been loaded)
     67  static ClassDescriptionMap                   _classList;              //!< a list, that stores all the loadable classes. (after one instance has been loaded)
    5468
    5569private:
    5670  std::string                                  _className;              //!< name of the class
    57   ParamDescriptionSet                          _parameters;              //!< List of parameters this class knows.
     71  ParamDescriptionMap                          _parameters;             //!< List of parameters this class knows.
    5872};
    5973
  • branches/new_class_id/src/lib/util/loading/load_param_description.h

    r9767 r9771  
    3535{
    3636public:
    37   LoadParamDescription(const std::string& paramName);
     37  LoadParamDescription(const std::string& paramName = "");
    3838  ~LoadParamDescription();
    3939
     
    4949
    5050private:
    51   const std::string          _name;                  //!< The Name of the Parameter.
     51  std::string                _name;                  //!< The Name of the Parameter.
    5252  unsigned int               _parameterCount;        //!< The Count of parameters.
    5353  std::string                _description;           //!< A longer description about this function.
  • branches/new_class_id/src/lib/util/loading/load_param_xml.h

    r9770 r9771  
    7171  virtual ~XmlLoadParam()
    7272  {
     73    this->setDescriptionValues(OperateClass::staticClassID(), executor->getParamCount(), executor->getDefaultValues(), executor->hasRetVal());
    7374    (*this->executor)(this->object, this->loadElem);
    7475    delete this->executor;
  • branches/new_class_id/src/story_entities/game_world_data.cc

    r9761 r9771  
    120120  // load the parameters
    121121  // name
    122   std::string string = grabParameter( root, "name");
     122  std::string string = LoadParamBase::grabParameter( root, "name");
    123123  if( string.empty() )
    124124  {
Note: See TracChangeset for help on using the changeset viewer.