Collage  1.0.1
Object-Oriented C++ Network Library
objectMap.h
1 
2 /* Copyright (c) 2012-2013, Daniel Nachbaur <danielnachbaur@googlemail.com>
3  * 2012-2013, Stefan Eilemann <eile@eyescale.ch>
4  *
5  * This file is part of Collage <https://github.com/Eyescale/Collage>
6  *
7  * This library is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Lesser General Public License version 2.1 as published
9  * by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef CO_OBJECTMAP_H
22 #define CO_OBJECTMAP_H
23 
24 #include <co/serializable.h> // base class
25 
26 namespace co
27 {
28 namespace detail { class ObjectMap; }
29 
39 class ObjectMap : public Serializable
40 {
41 public:
49  CO_API ObjectMap( ObjectHandler& handler, ObjectFactory& factory );
50 
58  CO_API virtual ~ObjectMap();
59 
71  CO_API bool register_( Object* object, const uint32_t type );
72 
84  CO_API bool deregister( Object* object );
85 
102  CO_API Object* map( const uint128_t& identifier, Object* instance = 0 );
103 
115  CO_API bool unmap( Object* object );
116 
118  CO_API void clear();
119 
121  CO_API virtual uint128_t commit( const uint32_t incarnation =
122  CO_COMMIT_NEXT );
123 
124 protected:
125  CO_API virtual bool isDirty() const;
126 
128  CO_API virtual void serialize( DataOStream& os, const uint64_t dirtyBits );
129 
131  CO_API virtual void deserialize( DataIStream& is, const uint64_t dirtyBits);
132 
133  virtual ChangeType getChangeType() const { return DELTA; }
134  CO_API virtual void notifyAttached();
135 
137  enum DirtyBits
138  {
139  DIRTY_ADDED = Serializable::DIRTY_CUSTOM << 0, // 1
140  DIRTY_REMOVED = Serializable::DIRTY_CUSTOM << 1, // 2
141  DIRTY_CHANGED = Serializable::DIRTY_CUSTOM << 2, // 4
142  DIRTY_CUSTOM = Serializable::DIRTY_CUSTOM << 3 // 8
143  };
144 
145 private:
146  detail::ObjectMap* const _impl;
147 
149  void _commitMasters( const uint32_t incarnation );
150 };
151 }
152 #endif // CO_OBJECTMAP_H
Interface for entities which map and register objects.
Definition: objectHandler.h:29
virtual CO_API void deserialize(DataIStream &is, const uint64_t dirtyBits)
Worker for unpack() and applyInstanceData().
Base class for distributed, inheritable objects.
Definition: serializable.h:38
CO_API void clear()
Deregister or unmap all registered and mapped objects.
A distributed object registry.
Definition: objectMap.h:39
virtual CO_API void serialize(DataOStream &os, const uint64_t dirtyBits)
Worker for pack() and getInstanceData().
CO_API Object * map(const uint128_t &identifier, Object *instance=0)
Map and return an object.
ChangeType
Object change handling characteristics, see Programming Guide.
Definition: object.h:49
virtual CO_API bool isDirty() const
CO_API bool unmap(Object *object)
Unmap an object from the object map.
CO_API bool register_(Object *object, const uint32_t type)
Add and register a new object as master instance to this object map.
use pack/unpack delta
Definition: object.h:54
A std::istream-like input data stream for binary data.
Definition: dataIStream.h:40
The interface to create objects, used by ObjectMap.
Definition: objectFactory.h:35
virtual CO_API void notifyAttached()
A distributed object.
Definition: object.h:45
A std::ostream-like interface for object serialization.
Definition: dataOStream.h:46
virtual CO_API ~ObjectMap()
Destroy this object map.
CO_API ObjectMap(ObjectHandler &handler, ObjectFactory &factory)
Construct a new object map.
virtual CO_API uint128_t commit(const uint32_t incarnation=CO_COMMIT_NEXT)
Commit all registered objects.
virtual ChangeType getChangeType() const
Definition: objectMap.h:133
CO_API bool deregister(Object *object)
Remove and deregister an object from this object map.