25 #ifndef WSHAREDOBJECT_H
26 #define WSHAREDOBJECT_H
29 #include <boost/thread.hpp>
32 #include "WCondition.h"
33 #include "WSharedObjectTicket.h"
34 #include "WSharedObjectTicketRead.h"
35 #include "WSharedObjectTicketWrite.h"
42 template <
typename T >
64 typedef boost::shared_ptr< WSharedObjectTicketRead< T > >
ReadTicket;
69 typedef boost::shared_ptr< WSharedObjectTicketWrite< T > >
WriteTicket;
74 typedef boost::shared_ptr< WSharedObject< T > >
SPtr;
79 typedef boost::shared_ptr< WSharedObject< T > >
ConstSPtr;
115 mutable boost::shared_ptr< boost::shared_mutex >
m_lock;
125 template <
typename T >
127 m_lock( new boost::shared_mutex ),
133 template <
typename T >
139 template <
typename T >
142 return m_changeCondition;
145 template <
typename T >
148 return boost::shared_ptr< WSharedObjectTicketRead< T > >(
153 template <
typename T >
158 return boost::shared_ptr< WSharedObjectTicketWrite< T > >(
164 return boost::shared_ptr< WSharedObjectTicketWrite< T > >(
170 #endif // WSHAREDOBJECT_H
boost::shared_ptr< WSharedObjectTicketWrite< T > > WriteTicket
Type for write tickets.
T ValueT
The type protected by this shared object class.
T m_object
The object wrapped by this class.
ReadTicket getReadTicket() const
Returns a ticket to get read access to the contained data.
WSharedObject()
Default constructor.
WriteTicket getWriteTicket(bool suppressNotify=false) const
Returns a ticket to get write access to the contained data.
Class which represents granted access to a locked object.
Wrapper around an object/type for thread safe sharing of objects among multiple threads.
boost::shared_ptr< WSharedObject< T > > ConstSPtr
Const shared ptr abbreviation.
boost::shared_ptr< boost::shared_mutex > m_lock
The lock to ensure thread safe access.
Class to encapsulate boost::condition_variable_any.
boost::shared_ptr< WSharedObject< T > > SPtr
Shared pointer abbreviation.
virtual ~WSharedObject()
Destructor.
boost::shared_ptr< WSharedObjectTicketRead< T > > ReadTicket
Type for read tickets.
boost::shared_ptr< WCondition > m_changeCondition
This condition set fires whenever the contained object changes.
boost::shared_ptr< WCondition > getChangeCondition() const
This condition fires whenever the encapsulated object changed.
Class which represents granted access to a locked object.