Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Message_AMOS.hh

Go to the documentation of this file.
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 #ifndef __Message_AMOS_HH 00012 #define __Message_AMOS_HH 1 00013 00014 #include "utility_AMOS.hh" 00015 #include <string> 00016 #include <vector> 00017 #include <iostream> 00018 00019 00020 00021 namespace AMOS { 00022 00023 const char E_ADD = 'A'; 00024 const char E_DELETE = 'D'; 00025 const char E_REPLACE = 'R'; 00026 const NCode_t F_NULL = Encode ("nul"); 00027 const NCode_t F_AHANG = Encode ("ahg"); 00028 const NCode_t F_ACTION = Encode ("act"); 00029 const NCode_t F_ADJACENCY = Encode ("adj"); 00030 const NCode_t F_BASEPOSITION = Encode ("bcp"); 00031 const NCode_t F_BHANG = Encode ("bhg"); 00032 const NCode_t F_BID = Encode ("bid"); 00033 const NCode_t F_CLEAR = Encode ("clr"); 00034 const NCode_t F_COMMENT = Encode ("com"); 00035 const NCode_t F_COUNT = Encode ("cnt"); 00036 const NCode_t F_EID = Encode ("eid"); 00037 const NCode_t F_EDGE = Encode ("edg"); 00038 const NCode_t F_FLAG = Encode ("flg"); 00039 const NCode_t F_FRAGMENT = Encode ("frg"); 00040 const NCode_t F_GAPS = Encode ("gap"); 00041 const NCode_t F_IID = Encode ("iid"); 00042 const NCode_t F_LIBRARY = Encode ("lib"); 00043 const NCode_t F_LINK = Encode ("lnk"); 00044 const NCode_t F_MAP = Encode ("map"); 00045 const NCode_t F_MEAN = Encode ("mea"); 00046 const NCode_t F_MEMBER = Encode ("mbr"); 00047 const NCode_t F_NODES = Encode ("nds"); 00048 const NCode_t F_OBJECT = Encode ("obj"); 00049 const NCode_t F_OFFSET = Encode ("off"); 00050 const NCode_t F_POSITION = Encode ("pos"); 00051 const NCode_t F_QUALITY = Encode ("qlt"); 00052 const NCode_t F_QUALITYCLEAR = Encode ("qcr"); 00053 const NCode_t F_READS = Encode ("rds"); 00054 const NCode_t F_SCORE = Encode ("scr"); 00055 const NCode_t F_SEQUENCE = Encode ("seq"); 00056 const NCode_t F_SD = Encode ("std"); 00057 const NCode_t F_SIZE = Encode ("sze"); 00058 const NCode_t F_SOURCE = Encode ("src"); 00059 const NCode_t F_STATUS = Encode ("sts"); 00060 const NCode_t F_TYPE = Encode ("typ"); 00061 const NCode_t F_VECTORCLEAR = Encode ("vcr"); 00062 const NCode_t M_NULL = Encode ("NUL"); 00063 const NCode_t M_UNIVERSAL = Encode ("UNV"); 00064 const NCode_t M_CONTIG = Encode ("CTG"); 00065 const NCode_t M_CONTIGEDGE = Encode ("CTE"); 00066 const NCode_t M_CONTIGLINK = Encode ("CTL"); 00067 const NCode_t M_DISTRIBUTION = Encode ("DST"); 00068 const NCode_t M_EDGE = Encode ("EDG"); 00069 const NCode_t M_FEATURE = Encode ("FEA"); 00070 const NCode_t M_FRAGMENT = Encode ("FRG"); 00071 const NCode_t M_GROUP = Encode ("GRP"); 00072 const NCode_t M_KMER = Encode ("KMR"); 00073 const NCode_t M_LAYOUT = Encode ("LAY"); 00074 const NCode_t M_LIBRARY = Encode ("LIB"); 00075 const NCode_t M_LINK = Encode ("LNK"); 00076 const NCode_t M_IDMAP = Encode ("MAP"); 00077 const NCode_t M_INDEX = Encode ("IDX"); 00078 const NCode_t M_OVERLAP = Encode ("OVL"); 00079 const NCode_t M_READ = Encode ("RED"); 00080 const NCode_t M_SCAFFOLD = Encode ("SCF"); 00081 const NCode_t M_SCAFFOLDEDGE = Encode ("SCE"); 00082 const NCode_t M_SCAFFOLDLINK = Encode ("SCL"); 00083 const NCode_t M_SEQUENCE = Encode ("SEQ"); 00084 const NCode_t M_TILE = Encode ("TLE"); 00085 00086 00087 //================================================ Message_t =================== 00097 //============================================================================== 00098 class Message_t 00099 { 00100 00101 private: 00102 00103 NCode_t mcode_m; 00104 std::vector<Message_t> subs_m; 00105 HASHMAP::hash_map<NCode_t,std::string> fields_m; 00106 00107 00108 public: 00109 00110 typedef HASHMAP::hash_map<NCode_t,std::string>::const_iterator const_iterator; 00111 00112 00113 //--------------------------------------------------- Message_t -------------- 00116 Message_t ( ) 00117 { 00118 mcode_m = M_NULL; 00119 } 00120 00121 00122 //--------------------------------------------------- ~Message_t ------------- 00125 ~Message_t ( ) 00126 { 00127 00128 } 00129 00130 00131 //--------------------------------------------------- begin ------------------ 00139 const_iterator begin ( ) const 00140 { 00141 return fields_m . begin( ); 00142 } 00143 00144 00145 //--------------------------------------------------- end -------------------- 00153 const_iterator end ( ) const 00154 { 00155 return fields_m . end( ); 00156 } 00157 00158 00159 //--------------------------------------------------- clear ------------------ 00164 void clear ( ) 00165 { 00166 mcode_m = M_NULL; 00167 fields_m . clear( ); 00168 subs_m . clear( ); 00169 } 00170 00171 00172 //--------------------------------------------------- countFields ------------ 00177 Size_t countFields ( ) const 00178 { 00179 return fields_m . size( ); 00180 } 00181 00182 00183 //--------------------------------------------------- countSubMessages ------- 00188 Size_t countSubMessages ( ) const 00189 { 00190 return subs_m . size( ); 00191 } 00192 00193 00194 //--------------------------------------------------- empty ------------------ 00199 bool empty ( ) const 00200 { 00201 return (fields_m . empty( ) && subs_m . empty( )); 00202 } 00203 00204 00205 //--------------------------------------------------- exists ----------------- 00211 bool exists (NCode_t fcode) const 00212 { 00213 return fields_m . find (fcode) == fields_m . end( ) ? false : true; 00214 } 00215 00216 00217 //--------------------------------------------------- exists ----------------- 00223 bool exists (const std::string & fname) const 00224 { 00225 return exists (Encode (fname)); 00226 } 00227 00228 00229 //--------------------------------------------------- getField --------------- 00240 const std::string & getField (NCode_t fcode) const 00241 { 00242 HASHMAP::hash_map<NCode_t,std::string>::const_iterator 00243 mi = fields_m . find (fcode); 00244 if ( mi == fields_m . end( ) ) 00245 AMOS_THROW_ARGUMENT 00246 ("Cannot retrieve absent field '" + Decode (fcode) + "'"); 00247 return mi -> second; 00248 } 00249 00250 00251 //--------------------------------------------------- getField --------------- 00262 const std::string & getField (const std::string & fname) const 00263 { 00264 return getField (Encode (fname)); 00265 } 00266 00267 00268 //--------------------------------------------------- getSubMessages --------- 00273 const std::vector<Message_t> & getSubMessages ( ) const 00274 { 00275 return subs_m; 00276 } 00277 00278 00279 //--------------------------------------------------- getSubMessages --------- 00284 std::vector<Message_t> & getSubMessages ( ) 00285 { 00286 return subs_m; 00287 } 00288 00289 00290 //--------------------------------------------------- getMessageCode --------- 00298 NCode_t getMessageCode ( ) const 00299 { 00300 return mcode_m; 00301 } 00302 00303 00304 //--------------------------------------------------- operator[] ------------- 00307 const std::string & operator[] (NCode_t fcode) const 00308 { 00309 return getField (fcode); 00310 } 00311 00312 const std::string & operator[] (const std::string & fname) const 00313 { 00314 return getField (fname); 00315 } 00316 00317 00318 //--------------------------------------------------- read ------------------- 00330 bool read (std::istream & in); 00331 00332 00333 //--------------------------------------------------- removeField ------------ 00342 void removeField (NCode_t fcode) 00343 { 00344 fields_m . erase (fcode); 00345 } 00346 00347 00348 //--------------------------------------------------- removeField ------------ 00357 void removeField (const std::string & fname) 00358 { 00359 removeField (Encode (fname)); 00360 } 00361 00362 00363 //--------------------------------------------------- setSubMessages --------- 00369 void setSubMessages (const std::vector<Message_t> & subs) 00370 { 00371 subs_m = subs; 00372 } 00373 00374 00375 //--------------------------------------------------- setField --------------- 00389 void setField (NCode_t fcode, const std::string & data); 00390 00391 00392 //--------------------------------------------------- setField --------------- 00407 void setField (const std::string & fname, const std::string & data) 00408 { 00409 setField (Encode (fname), data); 00410 } 00411 00412 00413 //--------------------------------------------------- setMessageCode --------- 00419 void setMessageCode (NCode_t mcode) 00420 { 00421 mcode_m = mcode; 00422 } 00423 00424 00425 //--------------------------------------------------- setMessageCode --------- 00435 void setMessageCode (const std::string & mname) 00436 { 00437 setMessageCode (Encode (mname)); 00438 } 00439 00440 00441 //--------------------------------------------------- skip ------------------- 00456 static NCode_t skip (std::istream & in); // const 00457 00458 00459 //--------------------------------------------------- write ------------------ 00471 void write (std::ostream & out) const; 00472 00473 }; 00474 00475 00476 00477 00478 00479 //================================================ IMessagable_t =============== 00486 //============================================================================== 00487 class IMessagable_t 00488 { 00489 00490 public: 00491 00492 //--------------------------------------------------- IMessagable_t ---------- 00495 IMessagable_t ( ) 00496 { 00497 00498 } 00499 00500 00501 //--------------------------------------------------- ~IMessagable_t --------- 00504 virtual ~IMessagable_t ( ) 00505 { 00506 00507 } 00508 00509 00510 //--------------------------------------------------- getNCode --------------- 00515 virtual NCode_t getNCode ( ) const = 0; 00516 00517 00518 //--------------------------------------------------- readMessage ------------ 00531 virtual void readMessage (const Message_t & msg) = 0; 00532 00533 00534 //--------------------------------------------------- writeMessage ----------- 00543 virtual void writeMessage (Message_t & msg) const = 0; 00544 00545 }; 00546 00547 } // namespace AMOS 00548 00549 #endif // #ifndef __Message_AMOS_HH

Generated on Tue May 17 15:19:02 2005 for libAMOS by doxygen 1.3.8