variable.h File Reference


Detailed Description

Management of runtime variable

Id
variable.h,v 1.8 2004/01/15 17:29:44 lecroart Exp

Definition in file variable.h.

#include "nel/misc/types_nl.h"
#include "nel/misc/command.h"
#include "nel/misc/value_smoother.h"

Go to the source code of this file.

Namespaces

namespace  NLMISC

Defines

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


Define Documentation

#define NLMISC_DYNVARIABLE __type,
__name,
__help   ) 
 

Value:

class __name##Class : public NLMISC::IVariable \
{ \
public: \
        __name##Class () : IVariable(#__name, __help) { } \
         \
        virtual void fromString(const std::string &val, bool human=false) \
        { \
                /*std::stringstream ss (val);*/ \
                __type p; \
                /*ss >> p;*/ \
                NLMISC::fromString(val, p) ; \
                ptr (&p, false, human); \
        } \
         \
        virtual std::string toString(bool human) const \
        { \
                __type p; \
                ptr (&p, true, human); \
                /*std::stringstream ss;*/ \
                /*ss << p;*/ \
                /*return ss.str();*/ \
                return NLMISC::toString(p); \
        } \
        \
        void ptr(__type *pointer, bool get, bool human) const; \
}; \
__name##Class __name##Instance; \
void __name##Class::ptr(__type *pointer, bool get, bool human) const
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 99 of file variable.h.

#define NLMISC_VARIABLE __type,
__var,
__help   )     NLMISC::CVariablePtr<__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 64 of file variable.h.


Generated on Tue Mar 16 06:43:29 2004 for NeL by doxygen 1.3.6