LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Classes | Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
lsst::afw::table::detail::SchemaImpl Class Reference

A private implementation class to hide the messy details of Schema. More...

#include <SchemaImpl.h>

Inheritance diagram for lsst::afw::table::detail::SchemaImpl:
lsst::daf::base::Citizen

Classes

struct  MakeItem
 Boost.MPL metafunction that returns a SchemaItem<T> given a T. More...
 
struct  VisitorWrapper
 A functor-wrapper used in the implementation of Schema::forEach. More...
 

Public Types

typedef boost::mpl::transform
< FieldTypes, MakeItem >::type 
ItemTypes
 An MPL sequence of all the allowed SchemaItem templates. More...
 
typedef
boost::make_variant_over
< ItemTypes >::type 
ItemVariant
 A Boost.Variant type that can hold any one of the allowed SchemaItem types. More...
 
typedef std::vector< ItemVariantItemContainer
 A std::vector whose elements can be any of the allowed SchemaItem types. More...
 
typedef std::map< std::string,
int > 
NameMap
 A map from field names to position in the vector, so we can do name lookups. More...
 
typedef std::map< int, int > OffsetMap
 A map from standard field offsets to position in the vector, so we can do field lookups. More...
 
typedef std::map< std::pair
< int, int >, int > 
FlagMap
 A map from Flag field offset/bit pairs to position in the vector, so we can do Flag field lookups. More...
 
- Public Types inherited from lsst::daf::base::Citizen
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

int getRecordSize () const
 The size of a record in bytes. More...
 
int getFieldCount () const
 The total number of fields. More...
 
int getFlagFieldCount () const
 The number of Flag fields. More...
 
int getNonFlagFieldCount () const
 The number of non-Flag fields. More...
 
template<typename T >
SchemaItem< T > find (std::string const &name) const
 Find an item by name (used to implement Schema::find). More...
 
template<typename T >
SchemaItem< T > find (Key< T > const &key) const
 Find an item by key (used to implement Schema::find). More...
 
SchemaItem< Flag > find (Key< Flag > const &key) const
 Find an item by key (used to implement Schema::find). More...
 
std::set< std::string > getNames (bool topOnly) const
 Return a set of field names (used to implement Schema::getNames). More...
 
std::set< std::string > getNames (bool topOnly, std::string const &prefix) const
 Return a set of field names (used to implement SubSchema::getNames). More...
 
template<typename T >
int contains (SchemaItem< T > const &item, int flags) const
 
template<typename T >
Key< T > addField (Field< T > const &field, bool doReplace=false)
 Add a field to the schema (used to implement Schema::addField). More...
 
Key< Flag > addField (Field< Flag > const &field, bool doReplace=false)
 Add a field to the schema (used to implement Schema::addField). More...
 
template<typename T >
Key< Array< T > > addField (Field< Array< T > > const &field, bool doReplace=false)
 Add a field to the schema (used to implement Schema::addField). More...
 
template<typename T >
void replaceField (Key< T > const &key, Field< T > const &field)
 Replace the Field in an existing SchemaItem without changing the Key. More...
 
ItemContainer const & getItems () const
 Return the vector of SchemaItem variants. More...
 
 SchemaImpl ()
 Default constructor. More...
 
- Public Member Functions inherited from lsst::daf::base::Citizen
 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 Attributes

static int const VERSION = 1
 

Private Member Functions

template<typename T >
Key< T > addFieldImpl (int elementSize, int elementCount, Field< T > const &field, bool doReplace)
 

Private Attributes

int _recordSize
 
int _lastFlagField
 
int _lastFlagBit
 
ItemContainer _items
 
NameMap _names
 
OffsetMap _offsets
 
FlagMap _flags
 

Friends

class detail::Access
 

Additional Inherited Members

- Static Public Member Functions inherited from lsst::daf::base::Citizen
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...
 
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...
 
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...
 
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

A private implementation class to hide the messy details of Schema.

This can't be a real pimpl class, because some of the most important functionality is in the forEach function, a templated function we can't explicitly instantiate in a source file. But putting all the details here draws a clear line between what users should look at (Schema) and what they shouldn't (this).

Because Schema holds SchemaImpl by shared pointer, one SchemaImpl can be shared between multiple Schemas (and SubSchemas), which implement copy-on-write by creating a new SchemaImpl if the pointer they have isn't unique when they are modified.

SchemaImpl inherits from Citizen; this allows both Schemas and SubSchemas to be tracked in a more meaningful way than if we derived either of those from Citizen.

Definition at line 56 of file SchemaImpl.h.

Member Typedef Documentation

typedef std::map<std::pair<int,int>,int> lsst::afw::table::detail::SchemaImpl::FlagMap

A map from Flag field offset/bit pairs to position in the vector, so we can do Flag field lookups.

Definition at line 82 of file SchemaImpl.h.

A std::vector whose elements can be any of the allowed SchemaItem types.

Definition at line 76 of file SchemaImpl.h.

An MPL sequence of all the allowed SchemaItem templates.

Definition at line 72 of file SchemaImpl.h.

typedef boost::make_variant_over< ItemTypes >::type lsst::afw::table::detail::SchemaImpl::ItemVariant

