Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


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
Files:
1 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/shell/shell_command.cc

    r9734 r9777  
    300300    if (sc != NULL)
    301301    {
    302       for(std::vector<BaseObject*>::const_iterator bo = boList.begin(); bo != boList.end(); ++bo)
    303       {
    304         PRINT(0)("Command '%s' on '%s::%s'\n", sc->getCName(), (*bo)->getClassCName(), (*bo)->getCName());
    305         (*sc->executor)((*bo), inputSplits.subSet(paramBegin));
    306       }
     302
     303      if(sc->executor->getType() == Executor<const SubString>::FunctionStatic )
     304      {
     305        PRINT(0)("Static Command '%s' of Class '%s' with parameters\n", sc->getCName(), sc->shellClass->getCName());
     306        (*sc->executor)(NULL, inputSplits.subSet(paramBegin));
     307      }
     308      else
     309        for(std::vector<BaseObject*>::const_iterator bo = boList.begin(); bo != boList.end(); ++bo)
     310        {
     311          PRINT(0)("Command '%s' on '%s::%s'\n", sc->getCName(), (*bo)->getClassCName(), (*bo)->getCName());
     312          (*sc->executor)((*bo), inputSplits.subSet(paramBegin));
     313        }
    307314      return true;
    308315    }
     
    377384    else
    378385    {
    379 //       if(this->completors[parameter] == NULL)
    380 //       delete this->completors[parameter];
    381 //       this->completors[parameter] = completorPlugin.clone();
     386      //       if(this->completors[parameter] == NULL)
     387      //       delete this->completors[parameter];
     388      //       this->completors[parameter] = completorPlugin.clone();
    382389    }
    383390    return this;
  • branches/new_class_id/src/lib/shell/shell_command.h

    r9769 r9777  
    5656   */
    5757#define SHELL_COMMAND_STATIC(command, class, function) \
    58            OrxShell::ShellCommand* shell_command_##class##_##command = OrxShell::ShellCommand::registerCommand(#command, #class, createExecutor<class, BaseObject>(function))
     58           OrxShell::ShellCommand* shell_command_##class##_##command = OrxShell::ShellCommand::registerCommand(#command, #class, createExecutor<class, BaseObject>(&class::function))
    5959
    6060
  • branches/new_class_id/src/lib/shell/some_shell_commands.cc

    r9721 r9777  
    2929
    3030#include "network_game_rules.h"
    31   SHELL_COMMAND(say, NetworkGameRules, shellSay)->setAlias("say");
     31SHELL_COMMAND(say, NetworkGameRules, shellSay)->setAlias("say");
    3232
    3333#include "player_stats.h"
    34   SHELL_COMMAND(nick, PlayerStats, shellNick)->setAlias("nick");
     34SHELL_COMMAND(nick, PlayerStats, shellNick)->setAlias("nick");
    3535
    3636// #include "class_list.h"
     
    4040
    4141#include "p_node.h"
    42   SHELL_COMMAND(debugNode, PNode, debugNode);
    43   SHELL_COMMAND(setPosition, PNode, setAbsCoor);
     42SHELL_COMMAND(debugNode, PNode, debugNode);
     43SHELL_COMMAND(setPosition, PNode, setAbsCoor);
    4444
    4545#include "render_2d.h"
    46   SHELL_COMMAND(toggleNodeVisibility, Render2D, toggleNodesVisibility);
     46SHELL_COMMAND(toggleNodeVisibility, Render2D, toggleNodesVisibility);
    4747
    4848
    4949#include "material.h"
    50   SHELL_COMMAND(setDiffuseTexture, Material, setDiffuseMap)
    51       ->defaultValues(MT_NULL, (int)GL_TEXTURE_2D)
    52       ->completionPlugin(0, CompletorFileSystem());
     50SHELL_COMMAND(setDiffuseTexture, Material, setDiffuseMap)
     51->defaultValues(MT_NULL, (int)GL_TEXTURE_2D)
     52->completionPlugin(0, CompletorFileSystem());
    5353
    5454#include "loading/resource_manager.h"
    5555SHELL_COMMAND(debug, ResourceManager, debug);
     56#include "loading/load_param_class_description.h"
     57OrxShell::ShellCommand* shell_command_LPCD_printAll =
     58  OrxShell::ShellCommand::registerCommand("printAll", "LoadParamClassDescription",
     59                                          new Executor2_static<LoadParamClassDescription, const SubString, const std::string&, bool>(&LoadParamClassDescription::printAll))
     60//SHELL_COMMAND_STATIC(print, LoadParamClassDescription, printAll)
     61->defaultValues(MT_NULL, true);
  • 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.