00001
00002 #include"ImLib3D.hpp"
00003
00004
00005
00006 class MyStreamableClass : public Streamable
00007 {
00008 float someComplexBinaryData;
00009 public:
00011 void Read( ImLib3DFile *file,XMLNode *parentNode=NULL,XMLNode *node=NULL);
00012 void Write(ImLib3DFile *file,XMLNode *parentNode=NULL,XMLNode *node=NULL) const;
00013 MyStreamableClass(float theData) : someComplexBinaryData(theData)
00014 {
00015 ;
00016 }
00017 MyStreamableClass(const string &fname)
00018 {
00019 ReadFromFile(fname);
00020 }
00021 };
00022
00023 int main (int argc, char** argv)
00024 {
00025 MyStreamableClass myObj(3);
00026
00027 string fname="streamable.test";
00028 myObj.WriteToFile(fname);
00029
00030
00031 }
00032
00033
00034
00035
00036
00037 inline
00038 void
00039 MyStreamableClass::Write( ImLib3DFile *file,XMLNode *parentNode,XMLNode *node) const
00040 {
00041
00042 node = CreateWriteNode("MyStreamableClassFile",file,parentNode,node);
00043
00044
00045 XMLNode* dataNode = file->AddChild(node, "DataNode");
00046 file->AddBinaryNode(dataNode, sizeof(float));
00047
00048
00049 file->BinaryWrite((void*)(&someComplexBinaryData), sizeof(float));
00050
00051
00052 }
00053
00054 inline
00055 void
00056 MyStreamableClass::Read( ImLib3DFile *file,XMLNode *parentNode,XMLNode *node)
00057 {
00058
00059 node = CreateReadNode("MyStreamableClassFile",file,parentNode,node);
00060
00061
00062 XMLNode* dataNode = file -> GetChild(node, "DataNode");
00063
00064 file->ReadBinaryNode(dataNode);
00065
00066 file->BinaryRead((void*)(&someComplexBinaryData), sizeof(float));
00067
00068
00069 if(!file->CheckBinaryReadComplete())
00070 {ThrowError("ImageVectorsFile::Read bad read size ");}
00071 }
00072