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

IpcServer.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_SERVER_H
00034 #define ALP_IPC_SERVER_H
00035 
00036 // Includes ------------------------------------------------------------------
00037 #include <string>
00038 
00039 #include <hiker/ipc.h>
00040 #include <hiker/types.h>
00041 
00042 
00043 // Typedefs ------------------------------------------------------------------
00044 namespace alp {
00045 
00046 namespace ipc {
00047 
00048 class Message;
00049 
00050 class Server
00051 {
00052         public:
00053                 enum CallbackFlags
00054                 {
00055                         cfConnect = 0x01,
00056                         cfDisconnect = 0x02,
00057                         cfReceive = 0x04,
00058                         cfAll = cfConnect | cfDisconnect | cfReceive
00059                 };
00060 
00061                 Server(const char* name, AlpIpcChannelAccessMode mode, int flags = cfAll);
00062                 Server(const std::string& name, AlpIpcChannelAccessMode mode, int flags = cfAll);
00063                 virtual ~Server();
00064 
00065                 virtual alp_status_t Run();
00066 
00067                 alp_status_t    Status() const;
00068                 int                             Flags() const;
00069                 alp_status_t    Send(Message& msg);
00070                 
00071                 uid_t                   GetConnectionUID() const;
00072                 gid_t                   GetConnectionGID() const;
00073                 pid_t                   GetConnectionPID() const;
00074 
00075         protected:
00076                 virtual void OnChannelConnect(AlpConnection* connection) {;}
00077                 virtual void OnChannelDisconnect(AlpConnection* connection) {;}
00078                 virtual void OnMessageReceived(Message& message) {;}
00079 
00080         private:
00081                 void Init(const char* name, AlpIpcChannelAccessMode mode);
00082 
00083                 static void     ChannelConnectCB(AlpConnection* connection,
00084                                                                          Server* server);
00085                 static void ChannelDisconnectCB(AlpConnection* connection,
00086                                                                                 Server* server);
00087                 static void     MessageReceiveCB(AlpConnection* connection,
00088                                                                          AlpMessage* message,
00089                                                                          Server* server);
00090 
00091                 AlpChannel*             fServerChannel;
00092                 alp_status_t    fStatus;
00093                 int                             fFlags;
00094                 AlpConnection*  fCurrentConnection;
00095 };
00096 
00097 }       // namespace ipc
00098 
00099 }       // namespace alp
00100 
00101 
00102 
00103 #endif  // ALP_IPC_SERVER_H

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