diff options
author | Henri Herscher <henri@oreka.org> | 2005-10-20 13:40:58 +0000 |
---|---|---|
committer | Henri Herscher <henri@oreka.org> | 2005-10-20 13:40:58 +0000 |
commit | 7e1d63dd9fd149e4934bf77095c8610fac786b04 (patch) | |
tree | 5fe486a1b0300c3b84fb559107a868e5cc2c95da /orkbasecxx/messages | |
parent | 467768fc956fc3e5a253373f26c71c681b31b6b8 (diff) |
First checkin
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@2 09dcff7a-b715-0410-9601-b79a96267cd0
Diffstat (limited to 'orkbasecxx/messages')
-rw-r--r-- | orkbasecxx/messages/AsyncMessage.cpp | 46 | ||||
-rw-r--r-- | orkbasecxx/messages/AsyncMessage.h | 48 | ||||
-rw-r--r-- | orkbasecxx/messages/Makefile.am | 8 | ||||
-rw-r--r-- | orkbasecxx/messages/Message.cpp | 41 | ||||
-rw-r--r-- | orkbasecxx/messages/Message.h | 55 | ||||
-rw-r--r-- | orkbasecxx/messages/SyncMessage.cpp | 14 | ||||
-rw-r--r-- | orkbasecxx/messages/SyncMessage.h | 31 |
7 files changed, 243 insertions, 0 deletions
diff --git a/orkbasecxx/messages/AsyncMessage.cpp b/orkbasecxx/messages/AsyncMessage.cpp new file mode 100644 index 0000000..e32cb50 --- /dev/null +++ b/orkbasecxx/messages/AsyncMessage.cpp @@ -0,0 +1,46 @@ +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +#include "AsyncMessage.h" + +//void AsyncMessage::send(XmlRpc::XmlRpcClient& c) +//{ +// ; +//} + +#define SIMPLERESPONSE_CLASS "simpleresponse" +#define SUCCESS_PARAM "sucess" +#define SUCCESS_DEFAULT true +#define COMMENT_PARAM "comment" + +SimpleResponseMsg::SimpleResponseMsg() +{ + m_success = false; +} + + +void SimpleResponseMsg::Define(Serializer* s) +{ + s->BoolValue(SUCCESS_PARAM, m_success); + s->StringValue(COMMENT_PARAM, m_comment); +} + +CStdString SimpleResponseMsg::GetClassName() +{ + return CStdString(SIMPLERESPONSE_CLASS); +} + +ObjectRef SimpleResponseMsg::NewInstance() +{ + return ObjectRef(new SimpleResponseMsg); +} diff --git a/orkbasecxx/messages/AsyncMessage.h b/orkbasecxx/messages/AsyncMessage.h new file mode 100644 index 0000000..bbdb313 --- /dev/null +++ b/orkbasecxx/messages/AsyncMessage.h @@ -0,0 +1,48 @@ +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +#ifndef __ASYNCMESSAGE_H__ +#define __ASYNCMESSAGE_H__ + +//#include "XmlRpc.h" +#include "Message.h" + +/** An AsyncMessage is an asynchronous message ("fire and forget"). + It can also be the response to a synchronous message. +*/ +class DLL_IMPORT_EXPORT AsyncMessage : public Message +{ +//public: +// void send(XmlRpc::XmlRpcClient& c); +}; + +/** A SimpleResponseMsg is used as a response when commands can just succeed or fail. + Additionally, there is textual comment field e.g. for error messages. +*/ +class DLL_IMPORT_EXPORT SimpleResponseMsg : public AsyncMessage +{ +public: + SimpleResponseMsg(); + void Define(Serializer* s); + inline void Validate() {}; + + CStdString GetClassName(); + ObjectRef NewInstance(); + inline ObjectRef Process() {return ObjectRef();}; + + bool m_success; + CStdString m_comment; +}; + +#endif + diff --git a/orkbasecxx/messages/Makefile.am b/orkbasecxx/messages/Makefile.am new file mode 100644 index 0000000..0465da7 --- /dev/null +++ b/orkbasecxx/messages/Makefile.am @@ -0,0 +1,8 @@ +METASOURCES = AUTO +noinst_LTLIBRARIES = libmessages.la +libmessages_la_SOURCES = AsyncMessage.cpp AsyncMessage.h Message.cpp Message.h\ + SyncMessage.cpp SyncMessage.h + +#libmessages_la_LIBADD = -L/projects/ext/xmlrpc++/xmlrpc++0.7/ -lXmlRpc +INCLUDES = -I@top_srcdir@ +AM_CXXFLAGS = -D_REENTRANT diff --git a/orkbasecxx/messages/Message.cpp b/orkbasecxx/messages/Message.cpp new file mode 100644 index 0000000..ad6e533 --- /dev/null +++ b/orkbasecxx/messages/Message.cpp @@ -0,0 +1,41 @@ +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +#define _WINSOCKAPI_ // prevents the inclusion of winsock.h + +#pragma warning( disable: 4786 ) // disables truncated symbols in browse-info warning + +#include "serializers/XmlRpcSerializer.h" +#include "Message.h" + + +char Message::m_hostname[HOSTNAME_BUF_LEN] = ""; + +Message::Message() +{ + m_creationTime = time(NULL); + ACE_OS::hostname(m_hostname, HOSTNAME_BUF_LEN); +} + + +bool Message::InvokeXmlRpc(CStdString& hostname, int tcpPort) +{ +/* + XmlRpcSerializer serializer(this); + return serializer.Invoke(hostname, tcpPort); + //serializerRef.reset(new XmlRpcSerializer(this)); + //serializerRef->Invoke(hostname, tcpPort); +*/ + return true; +} + diff --git a/orkbasecxx/messages/Message.h b/orkbasecxx/messages/Message.h new file mode 100644 index 0000000..1ecceb6 --- /dev/null +++ b/orkbasecxx/messages/Message.h @@ -0,0 +1,55 @@ +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +#ifndef __MESSAGE_H__ +#define __MESSAGE_H__ + +//#ifdef WIN32 +#pragma warning( disable: 4786 ) // disables truncated symbols in browse-info warning +#pragma warning( disable: 4018 ) // signed/unsigned mismatch +//#endif + +#include "OrkBase.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_unistd.h" + +#include "serializers/Serializer.h" +#include "Object.h" + +#define HOSTNAME_BUF_LEN 40 + +#define TIMESTAMP_PARAM "timestamp" +#define CAPTURE_PORT_PARAM "captureport" +#define FILENAME_PARAM "filename" + +#define SUCCESS_PARAM "sucess" +#define SUCCESS_DEFAULT true + +/** A Message is an Object that is meant to be sent to a remote server. +*/ +class DLL_IMPORT_EXPORT Message : public Object +{ +public: + Message(); + + bool InvokeXmlRpc(CStdString& hostname, int tcpport); +protected: + time_t m_creationTime; + bool m_sent; + static char m_hostname[HOSTNAME_BUF_LEN]; +}; + +typedef boost::shared_ptr<Message> MessageRef; + +#endif + diff --git a/orkbasecxx/messages/SyncMessage.cpp b/orkbasecxx/messages/SyncMessage.cpp new file mode 100644 index 0000000..b49fd64 --- /dev/null +++ b/orkbasecxx/messages/SyncMessage.cpp @@ -0,0 +1,14 @@ +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +#include "SyncMessage.h" diff --git a/orkbasecxx/messages/SyncMessage.h b/orkbasecxx/messages/SyncMessage.h new file mode 100644 index 0000000..598ffe3 --- /dev/null +++ b/orkbasecxx/messages/SyncMessage.h @@ -0,0 +1,31 @@ +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +#pragma warning( disable: 4786 ) + +#ifndef __SYNCMESSAGE_H__ +#define __SYNCMESSAGE_H__ + + +#include "Message.h" + +/** A SyncMessage is a synchronous message that needs an immediate answer from the remote server. + The response should be an AsyncMessage +*/ +class DLL_IMPORT_EXPORT SyncMessage : public Message +{ +public: +}; + +#endif + |