Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/lib/util/loading/load_param_class_description.cc @ 9771

Last change on this file since 9771 was 9771, checked in by bensch, 18 years ago

first step in the direction of parameter descriptions… again

File size: 4.2 KB
RevLine 
[4597]1/*
[4250]2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
[4285]12   main-programmer: Benjamin Grauer
[4250]13   co-programmer: ...
14*/
15
[9765]16#include "load_param_class_description.h"
[5556]17
[5691]18#include "multi_type.h"
[8362]19#include "debug.h"
20
[4860]21/**
[4836]22 *  A list, that holds all the classes that are loadable (classes not objects!!)
[5546]23 */
[9771]24LoadParamClassDescription::ClassDescriptionMap LoadParamClassDescription::_classList;
[4254]25
[4251]26/**
[4836]27 *  if the description of Parameters should be executed
[5546]28 */
[9768]29bool LoadParamClassDescription::_parametersDescription = false;
[4254]30
[4256]31/**
[4836]32 * @param className the name of the class to be loadable
[5546]33 */
[9765]34LoadParamClassDescription::LoadParamClassDescription(const std::string& className)
[9768]35    : _className(className)
36{ }
[4254]37
[4256]38/**
[4836]39 *  deletes a classDescription (deletes all the parameterDescriptions as well
[5546]40 */
[9765]41LoadParamClassDescription::~LoadParamClassDescription()
[9768]42{}
[4254]43
[9765]44void LoadParamClassDescription::deleteAllDescriptions()
[5226]45{
[9768]46  LoadParamClassDescription::_classList.clear();
[5226]47}
48
49
[9771]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
[4256]71/**
[9771]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
[5100]112 * @param fileName prints the output to a File
113 * @todo implement it
[5546]114 */
[9765]115void LoadParamClassDescription::printAll(const std::string& fileName)
[4255]116{
[9771]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();
[9768]121       classIt ++)
[5226]122  {
[9771]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();
[9768]126         ++param)
[5546]127    {
[9771]128    ///  (*param).second.print();
[5546]129    }
[9771]130    PRINT(0)("</%s>\n\n", (*classIt).second._className.c_str());
[5226]131  }
[9771]132  PRINT(0)("===============================================================\n");
[4255]133}
Note: See TracBrowser for help on using the repository browser.