40 {
42 if (id == 0) return empty;
44 if (r.second) {
45
46 CatalogVector factoryArgs;
47
48
52 indexIter !=
_index.
end() && indexIter->get(indexKeys.id) ==
id; ++indexIter) {
53 if (name.empty()) {
54 name = indexIter->get(indexKeys.name);
55 } else if (name != indexIter->get(indexKeys.name)) {
57 MalformedArchiveError,
58 (boost::format("Inconsistent name in index for ID %d; got '%s', expected '%s'") %
59 indexIter->get(indexKeys.id) % indexIter->get(indexKeys.name) % name)
60 .str());
61 }
63 module = indexIter->get(indexKeys.module);
64 } else if (module != indexIter->get(indexKeys.module)) {
66 MalformedArchiveError,
67 (boost::format(
68 "Inconsistent module in index for ID %d; got '%s', expected '%s'") %
69 indexIter->get(indexKeys.id) % indexIter->get(indexKeys.module) % module)
70 .str());
71 }
72 int catArchive = indexIter->get(indexKeys.catArchive);
74 break;
75 }
79 MalformedArchiveError,
80 (boost::format(
81 "Invalid catalog number in index for ID %d; got '%d', max is '%d'") %
83 .str());
84 }
85 BaseCatalog& fullCatalog =
_catalogs[catN];
87 std::size_t i2 = i1 + indexIter->get(indexKeys.nRows);
88 if (i2 > fullCatalog.size()) {
90 (boost::format("Index and data catalogs do not agree for ID %d; "
91 "catalog %d has %d rows, not %d") %
92 indexIter->get(indexKeys.id) % indexIter->get(indexKeys.catArchive) %
93 fullCatalog.size() % i2)
94 .str());
95 }
96 factoryArgs.push_back(
BaseCatalog(fullCatalog.getTable(), fullCatalog.begin() + i1,
97 fullCatalog.begin() + i2));
98 }
99 try {
101 r.first->second = factory.read(self, factoryArgs);
102 } catch (pex::exceptions::Exception& err) {
104 (boost::format("loading object with id=%d, name='%s'") % id % name).str());
105 throw;
106 }
107
108
109 assert(r.first->second);
110 } else if (!r.first->second) {
111
112
113
114
115
116
118 (boost::format("Not trying to reload object with id=%d; a previous attempt to "
119 "load it already failed.") %
120 id)
121 .str());
122 }
123 return r.first->second;
124 }
table::Key< std::string > name
#define LSST_EXCEPT_ADD(e, m)
Add the current location and a message to an existing exception before rethrowing it.
iterator find(typename Field< T >::Value const &value, Key< T > const &key)
Return an iterator to the record with the given value.
CatalogIterator< typename Internal::iterator > iterator
static PersistableFactory const & lookup(std::string const &name, std::string const &module="")
Return the factory that has been registered with the given name.
CatalogT< BaseRecord > BaseCatalog
static constexpr int const NO_CATALOGS_SAVED
Special value used for catArchive, catPersistable, and row0 when an object with no state is saved.