2#include "boost/format.hpp"
13class SimpleIdFactory :
public IdFactory {
15 RecordId operator()()
override {
return ++_current; }
17 void notify(
RecordId id)
override { _current =
id; }
27class 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);
#define LSST_EXCEPT(type,...)
static std::shared_ptr< IdFactory > makeSimple()
Return a simple IdFactory that simply counts from 1.
static std::shared_ptr< IdFactory > makeSource(RecordId expId, int reserved)
Return an IdFactory that includes another, fixed ID in the higher-order bits.
std::int64_t RecordId
Type used for unique IDs for records.