00001 /* 00002 $Id: netvariables.h,v 1.5 2001/03/05 10:00:51 mbn Exp $ 00003 00004 ------------------------------------------------------------------------ 00005 ClanLib, the platform independent game SDK. 00006 00007 This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE 00008 version 2. See COPYING for details. 00009 00010 For a total list of contributers see CREDITS. 00011 00012 ------------------------------------------------------------------------ 00013 */ 00014 00015 #ifndef header_netvariables 00016 #define header_netvariables 00017 00019 00020 class CL_NetVariables 00021 //: Easy serialization of a data structure. 00022 // 00023 // The netvariables class is used to read a set of variables from an object, 00024 // and write them structured, in network byte order, to an output source. 00025 // 00026 // The Netvariables interface can also read the data again, and produce 'diff' 00027 // packages where it only write variables that have changed since last write. 00028 { 00030 public: 00031 CL_NetVariables(); 00032 // Construct a netvariables object. 00033 00034 virtual ~CL_NetVariables(); 00035 00037 bool is_different(); 00038 // Returns true if the variables have changed since last save. 00039 00041 void add_bool(bool *var, int array = 1); 00042 // Add booleans to the data structure. 00043 00044 void add_int(int *var, int array = 1); 00045 // Add integers to the data structure. 00046 00047 void add_short(short *var, int array = 1); 00048 // Add shorts to the data structure. 00049 00050 void add_float(float *var, int array = 1); 00051 // Add floats to the data structure. 00052 00053 void add_double(double *var, int array = 1); 00054 // Add doubles to the data structure. 00055 00056 void add_vars(CL_NetVariables *variables, int array = 1); 00057 // Add structures to the data structure. 00058 00059 void save_all(class CL_OutputSource *msg); 00060 // Write all variables in the data structure to the output source. 00061 00062 void load_all(class CL_InputSource *msg); 00063 // Read all variables in the data structure from the input source. 00064 00065 void save_diff(class CL_OutputSource *msg); 00066 // Write all variables that have changed since last save. 00067 00068 void load_diff(class CL_InputSource *msg); 00069 // Read a diff produced with save_diff from the input source. 00070 00071 public: 00072 class CL_NetVariables_Generic *impl; 00073 }; 00074 00075 #endif
1.2.6 written by Dimitri van Heesch,
© 1997-2001