Wallaroo  0.8
Public Member Functions | Friends | List of all members
wallaroo::Catalog Class Reference

#include <catalog.h>

Public Member Functions

 Catalog ()
 
detail::PartShell operator[] (const std::string &id) const
 
void Add (const std::string &id, const cxx0x::shared_ptr< Part > &dev)
 
void Remove (const std::string &id)
 
void Clear ()
 
std::size_t Size () const
 
template<class P1 , class P2 >
detail::PartShell Create (const std::string &id, const std::string &className, const P1 &p1, const P2 &p2)
 
template<class P >
detail::PartShell Create (const std::string &id, const std::string &className, const P &p)
 
detail::PartShell Create (const std::string &id, const std::string &className)
 
bool IsWiringOk () const
 
void CheckWiring () const
 
void Init ()
 

Friends

class Context
 
class UseAsExpression
 
class SetExpression
 
UseExpression use (const std::string &destClass)
 
bool IsWiringOk ()
 
void CheckWiring ()
 

Detailed Description

Catalog of parts available for the application.

It can create the instances from the name of a class previously registered with one of the macros WALLAROO_REGISTER(C), WALLAROO_DYNLIB_REGISTER(C).

Alternatively, you can add an instance, provided that its class derives from wallaroo::Part.

Each item in the catalog is identified by a id, with which you can perform a lookup.

Constructor & Destructor Documentation

wallaroo::Catalog::Catalog ( )
inline

Build an empty catalog.

Member Function Documentation

void wallaroo::Catalog::Add ( const std::string &  id,
const cxx0x::shared_ptr< Part > &  dev 
)
inline

Add an element to the catalog

Parameters
idThe name of the element to add
devThe element to add (its class must derive from wallaroo::Part)
Exceptions
DuplicatedElementIf a part with the name id is already in the catalog
void wallaroo::Catalog::CheckWiring ( ) const
inline

Check if the wiring of the objects inside the container is correct according to the multiplicity declared in the Collaborator definition.

Exceptions
WiringErrorIf the wiring does not match with the multiplicity declared.
void wallaroo::Catalog::Clear ( )
inline

Remove all elements of the catalog

template<class P1 , class P2 >
detail::PartShell wallaroo::Catalog::Create ( const std::string &  id,
const std::string &  className,
const P1 &  p1,
const P2 &  p2 
)
inline

Instantiate a class having a 2 parameters constructor and add it to the catalog

Parameters
idThe name of the element to create and add
classNameThe name of the class to instantiate (must derive from wallaroo::Part)
p1The first parameter of the class constructor
p2The second parameter of the class constructor
Returns
The element created.
Exceptions
DuplicatedElementIf an element with the name id is already in the catalog
ElementNotFoundIf className class has not been registered
template<class P >
detail::PartShell wallaroo::Catalog::Create ( const std::string &  id,
const std::string &  className,
const P &  p 
)
inline

Instantiate a class having a 1 parameters constructor and add it to the catalog

Parameters
idThe name of the element to create and add
classNameThe name of the class to instantiate (must derive from wallaroo::Part)
pThe parameter of the class constructor
Returns
The element created.
Exceptions
DuplicatedElementIf an element with the name id is already in the catalog
ElementNotFoundIf className class has not been registered
detail::PartShell wallaroo::Catalog::Create ( const std::string &  id,
const std::string &  className 
)
inline

Instantiate a class having a default constructor and add it to the catalog

Parameters
idThe name of the element to create and add
classNameThe name of the class to instantiate (must derive from wallaroo::Part)
Returns
The element created.
Exceptions
DuplicatedElementIf an element with the name id is already in the catalog
ElementNotFoundIf className class has not been registered
void wallaroo::Catalog::Init ( )
inline

This method calls Part::Init on every Part contained. You can call it in the setup phase of your application to perform the initialization required by each part before the run. Ideally you should call it after wiring and attributes setting, so that your objects already have dependencies and the right attribute values. This method rethrows every exception thrown by each Part::Init.

bool wallaroo::Catalog::IsWiringOk ( ) const
inline

Check if the wiring of the objects inside the container is correct according to the multiplicity declared in the Collaborator definition.

Returns
false If the wiring does not match with the multiplicity declared.
detail::PartShell wallaroo::Catalog::operator[] ( const std::string &  id) const
inline

Look for the element id in the catalog. It returns a class that provides conversion operator so that you can write eg:

shared_ptr< Foo > foo = catalog[ "foo" ];
Parameters
idThe name of the element
Returns
The element.
Exceptions
ElementNotFoundIf an element with key id cannot be found in the catalog.
void wallaroo::Catalog::Remove ( const std::string &  id)
inline

Remove an element from the catalog

Parameters
idThe name of the element to remove
Exceptions
ElementNotFoundIf an element with key id cannot be found in the catalog.
std::size_t wallaroo::Catalog::Size ( ) const
inline

Returns the number of the elements contained in the catalog.

Returns
the size of the container

Friends And Related Function Documentation

void CheckWiring ( )
friend
friend class Context
friend
bool IsWiringOk ( )
friend
friend class SetExpression
friend
UseExpression use ( const std::string &  destClass)
friend

This function provides the "use" part in the syntax use( "part1" ).as( "collaborator" ).of( "part2" )

Exceptions
CatalogNotSpecifiedif the current catalog has not been selected including this function in a wallaroo_within section
friend class UseAsExpression
friend

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