2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
6 // $Header: r:/t2repos/thief2/src/object/propval_.h,v 1.3 2000/01/29 13:24:47 adurant Exp $
13 ////////////////////////////////////////////////////////////
14 // DEFAULT VALUE MANIPULATORS
16 // This is the default "value manipulator" for the proprerty system.
17 // It should work for scalars and pointer-free structures.
20 class cDefaultPropValueFuncs
: public cPropValueFuncs
24 cDefaultPropValueFuncs(int size
) :size_(size
) {};
25 ~cDefaultPropValueFuncs();
28 // cPropValueFuncs members
30 uint
Version(void); // returns size
31 void Init(ObjID obj
, void* value
); // no-op
32 void New(ObjID obj
, void* value
, void *sug
= NULL
); // copy sug or zero out
33 void Term(ObjID obj
, void* value
); // no-op
34 void Copy(ObjID obj
, void* targ
, void* src
); // memcpy
35 void Read(ObjID obj
, void* value
, uint ver
, PropReadFunc read
, PropFile
* file
); // read
36 void Write(ObjID obj
, void* value
, PropWriteFunc write
, PropFile
* file
); // write
39 ////////////////////////////////////////////////////////////
40 // TEMPLATE VALUE FUNCS
42 // For when your property happens to be a class
44 // You probably want to overload read and write.
47 template <class VALUE
> class cPropClassValueFuncs
: public cPropValueFuncs
50 void Init(ObjID
, void* ) { };
51 void New(ObjID obj
, void* value
, void* sug
)
54 *(VALUE
*)value
= VALUE(); // use default constructor
58 void Term(ObjID
, void* value
) { ((VALUE
*)value
)->~VALUE(); } // call destructor
59 void Copy(ObjID
, void* t
, void* s
) { *(VALUE
*)t
= *(VALUE
*)s
;};
60 void Read(ObjID
, void* value
, uint
, PropReadFunc read
, PropFile
* file
)
61 { read(file
,value
,sizeof(VALUE
));};
62 void Write(ObjID
, void* value
, PropWriteFunc write
, PropFile
* file
)
63 { write(file
,value
,sizeof(VALUE
));};