33 #ifndef WALLAROO_COLLABORATOR_H_
34 #define WALLAROO_COLLABORATOR_H_
53 template <
typename T >
54 cxx0x::shared_ptr< T >
GetShared(
const cxx0x::shared_ptr< T >& s ) {
return s; }
56 template <
typename T >
57 cxx0x::shared_ptr< T >
GetShared(
const cxx0x::weak_ptr< T >& s )
59 if ( cxx0x::shared_ptr< T > result = s.lock() )
return result;
65 template <
typename T >
66 bool NotEmpty(
const cxx0x::shared_ptr< T >& p ) {
return static_cast<bool>( p ); }
68 template <
typename T >
69 bool NotEmpty(
const cxx0x::weak_ptr< T >& p ) {
return !p.expired(); }
78 template <
typename T >
static bool WiringOk(
const T& ) {
return true; }
84 template <
typename T >
static bool WiringOk(
const cxx0x::weak_ptr< T >& t ) {
return !t.expired(); }
85 template <
typename T >
static bool WiringOk(
const cxx0x::shared_ptr< T >& t ) {
return static_cast< bool >( t ); }
94 template <
typename E,
typename Allocator = std::allocator< E > >
class C = std::vector
98 template <
typename T >
101 const std::size_t s = t -> size();
102 return ( s >= MIN && ( MAX == 0 || s <= MAX ) );
107 template < std::
size_t MAX,
template <
typename E,
typename Allocator = std::allocator< E > >
class C >
110 template <
typename T >
111 static bool WiringOk(
const T* t ) {
return ( t -> size() <= MAX ); }
112 template <
typename T >
struct Container {
typedef C< T >
Type; };
114 template < std::
size_t MIN,
template <
typename E,
typename Allocator = std::allocator< E > >
class C >
117 template <
typename T >
118 static bool WiringOk(
const T* t ) {
return ( t -> size() >= MIN ); }
119 template <
typename T >
struct Container {
typedef C< T >
Type; };
121 template <
template <
typename E,
typename Allocator = std::allocator< E > >
class C >
124 template <
typename T >
126 template <
typename T >
struct Container {
typedef C< T >
Type; };
132 template <
template <
typename E,
typename Allocator = std::allocator< E > >
class C = std::vector >
135 template <
typename T >
static bool WiringOk(
const T* ) {
return true; }
163 template <
typename X >
class Ownership = cxx0x::weak_ptr
169 typedef Ownership< T >
Ptr;
179 owner -> Register( name,
this );
186 void Link(
const cxx0x::shared_ptr< Part >& dev )
188 if ( cxx0x::shared_ptr< T > _dev = cxx0x::dynamic_pointer_cast< T >( dev ) )
224 virtual bool WiringOk()
const {
return P::WiringOk( part ); }
240 template <
typename E,
typename Allocator = std::allocator< E > >
class C,
241 template <
typename X >
class Ownership
248 typedef Ownership< T >
Ptr;
260 owner -> Register( name,
this );
267 void Link(
const cxx0x::shared_ptr< Part >& part )
269 if ( cxx0x::shared_ptr< T > obj = cxx0x::dynamic_pointer_cast< T >( part ) )
270 Cont::push_back( obj );
293 template <
typename E,
typename Allocator = std::allocator< E > >
class C,
294 template <
typename X >
class Ownership
297 public Collaborator < T, bounded_collection< 0, 0, C >, Ownership >
Ownership< T > Ptr
Definition: collaborator.h:169
Collaborator(const std::string &name, const RegToken &token)
Definition: collaborator.h:176
Definition: collaborator.h:133
Collaborator(const std::string &name, const RegToken &token)
Definition: collaborator.h:300
Part * GetPart() const
Definition: part.h:60
virtual bool WiringOk() const
Definition: collaborator.h:279
bool NotEmpty(const cxx0x::shared_ptr< T > &p)
Definition: collaborator.h:66
static bool WiringOk(const T *t)
Definition: collaborator.h:118
cxx0x::shared_ptr< T > GetShared(const cxx0x::shared_ptr< T > &s)
Definition: collaborator.h:54
C< T > Type
Definition: collaborator.h:104
static bool WiringOk(const cxx0x::weak_ptr< T > &t)
Definition: collaborator.h:84
static bool WiringOk(const cxx0x::shared_ptr< T > &t)
Definition: collaborator.h:85
static bool WiringOk(const T *)
Definition: collaborator.h:135
C< T > Type
Definition: collaborator.h:119
static bool WiringOk(const T *t)
Definition: collaborator.h:111
C< T > Type
Definition: collaborator.h:112
Definition: collaborator.h:104
Definition: collaborator.h:136
Definition: exceptions.h:74
static bool WiringOk(const T &)
Definition: collaborator.h:78
Definition: collaborator.h:82
C< T > Type
Definition: collaborator.h:136
cxx0x::shared_ptr< T > SharedPtr
Definition: collaborator.h:170
void Link(const cxx0x::shared_ptr< Part > &dev)
Definition: collaborator.h:186
Definition: attribute.h:45
static bool WiringOk(const T *)
Definition: collaborator.h:125
void Link(const cxx0x::shared_ptr< Part > &part)
Definition: collaborator.h:267
Definition: exceptions.h:110
static bool WiringOk(const T *t)
Definition: collaborator.h:99
virtual bool WiringOk() const
Definition: collaborator.h:224
SharedPtr operator->()
Definition: collaborator.h:197
Definition: dependency.h:49
C< T > Type
Definition: collaborator.h:126
Definition: collaborator.h:76
Definition: collaborator.h:96
Definition: collaborator.h:165
Collaborator(const std::string &name, const RegToken &token)
Definition: collaborator.h:257