My Project
|
00001 /* 00002 $Id: NeutronVector.hh 2332 2012-02-16 01:05:03Z jisuzuki $ 00003 */ 00004 00005 00006 #ifndef NEUTRONVECTOR_HH 00007 #define NEUTRONVECTOR_HH 00008 #include <boost/serialization/serialization.hpp> 00009 00010 #include "Header.hh" 00011 00014 00033 template < class T , class H > 00034 class NeutronVector 00035 { 00036 private: 00037 void erase(); 00038 00039 friend class boost::serialization::access; 00043 template <class Archive> 00044 void serialize(Archive &ar, const unsigned int ver); 00045 00046 friend class WriteNeXusFile; 00050 template <class Write> 00051 void NXwrite(Write &W) const; 00052 00053 friend class ReadNeXusFile; 00057 template <class Read> 00058 void NXread(Read &R); 00059 00060 protected: 00064 template <class Archive> 00065 std::vector<std::string> presave(Archive &ar, const std::string &masterfile, const unsigned int splitnum) const; 00066 00070 template <class Archive> 00071 void preload(Archive &ar, 00072 std::vector<std::string> &S, std::vector<UInt4> &csize); 00073 00074 template <class Archive> 00075 friend class WriteSerializationFile; 00077 00078 template <class Archive> 00079 friend class ReadSerializationFile; 00081 00082 protected: 00083 vector< T* > v; 00084 H *header; 00085 00086 public: 00087 NeutronVector(); 00088 NeutronVector( H pheader ); 00089 ~NeutronVector(); 00090 NeutronVector( const NeutronVector &ob ); 00091 00092 NeutronVector operator=( const NeutronVector &ob ); 00093 00094 void Allocate( UInt4 size ); 00100 void Set( UInt4 index, T* value ); 00101 00102 00103 UInt4 AddPointer( T* value ); 00112 UInt4 Add( T value ); 00121 UInt4 Add( NeutronVector<T,H> &value ); 00122 00123 00124 T Put( UInt4 index=0 ); 00125 T* PutPointer( UInt4 index=0 ); 00126 00127 T* operator()( UInt4 index ) { return PutPointer( index ); } 00134 00135 T &ref(UInt4 index) { return *v[index]; } 00136 00138 // Put(), PutPointer(), operator() are to be replaced by this method 00139 const T &ref(UInt4 index) const { return *v[index]; } 00140 00141 void InputHeader( H pheader ); 00149 H PutHeader(); 00150 H *PutHeaderPointer() const { return header; } 00153 void reset(){ erase(); } 00157 UInt4 PutTableSize() const { return v.size(); } 00159 UInt4 EraseElement( UInt4 i ); 00168 UInt4 PutSize() const { return PutTableSize(); } 00171 UInt4 ClearElement( UInt4 i ); 00176 UInt4 copy( UInt4 i ); 00185 void AddToHeader( string Key, Int4 value ){ header->Add( Key, value ); } 00193 void AddToHeader( string Key, Double value ){ header->Add( Key, value ); } 00201 void AddToHeader( string Key, string value ){ header->Add( Key, value ); } 00209 void AddToHeader( string Key, vector<Int4> value ){ header->Add( Key, value ); } 00217 void AddToHeader( string Key, vector<Double> value ){ header->Add( Key, value ); } 00225 void AddToHeader( string Key, vector<string> value ){ header->Add( Key, value ); } 00240 template <class Func> 00241 void Transform(const std::string &Key, std::vector< Func > F, const std::string &newunit="None"); 00242 00244 void Reverse(void) ; 00245 00254 void Resize(UInt4 newsize); 00255 00256 NeutronVector<T, H> & operator+=(const NeutronVector<T, H> &r ); 00257 NeutronVector<T, H> & operator-=(const NeutronVector<T, H> &r ); 00258 NeutronVector<T, H> & operator*=(const NeutronVector<T, H> &r ); 00259 NeutronVector<T, H> & operator/=(const NeutronVector<T, H> &r ); 00260 00261 NeutronVector<T, H> operator+( NeutronVector<T, H> &r ); 00262 NeutronVector<T, H> operator-( NeutronVector<T, H> &r ); 00263 NeutronVector<T, H> operator*( NeutronVector<T, H> &r ); 00264 NeutronVector<T, H> operator/( NeutronVector<T, H> &r ); 00265 00266 00267 }; 00269 00270 #include "NeutronVector.cc" 00271 00272 #endif