// EdoId_t.cxx #include "EdoId.h" #include #include #include "FileType.h" #include "FileId.h" #include "EventId.h" #include "EdoType.h" #include "EdoKey.h" #include "EdoTypeKey.h" using std::cout; using std::endl; using hes::Index; using hes::IndexVector; using hes::FileType; using hes::FileId; using hes::EventId; using hes::EdoType; using hes::EdoKey; using hes::EdoTypeKey; using hes::EdoId; int main() { string line = "--------------------------------------"; cout << line << endl; { cout << "Size of EdoId is " << sizeof(EdoId) << " bytes" << endl; assert( sizeof(EdoId) == 4 ); cout << line << endl; } { cout << "Version: " << EdoId::version() << endl; assert( EdoId::version() == 1 ); cout << line << endl; } { assert( EdoId::id_count() == 0 ); assert( EdoId::max_id_count() > 100000 ); EdoId id; assert( EdoId::id_count() == 0 ); assert( ! id.is_valid() ); cout << id << endl; cout << id.event_id() << endl; cout << id.type() << endl; cout << id.key() << endl; cout << id.type_key() << endl; cout << id.file_id() << endl; cout << line << endl; } { FileType ftype(1); FileId fid(ftype, 0xabababL, 0x12121212L); EventId eid(0xcdcdcdcd, 0x34343434); EdoType typ(0xefefefef); EdoKey key("mykey"); EdoId id(fid, eid, typ, key); assert( EdoId::id_count() == 1 ); cout << fid << endl; cout << eid << endl; cout << typ << endl; cout << key << endl; cout << id << endl; cout << id.file_id() << endl;; cout << id.event_id() << endl; cout << id.type() << endl; cout << id.key() << endl; cout << id.type_key() << endl; assert( id.is_valid() ); assert( id.file_id() == fid ); assert( id.event_id() == eid ); assert( id.type() == typ ); assert( id.key() == key ); assert( id.type_key() == EdoTypeKey(typ,key) ); cout << line << endl; const IndexVector& idxs = id.indices(); assert( idxs.size() == 7 ); assert( idxs[0] == fid.type_hi_index() ); { EdoId id2(idxs); cout << id2 << endl; assert( id2 == id ); assert( EdoId::id_count() == 1 ); } cout << line << endl; { IndexVector::const_iterator iidx = idxs.begin(); EdoId id2(iidx, EdoId::version()); cout << id2 << endl; assert( id2 == id ); assert( EdoId::id_count() == 1 ); assert( iidx = idxs.end() ); } cout << line << endl; } return 0; }