// PlacementCategory_t.cxx #include "PlacementCategory.h" #include "hesbase/FileType.h" #include "hesbase/FileId.h" using hes::FileType; using hes::FileId; using hes::EventId; using hes::EdoType; using hes::EdoKey; using hes::EdoTypeKey; using hes::EdoId; using hes::PlacementCategoryType; using hes::PlacementCategory; int main() { string line = "--------------------------------------"; cout << line << endl; { PlacementCategory pc; cout << pc << endl; assert( ! pc.is_valid() ); cout << line << endl; } FileId fid(FileType(1), 0xabcdefL, 0x12345678L); FileId fid2(FileType(1), 0xabcdefL, 0x24681234L); assert( fid.is_valid() ); EventId eid(0xdeadbeefL, 0xdeadbeefL); EventId eid2(0x12345678L, 0xdeadbeefL); EdoType t1(1); EdoType t2(2); EdoType t3(3); EdoKey k1("one"); EdoKey k2("two"); EdoKey k3("three"); EdoTypeKey tk11(t1,k1); EdoTypeKey tk12(t1,k2); EdoTypeKey tk22(t2,k2); EdoTypeKey tk21(t2,k1); EdoTypeKey tk13(t1,k3); EdoTypeKey tk31(t3,k1); EdoId eid11(fid, eid, t1, k1); EdoId eid12(fid, eid, t1, k2); EdoId eid21(fid, eid, t2, k1); EdoId eid31(fid, eid, t3, k1); EdoId eid22_badev(fid, eid2, t2, k2); EdoId eid22_badfi(fid2, eid, t2, k2); PlacementCategoryType pct("mycat"); cout << pct << endl; { PlacementCategory pc(pct, eid); cout << pc << endl; assert( ! pc.is_valid() ); } cout << line << endl; pct.insert(tk11); pct.insert(t2); pct.insert(tk31); cout << pct << endl; { PlacementCategory pc(pct, eid); cout << pc << endl; assert( ! pc.is_valid() ); } cout << line << endl; pct.close(); PlacementCategory::size_type nid = 0; cout << pct << endl; PlacementCategory pc(pct, eid); cout << pc << endl; assert( pc.is_valid() ); assert( &pc.type() == &pct ); assert( pc.event_id() == eid ); assert( pc.size() == nid ); assert( pc.edo_ids().size() == nid ); cout << line << endl; pc.insert(eid11); ++nid; pc.insert(eid21); ++nid; pc.insert(eid31); ++nid; cout << pc << endl; assert( pc.is_valid() ); assert( &pc.type() == &pct ); assert( pc.size() == nid ); assert( pc.edo_ids().size() == nid ); cout << line << endl; pc.insert(eid12); assert( pc.size() == nid ); pc.insert(eid21); assert( pc.size() == nid ); pc.insert(eid22_badev); assert( pc.size() == nid ); pc.insert(eid22_badfi); ++nid; assert( pc.size() == nid ); cout << pc << endl; assert( pc.is_valid() ); assert( &pc.type() == &pct ); assert( pc.has(tk11) ); assert( pc.edo_id(tk11).is_valid() ); assert( pc.edo_id(t1,k1).is_valid() ); assert( pc.has(t1, k1) ); assert( pc.has(tk21) ); assert( ! pc.has(tk13) ); assert( ! pc.edo_id(tk13).is_valid() ); assert( ! pc.edo_id(t1,k3).is_valid() ); assert( ! pc.has(tk12) ); assert( ! pc.edo_id(tk12).is_valid() ); cout << line << endl; return 0; }