X3DField.h

Go to the documentation of this file.
00001 #ifndef X3DFIELD_H
00002 #define X3DFIELD_H
00003 
00004 #include "SFString.h"
00005 #include <typeinfo>
00006 
00007 namespace X3DTK {
00008 
00009 class X3DField
00010 {
00011   friend bool operator== (const X3DField &f1, const X3DField &f2);
00012   friend bool operator!= (const X3DField &f1, const X3DField &f2);
00013 
00014 public:
00015   X3DField(const std::type_info &type, unsigned char *data);
00016   inline const std::type_info &getType() const {return _type;};
00017   inline unsigned char *data() const {return _data;};
00018 
00019 private:  
00020   const std::type_info &_type;
00021   unsigned char *_data;
00022 
00023 public:
00024   static const X3DField null;  
00025 };
00026 
00027 inline bool operator== (const X3DField &f1, const X3DField &f2)
00028 {
00029   return ((f1._type == f2._type) && (f1._data == f2._data));
00030 }
00031 
00032 inline bool operator!= (const X3DField &f1, const X3DField &f2)
00033 {
00034   return ((f1._type != f2._type) || (f1._data != f2._data));
00035 }
00036 
00037 class X3DFieldLoader
00038 {
00039 public:
00040   virtual void load(X3DField &field, const SFString &value) = 0;
00041 };
00042 
00043 template<class V>
00044 class FieldLoader : public X3DFieldLoader
00045 {
00046 public:
00047   void load(X3DField &field, const SFString &value);
00048 };
00049 
00050 
00051 class X3DFieldWriter
00052 {
00053 public:
00054   virtual SFString write(const X3DField &field) = 0;
00055   virtual void writeToFile(SFString &output, const SFString &name, const X3DField &field, const SFString &init) = 0;
00056 };
00057 
00058 template<class V>
00059 class FieldWriter : public X3DFieldWriter
00060 {
00061 public:
00062   SFString write(const X3DField &field);
00063   void writeToFile(SFString &output, const SFString &name, const X3DField &field, const SFString &init);
00064   void write(SFString &output, const V &value);
00065 };
00066 
00067 
00068 template<>
00069 class FieldLoader<bool> : public X3DFieldLoader
00070 {
00071 public:
00072   void load(X3DField &field, const SFString &value);
00073 };
00074 
00075 template<>
00076 class FieldLoader<int> : public X3DFieldLoader
00077 {
00078 public:
00079   void load(X3DField &field, const SFString &value);
00080 };
00081 
00082 template<>
00083 class FieldLoader<float> : public X3DFieldLoader
00084 {
00085 public:
00086   void load(X3DField &field, const SFString &value);
00087 };
00088 
00089 template<>
00090 class FieldWriter<bool> : public X3DFieldWriter
00091 {
00092 public:
00093   SFString write(const X3DField &field);
00094   void writeToFile(SFString &output, const SFString &name, const X3DField &field, const SFString &init);
00095   void write(SFString &output, const bool &value);
00096 };
00097 
00098 template<>
00099 class FieldWriter<int> : public X3DFieldWriter
00100 {
00101 public:
00102   SFString write(const X3DField &field);
00103   void writeToFile(SFString &output, const SFString &name, const X3DField &field, const SFString &init);
00104   void write(SFString &output, const int &value);
00105 };
00106 
00107 template<>
00108 class FieldWriter<float> : public X3DFieldWriter
00109 {
00110 public:
00111   SFString write(const X3DField &field);
00112   void writeToFile(SFString &output, const SFString &name, const X3DField &field, const SFString &init);
00113   void write(SFString &output, const float &value);
00114 };
00115 
00116 }
00117 
00118 #include "X3DField.inl"
00119 
00120 #endif

Generated on Fri Jul 30 12:02:29 2004 for X3DToolKit by doxygen 1.3.6