lsst.daf.base  17.0.1-1-gaef33af+3
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
lsst::daf::base::Citizen Class Reference

Citizen is a class that should be among all LSST classes base classes, and handles basic memory management. More...

#include <Citizen.h>

Inheritance diagram for lsst::daf::base::Citizen:
lsst::daf::base::PropertySet lsst::daf::base::PropertyList

Public Types

enum  { magicSentinel = 0xdeadbeef }
 
typedef unsigned long memId
 Type of the block's ID. More...
 
typedef memId(* memNewCallback) (const memId cid)
 A function used to register a callback. More...
 
typedef memId(* memCallback) (const Citizen *ptr)
 

Public Member Functions

 Citizen (const std::type_info &)
 
 Citizen (Citizen const &)
 
 ~Citizen ()
 
Citizenoperator= (Citizen const &)
 
std::string repr () const
 Return a string representation of a Citizen. More...
 
void markPersistent (void)
 Mark a Citizen as persistent and not destroyed until process end. More...
 
memId getId () const
 Return the Citizen's ID. More...
 

Static Public Member Functions

static bool hasBeenCorrupted ()
 Check all allocated blocks for corruption. More...
 
static memId getNextMemId ()
 Return the memId of the next object to be allocated. More...
 
static int init ()
 Called once when the memory system is being initialised. More...
 
Census

Provide a list of current Citizens

static int census (int, memId startingMemId=0)
 How many active Citizens are there? More...
 
static void census (std::ostream &stream, memId startingMemId=0)
 Print a list of all active Citizens to stream, sorted by ID. More...
 
static const std::vector< const Citizen * > * census ()
 Return a (newly allocated) std::vector of active Citizens sorted by ID. More...
 
callbackIDs

Set callback Ids.

The old Id is returned

static memId setNewCallbackId (memId id)
 Call the NewCallback when block is allocated. More...
 
static memId setDeleteCallbackId (memId id)
 Call the current DeleteCallback when block is deleted. More...
 

Friends

class PersistentCitizenScope
 

callbacks

Set the New/Delete callback functions; in each case the previously installed callback is returned.

These callback functions return a value which is Added to the previously registered id.

The default callback functions are called default{New,Delete}Callback; you may want to set a break point in these callbacks from your favourite debugger

static memNewCallback setNewCallback (memNewCallback func)
 Set the NewCallback function. More...
 
static memCallback setDeleteCallback (memCallback func)
 Set the DeleteCallback function. More...
 
static memCallback setCorruptionCallback (memCallback func)
 Set the CorruptionCallback function. More...
 

Detailed Description

Citizen is a class that should be among all LSST classes base classes, and handles basic memory management.

Instances of subclasses of Citizen will automatically be given a unique id.

You can ask for infomation about the currently allocated Citizens using the census functions, request that a function of your choice be called when a specific block ID is allocated or deleted, and check whether any of the data blocks are known to be corrupted

Definition at line 55 of file Citizen.h.

Member Typedef Documentation

◆ memCallback

typedef memId(* lsst::daf::base::Citizen::memCallback) (const Citizen *ptr)

Definition at line 61 of file Citizen.h.

◆ memId

typedef unsigned long lsst::daf::base::Citizen::memId

Type of the block's ID.

Definition at line 58 of file Citizen.h.

◆ memNewCallback

typedef memId(* lsst::daf::base::Citizen::memNewCallback) (const memId cid)

A function used to register a callback.

Definition at line 60 of file Citizen.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
magicSentinel 

Definition at line 88 of file Citizen.h.

Constructor & Destructor Documentation

◆ Citizen() [1/2]

lsst::daf::base::Citizen::Citizen ( const std::type_info type)

Definition at line 163 of file Citizen.cc.

◆ Citizen() [2/2]

lsst::daf::base::Citizen::Citizen ( Citizen const &  citizen)

Definition at line 166 of file Citizen.cc.

◆ ~Citizen()

lsst::daf::base::Citizen::~Citizen ( )

Definition at line 169 of file Citizen.cc.

