3 #include "Alignment/Geners/interface/IOException.hh" 5 #include "Alignment/Geners/interface/StringArchive.hh" 6 #include "Alignment/Geners/interface/streamposIO.hh" 11 std::vector<unsigned long long> idlist;
12 catalog_.search(reference.namePattern(),
13 reference.categoryPattern(),
15 const unsigned long nfound = idlist.size();
16 for (
unsigned long i=0;
i<nfound; ++
i)
18 CPP11_shared_ptr<const CatalogEntry> pentry =
19 catalog_.retrieveEntry(idlist[
i]);
20 if (reference.isIOCompatible(*pentry))
21 addItemToReference(reference, idlist[i]);
25 std::istream& StringArchive::inputStream(
const unsigned long long id,
28 if (!
id)
throw gs::IOInvalidArgument(
29 "In gs::StringArchive::inputStream: invalid item id");
32 unsigned long long itemLen;
33 if (!catalog_.retrieveStreampos(
id, &cCode, &itemLen, &pos))
35 std::ostringstream os;
36 os <<
"In gs::StringArchive::inputStream: " 37 <<
"failed to locate item with id " <<
id;
38 throw gs::IOInvalidArgument(os.str());
46 bool StringArchive::isEqual(
const AbsArchive& cata)
const 48 const StringArchive&
r =
static_cast<const StringArchive&
>(cata);
49 return lastpos_ == r.lastpos_ &&
51 stream_ == r.stream_ &&
52 catalog_ == r.catalog_;
57 write_pod(of, lastpos_);
58 write_pod(of,
name());
60 stream_.classId().write(of) &&
62 catalog_.classId().write(of) &&
66 StringArchive* StringArchive::read(
const ClassId&
id, std::istream&
in)
68 static const ClassId current(ClassId::makeId<StringArchive>());
69 current.ensureSameId(
id);
71 std::streampos lastpos;
72 read_pod(in, &lastpos);
75 if (in.fail())
throw IOReadFailure(
76 "In gs::StringArchive::read: input stream failure");
77 CPP11_auto_ptr<StringArchive> archive(
new StringArchive(nam.c_str()));
78 archive->lastpos_ = lastpos;
79 ClassId streamId(in, 1);
80 CharBuffer::restore(streamId, in, &archive->stream_);
82 CPP11_auto_ptr<ContiguousCatalog>
p(ContiguousCatalog::read(catId, in));
84 archive->catalog_ = *
p;
85 return archive.release();
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)