Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/util/shell_command.h @ 5129

Last change on this file since 5129 was 5129, checked in by bensch, 20 years ago

orxonox/trunk: minor extension-addition to the Shell.

File size: 2.4 KB
RevLine 
[4838]1/*!
[5129]2 * @file shell_command.h
[5068]3 * Definition of a on-screen-shell
[3245]4*/
[1853]5
[5129]6#ifndef _SHELL_COMMAND_H
7#define _SHELL_COMMAND_H
[1853]8
[5129]9#include "base_object.h"
[1853]10
[5068]11#include <stdarg.h>
12
[5129]13typedef enum ShellParameterType
14{
15  ShellParameterNull,
16  ShellParameterChar,
17  ShellParameterString,
18  ShellParameterInt,
19  ShellParameterUInt,
20  ShellParameterFloat,
21  /* ... */
22};
[5127]23
[4838]24// FORWARD DECLARATION
[5068]25template<class T> class tList;
[5118]26template<class T> class tIterator;
[5129]27#define MAX_SHELL_COMMAND_SIZE
[3543]28
[5129]29class ShellCommandBase
30{
[5068]31  public:
[5129]32    static bool execute (const char* executionString);
[2036]33
[5129]34  protected:
35    ShellCommandBase(const char* commandName, ClassID classID);
[1853]36
[5129]37    static bool isRegistered(const char* commandName, ClassID classID);
[1853]38
[3245]39
[5129]40  private:
41    char*                            commandName;         //!< The name of the Command when executed
42    long                             classID;             //!< The ID of the Class asociated to this Command
[3245]43
[5068]44
[5129]45    static tList<ShellCommandBase>*  commandList;         //!< A list of availiable commands.
46};
[5068]47
[5129]48//! keeps information about a ShellCommand
49template<class T> class ShellCommand : public ShellCommandBase
50{
51  public:
52    static void registerCommand(const char* commandName, void* pointerToFunction, ClassID classID, ShellParameterType param1Type, void* Object = NULL);
[5069]53
[5129]54    static void unregisterCommand(const char* commandNaame, ClassID classID);
[5068]55
56  private:
[5129]57    ShellCommand(const char* command, void* pointerToFunction, ClassID classID, ShellParameterType param1Type, void* Object = NULL);
[5068]58
59
[5129]60  public:
61    void*                functionPointer;     //!< The pointer to the function of the Class (or static pointer if ClassID == CL_NULL )
62    T*                   Object;              //!< The pointer to the object to apply this function to (NULL if classID == CL_NULL )
63};
[5113]64
[5129]65template<class T>
66    ShellCommand<T>::ShellCommand(const char* commandName, void* pointerToFunction, ClassID classID, ShellParameterType param1Type, void* Object)
67  : ShellCommandBase (command, classID)
68{
[5113]69
[5129]70}
[5120]71
[5129]72template<class T>
73    void ShellCommand<T>::registerCommand(const char* commandName, void* pointerToFunction, ClassID classID, ShellParameterType param1Type, void* Object)
74{
75  if (isRegistered() == true)
76    return;
77  else
78  {
79    ShellCommand<T>* newCommand = new ShellCommand<T>(command);
80    elem->functionPointer = pointerToFunction;
81    elem->parameter1 = param1Type;
82    elem->Object = Object;
[5068]83
84
[5129]85  }
86}
[5068]87
[5129]88#endif /* _SHELL_COMMAND_H */
Note: See TracBrowser for help on using the repository browser.