# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

command.h File Reference

Management of runtime command line processing. More...

#include "nel/misc/types_nl.h"
#include <string>
#include <map>
#include <vector>
#include <sstream>
#include <istream>
#include "nel/misc/stream.h"
#include "nel/misc/log.h"

Go to the source code of this file.

Namespaces

namespace  NLMISC

Defines

#define NLMISC_COMMAND(__name, __help, __args)
 Create a function that can be call in realtime. More...

#define NLMISC_VARIABLE(__type, __var, __help)   NLMISC::CVariable<__type> __var##Instance(#__var, __help " (" #__type ")", &__var)
 Add a variable that can be modify in realtime. More...

#define NLMISC_DYNVARIABLE(__type, __name, __help)
 Add a variable that can be modify in realtime. More...


Detailed Description

Management of runtime command line processing.

Id:
command.h,v 1.17 2002/11/29 10:07:54 lecroart Exp

Definition in file command.h.


Define Documentation

#define NLMISC_COMMAND __name,
__help,
__args   
 

Value:

struct __name##Class: public NLMISC::ICommand \
{ \
        __name##Class() : NLMISC::ICommand(#__name,__help,__args) { } \
        virtual bool execute(const std::vector<std::string> &args, NLMISC::CLog &log); \
}; \
__name##Class __name##Instance; \
bool __name##Class::execute(const std::vector<std::string> &args, NLMISC::CLog &log)
Create a function that can be call in realtime.

Example:

        // I want to create a function that compute the square of the parameter and display the result
        NLMISC_COMMAND(square,"display the square of the parameter","<value>")
        {
                // check args, if there s not the right number of parameter, return bad
                if(args.size() != 1) return false;
                // get the value
                uint32 val = atoi(args[0].c_str());
                // display the result on the displayer
                log.displayNL("The square of %d is %d", val, val*val);
                return true;
        }

Please use the same casing than for the function (first letter in lower case and after each word first letter in upper case) ie: myFunction, step, orderByName, lookAtThis

Author:
Vianney Lecroart , Nevrax France
Date:
2001

Definition at line 71 of file command.h.

#define NLMISC_DYNVARIABLE __type,
__name,
__help   
 

Add a variable that can be modify in realtime.

The code profide the way to access to the variable in the read and write access (depending of the get boolean value)

Example:

        // a function to read the variable
        uint8 getVar() { return ...; }

        // a function to write the variable
        void setVar(uint8 val) { ...=val; }

        // I want to look and change the variable in realtime:
        NLMISC_DYNVARIABLE(uint8, FooBar, "this is a dummy variable")
        {
                // read or write the variable
                if (get)
                        *pointer = getVar();
                else
                        setVar(*pointer);
        }

Please use the same casing than for the variable (first letter of each word in upper case) ie: MyVariable, NetSpeedLoop, Time

Author:
Vianney Lecroart , Nevrax France
Date:
2001

Definition at line 136 of file command.h.

#define NLMISC_VARIABLE __type,
__var,
__help       NLMISC::CVariable<__type> __var##Instance(#__var, __help " (" #__type ")", &__var)
 

Add a variable that can be modify in realtime.

The variable must be global. If you must acces the variable with function, use NLMISC_DYNVARIABLE

Example:

        // I want to look and change the variable 'foobar' in realtime, so, first i create it:
        uint8 foobar;
        // and then, I add it
        NLMISC_VARIABLE(uint8, FooBar, "this is a dummy variable");

Please use the same casing than for the variable (first letter of each word in upper case) ie: MyVariable, NetSpeedLoop, Time

Author:
Vianney Lecroart , Nevrax France
Date:
2001

Definition at line 101 of file command.h.