A Boost.Variant type that can hold any one of the allowed SchemaItem types.

Definition at line 74 of file SchemaImpl.h.

typedef std::map<std::string,int> lsst::afw::table::detail::SchemaImpl::NameMap

A map from field names to position in the vector, so we can do name lookups.

Definition at line 78 of file SchemaImpl.h.

A map from standard field offsets to position in the vector, so we can do field lookups.

Definition at line 80 of file SchemaImpl.h.

Constructor & Destructor Documentation

lsst::afw::table::detail::SchemaImpl::SchemaImpl ( )
inlineexplicit

Default constructor.

Definition at line 141 of file SchemaImpl.h.

141  :
142  daf::base::Citizen(typeid(this)),
144  {}

Member Function Documentation

template<typename T >
Key<T> lsst::afw::table::detail::SchemaImpl::addField ( Field< T > const &  field,
bool  doReplace = false 
)

Add a field to the schema (used to implement Schema::addField).

Key<Flag> lsst::afw::table::detail::SchemaImpl::addField ( Field< Flag > const &  field,
bool  doReplace = false 
)

Add a field to the schema (used to implement Schema::addField).

template<typename T >
Key< Array<T> > lsst::afw::table::detail::SchemaImpl::addField ( Field< Array< T > > const &  field,
bool  doReplace = false 
)

Add a field to the schema (used to implement Schema::addField).

template<typename T >
Key<T> lsst::afw::table::detail::SchemaImpl::addFieldImpl ( int  elementSize,
int  elementCount,
Field< T > const &  field,
bool  doReplace 
)
private
template<typename T >
int lsst::afw::table::detail::SchemaImpl::contains ( SchemaItem< T > const &  item,
int  flags 
) const
template<typename T >
SchemaItem<T> lsst::afw::table::detail::SchemaImpl::find ( std::string const &  name) const

Find an item by name (used to implement Schema::find).

template<typename T >
SchemaItem<T> lsst::afw::table::detail::SchemaImpl::find ( Key< T > const &  key) const

Find an item by key (used to implement Schema::find).

SchemaItem<Flag> lsst::afw::table::detail::SchemaImpl::find ( Key< Flag > const &  key) const

Find an item by key (used to implement Schema::find).

int lsst::afw::table::detail::SchemaImpl::getFieldCount ( ) const
inline

The total number of fields.

Definition at line 88 of file SchemaImpl.h.

88 { return _names.size(); }
int lsst::afw::table::detail::SchemaImpl::getFlagFieldCount ( ) const
inline

The number of Flag fields.

Definition at line 91 of file SchemaImpl.h.

91 { return _flags.size(); }
ItemContainer const& lsst::afw::table::detail::SchemaImpl::getItems ( ) const
inline

Return the vector of SchemaItem variants.

Fields are in the order they are added. That means they're also ordered with increasing Key offsets, except for Flag fields, which are in increasing order of (offset, bit) relative to each other, but not relative to all the other fields.

Definition at line 138 of file SchemaImpl.h.

138 { return _items; }
std::set<std::string> lsst::afw::table::detail::SchemaImpl::getNames ( bool  topOnly) const

Return a set of field names (used to implement Schema::getNames).

std::set<std::string> lsst::afw::table::detail::SchemaImpl::getNames ( bool  topOnly,
std::string const &  prefix 
) const

Return a set of field names (used to implement SubSchema::getNames).

int lsst::afw::table::detail::SchemaImpl::getNonFlagFieldCount ( ) const
inline

The number of non-Flag fields.

Definition at line 94 of file SchemaImpl.h.

94 { return _offsets.size(); }
int lsst::afw::table::detail::SchemaImpl::getRecordSize ( ) const
inline

The size of a record in bytes.

Definition at line 85 of file SchemaImpl.h.

template<typename T >
void lsst::afw::table::detail::SchemaImpl::replaceField ( Key< T > const &  key,
Field< T > const &  field 
)

Replace the Field in an existing SchemaItem without changing the Key.

Friends And Related Function Documentation

friend class detail::Access
friend

Definition at line 184 of file SchemaImpl.h.

Member Data Documentation

FlagMap lsst::afw::table::detail::SchemaImpl::_flags
private

Definition at line 195 of file SchemaImpl.h.

ItemContainer lsst::afw::table::detail::SchemaImpl::_items
private

Definition at line 192 of file SchemaImpl.h.

int lsst::afw::table::detail::SchemaImpl::_lastFlagBit
private

Definition at line 191 of file SchemaImpl.h.

int lsst::afw::table::detail::SchemaImpl::_lastFlagField
private

Definition at line 190 of file SchemaImpl.h.

NameMap lsst::afw::table::detail::SchemaImpl::_names
private

Definition at line 193 of file SchemaImpl.h.

OffsetMap lsst::afw::table::detail::SchemaImpl::_offsets
private

Definition at line 194 of file SchemaImpl.h.

int lsst::afw::table::detail::SchemaImpl::_recordSize
private

Definition at line 189 of file SchemaImpl.h.

int const lsst::afw::table::detail::SchemaImpl::VERSION = 1
static

Definition at line 69 of file SchemaImpl.h.


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