Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

doxy

File size: 2.6 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 * @brief Creates a Description of a LoadParam
23 * @param paramName the name of the parameter to load
24 */
25LoadParamDescription::LoadParamDescription(const std::string& paramName)
26    : _name(paramName), _parameterCount(0)
27{ }
28
29/**
30 * @param descriptionText The text to set as a description for this Parameter
31 */
32void LoadParamDescription::setDescription(const std::string& descriptionText)
33{
34  this->_description = descriptionText;
35}
36
37/**
38 * @brief sets the Values of the LoadParam in the Description.
39 * @param paramCount the count of arguments the underlying paramDescription takes.
40 * @param defaultValues the default Values the underlying parameter takes.
41 * @param retVal if the underlying parameter has a return value
42 */
43void LoadParamDescription::setValues(unsigned int paramCount,
44                                     const MultiType* const defaultValues,
45                                     bool retVal)
46{
47  this->_parameterCount = paramCount;
48  for (unsigned int i = 0; i < paramCount; ++i)
49  {
50    this->_defaultValues.push_back(defaultValues[i].getString());
51    this->_types.push_back(MultiType::MultiTypeToString(defaultValues[i].getType()));
52  }
53
54}
55
56
57/**
58 *  prints out this parameter, its input method and the description (if availiable)
59 */
60void LoadParamDescription::print() const
61{
62  PRINT(0)(" <%s>", this->_name.c_str());
63  for (unsigned int i = 0; i < this->_parameterCount; i++)
64  {
65    if (i > 0)
66      PRINT(0)(",");
67    PRINT(0)("%s", this->_types[i].c_str());
68  }
69  PRINT(0)("</%s>", this->_name.c_str());
70  if (!this->_description.empty())
71    PRINT(0)(" <!-- %s", this->_description.c_str());
72  // default values
73  if (this->_parameterCount > 0)
74  {
75    PRINT(0)(" (Default: ");
76    for (unsigned int i = 0; i < this->_parameterCount; i++)
77    {
78      if (i > 0)
79        PRINT(0)(", ");
80      if (this->_types[i] == "string")
81      { // leave brackets !!
82        PRINT(0)("\"%s\"", this->_defaultValues[i].c_str());
83      }
84      else
85      {
86        PRINT(0)("%s", this->_defaultValues[i].c_str());
87      }
88    }
89    PRINT(0)(")");
90  }
91  if (!this->_description.empty() || this->_parameterCount > 0)
92    PRINT(0)(" -->");
93
94  PRINT(0)("\n");
95}
96
97
Note: See TracBrowser for help on using the repository browser.