Collage  1.7.0
High-performance C++ library for developing object-oriented distributed applications.
objectMap.h
1 
2 /* Copyright (c) 2012-2013, Daniel Nachbaur <danielnachbaur@googlemail.com>
3  * 2012-2014, 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
29 {
30 class ObjectMap;
31 }
32 
42 class ObjectMap : public Serializable
43 {
44 public:
52  CO_API ObjectMap(ObjectHandler& handler, ObjectFactory& factory);
53 
61  CO_API virtual ~ObjectMap();
62 
74  CO_API bool register_(Object* object, const uint32_t type);
75 
87  CO_API bool deregister(Object* object);
88 
105  CO_API Object* map(const uint128_t& identifier, Object* instance = 0);
106 
118  CO_API bool unmap(Object* object);
119 
121  CO_API void clear();
122 
124  CO_API uint128_t
125  commit(const uint32_t incarnation = CO_COMMIT_NEXT) override;
126 
127 protected:
128  CO_API bool isDirty() const override;
129 
131  CO_API void serialize(DataOStream& os, const uint64_t dirtyBits) override;
132 
134  CO_API void deserialize(DataIStream& is, const uint64_t dirtyBits) override;
136  ChangeType getChangeType() const override { return DELTA; }
137  CO_API void notifyAttached() override;
138 
140  enum DirtyBits
141  {
142  DIRTY_ADDED = Serializable::DIRTY_CUSTOM << 0, // 1
143  DIRTY_REMOVED = Serializable::DIRTY_CUSTOM << 1, // 2
144  DIRTY_CHANGED = Serializable::DIRTY_CUSTOM << 2, // 4
145  DIRTY_CUSTOM = Serializable::DIRTY_CUSTOM << 3 // 8
146  };
147 
148 private:
149  detail::ObjectMap* const _impl;
150 
152  void _commitMasters(const uint32_t incarnation);
153 };
154 }
155 #endif // CO_OBJECTMAP_H
Base class for distributed, inheritable objects.
Definition: serializable.h:39
CO_API std::string serialize(const ConnectionDescriptions &)
Serialize a vector of connection descriptions to a string.
A distributed object.
Definition: object.h:47
ChangeType getChangeType() const override
Definition: objectMap.h:136
ChangeType
Object change handling characteristics, see Programming Guide.
Definition: object.h:51
A std::ostream-like interface for object serialization.
Definition: dataOStream.h:56
Object-oriented network library.
Definition: barrier.h:27
A distributed object registry.
Definition: objectMap.h:42
Interface for entities which map and register objects.
Definition: objectHandler.h:29
The interface to create objects, used by ObjectMap.
Definition: objectFactory.h:35
A std::istream-like input data stream for binary data.
Definition: dataIStream.h:45
CO_API bool deserialize(std::string &data, ConnectionDescriptions &descriptions)
Deserialize a vector or connection descriptions from a string.