barrier.h

00001 
00002 /* Copyright (c) 2006-2009, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *
00004  * This library is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Lesser General Public License version 2.1 as published
00006  * by the Free Software Foundation.
00007  *  
00008  * This library is distributed in the hope that it will be useful, but WITHOUT
00009  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00010  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00011  * details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this library; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016  */
00017 
00018 #ifndef EQNET_BARRIER_H
00019 #define EQNET_BARRIER_H
00020 
00021 #include <eq/net/object.h>   // base class
00022 #include <eq/net/types.h>
00023 #include <eq/base/monitor.h> // member
00024 
00025 #include <map>
00026 
00027 namespace eq
00028 {
00029 namespace net
00030 {
00031     class Node;
00032 
00034     class Barrier : public Object
00035     {
00036     public:
00047         EQ_EXPORT Barrier( NodePtr master, const uint32_t height = 0 );
00048 
00050         EQ_EXPORT Barrier();
00051 
00053         EQ_EXPORT virtual ~Barrier();
00054 
00063         void setHeight( const uint32_t height ) { _height = height; }
00064 
00066         void increase() { ++_height; }
00067 
00069         uint32_t getHeight() const { return _height; }
00071 
00080         EQ_EXPORT void enter();
00082 
00083     protected:
00084         virtual void attachToSession( const uint32_t id, 
00085                                       const uint32_t instanceID, 
00086                                       Session* session );
00087         virtual ChangeType getChangeType() const { return DELTA; }
00088 
00089         virtual void getInstanceData( DataOStream& os );
00090         virtual void applyInstanceData( DataIStream& is );
00091         virtual void pack( DataOStream& os );
00092         virtual void unpack( DataIStream& is );
00093 
00094     private:
00096         NodeID   _masterID;
00097 
00099         uint32_t _height;
00100 
00102         NodePtr _master;
00103 
00105         std::map< uint32_t, NodeVector > _enteredNodes;
00106         
00108         base::Monitor<uint32_t> _leaveNotify;
00109 
00110         /* The command handlers. */
00111         CommandResult _cmdEnter( Command& command );
00112         CommandResult _cmdEnterReply( Command& command );
00113 
00114         CHECK_THREAD_DECLARE( _thread );
00115     };
00116 }
00117 }
00118 
00119 #endif // EQNET_BARRIER_H
00120 
Generated on Sat Feb 6 12:59:41 2010 for Equalizer 0.9.1 by  doxygen 1.6.1