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,
73 return std::make_shared<SourceIdFactory>(expId, reserved);
std::int64_t RecordId
Type used for unique IDs for records.
static std::shared_ptr< IdFactory > makeSource(RecordId expId, int reserved)
Return an IdFactory that includes another, fixed ID in the higher-order bits.
A base class for image defects.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
static std::shared_ptr< IdFactory > makeSimple()
Return a simple IdFactory that simply counts from 1.