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 Types | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
lsst::pex::logging::PropertyPrinter Class Reference

an class for printing the values associated with a name in a PropertySet. More...

#include <PropertyPrinter.h>

Public Types

typedef PrinterList::iterator iterator
 

Public Member Functions

 PropertyPrinter (const lsst::daf::base::PropertySet &prop, const std::string &name, const PrinterFactory &fact=defaultPrinterFactory)
 
iterator begin ()
 
iterator last ()
 
size_t valueCount ()
 

Static Public Attributes

static PrinterFactory defaultPrinterFactory
 

Private Attributes

boost::shared_ptr< PrinterList_list
 

Detailed Description

an class for printing the values associated with a name in a PropertySet.

This class is vital if one needs to print out all the values in a PropertySet without knowing the data types associated with the names. In particular, it gives one the ability to write each value associated with a name individually and it any order. A typical use looks like this:

* std::vector<std::string>::iterator ni;
* std::vector<std::string> names(ps.paramNames(true));
*
* for(ni = names.begin(); ni != names.end(); ++ni) {
* PropertyPrinter pp(ps, *ni);
*
* for(PropertyPrinter::iterator i=pp.begin(); i.notAtEnd(); ++i) {
* strm << *ni << ": ";
* i.write(&strm) << endl;
* }
* }
*

A PropertyPrinter is constructed for a particular name found in the PropertySet. (If a property with that name doesn't exist, a pex::exceptions::NotFoundError is thrown.) The PropertyPrinter is wrapped around the array of values associated with the name. One can get an Iterator for the values and send each one to a stream.

A PropertyPrinter can only print out property types that it has been configured for via the PrinterFactory instance that is passed in during construction. If one is not provided, a default is set which supports the following types:

*   short          char              float
*   int            signed char       double
*   long           unsigned char     bool
*   long long      string            DateTime
* 

Other types can be supported by passing the name of factory function that can create a printer instance to a PrinterFactory that will eventually be used with a PropertyPrinter (see PrinterFactory for details.

Definition at line 451 of file PropertyPrinter.h.

Member Typedef Documentation

the iterator type used for iterating through values.

Definition at line 457 of file PropertyPrinter.h.

Constructor & Destructor Documentation

lsst::pex::logging::PropertyPrinter::PropertyPrinter ( const lsst::daf::base::PropertySet prop,
const std::string &  name,
const PrinterFactory fact = defaultPrinterFactory 
)

create the PropertyPrinter for a given name

Member Function Documentation

iterator lsst::pex::logging::PropertyPrinter::begin ( )

return an iterator set at the start of the list of values

iterator lsst::pex::logging::PropertyPrinter::last ( )

return an iterator set at the last of the list of values

size_t lsst::pex::logging::PropertyPrinter::valueCount ( )
inline

return the number of values associated with the property

Definition at line 485 of file PropertyPrinter.h.

485 { return _list.get()->valueCount(); }
boost::shared_ptr< PrinterList > _list

Member Data Documentation

boost::shared_ptr<PrinterList> lsst::pex::logging::PropertyPrinter::_list
private

Definition at line 489 of file PropertyPrinter.h.

PrinterFactory lsst::pex::logging::PropertyPrinter::defaultPrinterFactory
static

the default look-up table for creating iterators for different types. Users are allowsd add new printers. See PropertyFactory for more details.

Definition at line 464 of file PropertyPrinter.h.


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