LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
lsst.afw.table::SubSchema Class Reference

A proxy type for name lookups in a Schema. More...

#include <Schema.h>

Public Member Functions

template<typename T >
SchemaItem< T > find (std::string const &name) const
 Find a nested SchemaItem by name. More...
 
SubSchema operator[] (std::string const &name) const
 Return a nested proxy. More...
 
std::string const & getPrefix () const
 Return the prefix that defines this SubSchema relative to its parent Schema. More...
 
std::set< std::string > getNames (bool topOnly=false) const
 Return a set of nested names that start with the SubSchema's prefix. More...
 
template<typename T >
 operator Key< T > () const
 Implicit conversion to the appropriate Key type. More...
 
template<typename T >
 operator Field< T > () const
 Implicit conversion to the appropriate Key type. More...
 

Private Types

typedef detail::SchemaImpl Impl
 

Private Member Functions

 SubSchema (boost::shared_ptr< Impl > impl, boost::shared_ptr< AliasMap > aliases, std::string const &name)
 

Private Attributes

boost::shared_ptr< Impl_impl
 
boost::shared_ptr< AliasMap_aliases
 
std::string _name
 

Friends

class Schema
 

Detailed Description

A proxy type for name lookups in a Schema.

Elements of schema names are assumed to be separated by periods ("a.b.c.d"); an incomplete lookup is one that does not resolve to a field. Not that even complete lookups can have nested names; a Point field, for instance, has "x" and "y" nested names.

This proxy object is implicitly convertible to both the appropriate Key type and the appropriate Field type, if the name is a complete one, and supports additional find() operations for nested names.

SubSchema is implemented as a proxy that essentially calls Schema::find after concatenating strings. It does not provide any performance advantage over using Schema::find directly. It is also lazy, so looking up a name prefix that does not exist within the schema is not considered an error until the proxy is used.

Some examples:

* Schema schema(false);
* Key<int> a_i = schema.addField<int>("a.i", "integer field");
* Key< Point<double> > a_p = schema.addField< Point<double> >("a.p", "point field");
*
* assert(schema["a.i"] == a_i);
* SubSchema a = schema["a"];
* assert(a["i"] == a_i);
* Field<int> f_a_i = schema["a.i"];
* assert(f_a_i.getDoc() == "integer field");
* assert(schema["a.i"] == "a.i");
* assert(schema.find("a.p.x") == a_p.getX());
*

Definition at line 330 of file Schema.h.

Member Typedef Documentation

Definition at line 331 of file Schema.h.

Constructor & Destructor Documentation

lsst.afw.table::SubSchema::SubSchema ( boost::shared_ptr< Impl impl,
boost::shared_ptr< AliasMap aliases,
std::string const &  name 
)
private

Member Function Documentation

template<typename T >
SchemaItem<T> lsst.afw.table::SubSchema::find ( std::string const &  name) const

Find a nested SchemaItem by name.

std::set<std::string> lsst.afw.table::SubSchema::getNames ( bool  topOnly = false) const

Return a set of nested names that start with the SubSchema's prefix.

Returns an instance of Python's builtin set in Python.

See Also
Schema::getNames
std::string const& lsst.afw.table::SubSchema::getPrefix ( ) const
inline

Return the prefix that defines this SubSchema relative to its parent Schema.

Definition at line 342 of file Schema.h.

342 { return _name; }
template<typename T >
lsst.afw.table::SubSchema::operator Field< T > ( ) const
inline

Implicit conversion to the appropriate Key type.

Implicit conversion operators cannot be translated to Python. Instead, the SWIG wrappers provide an equivalent asField() method.

Definition at line 368 of file Schema.h.

368 { return _impl->find<T>(_aliases->apply(_name)).field; }
tbl::Key< int > field
boost::shared_ptr< AliasMap > _aliases
Definition: Schema.h:377
boost::shared_ptr< Impl > _impl
Definition: Schema.h:376
template<typename T >
lsst.afw.table::SubSchema::operator Key< T > ( ) const
inline

Implicit conversion to the appropriate Key type.

Implicit conversion operators cannot be translated to Python. Instead, the SWIG wrappers provide an equivalent asKey() method.

Definition at line 359 of file Schema.h.

359 { return _impl->find<T>(_aliases->apply(_name)).key; }
boost::shared_ptr< AliasMap > _aliases
Definition: Schema.h:377
boost::shared_ptr< Impl > _impl
Definition: Schema.h:376
SubSchema lsst.afw.table::SubSchema::operator[] ( std::string const &  name) const

Return a nested proxy.

Friends And Related Function Documentation

friend class Schema
friend

Definition at line 372 of file Schema.h.

Member Data Documentation

boost::shared_ptr< AliasMap > lsst.afw.table::SubSchema::_aliases
private

Definition at line 377 of file Schema.h.

boost::shared_ptr< Impl > lsst.afw.table::SubSchema::_impl
private

Definition at line 376 of file Schema.h.

std::string lsst.afw.table::SubSchema::_name
private

Definition at line 378 of file Schema.h.


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