Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

phMessage.h

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002     Phission : 
00003         Realtime Vision Processing System
00004 
00005     Copyright (C) 2003 Philip D.S. Thoren (pthoren@cs.uml.edu)
00006     University of Massachusetts at Lowell,
00007     Laboratory for Artificial Intelligence and Robotics
00008 
00009     This file is part of Phission.
00010 
00011     Phission is free software; you can redistribute it and/or modify
00012     it under the terms of the GNU General Public License as published by
00013     the Free Software Foundation; either version 2 of the License, or
00014     (at your option) any later version.
00015 
00016     Phission is distributed in the hope that it will be useful,
00017     but WITHOUT ANY WARRANTY; without even the implied warranty of
00018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019     GNU General Public License for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with Phission; if not, write to the Free Software
00023     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024 
00025  ---------------------------------------------------------------------------*/
00026 /* -------------------------------------------------------------------------- *
00027  * phClientHandler.h: Header for the client handler that the server spawns to *
00028  * handle multiple client requests.                                           *
00029  * -------------------------------------------------------------------------- */
00030 #ifndef PHMESSAGE_H
00031 #define PHMESSAGE_H
00032 
00033 #include <phission.h>
00034 #include <stdio.h>
00035 
00036 /* -------------------------------------------------------------------------- */
00037 #ifndef phID_INVALID
00038 #define phID_INVALID 4294967295U
00039 #endif
00040 #ifndef phCLASS_INVALID
00041 #define phCLASS_INVALID 4294967295U
00042 #endif
00043 #ifndef phTIME_INVALID
00044 #define phTIME_INVALID 4294967295U
00045 #endif
00046 #ifndef phMESSAGE_INVALID
00047 #define phMESSAGE_INVALID 4294967295U
00048 #endif
00049 #ifndef phMUTEX_INVALID
00050 #define phMUTEX_INVALID 4294967295U
00051 #endif
00052 /* -------------------------------------------------------------------------- */
00053 #define phCLIENT_INVALID_MSG       0
00054 #define phCLIENT_LOCK_MSG       1001
00055 #define phCLIENT_UNLOCK_MSG     1002
00056 #define phCLIENT_SUCCESS        1003
00057 #define phCLIENT_FAIL           1004
00058 #define phCLIENT_HELLO          1111
00059 #define phCLIENT_GOODBYE        1222
00060 #define phCLIENT_ECHO           1333
00061 
00062 #define phCLIENT_REQUEST        phCLIENT_LOCK_MSG
00063 #define phCLIENT_RELEASE        phCLIENT_UNLOCK_MSG
00064 
00065 #define phNODE_REQUEST          2001
00066 #define phNODE_REPLY            2002
00067 #define phNODE_RELEASE          2003
00068 
00069 #define phCLASS_CLIENT  1
00070 #define phCLASS_NODE    2
00071 
00072 class phMessage : public phObject
00073 {
00074 private:
00075 #define phMessage_nfields() 7
00076     uint32_t m_src_id;
00077     uint32_t m_dst_id;
00078     uint32_t m_src_class;
00079     uint32_t m_dst_class;
00080     uint32_t m_message_id;
00081     uint32_t m_mutex_id;
00082     uint32_t m_timestamp;
00083    
00084     uint8_t *m_buf;
00085     uint32_t m_buf_size;
00086 
00087     void reset();
00088     uint32_t getDataSize();
00089     int alloc_buffer( uint8_t **pbuf, uint32_t *psize );
00090     int getData( uint8_t **pbuf, uint32_t *psize );
00091     int setData( uint8_t *buf, uint32_t size );
00092 
00093     
00094 public:
00095     phMessage();
00096     phMessage(phMessage &message);
00097     ~phMessage();
00098 
00099     phMessage &operator =( phMessage &m );
00100 
00101     int set(uint32_t src_id, uint32_t dst_id,
00102             uint32_t src_class, uint32_t dst_class,
00103             uint32_t message_id, uint32_t mutex_id,
00104             uint32_t timestamp );
00105     int set( phMessage &message );
00106     int setSrcId        (uint32_t src_id);
00107     int setDstId        (uint32_t dst_id);
00108     int setSrcClass     (uint32_t src_class);
00109     int setDstClass     (uint32_t dst_class);
00110     int setMessageId    (uint32_t message_id);
00111     int setMutexId      (uint32_t mutex_id);
00112     int setTimestamp    (uint32_t timestamp );
00113     
00114     uint32_t getSrcId();
00115     uint32_t getDstId();
00116     uint32_t getSrcClass();
00117     uint32_t getDstClass();
00118     uint32_t getMessageId();
00119     uint32_t getMutexId();
00120     uint32_t getTimestamp();
00121 
00122     int receive( phSocket *sock );
00123     int send( phSocket *sock );
00124     
00125     int print( FILE *fd  = stdout, int short_print = 0);
00126 };
00127 
00128 
00129 #endif /* PHMESSAGE_H */




Copyright (C) 2002 - 2007 Philip D.S. Thoren ( pthoren@users.sourceforge.net )
University Of Massachusetts at Lowell
Robotics Lab
SourceForge.net Logo

Generated on Sat Jun 16 02:44:05 2007 for phission by  doxygen 1.4.4