Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 5134 was 5130, checked in by bensch, 19 years ago

orxonox/trunk: flush

File size: 2.9 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
13#define MAX_SHELL_COMMAND_SIZE
14
15typedef enum ShellParameterType
16{
17  ShellParameterNull,
18  ShellParameterChar,
19  ShellParameterString,
20  ShellParameterInt,
21  ShellParameterUInt,
22  ShellParameterFloat,
23  /* ... */
24};
25
26
27// FORWARD DECLARATION
28template<class T> class tList;
29template<class T> class tIterator;
30
31class ShellCommandBase : public BaseObject
32{
33  public:
34    static bool execute (const char* executionString);
35
36//    virtual void execute (...);
37
38  protected:
39    ShellCommandBase(const char* commandName, ClassID classID, void* functionPointer, unsigned int paramCount, va_list parameters);
40    ~ShellCommandBase();
41
42    static bool isRegistered(const char* commandName, ClassID classID, unsigned int paramCount, va_list parameters);
43
44
45  protected:
46    void*                            functionPointer;     //!< The pointeer to the function of the Class (or static pointer if ClassID == CL_NULL )
47    unsigned int                     paramCount;          //!< the count of parameters
48    ShellParameterType*              parameters;          //!< Parameters
49
50  private:
51    char*                            commandName;         //!< The name of the Command when executed
52    long                             classID;             //!< The ID of the Class asociated to this Command
53
54    // STATIC MEMBERS
55    static tList<ShellCommandBase>*  commandList;         //!< A list of availiable commands.
56};
57
58//! keeps information about a ShellCommand
59template<class T> class ShellCommand : public ShellCommandBase
60{
61  public:
62    static void registerCommand(const char* commandName, ClassID classID, T* object, void (T::*functionPointer)(), unsigned int paramCount, ...);
63
64    static void unregisterCommand(const char* commandNaame, ClassID classID);
65
66  private:
67    ShellCommand(const char* command, ClassID classID, T* object, void* functionPointer, unsigned int paramCount, va_list parameters);
68
69
70  public:
71    T*                   objectPointer;       //!< The pointer to the object to apply this function to (NULL if classID == CL_NULL )
72};
73
74template<class T>
75    ShellCommand<T>::ShellCommand(const char* commandName, ClassID classID, T* object, void* functionPointer, unsigned int paramCount, va_list parameters)
76  : ShellCommandBase (commandName, classID, functionPointer, paramCount, parameters)
77{
78
79}
80
81template<class T>
82    void ShellCommand<T>::registerCommand(const char* commandName, ClassID classID, T* object, void (T::*functionPointer)(), unsigned int paramCount, ...)
83{
84  va_list parameters;
85  va_start(parameters, paramCount);
86
87  if (isRegistered(commandName, classID, paramCount, parameters) == true)
88    return;
89  else
90  {
91
92//    ShellCommand<T>* newCommand = new ShellCommand<T>(commandName, classID, object, functionPointer, paramCount, parameters);
93  }
94}
95
96#endif /* _SHELL_COMMAND_H */
Note: See TracBrowser for help on using the repository browser.