This is the simple Serviceholder class needed for de/serialization purposes.
authorBjoern Sikora <bjoern.sikora@intra2net.com>
Fri, 7 Aug 2009 11:02:15 +0000 (13:02 +0200)
committerBjoern Sikora <bjoern.sikora@intra2net.com>
Fri, 7 Aug 2009 11:02:15 +0000 (13:02 +0200)
src/serviceholder.cpp [new file with mode: 0644]
src/serviceholder.h [new file with mode: 0644]

diff --git a/src/serviceholder.cpp b/src/serviceholder.cpp
new file mode 100644 (file)
index 0000000..1d4c073
--- /dev/null
@@ -0,0 +1,61 @@
+/** @file
+ * @brief Serviceholder class implementation. This class holds Service objects in a list for serialization.
+ *
+ *
+ *
+ * @copyright Intra2net AG
+ * @license GPLv2
+*/
+
+#include "serviceholder.h"
+
+using namespace std;
+
+
+/**
+ * Default constructor. Invoked on serialization and deserialization.
+ */
+Serviceholder::Serviceholder()
+{
+}
+
+
+/**
+ * Default destructor. While serializing and deserializing we use boost/shared_ptr, the resources are managed correctly.
+ */
+Serviceholder::~Serviceholder()
+{
+}
+
+
+/**
+ * Serialize function needed by boost/serialization to define which members should be stored as the object state.
+ * In this case the STL list of Service pointers will be serialized.
+ * @param ar Archive
+ * @param version Version
+ */
+template<class Archive>
+void Serviceholder::serialize(Archive & ar, const unsigned int version)
+{
+    ar & Hold_services;
+}
+
+
+/**
+ * Add Service * to internal list.
+ * @param service Pointer to Service object.
+ */
+void Serviceholder::add_service(Service * service)
+{
+    Hold_services.push_back(service);
+}
+
+
+/**
+ * Needed after deserialization to get the valid list of Service* back.
+ * @return The list of Service*.
+ */
+std::list<Service*> Serviceholder::get_hold_services()
+{
+    return Hold_services;
+}
diff --git a/src/serviceholder.h b/src/serviceholder.h
new file mode 100644 (file)
index 0000000..80b44b6
--- /dev/null
@@ -0,0 +1,49 @@
+/** @file
+ * @brief Serviceholder class header. This class holds Service objects in a list for serialization.
+ *
+ *
+ *
+ * @copyright Intra2net AG
+ * @license GPLv2
+*/
+
+#ifndef SERVICEHOLDER_H
+#define SERVICEHOLDER_H
+
+#include <list>
+
+#include "service.h"
+#include "logger.h"
+
+#include <boost/serialization/array.hpp>
+#include <boost/serialization/list.hpp>
+#include <boost/shared_ptr.hpp>
+
+typedef boost::shared_ptr<Logger> LoggerPtr;
+
+class Serviceholder
+{
+private:
+    friend class boost::serialization::access;
+
+    std::list<Service*> Hold_services;
+
+    template<class Archive>
+    void serialize(Archive &, const unsigned int);
+
+    int Test;
+
+public:
+
+    Serviceholder();
+
+    Serviceholder(LoggerPtr);
+
+    ~Serviceholder();
+
+    void add_service(Service *);
+
+    std::list<Service*> get_hold_services();
+};
+
+#endif