00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef OT_NUM_H
00025 #define OT_NUM_H
00026
00027
00029
00030
00031
00032 template <class X> class ot_num : public ot_obj
00033 {
00034
00035 protected:
00036
00038 X m_value;
00039
00043 ot_num(OT_OBJECT_TYPE t,X val) : ot_obj(t),m_value(val) {}
00044
00045 public:
00046
00047
00048
00049
00050
00051
00053 virtual ~ot_num() {}
00054
00055 bool operator == (const ot_obj *o) const
00056 {
00057 if(o && o->getType()==getType()) return(m_value == ((ot_num *) o)->m_value);
00058 else return(false);
00059 }
00060
00061
00062
00063
00064
00065
00069 void asXml(ostream &s=cout,int i=0) const;
00070
00073 bool asData(ostream &s) const;
00074
00075
00076
00077
00078
00079
00082 const X get(void) const {return(m_value);}
00083 };
00084
00085
00086
00087
00088
00089 template <class X> void ot_num<X>::asXml(ostream &s,int i) const
00090 {
00091 xmlTag<string> o(s,i,"object");
00092
00093 switch((int) getType())
00094 {
00095 case OT_INT:
00096 xmlTag<string> (s,i+3,"type","ot_int");
00097 break;
00098
00099 case OT_FLOAT:
00100 xmlTag<string> (s,i+3,"type","ot_float");
00101 break;
00102 }
00103
00104 xmlTag<X> (s,i+3,"value",m_value);
00105 }
00106
00107
00108
00109 template <class X> bool ot_num<X>::asData(ostream &s) const
00110 {
00111 int type = getType();
00112
00113 s.write((const char *) &type,sizeof(int));
00114
00115 s.write((const char *) &m_value,sizeof(m_value));
00116
00117 return(true);
00118 }
00119
00120 #else
00121 #endif
00122