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

phLamportSystem.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 #ifndef PHLAMPORTSYSTEM_H
00027 #define PHLAMPORTSYSTEM_H
00028 
00029 #include <phission.h>
00030 #include <phMessage.h>
00031 #include <phRequestDB.h>
00032 
00033 /* -------------------------------------------------------------------------- */
00034 /* forward declarations of these classes. The headers are included in the
00035  * source file. This prevents craziness in the header files of the particular
00036  * classes that include this header file. Although I suppose all the classes
00037  * could be forward declarations */
00038 class phClientHandler;
00039 class phNodeComm; 
00040 
00041 /* -------------------------------------------------------------------------- */
00042 class phLamportSystem : protected phMutex
00043 {
00044 private:
00045     phObjectList m_client_list;
00046     phObjectList m_node_list;
00047 
00048     uint32_t m_node_id;   
00049 
00050     phRequestDB m_db;
00051     
00052 public:
00053     phLamportSystem();
00054     ~phLamportSystem();
00055 
00056     int         setNodeId(uint32_t node_id);
00057     uint32_t    getNodeId();
00058     
00059     int             registerResource( phClientHandler *client );
00060     int             removeResource  ( phClientHandler *client );
00061     phClientHandler *getClient      ( uint32_t id );
00062     
00063     int         registerResource( phNodeComm *node );
00064     int         removeResource  ( phNodeComm *node );
00065     phNodeComm  *getNode        ( uint32_t id );
00066 
00067 
00068     /* Send the message to only one destination node */
00069     /* used for REPLY */
00070     int send_message(uint32_t message_id,
00071                      uint32_t dst_id,
00072                      uint32_t mutex_id,
00073                      uint32_t timestamp );
00074     
00075     /* send the message to all the other connected node controllers */
00076     /* used for REQUEST and RELEASE */
00077     int broadcast_message( uint32_t message_id,
00078                            uint32_t mutex_id,
00079                            uint32_t timestamp );
00080     
00081     /* Messages can be routed from the system
00082      * to any node/client using this.
00083      *
00084      * If a node is granted a mutex, the system instance 
00085      * will call this with a specific message that will
00086      * be sent via the phClientHandler. 
00087      *
00088      * if  a node is requesting a mutex, the system 
00089      * will set the clock value and send the request to
00090      * other nodes and put the request message into the
00091      * queue. */
00092     int handle_message( phMessage message );
00093 };
00094 
00095 #endif /* PHLAMPORTSYSTEM_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