25 #ifndef LSST_DAF_BASE_CITIZEN_H
26 #define LSST_DAF_BASE_CITIZEN_H
35 #include "boost/noncopyable.hpp"
42 class PersistentCitizenScope;
64 Citizen(
const std::type_info &);
70 std::string
repr()
const;
74 static void census(std::ostream &stream,
memId startingMemId = 0);
75 static const std::vector<const Citizen *> *
census();
93 typedef std::map<Citizen const*, CitizenInfo>
table;
unsigned long memId
Type of the block's ID.
static int init()
Called once when the memory system is being initialised.
~PersistentCitizenScope()
Citizen & operator=(Citizen const &)
memId getId() const
Return the Citizen's ID.
memId(* memNewCallback)(const memId cid)
A function used to register a callback.
static memCallback setCorruptionCallback(memCallback func)
Set the CorruptionCallback function.
std::map< Citizen const *, CitizenInfo > table
memId(* memCallback)(const Citizen *ptr)
static table _activeCitizens
void markPersistent(void)
Mark a Citizen as persistent and not destroyed until process end.
std::string repr() const
Return a string representation of a Citizen.
static memId setNewCallbackId(memId id)
Call the NewCallback when block is allocated.
std::pair< memId, pthread_t > CitizenInfo
static memNewCallback setNewCallback(memNewCallback func)
Set the NewCallback function.
static bool & _shouldPersistCitizens()
Set the NewCallback function.
static bool hasBeenCorrupted()
Check all allocated blocks for corruption.
static memCallback _deleteCallback
static table _persistentCitizens
static memId setDeleteCallbackId(memId id)
Call the current DeleteCallback when block is deleted.
Citizen(const std::type_info &)
static memCallback setDeleteCallback(memCallback func)
Set the DeleteCallback function.
static memId _nextMemIdAndIncrement(void)
Return the memId and prepare for the next object to be allocated.
static memId _nextMemId(void)
Return the memId of the next object to be allocated.
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
static memCallback _corruptionCallback
static const std::vector< const Citizen * > * census()
Return a (newly allocated) std::vector of active Citizens sorted by ID.
static memId _addCitizen(Citizen const *c)
static memNewCallback _newCallback
static memId getNextMemId()
Return the memId of the next object to be allocated.
bool _hasBeenCorrupted() const