lsst.afw  14.0-42-g99f9a3040+1
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public 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  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< ItemVariant > ItemContainer
 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...
 
typedef unsigned long memId
 
typedef memId(* memNewCallback) (const memId cid)
 
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...
 
template<typename F >
void findAndApply (std::string const &name, F &&func) const
 Find an item by name and run the given functor on it. 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...
 
Key< std::string > addField (Field< std::string > 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...
 
std::string repr () const
 
void markPersistent (void)
 
memId getId () const
 

Static Public Member Functions

static bool hasBeenCorrupted ()
 
static memId getNextMemId ()
 
static int init ()
 
static int census (int, memId startingMemId=0)
 
static void census (std::ostream &stream, memId startingMemId=0)
 
static const std::vector< const Citizen *> * census ()
 
static int census (int, memId startingMemId=0)
 
static void census (std::ostream &stream, memId startingMemId=0)
 
static const std::vector< const Citizen *> * census ()
 
static memId setNewCallbackId (memId id)
 
static memId setNewCallbackId (memId id)
 
static memId setDeleteCallbackId (memId id)
 
static memId setDeleteCallbackId (memId id)
 
static memNewCallback setNewCallback (memNewCallback func)
 
static memCallback setDeleteCallback (memCallback func)
 
static memCallback setCorruptionCallback (memCallback func)
 

Public Attributes

 magicSentinel
 

Static Public Attributes

static int const VERSION = 1
 

Friends

class detail::Access
 

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 53 of file SchemaImpl.h.

Member Typedef Documentation

◆ FlagMap

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

Definition at line 77 of file SchemaImpl.h.

◆ ItemContainer

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

Definition at line 71 of file SchemaImpl.h.

◆ ItemTypes

An MPL sequence of all the allowed SchemaItem templates.

Definition at line 67 of file SchemaImpl.h.

◆ ItemVariant

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 69 of file SchemaImpl.h.

◆ NameMap

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

Definition at line 73 of file SchemaImpl.h.

◆ OffsetMap

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

Definition at line 75 of file SchemaImpl.h.

Constructor & Destructor Documentation

◆ SchemaImpl()

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

Default constructor.

Definition at line 151 of file SchemaImpl.h.

Member Function Documentation

◆ addField() [1/4]

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).

◆ addField() [2/4]

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).

◆ addField() [3/4]

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).

◆ addField() [4/4]

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

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

◆ contains()

template<typename T >
int lsst::afw::table::detail::SchemaImpl::contains ( SchemaItem< T > const &  item,
int  flags 
) const

◆ find() [1/3]

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).

◆ find() [2/3]

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).

◆ find() [3/3]

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

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

◆ findAndApply()

template<typename F >
void lsst::afw::table::detail::SchemaImpl::findAndApply ( std::string const &  name,
F &&  func 
) const
inline

Find an item by name and run the given functor on it.

Definition at line 104 of file SchemaImpl.h.

◆ getFieldCount()

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

The total number of fields.

Definition at line 83 of file SchemaImpl.h.

◆ getFlagFieldCount()

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

The number of Flag fields.

Definition at line 86 of file SchemaImpl.h.

◆ getItems()

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 148 of file SchemaImpl.h.

◆ getNames() [1/2]

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

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

◆ getNames() [2/2]

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).

◆ getNonFlagFieldCount()

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

The number of non-Flag fields.

Definition at line 89 of file SchemaImpl.h.

◆ getRecordSize()

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

The size of a record in bytes.

Definition at line 80 of file SchemaImpl.h.

◆ replaceField()

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

◆ detail::Access

friend class detail::Access
friend

Definition at line 195 of file SchemaImpl.h.

Member Data Documentation

◆ VERSION

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

Definition at line 64 of file SchemaImpl.h.


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