Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/lib/util/loading/load_param_description.cc @ 9774

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

nice output

File size: 3.2 KB
Line 
1/*
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:
12   main-programmer: Benjamin Grauer
13   co-programmer: ...
14*/
15
16#include "load_param_description.h"
17
18#include "multi_type.h"
19#include "debug.h"
20
21/**
22 * @param paramName the name of the parameter to load
23 */
24LoadParamDescription::LoadParamDescription(const std::string& paramName)
25    : _name(paramName), _parameterCount(0)
26{ }
27
28/**
29 *  removes all the alocated memory
30 */
31LoadParamDescription::~LoadParamDescription()
32{}
33
34/**
35 * @param descriptionText The text to set as a description for this Parameter
36 */
37void LoadParamDescription::setDescription(const std::string& descriptionText)
38{
39  this->_description = descriptionText;
40}
41
42void LoadParamDescription::setValues(unsigned int paramCount,
43                                     const MultiType* const defaultValues,
44                                     bool retVal)
45{
46  this->_parameterCount = paramCount;
47  for (unsigned int i = 0; i < paramCount; ++i)
48  {
49    this->_defaultValues.push_back(defaultValues[i].getString());
50    this->_types.push_back(MultiType::MultiTypeToString(defaultValues[i].getType()));
51  }
52
53}
54
55
56/**
57 *  prints out this parameter, its input method and the description (if availiable)
58 */
59void LoadParamDescription::print() const
60{
61  PRINT(0)(" <%s>", this->_name.c_str());
62  for (unsigned int i = 0; i < this->_parameterCount; i++)
63  {
64    if (i > 0)
65      PRINT(0)(",");
66    PRINT(0)("%s", this->_types[i].c_str());
67    // FIXME
68    //     switch (this->types[i])
69    //     {
70    //       default:
71    //         PRINTF(3)("none");
72    //         break;
73    //       case ParameterBool:
74    //         PRINT(3)("bool");
75    //         break;
76    //       case ParameterChar:
77    //         PRINT(3)("char");
78    //         break;
79    //       case ParameterString:
80    //         PRINT(3)("string");
81    //         break;
82    //       case ParameterInt:
83    //         PRINT(3)("int");
84    //         break;
85    //       case ParameterUInt:
86    //         PRINT(3)("Uint");
87    //         break;
88    //       case ParameterFloat:
89    //         PRINT(3)("float");
90    //         break;
91    //       case ParameterLong:
92    //         PRINT(3)("long");
93    //         break;
94    //       case ParameterXML:
95    //         PRINT(3)("XML");
96    //         break;
97    //     }
98  }
99  PRINT(0)("</%s>", this->_name.c_str());
100  if (!this->_description.empty())
101    PRINT(0)(" <!-- %s", this->_description.c_str());
102  // default values
103  if (this->_parameterCount > 0)
104  {
105    PRINT(0)(" (Default: ");
106    for (unsigned int i = 0; i < this->_parameterCount; i++)
107    {
108      if (i > 0)
109        PRINT(0)(", ");
110      if (this->_types[i] == "string")
111      { // leave brackets !!
112        PRINT(0)("\"%s\"", this->_defaultValues[i].c_str());
113      }
114      else
115      {
116        PRINT(0)("%s", this->_defaultValues[i].c_str());
117      }
118    }
119    PRINT(0)(")");
120  }
121  if (!this->_description.empty() || this->_parameterCount > 0)
122    PRINT(0)(" -->");
123
124  PRINT(0)("\n");
125}
126
127
Note: See TracBrowser for help on using the repository browser.