33 #ifndef WALLAROO_CATALOG_H_
34 #define WALLAROO_CATALOG_H_
49 class UseAsExpression;
85 Parts::const_iterator i = parts.find(
id );
95 void Add(
const std::string&
id,
const cxx0x::shared_ptr< Part >& dev )
97 std::pair< Parts::iterator, bool > result =
98 parts.insert( std::make_pair(
id, dev ) );
118 std::size_t
Size()
const {
return parts.size(); }
129 template <
class P1,
class P2 >
133 C c = C::ForName( className );
134 cxx0x::shared_ptr< Part > obj = c.NewInstance( p1, p2 );
152 C c = C::ForName( className );
153 cxx0x::shared_ptr< Part > obj = c.NewInstance( p );
169 C c = C::ForName( className );
170 cxx0x::shared_ptr< Part > obj = c.NewInstance();
182 return FindWrongMultiplicity().empty();
191 const std::string wrongPart = FindWrongMultiplicity();
192 if ( !wrongPart.empty() )
throw WiringError( wrongPart );
204 for ( Parts::const_iterator i = parts.begin(); i != parts.end(); ++i )
205 i -> second ->
Init();
216 std::string FindWrongMultiplicity()
const
218 for( Parts::const_iterator i = parts.begin(); i != parts.end(); ++i )
220 if ( ! i -> second -> MultiplicitiesOk() )
221 return( i -> first );
223 return std::string();
226 typedef cxx0x::unordered_map< std::string, cxx0x::shared_ptr< Part > > Parts;
239 static Catalog* current = NULL;
251 destClass( _destClass ),
252 attribute( _attribute )
260 srcClass.
Wire( attribute, destClass );
266 void of(
const std::string& srcClass )
269 Catalog* current = Catalog::Current();
271 of( ( *current )[ srcClass ] );
275 const std::string attribute;
284 : destClass( _destClass )
313 Catalog* current = Catalog::Current();
315 return use( ( *current )[ destClass ] );
325 part( _part ), attribute( _attribute ) {}
328 template <
typename T >
329 void to(
const T& value )
336 const std::string attribute;
351 Catalog* current = Catalog::Current( );
356 const std::string attribute;
375 previous = Catalog::Current();
376 Catalog::Current() = &c;
380 Catalog::Current() = previous;
419 #define wallaroo_within( C ) \
420 for ( wallaroo::Context context( C ); context.FirstTime(); context.Terminate() )
UseExpression(const detail::PartShell &_destClass)
Definition: catalog.h:283
void Clear()
Definition: catalog.h:113
Definition: partshell.h:51
void Add(const std::string &id, const cxx0x::shared_ptr< Part > &dev)
Definition: catalog.h:95
void Remove(const std::string &id)
Definition: catalog.h:107
Definition: catalog.h:321
Definition: catalog.h:247
UseAsExpression(detail::PartShell &_destClass, const std::string &_attribute)
Definition: catalog.h:250
SetOfExpression of(const detail::PartShell &part)
Definition: catalog.h:345
bool FirstTime() const
Definition: catalog.h:382
Definition: catalog.h:341
bool IsWiringOk() const
Definition: catalog.h:180
Definition: exceptions.h:152
friend UseExpression use(const std::string &destClass)
Definition: catalog.h:310
Definition: catalog.h:369
void CheckWiring() const
Definition: catalog.h:189
detail::PartShell operator[](const std::string &id) const
Definition: catalog.h:83
Definition: exceptions.h:128
void Init()
Definition: catalog.h:202
Definition: exceptions.h:92
UseAsExpression as(const std::string &attribute)
Definition: catalog.h:287
UseExpression use(const detail::PartShell &destClass)
Definition: catalog.h:300
~Context()
Definition: catalog.h:378
detail::PartShell Create(const std::string &id, const std::string &className, const P &p)
Definition: catalog.h:149
void of(const std::string &srcClass)
Definition: catalog.h:266
void to(const T &value)
Definition: catalog.h:329
Catalog()
Definition: catalog.h:71
void Terminate()
Definition: catalog.h:386
detail::PartShell Create(const std::string &id, const std::string &className)
Definition: catalog.h:166
SetOfExpression of(const std::string &part)
Definition: catalog.h:348
Definition: catalog.h:280
SetOfExpression(const detail::PartShell &_part, const std::string &_attribute)
Definition: catalog.h:324
void of(const detail::PartShell &srcClass)
Definition: catalog.h:257
void SetAttribute(const std::string &attribute, const T &value) const
Definition: partshell.h:68
std::size_t Size() const
Definition: catalog.h:118
Definition: attribute.h:45
Definition: exceptions.h:193
SetExpression set_attribute(const std::string &attribute)
Definition: catalog.h:364
SetExpression(const std::string &att)
Definition: catalog.h:344
detail::PartShell Create(const std::string &id, const std::string &className, const P1 &p1, const P2 &p2)
Definition: catalog.h:130
void Wire(const std::string &collaboratorName, const PartShell &destination) const
Definition: partshell.h:62
Context(Catalog &c)
Definition: catalog.h:372