more work
authorMichal Voců <michal@ruk.cuni.cz>
Wed, 10 Oct 2007 20:57:54 +0000 (20:57 +0000)
committerMichal Voců <michal@ruk.cuni.cz>
Wed, 10 Oct 2007 20:57:54 +0000 (20:57 +0000)
org.glite.lb.logger/src-nt/HTTPTransport.cpp
org.glite.lb.logger/src-nt/Message.H
org.glite.lb.logger/src-nt/MessageStore.H [new file with mode: 0644]

index c77606f..9ed4e16 100644 (file)
@@ -156,9 +156,8 @@ HTTPTransport::receive(Connection *conn, Message* &msg)
        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;
 }
index f9b0f17..37492bf 100644 (file)
@@ -2,16 +2,33 @@
 #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) 
@@ -28,15 +45,18 @@ public:
 
        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;
diff --git a/org.glite.lb.logger/src-nt/MessageStore.H b/org.glite.lb.logger/src-nt/MessageStore.H
new file mode 100644 (file)
index 0000000..86c747f
--- /dev/null
@@ -0,0 +1,76 @@
+#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