Main Page | Modules | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Namespace Members | Data Fields | Globals

IpcMessage.h

Go to the documentation of this file.
00001 /********************************************************************
00002 
00003 Copyright 2006, ACCESS Systems Americas, Inc. All rights reserved.
00004 
00005 The contents of this file are subject to the Mozilla Public License Version
00006 1.1 (the "License"); you may not use this file except in compliance with
00007 the License. You may obtain a copy of the License at
00008 http://www.mozilla.org/MPL/
00009 
00010 Software distributed under the License is distributed on an "AS IS" basis,
00011 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012 for the specific language governing rights and limitations under the
00013 License.
00014 
00015 The Original Code is the entire contents of this file.
00016 
00017 The Initial Developer of the Original Code is ACCESS Systems Americas, Inc.
00018 
00019 Portions created by ACCESS Systems Americas, Inc. are Copyright © 2006. All
00020 Rights Reserved.
00021 
00022 Contributor(s): none.
00023 
00024 ********************************************************************/
00033 #ifndef ALP_IPC_MESSAGE_H
00034 #define ALP_IPC_MESSAGE_H
00035 
00036 // Includes ------------------------------------------------------------------
00037 #include <stdint.h>
00038 #include <string>
00039 
00040 #include <hiker/ipc.h>
00041 #include <hiker/types.h>
00042 
00043 
00044 // Typedefs ------------------------------------------------------------------
00045 namespace alp {
00046 
00047 class string;
00048 
00049 namespace ipc {
00050 
00051 struct Array
00052 {
00053         unsigned char*  array;
00054         uint32_t                len;
00055 
00056         Array() : array(NULL), len(0) {;}
00057         Array(unsigned char* a, uint32_t l)
00058                 :       array(a), len(l)
00059         {;}
00060 };
00061 
00062 class Message
00063 {
00064         public:
00065                 enum PackMode { none, send, receive };
00066 
00067                 Message();
00068                 Message(AlpMessage* msg);
00069                 Message(int what);
00070                 Message(const Message& rhs);
00071                 ~Message();
00072 
00073                 Message&        operator=(const Message&);
00074 
00075                 inline alp_status_t     Status() const  { return fStatus; }
00076                 inline PackMode         Mode() const    { return fMode; }
00077                 inline int                      What() const    { return fWhat; }
00078 
00079                 alp_status_t    AddInt32(int32_t i);
00080                 alp_status_t    AddUInt32(uint32_t i);
00081                 alp_status_t    AddBool(bool b);
00082                 alp_status_t    AddFloat(float f);
00083                 alp_status_t    AddString(const char* s);
00084                 alp_status_t    AddString(const std::string& s);
00085                 alp_status_t    AddString(const alp::string& s);
00086                 alp_status_t    AddByteArray(const unsigned char* a, uint32_t len);
00087 
00088                 alp_status_t    GetInt32(int32_t& i);
00089                 alp_status_t    GetUInt32(uint32_t& i);
00090                 alp_status_t    GetBool(bool& b);
00091                 alp_status_t    GetFloat(float& f);
00092                 alp_status_t    GetString(char*& s);
00093                 alp_status_t    GetString(std::string& s);
00094                 alp_status_t    GetString(alp::string& s);
00095                 alp_status_t    GetByteArray(unsigned char*& a, uint32_t& len);
00096 
00097         private:
00098                 AlpMessage*             GetMessage();
00099                 alp_status_t    Send(AlpConnection* channel);
00100 
00101                 class MessageSharedPtr;
00102 
00103                 MessageSharedPtr*       fMessage;
00104                 PackMode                        fMode;
00105                 alp_status_t            fStatus;
00106                 int                                     fWhat;
00107 
00108         friend class Server;
00109         friend class Client;
00110 };
00111 
00112 
00113 // Prototypes ----------------------------------------------------------------
00114 Message& operator<<(Message& ipc, const int32_t i);
00115 Message& operator<<(Message& ipc, const uint32_t i);
00116 Message& operator<<(Message& ipc, const bool b);
00117 Message& operator<<(Message& ipc, const float f);
00118 Message& operator<<(Message& ipc, const char* s);
00119 Message& operator<<(Message& ipc, const std::string& s);
00120 Message& operator<<(Message& ipc, const Array& a);
00121 
00122 Message& operator>>(Message& ipc, int32_t& i);
00123 Message& operator>>(Message& ipc, uint32_t& i);
00124 Message& operator>>(Message& ipc, bool& b);
00125 Message& operator>>(Message& ipc, float& f);
00126 Message& operator>>(Message& ipc, char*& s);
00127 Message& operator>>(Message& ipc, std::string& s);
00128 Message& operator>>(Message& ipc, Array& a);
00129 
00130 }       // namespace ipc
00131 
00132 }       // namespace alp
00133 
00134 
00135 
00136 #endif  // ALP_IPC_MESSAGE_H

Generated on Sat Dec 16 20:29:47 2006 for hiker-0.9 by  doxygen 1.4.4