Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9777 in orxonox.OLD for branches/new_class_id/src/lib/util


Ignore:
Timestamp:
Sep 20, 2006, 9:49:13 AM (18 years ago)
Author:
bensch
Message:

calling static functions again out of the Shell

Location:
branches/new_class_id/src/lib/util
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/util/Makefile.am

    r9768 r9777  
    1919                loading/game_loader.cc \
    2020                loading/load_param.cc \
    21                 loading/load_param_xml.cc \
    2221                loading/load_param_description.cc \
    2322                loading/load_param_class_description.cc \
  • branches/new_class_id/src/lib/util/loading/load_param.cc

    r9776 r9777  
    106106  return NULL;
    107107}
    108 
    109 
    110 
  • branches/new_class_id/src/lib/util/loading/load_param_class_description.cc

    r9776 r9777  
    114114}
    115115
    116 
    117 
    118 
    119116/**
    120117 * @brief prints out all loadable Classes, and their parameters
    121118 * @param fileName prints the output to a File
    122  * @todo implement it
     119 * @param withComments if Comments should be included.
    123120 */
    124 void LoadParamClassDescription::printAll(const std::string& fileName)
     121void LoadParamClassDescription::printAll(const std::string& fileName, bool withComments)
    125122{
    126   PRINT(0)("===============================================================\n");
    127   PRINT(0)(" Listing all the Loadable Options (loaded since Game started).\n\n");
     123  printf("================== function called\n");
     124
     125  FILE* stream;
     126  if( (stream = fopen (fileName.c_str(), "w")) == NULL)
     127  {
     128    PRINTF(2)("File '%s' could not be opened for writing\n Printing to stdout\n", fileName.c_str());
     129    LoadParamClassDescription::printAllTo(stdout, withComments);
     130    return;
     131  }
     132  else
     133    LoadParamClassDescription::printAllTo(stream, withComments);
     134
     135  fclose (stream);
     136}
     137
     138/**
     139 * @brief prints out all loadable Classes, and their parameters to a stream
     140 * @param stream the stream to print to.
     141 * @param withComments if Comments should be included.
     142 */
     143void LoadParamClassDescription::printAllTo(FILE* stream, bool withComments)
     144{
     145  fprintf(stream, "===============================================================\n");
     146  fprintf(stream, " Listing all the Loadable Options (loaded since Game started).\n\n");
    128147  for (ClassDescriptionMap::const_iterator classIt = LoadParamClassDescription::_classList.begin();
    129148       classIt != LoadParamClassDescription::_classList.end();
    130149       classIt ++)
    131150  {
    132     PRINT(0)("<%s>\n", (*classIt).second._className.c_str());
     151    fprintf(stream, "<%s>\n", (*classIt).second._className.c_str());
    133152    for (ParamDescriptionMap::const_iterator param = (*classIt).second._parameters.begin();
    134153         param != (*classIt).second._parameters.end();
    135154         ++param)
    136155    {
    137       (*param).second.print();
     156      (*param).second.print(stream, withComments);
    138157    }
    139     PRINT(0)("</%s>\n\n", (*classIt).second._className.c_str());
     158    fprintf(stream, "</%s>\n\n", (*classIt).second._className.c_str());
    140159  }
    141   PRINT(0)("===============================================================\n");
     160  fprintf(stream, "===============================================================\n");
    142161}
  • branches/new_class_id/src/lib/util/loading/load_param_class_description.h

    r9776 r9777  
    2525#include "class_id.h"
    2626#include <map>
    27 #include <set>
    2827// Forward Declaration //
    2928class MultiType;
     
    5958  static void deleteAllDescriptions();
    6059
    61   static void printAll(const std::string& fileName = "");
     60  static void printAll(const std::string& fileName = "", bool withComments = true);
     61  static void printAllTo(FILE* stream = stdout, bool withComments = true);
    6262
    6363private:
  • branches/new_class_id/src/lib/util/loading/load_param_description.cc

    r9776 r9777  
    5656
    5757/**
    58  *  prints out this parameter, its input method and the description (if availiable)
     58 * @brief prints out this parameter, its input method and the description (if availiable)
     59 * @param stream the stream to print to.
     60 * @param withComments if the comments should be appended.
    5961 */
    60 void LoadParamDescription::print() const
     62void LoadParamDescription::print(FILE* stream, bool withComments) const
    6163{
    62   PRINT(0)(" <%s>", this->_name.c_str());
     64  fprintf(stream, " <%s>", this->_name.c_str());
    6365  for (unsigned int i = 0; i < this->_parameterCount; i++)
    6466  {
    6567    if (i > 0)
    66       PRINT(0)(",");
    67     PRINT(0)("%s", this->_types[i].c_str());
     68      fprintf(stream, ",");
     69    fprintf(stream, "%s", this->_types[i].c_str());
    6870  }
    69   PRINT(0)("</%s>", this->_name.c_str());
     71  fprintf(stream, "</%s>", this->_name.c_str());
    7072  if (!this->_description.empty())
    71     PRINT(0)(" <!-- %s", this->_description.c_str());
     73    fprintf(stream, " <!-- %s", this->_description.c_str());
    7274  // default values
    7375  if (this->_parameterCount > 0)
    7476  {
    75     PRINT(0)(" (Default: ");
     77    fprintf(stream, " (Default: ");
    7678    for (unsigned int i = 0; i < this->_parameterCount; i++)
    7779    {
    7880      if (i > 0)
    79         PRINT(0)(", ");
     81        fprintf(stream, ", ");
    8082      if (this->_types[i] == "string")
    8183      { // leave brackets !!
    82         PRINT(0)("\"%s\"", this->_defaultValues[i].c_str());
     84        fprintf(stream, "\"%s\"", this->_defaultValues[i].c_str());
    8385      }
    8486      else
    8587      {
    86         PRINT(0)("%s", this->_defaultValues[i].c_str());
     88        fprintf(stream, "%s", this->_defaultValues[i].c_str());
    8789      }
    8890    }
    89     PRINT(0)(")");
     91    fprintf(stream, ")");
    9092  }
    9193  if (!this->_description.empty() || this->_parameterCount > 0)
    92     PRINT(0)(" -->");
     94    fprintf(stream, " -->");
    9395
    94   PRINT(0)("\n");
     96  fprintf(stream, "\n");
    9597}
    9698
  • branches/new_class_id/src/lib/util/loading/load_param_description.h

    r9776 r9777  
    4646  void setDescription(const std::string& descriptionText);
    4747  void setValues(unsigned int paramCount,
    48                  const MultiType* const defaultValues,
    49                  bool retVal = false);
     48                 const MultiType* const defaultValues,
     49                 bool retVal = false);
     50
    5051  /** @returns the descriptionString */
    5152  const std::string& description() { return this->_description; };
    5253
    53   void print() const;
     54  void print(FILE* stream = stdout, bool withComments = true) const;
    5455
    5556private:
Note: See TracChangeset for help on using the changeset viewer.