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, 19 years ago

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

File size: 2.4 KB
Line 
1/*!
2 * @file shell_command.h
3 * Definition of a on-screen-shell
4*/
5
6#ifndef _SHELL_COMMAND_H
7#define _SHELL_COMMAND_H
8
9#include "base_object.h"
10
11#include <stdarg.h>
12
13typedef enum ShellParameterType
14{
15  ShellParameterNull,
16  ShellParameterChar,
17  ShellParameterString,
18  ShellParameterInt,
19  ShellParameterUInt,
20  ShellParameterFloat,
21  /* ... */
22};
23
24// FORWARD DECLARATION
25template<class T> class tList;
26template<class T> class tIterator;
27#define MAX_SHELL_COMMAND_SIZE
28
29class ShellCommandBase
30{
31  public:
32    static bool execute (const char* executionString);
33
34  protected:
35    ShellCommandBase(const char* commandName, ClassID classID);
36
37    static bool isRegistered(const char* commandName, ClassID classID);
38
39
40  private:
41    char*                            commandName;         //!< The name of the Command when executed
42    long                             classID;             //!< The ID of the Class asociated to this Command
43
44
45    static tList<ShellCommandBase>*  commandList;         //!< A list of availiable commands.
46};
47
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);
53
54    static void unregisterCommand(const char* commandNaame, ClassID classID);
55
56  private:
57    ShellCommand(const char* command, void* pointerToFunction, ClassID classID, ShellParameterType param1Type, void* Object = NULL);
58
59
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};
64
65template<class T>
66    ShellCommand<T>::ShellCommand(const char* commandName, void* pointerToFunction, ClassID classID, ShellParameterType param1Type, void* Object)
67  : ShellCommandBase (command, classID)
68{
69
70}
71
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;
83
84
85  }
86}
87
88#endif /* _SHELL_COMMAND_H */
Note: See TracBrowser for help on using the repository browser.