Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

/home/groups/n/no/noxwizard/cvs/src/amx/amxvarserver.h

Go to the documentation of this file.
00001   /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
00002     || NoX-Wizard UO Server Emulator (NXW) [http://noxwizard.sourceforge.net]  ||
00003     ||                                                                         ||
00004     || This software is free software released under GPL2 license.             ||
00005     || You can find detailed license information in nox-wizard.cpp file.       ||
00006     ||                                                                         ||
00007     || For any question post to NoX-Wizard forums.                             ||
00008     -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
00009 
00016 #ifndef __AMXVARSERVER_H__
00017 #define __AMXVARSERVER_H__
00018 
00019 #include "nxwcommn.h"
00020 using namespace std;
00021 
00022 typedef enum
00023 {
00024         AMXVARSRV_OK = 0,
00025         AMXVARSRV_UNKNOWN_VAR,
00026         AMXVARSRV_DUPLICATE_VAR,
00027         AMXVARSRV_WRONG_TYPE,
00028         AMXVARSRV_ACCESS_DENIED
00029 } AMXVARSRV_ERROR;
00030 
00031 typedef enum
00032 {
00033         AMXVARSRV_UNDEFINED             = 0,
00034         AMXVARSRV_INTEGER               = 1,
00035         AMXVARSRV_LOGICAL               = 2,
00036         AMXVARSRV_STRING                = 3,
00037         AMXVARSRV_INTEGERVECTOR = 4,
00038         AMXVARSRV_SCRIPTID              = 5
00039 } AMXVARSRV_DATATYPE;
00040 
00041 class amxVariable
00042 {
00043         public:
00044                 virtual                         ~amxVariable() {}
00045                 virtual AMXVARSRV_DATATYPE      getType();
00046                 virtual SI32                    getSize( const SI32 index = -1 );
00047 };
00048 
00049 class amxIntegerVariable : public amxVariable
00050 {
00051         private:
00052                 SI32                            value;
00053         public:
00054                                                 amxIntegerVariable( const SI32 initialValue = 0 );
00055                                                 ~amxIntegerVariable();
00056                 AMXVARSRV_DATATYPE              getType();
00057                 SI32                            getValue();
00058                 void                            setValue( const SI32 newValue );
00059                 SI32                            getSize();
00060                 SI32                            getSize( const SI32 index = -1 );
00061 };
00062 
00063 class amxIntegerVector : public amxVariable
00064 {
00065         private:
00066                 vector< SI32 >                  value;
00067         public:
00068                                                 amxIntegerVector( const SI32 size, const SI32 initialValue = 0 );
00069                                                 ~amxIntegerVector();
00070                 AMXVARSRV_DATATYPE              getType();
00071                 SI32                            getValue( const SERIAL index );
00072                 void                            setValue( const SERIAL index, const SI32 newValue );
00073                 SI32                            getSize( const SI32 index = -1 );
00074 };
00075 
00076 class amxStringVariable : public amxVariable
00077 {
00078         private:
00079                 std::string                     value;
00080         public:
00081                                                 amxStringVariable( const std::string& initialValue = "");
00082                                                 ~amxStringVariable();
00083                 AMXVARSRV_DATATYPE              getType();
00084                 std::string                     getValue();
00085                 void                            setValue( const std::string& newValue = "");
00086                 SI32                            getSize();
00087                 SI32                            getSize( const SI32 index = -1 );
00088 };
00089 
00090 class amxScriptIdVariable : public amxVariable
00091 {
00092         private:
00093                 SERIAL  value; 
00094         public:
00095                                                 
00096                 amxScriptIdVariable( char* initialValue );
00097                 amxScriptIdVariable( SERIAL initialValue = INVALID );
00098                 ~amxScriptIdVariable();
00099         
00100                 AMXVARSRV_DATATYPE getType();
00101                 SERIAL getValue();
00102                 void setValue( char* newValue );
00103                 void setValue( SERIAL initialValue = INVALID );
00104                 SI32 getSize();
00105                 SI32 getSize( const SI32 index = -1 );
00106 };
00107 
00108 typedef pair< SI32, amxVariable* >              amxVariablePair;
00109 typedef map< SI32, amxVariable* >               amxVariableMap;
00110 typedef amxVariableMap::iterator                amxVariableMapIterator;
00111 
00112 typedef pair< SI32, amxVariableMap >            amxObjectVariablePair;
00113 typedef map< SI32, amxVariableMap >             amxObjectVariableMap;
00114 typedef amxObjectVariableMap::iterator          amxObjectVariableMapIterator;
00115 
00116 class amxVariableServer
00117 {
00118         private:
00119                 amxObjectVariableMap            varMap;
00120                 SI32                            error;
00121                 LOGICAL                         mode;
00122         public:
00123                                                 amxVariableServer();
00124                                                 ~amxVariableServer();
00125                 LOGICAL                         inUserMode();
00126                 LOGICAL                         inServerMode();
00127                 void                            setUserMode();
00128                 void                            setServerMode();
00129                 SI32                            getError();
00130                 SI32                            firstVariable( const SERIAL serial );
00131                 SI32                            nextVariable( const SERIAL serial, const SI32 previous );
00132                 AMXVARSRV_DATATYPE              typeOfVariable( const SERIAL serial, const SI32 variable );
00133                 //
00134                 //      Integer variable
00135                 //
00136                 LOGICAL                         insertVariable( const SERIAL serial, const SI32 variable, const SI32 value );
00137                 LOGICAL                         updateVariable( const SERIAL serial, const SI32 variable, const SI32 value );
00138                 LOGICAL                         selectVariable( const SERIAL serial, const SI32 variable, SI32& value );
00139                 //
00140                 //      String variable
00141                 //
00142                 LOGICAL                         insertVariable( const SERIAL serial, const SI32 variable, const std::string& value );
00143                 LOGICAL                         updateVariable( const SERIAL serial, const SI32 variable, const std::string& value );
00144                 LOGICAL                         selectVariable( const SERIAL serial, const SI32 variable, std::string& value );
00145                 //
00146                 //      Integer vectors
00147                 //
00148                 LOGICAL                         insertVariable( const SERIAL serial, const SI32 variable, const SI32 size, const SI32 value );
00149                 LOGICAL                         updateVariable( const SERIAL serial, const SI32 variable, const SI32 index, const SI32 value );
00150                 LOGICAL                         selectVariable( const SERIAL serial, const SI32 variable, const SI32 index, SI32& value );
00151                 //
00152                 //      Type aspecific methods
00153                 //
00154                 LOGICAL                         deleteVariable( const SERIAL serial );
00155                 LOGICAL                         deleteVariable( const SERIAL serial, const SI32 variable );
00156                 LOGICAL                         existsVariable( const SERIAL serial, const SI32 variable, const SI32 type );
00157                 SI32                            countVariable();
00158                 SI32                            countVariable( const SERIAL serial );
00159                 SI32                            countVariable( const SERIAL serial, const SERIAL type );
00160                 LOGICAL                         copyVariable( const SERIAL fromSerial, const SERIAL toSerial );
00161                 LOGICAL                         moveVariable( const SERIAL fromSerial, const SERIAL toSerial );
00162                 void                            saveVariable( const SERIAL serial, FILE * stream );
00163                 SI32                            size( const SERIAL serial, const SI32 variable, const SI32 index = -1 );
00164 };
00165 
00166 extern amxVariableServer amxVS;
00167 #endif
SourceForge.net Logo