Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5166 in orxonox.OLD for trunk


Ignore:
Timestamp:
Sep 6, 2005, 1:45:46 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: doxygen-tags

Location:
trunk/src/lib/shell
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/shell/shell.cc

    r5164 r5166  
    7878}
    7979
    80 
    81 void Shell::testI (int i)
    82 {
    83   PRINTF(3)("This is the Test for one Int '%d'\n", i);
    84 }
    85 
    86 void Shell::testS (const char* s)
    87 {
    88   PRINTF(3)("This is the Test for one String '%s'\n", s);
    89 }
    90 
    91 void Shell::testB (bool b)
    92 {
    93   PRINTF(3)("This is the Test for one Bool: ");
    94   if (b)
    95     PRINTF(3)("true\n");
    96   else
    97     PRINTF(3)("false\n");
    98 }
    99 
    100 void Shell::testF (float f)
    101 {
    102   PRINTF(3)("This is the Test for one Float '%f'\n", f);
    103 }
    104 
    105 void Shell::testSF (const char* s, float f)
    106 {
    107   PRINTF(3)("This is the Test for one String '%s' and one Float '%f'\n",s , f);
    108 }
    109 
    110 
    111 
    11280Shell* Shell::singletonRef = NULL;
    11381
     
    270238 * adds a new Line to the List of Buffers
    271239 * @param line the Line as in the first argument in printf
    272  * @param args the arguments as a va_list
    273240 */
    274241bool Shell::addBufferLineStatic(const char* line, ...)
     
    445412/**
    446413 * adds multiple Characters to thr inputLine
    447  * @param characters a '\0' terminated char-array to add to the InputLine
     414 * @param characters a \\0 terminated char-array to add to the InputLine
    448415 */
    449416void Shell::addCharacters(const char* characters)
     
    497464}
    498465
     466/**
     467 * clears the Shell (empties all buffers)
     468 */
    499469void Shell::clear()
    500470{
     
    729699}
    730700
     701/**
     702 * completes a Function
     703 * @param functionBegin the beginning of the function String
     704 */
    731705bool Shell::functionComplete(const char* functionBegin)
    732706{
     
    849823}
    850824
     825/**
     826 * prints out some nice help about the Shell
     827 */
    851828void Shell::help() const
    852829{
     
    862839// HELPER FUNCTIONS  //
    863840///////////////////////
     841
     842/**
     843 * calculates the position of a Buffer-Display Line
     844 * @param lineNumber the lineNumber from the bottom to calculate the position from
     845 * @returns the Position of the Line.
     846 */
    864847Vector Shell::calculateLinePosition(unsigned int lineNumber)
    865848{
     
    887870  }
    888871}
     872
     873
     874
     875// void Shell::testI (int i)
     876// {
     877//   PRINTF(3)("This is the Test for one Int '%d'\n", i);
     878// }
     879//
     880// void Shell::testS (const char* s)
     881// {
     882//   PRINTF(3)("This is the Test for one String '%s'\n", s);
     883// }
     884//
     885// void Shell::testB (bool b)
     886// {
     887//   PRINTF(3)("This is the Test for one Bool: ");
     888//   if (b)
     889//     PRINTF(3)("true\n");
     890//   else
     891//     PRINTF(3)("false\n");
     892// }
     893//
     894// void Shell::testF (float f)
     895// {
     896//   PRINTF(3)("This is the Test for one Float '%f'\n", f);
     897// }
     898//
     899// void Shell::testSF (const char* s, float f)
     900// {
     901//   PRINTF(3)("This is the Test for one String '%s' and one Float '%f'\n",s , f);
     902// }
  • trunk/src/lib/shell/shell.h

    r5160 r5166  
    3939    inline static Shell* getInstance() { if (!Shell::singletonRef) Shell::singletonRef = new Shell();  return Shell::singletonRef; };
    4040
    41     void testI (int i);
    42     void testS (const char* s);
    43     void testB (bool b);
    44     void testF (float f);
    45     void testSF (const char* s, float f);
    46 
    4741    void activate();
    4842    void deactivate();
     
    5246
    5347    // BUFFER //
     48    /** @param bufferSize the new Buffer-Size */
    5449    void setBufferSize(unsigned int bufferSize) { this->bufferSize = bufferSize; };
    5550    void setBufferDisplaySize(unsigned int bufferDisplaySize);
     
    5954    void printToDisplayBuffer(const char* text);
    6055    void moveBuffer(unsigned int lineCount);
    61     void moveBufferTo(unsigned int lineNumber);
     56//    void moveBufferTo(unsigned int lineNumber);
    6257    const char* getBufferLine(unsigned int lineNumber);
    6358
     
    9388    const tList<const char>* createCompleteList(const tList<const char>* inputList, const char* classNameBegin);
    9489    const tList<const char>* createCompleteList(const tList<BaseObject>* inputList, const char* classNameBegin);
    95     const tList<const char>* createCompleteList(const tList<ShellCommandBase>* inputList, const char* classNameBegin);
     90//    const tList<const char>* createCompleteList(const tList<ShellCommandBase>* inputList, const char* classNameBegin);
    9691
    9792    // helpers //
    9893    Vector calculateLinePosition(unsigned int lineNumber);
    99 
     94//     void testI (int i);
     95//     void testS (const char* s);
     96//     void testB (bool b);
     97//     void testF (float f);
     98//     void testSF (const char* s, float f);
    10099
    101100  private:
     
    126125    char                     bufferArray[SHELL_BUFFER_SIZE];     //!< a BUFFER for fast writing
    127126    char                     keepBufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER to have multi-non-newLine commands be copied into the shell.
    128     bool                     keepBuffer;
     127    bool                     keepBuffer;             //!< if the keepbuffer contains unfinished lines.
    129128
    130129    // completion
  • trunk/src/lib/shell/shell_command.cc

    r5165 r5166  
    2828using namespace std;
    2929
     30/**
     31 * constructs and registers a new Command
     32 * @param commandName the name of the Command
     33 * @param className the name of the class to apply this command to
     34 * @param paramCount the count of parameters this command takes
     35 * @return self
     36 */
    3037ShellCommandBase::ShellCommandBase(const char* commandName, const char* className, unsigned int paramCount, ...)
    3138{
     
    8390}
    8491
     92/**
     93 * deconstructs a ShellCommand
     94 * @return
     95 */
    8596ShellCommandBase::~ShellCommandBase()
    8697{
     
    8899}
    89100
     101/**
     102 * unregisters all Commands that exist
     103 */
    90104void ShellCommandBase::unregisterAllCommands()
    91105{
     
    104118}
    105119
    106 
    107 void unregisterCommand(const char* commandName, const char* className)
     120/**
     121 * unregister an existing commandName
     122 * @param className the name of the Class the command belongs to.
     123 * @param commandName the name of the command itself
     124 *
     125 * @todo implement
     126 */
     127void ShellCommandBase::unregisterCommand(const char* commandName, const char* className)
    108128{
    109129  PRINTF(1)("IMPLEMENT THIS\n");
     
    113133
    114134
    115 
     135/**
     136 * checks if a command has already been registered.
     137 * @param commandName the name of the Command
     138 * @param className the name of the Class the command should apply to.
     139 * @param paramCount how many arguments the Command takes
     140 * @returns true, if the command is registered/false otherwise
     141 *
     142 * This is used internally, to see, if we have multiple command subscriptions.
     143 * This is checked in the registerCommand-function.
     144 */
    116145bool ShellCommandBase::isRegistered(const char* commandName, const char* className, unsigned int paramCount, ...)
    117146{
     
    240269}
    241270
    242 
     271/**
     272 * lets a command be described
     273 * @param description the description of the Given command
     274 */
    243275ShellCommandBase* ShellCommandBase::describe(const char* description)
    244276{
     
    252284}
    253285
     286/**
     287 * see ShellCommandBase::debug()
     288 */
    254289void ShellCommandBase::debugDyn()
    255290{
     
    257292}
    258293
     294/**
     295 * prints out nice information about the Shells Commands
     296 */
    259297void ShellCommandBase::debug()
    260298{
     
    269307  while(elem != NULL)
    270308  {
    271     PRINT(0)("Class %s registered command %s with %d parameters: ", elem->className, elem->getName(), elem->paramCount);
     309    PRINT(0)("Class:'%s':command:'%s':params:%d: ", elem->className, elem->getName(), elem->paramCount);
    272310    for (unsigned int i = 0; i< elem->paramCount; i++)
    273311      printf("%s ", ShellCommandBase::paramToString(elem->parameters[i]));
     
    281319}
    282320
    283 
    284 
     321/**
     322 * converts a Parameter to a String
     323 * @param parameter the Parameter we have.
     324 * @returns the Name of the Parameter at Hand
     325 */
    285326const char* ShellCommandBase::paramToString(long parameter)
    286327{
  • trunk/src/lib/shell/shell_command.h

    r5165 r5166  
    1515#include <stdarg.h>
    1616
    17 #define SHELL_COMMAND_MAX_SIZE
     17#define     SHELL_COMMAND_MAX_SIZE      //!< The maximum size of a Shell Command
    1818
    1919
     
    2222template<class T> class tList;
    2323
     24/**
     25 * an easy to use Macro to create a Command
     26 * @param command the name of the command (without "" around the string)
     27 * @param class the name of the class to apply this command to (without the "" around the string)
     28 * @param function the function to call
     29 */
    2430#define SHELL_COMMAND(command, class, function) \
    2531        ShellCommandBase* shell_command_##class##_##command = ShellCommand<class>::registerCommand(#command, #class, &class::function)
     
    3743    ShellCommandBase* describe(const char* description);
    3844
     45    /** @returns the CommandList of the Shell */
    3946    static const tList<ShellCommandBase>* getCommandList() { return ShellCommandBase::commandList; };
    4047
    4148    static void unregisterAllCommands();
    42     static void unregisterCommand(const char* commandNaame, const char* className);
     49    static void unregisterCommand(const char* commandName, const char* className);
    4350
    4451    static void debug();
     
    5461
    5562  private:
     63    /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */
    5664    virtual void executeCommand (BaseObject* object, const char* parameters) = NULL;
    5765
    5866  protected:
    5967    void*                            functionPointer;                      //!< The pointeer to the function of the Class (or static pointer if ClassID == CL_NULL )
    60     unsigned int                     paramCount;                           //!< the count of parameters
    61     unsigned int*                    parameters;                           //!< Parameters
    62     char*                            defaultStrings[FUNCTOR_MAX_ARGUMENTS];
    63     int                              defaultInts[FUNCTOR_MAX_ARGUMENTS];
    64     float                            defaultFloats[FUNCTOR_MAX_ARGUMENTS];
    65     bool                             defaultBools[FUNCTOR_MAX_ARGUMENTS];
     68    unsigned int                     paramCount;                           //!< the count of parameters.
     69    unsigned int*                    parameters;                           //!< Parameters the function of this Command takes.
     70    char*                            defaultStrings[FUNCTOR_MAX_ARGUMENTS];//!< A list of default Strings stored.
     71    int                              defaultInts[FUNCTOR_MAX_ARGUMENTS];   //!< A list of default Ints stored.
     72    float                            defaultFloats[FUNCTOR_MAX_ARGUMENTS]; //!< A list of default Floats stored.
     73    bool                             defaultBools[FUNCTOR_MAX_ARGUMENTS];  //!< A list of default Bools stored.
    6674
    6775  private:
     
    6977    const char*                      className;                            //!< The Name of the Class associated to this Command
    7078
    71     const char*                      description;
     79    const char*                      description;                          //!< A description for this commnand. (initially NULL). Assigned with (create)->describe("blablabla");
    7280
    7381    // STATIC MEMBERS
     
    8189// MACRO DEFINITIONS //
    8290///////////////////////
     91//! where to chek for default BOOL values
    8392#define   l_BOOL_DEFGRAB(i)         this->defaultBools[i]
     93//! where to chek for default INT values
    8494#define   l_INT_DEFGRAB(i)          this->defaultInts[i]
     95//! where to chek for default UINT values
    8596#define   l_UINT_DEFGRAB(i)         (unsigned int)this->defaultInts[i]
     97//! where to chek for default LONG values
    8698#define   l_LONG_DEFGRAB(i)         (long)this->defaultInts[i]
     99//! where to chek for default FLOAT values
    87100#define   l_FLOAT_DEFGRAB(i)        this->defaultFloats[i]
     101//! where to chek for default STRING values
    88102#define   l_STRING_DEFGRAB(i)       this->defaultStrings[i]
    89103
     
    91105// COMMAND REGISTRATION //
    92106//////////////////////////
    93 // NO ARGUMENTS
     107//! registers a command without any parameters
    94108#define ShellCommandRegister0() \
    95109  static ShellCommand<T>* registerCommand(const char* commandName, const char* className, void (T::*function)()) \
     
    100114  }
    101115
     116//! registers a command with 1 parameter
    102117#define ShellCommandRegister1(t1) \
    103118  static ShellCommand<T>* registerCommand(const char* commandName, const char* className, void (T::*function)(t1##_TYPE), t1##_TYPE d1 = t1##_DEFAULT) \
     
    108123  }
    109124
     125//! registers a command with 2 parameters
    110126#define ShellCommandRegister2(t1,t2) \
    111127  static ShellCommand<T>* registerCommand(const char* commandName, const char* className, void (T::*function)(t1##_TYPE, t2##_TYPE), t1##_TYPE d1 = t1##_DEFAULT, t2##_TYPE d2 = t2##_DEFAULT) \
     
    116132  }
    117133
     134//! registers a command with 3 parameters
    118135#define ShellCommandRegister3(t1,t2,t3) \
    119136  static ShellCommand<T>* registerCommand(const char* commandName, const char* className, void (T::*function)(t1##_TYPE, t2##_TYPE, t3##_TYPE), t1##_TYPE d1 = t1##_DEFAULT, t2##_TYPE d2 = t2##_DEFAULT, t3##_TYPE d3 = t3##_DEFAULT) \
     
    124141  }
    125142
     143//! registers a command with 4 parameters
    126144#define ShellCommandRegister4(t1,t2,t3,t4) \
    127145  static ShellCommand<T>* registerCommand(const char* commandName, const char* className, void (T::*function)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE), t1##_TYPE d1 = t1##_DEFAULT, t2##_TYPE d2 = t2##_DEFAULT, t3##_TYPE d3 = t3##_DEFAULT, t4##_TYPE d4 = t4##_DEFAULT) \
     
    132150  }
    133151
     152//! registers a command with 5 parameters
    134153#define ShellCommandRegister5(t1,t2,t3,t4,t5) \
    135154  static ShellCommand<T>* registerCommand(const char* commandName, const char* className, void (T::*function)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE, t5##_TYPE), t1##_TYPE d1 = t1##_DEFAULT, t2##_TYPE d2 = t2##_DEFAULT, t3##_TYPE d3 = t3##_DEFAULT, t4##_TYPE d4 = t4##_DEFAULT, t5##_TYPE d5 = t5##_DEFAULT) \
     
    143162// CONSTRUCTORS //
    144163/////////////////
     164//! creates a command that takes no parameters
    145165#define ShellCommandConstructor0() \
    146166  void (T::*functionPointer_0)(); \
     
    151171  }
    152172
     173//! creates a command that takes one parameter
    153174#define ShellCommandConstructor1(t1) \
    154175  void (T::*functionPointer_1_##t1)(t1##_TYPE); \
     
    159180  }
    160181
     182//! creates a command that takes two parameters
    161183#define ShellCommandConstructor2(t1,t2) \
    162184  void (T::*functionPointer_2_##t1##_##t2)(t1##_TYPE, t2##_TYPE); \
     
    167189  }
    168190
     191//! creates a command that takes three parameter
    169192#define ShellCommandConstructor3(t1,t2,t3) \
    170193  void (T::*functionPointer_3_##t1##_##t2##_##t3)(t1##_TYPE, t2##_TYPE, t3##_TYPE); \
     
    175198  }
    176199
     200//! creates a command that takes four parameter
    177201#define ShellCommandConstructor4(t1,t2,t3,t4) \
    178202  void (T::*functionPointer_4_##t1##_##t2##_##t3##_##t4)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE); \
     
    183207  }
    184208
     209//! creates a command that takes five parameter
    185210#define ShellCommandConstructor5(t1,t2,t3,t4,t5) \
    186211  void (T::*functionPointer_5_##t1##_##t2##_##t3##_##t4##_##t5)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE, t5##_TYPE); \
     
    194219// EXECUTION //
    195220///////////////
     221//! execute-macro for functions with no parameters
    196222#define ShellCommandExecute0() \
    197223  if (this->paramCount == 0) \
    198224    (dynamic_cast<T*>(object)->*functionPointer_0)()
    199225
     226//! execute-macro for functions with one parameter
    200227#define ShellCommandExecute1(t1) \
    201228   else if (this->paramCount == 1 && this->parameters[0] == t1##_PARAM) \
    202229    (dynamic_cast<T*>(object)->*functionPointer_1_##t1)(t1##_FUNC(parameters, t1##_DEFGRAB(0)))
    203230
     231//! execute-macro for functions with two parameters
    204232#define ShellCommandExecute2(t1,t2) \
    205233   else if (this->paramCount == 2 && this->parameters[0] == t1##_PARAM && this->parameters[1] == t2##_PARAM) \
    206234    (dynamic_cast<T*>(object)->*functionPointer_2_##t1##_##t2)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)))
    207235
     236//! execute-macro for functions with three parameters
    208237#define ShellCommandExecute3(t1,t2,t3) \
    209238   else if (this->paramCount == 3 && this->parameters[0] == t1##_PARAM && this->parameters[1] == t2##_PARAM && this->parameters[2] == t3##_PARAM) \
    210239    (dynamic_cast<T*>(object)->*functionPointer_3_##t1##_##t2##_##t3)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)), t3##_FUNC(sub.getString(2), t3##_DEFGRAB(2)))
    211240
     241//! execute-macro for functions with four parameters
    212242#define ShellCommandExecute4(t1,t2,t3,t4) \
    213243   else if (this->paramCount == 4 && this->parameters[0] == t1##_PARAM && this->parameters[1] == t2##_PARAM && this->parameters[2] == t3##_PARAM && this->parameters[3] == t4##_PARAM) \
    214244    (dynamic_cast<T*>(object)->*functionPointer_4_##t1##_##t2##_##t3##_##t4)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)), t3##_FUNC(sub.getString(2), t3##_DEFGRAB(2)), t4##_FUNC(sub.getString(3), t4##_DEFGRAB(3)))
    215245
     246//! execute-macro for functions with five parameters
    216247#define ShellCommandExecute5(t1,t2,t3,t4,t5) \
    217248   else if (this->paramCount == 5 && this->parameters[0] == t1##_PARAM && this->parameters[1] == t2##_PARAM && this->parameters[2] == t3##_PARAM && this->parameters[3] == t4##_PARAM && this->parameters[4] == t5##_PARAM) \
     
    228259#endif
    229260
     261//! FUNCTOR_LIST is the List of command-registerers
    230262#define FUNCTOR_LIST(x) ShellCommandRegister ## x
    231263#include "functor_list.h"
     
    234266
    235267  private:
     268//! FUNCTOR_LIST is the List of CommandConstructors
    236269#define FUNCTOR_LIST(x) ShellCommandConstructor ## x
    237270#include "functor_list.h"
     
    242275//      if (parameters != NULL)
    243276      SubString sub(parameters);
     277//! FUNCTOR_LIST is the List of Executive Functions
    244278#define FUNCTOR_LIST(x) ShellCommandExecute ## x
    245279#include "functor_list.h"
Note: See TracChangeset for help on using the changeset viewer.