25 #ifndef WSHAREDOBJECT_H
26 #define WSHAREDOBJECT_H
28 #include <boost/thread.hpp>
30 #include "WCondition.h"
31 #include "WSharedObjectTicket.h"
32 #include "WSharedObjectTicketRead.h"
33 #include "WSharedObjectTicketWrite.h"
40 template <
typename T >
62 typedef boost::shared_ptr< WSharedObjectTicketRead< T > >
ReadTicket;
67 typedef boost::shared_ptr< WSharedObjectTicketWrite< T > >
WriteTicket;
72 typedef boost::shared_ptr< WSharedObject< T > >
SPtr;
77 typedef boost::shared_ptr< WSharedObject< T > >
ConstSPtr;
113 mutable boost::shared_ptr< boost::shared_mutex >
m_lock;
123 template <
typename T >
125 m_lock( new boost::shared_mutex ),
131 template <
typename T >
137 template <
typename T >
140 return m_changeCondition;
143 template <
typename T >
146 return boost::shared_ptr< WSharedObjectTicketRead< T > >(
151 template <
typename T >
156 return boost::shared_ptr< WSharedObjectTicketWrite< T > >(
162 return boost::shared_ptr< WSharedObjectTicketWrite< T > >(
168 #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.