Member Function Documentation

◆ census() [1/3]

int lsst::daf::base::Citizen::census ( int  ,
memId  startingMemId = 0 
)
static

How many active Citizens are there?

Parameters
startingMemIdDon't print Citizens with lower IDs

Definition at line 238 of file Citizen.cc.

◆ census() [2/3]

void lsst::daf::base::Citizen::census ( std::ostream stream,
memId  startingMemId = 0 
)
static

Print a list of all active Citizens to stream, sorted by ID.

Parameters
streamstream to print to
startingMemIdDon't print Citizens with lower IDs

Definition at line 259 of file Citizen.cc.

◆ census() [3/3]

std::vector< dafBase::Citizen const * > const * lsst::daf::base::Citizen::census ( )
static

Return a (newly allocated) std::vector of active Citizens sorted by ID.

You are responsible for deleting it; or you can say std::unique_ptr<std::vector<Citizen const*> const> leaks(Citizen::census()); and not bother (that becomes std::unique_ptr in C++11)

Definition at line 287 of file Citizen.cc.

◆ getId()

dafBase::Citizen::memId lsst::daf::base::Citizen::getId ( ) const

Return the Citizen's ID.

Definition at line 206 of file Citizen.cc.

◆ getNextMemId()

dafBase::Citizen::memId lsst::daf::base::Citizen::getNextMemId ( )
static

Return the memId of the next object to be allocated.

Definition at line 209 of file Citizen.cc.

◆ hasBeenCorrupted()

bool lsst::daf::base::Citizen::hasBeenCorrupted ( )
static

Check all allocated blocks for corruption.

Definition at line 316 of file Citizen.cc.

◆ init()

int lsst::daf::base::Citizen::init ( )
static

Called once when the memory system is being initialised.

Definition at line 196 of file Citizen.cc.

◆ markPersistent()

void lsst::daf::base::Citizen::markPersistent ( void  )

Mark a Citizen as persistent and not destroyed until process end.

Definition at line 225 of file Citizen.cc.

◆ operator=()

Citizen& lsst::daf::base::Citizen::operator= ( Citizen const &  )
inline

Definition at line 67 of file Citizen.h.

◆ repr()

std::string lsst::daf::base::Citizen::repr ( ) const

Return a string representation of a Citizen.

Definition at line 219 of file Citizen.cc.

◆ setCorruptionCallback()

dafBase::Citizen::memCallback lsst::daf::base::Citizen::setCorruptionCallback ( Citizen::memCallback  func)
static

Set the CorruptionCallback function.

Parameters
funcfunction be called when block is found to be corrupted

Definition at line 391 of file Citizen.cc.

◆ setDeleteCallback()

dafBase::Citizen::memCallback lsst::daf::base::Citizen::setDeleteCallback ( Citizen::memCallback  func)
static

Set the DeleteCallback function.

Parameters
funcfunction be called when desired block is deleted

Definition at line 381 of file Citizen.cc.

◆ setDeleteCallbackId()

dafBase::Citizen::memId lsst::daf::base::Citizen::setDeleteCallbackId ( Citizen::memId  id)
static

Call the current DeleteCallback when block is deleted.

Parameters
idDesired ID

Definition at line 347 of file Citizen.cc.

◆ setNewCallback()

dafBase::Citizen::memNewCallback lsst::daf::base::Citizen::setNewCallback ( Citizen::memNewCallback  func)
static

Set the NewCallback function.

Parameters
funcThe new function to be called when a designated block is allocated

Definition at line 371 of file Citizen.cc.

◆ setNewCallbackId()

dafBase::Citizen::memId lsst::daf::base::Citizen::setNewCallbackId ( Citizen::memId  id)
static

Call the NewCallback when block is allocated.

Parameters
idDesired ID

Definition at line 337 of file Citizen.cc.

Friends And Related Function Documentation

◆ PersistentCitizenScope

friend class PersistentCitizenScope
friend

Definition at line 120 of file Citizen.h.


The documentation for this class was generated from the following files: