2 #include "boost/format.hpp"
13 class SimpleIdFactory :
public IdFactory {
15 RecordId operator()()
override {
return ++_current; }
17 void notify(
RecordId id)
override { _current =
id; }
21 SimpleIdFactory() : _current(0) {}
27 class SourceIdFactory :
public IdFactory {
30 if (++_lower & _upperMask) {
33 (boost::format(
"Next ID '%s' is too large for the number of reserved bits") %
37 return _upper | _lower;
42 if (newLower & _upperMask) {
44 pex::exceptions::InvalidParameterError,
45 (boost::format(
"Explicit ID '%s' does not have the correct form.") % newLower).str());
52 SourceIdFactory(
RecordId expId,
int reserved)
53 : _upper(expId << reserved),
56 if (_upper >> reserved != expId) {
57 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
58 (boost::format(
"Exposure ID '%s' is too large.") % expId).str());
73 return std::make_shared<SourceIdFactory>(expId, reserved);