else {
// we have a new message
// XXX - or we have an error, must handle it
- std::cout << request << std::endl << headers << std::endl;
- std::cout.write(body, content_length);
- std::cout.flush();
+ msg = new Message(body, content_length);
+ msg->setProperties(
}
return len;
}
#define _MESSAGE_H
#include "Properties.H"
+#include "MessageStore.H"
#include <string>
-class Message {
+class Message: public MessageStore::Storable {
public:
- class ID {
+
+ /** class that holds message state
+ *
+ */
+ class State : public MessageStore::Storable {
public:
- private:
+
+ /** Get size needed for storage (from Storable).
+ */
+ virtual int getStorageSize() const;
+
+ /** Save State (from Storable)
+ */
+ virtual int save(void* data, int len) const;
+
+ /** Load State (from Storable)
+ */
+ virtual int load(void* data, int len);
};
+
Message();
Message(void * data, unsigned int length)
std::string getProperty(const std::string &name, std::string &val) const
{ return m_properties.getProperty(name); }
-
+
void setProperty(const std::string &name, std::string &val)
{ m_properties.setProperty(name, val); }
-
+
Properties& getProperties()
{ return m_properties; }
+
+ void setProperties(Properties &)
+ {}
private:
- ID m_id;
+ MessageStore::ID m_id;
unsigned int m_length;
void * m_data;
Properties m_properties;
--- /dev/null
+#ifndef _MESSAGE_STORE_H_
+#define _MESSAGE_STORE_H_
+
+/** Permanent storage for messages and their states.
+ */
+
+class MessageStore {
+public:
+
+ /** Base class for everything that can be stored here.
+ */
+ class Storable {
+ public:
+ /** Get size needed for object storage.
+ */
+ virtual int getStorageSize() const = 0;
+
+ /** Save state of object into binary data.
+ */
+ virtual int save(void* data, int len) const = 0;
+
+ /** Load state of object from binary data.
+ */
+ virtual int load(void* data, int len) = 0;
+
+ virtual ~Storable() {}
+ };
+
+
+ /** Class that uniquely identifies stored content.
+ */
+ class ID: public Storable {
+ public:
+ /** Default constructor.
+ *
+ * Creates new unique ID.
+ */
+ ID();
+
+ /** Copy constructor.
+ */
+ ID(const ID& src);
+
+ /** Destructor.
+ */
+ ~ID();
+
+ /** Assignment operator.
+ */
+ ID& operator=(const ID& src);
+
+ /** Return the string suitable for printing.
+ */
+ std::string toString() const;
+
+ /** Comparison operator
+ */
+ int operator==();
+
+ /** Get size needed for storage (from Storable).
+ */
+ virtual int getStorageSize() const;
+
+ /** Save ID (from Storable)
+ */
+ virtual int save(void* &data, int len) const;
+
+ /** Load ID (from Storable)
+ */
+ virtual int load(void* data, int len);
+
+ private:
+ };
+};
+
+#endif