Equalizer 1.0

barrier.h

00001 
00002 /* Copyright (c) 2006-2011, 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 CO_BARRIER_H
00019 #define CO_BARRIER_H
00020 
00021 #include <co/object.h>   // base class
00022 #include <co/types.h>
00023 #include <co/base/monitor.h> // member
00024 
00025 #include <map>
00026 
00027 namespace co
00028 {
00030     class Barrier : public Object
00031     {
00032     public:
00044         CO_API Barrier( NodePtr master, const uint32_t height = 0 );
00045 
00047         CO_API Barrier();
00048 
00050         CO_API virtual ~Barrier();
00051 
00060         void setHeight( const uint32_t height ) { _height = height; }
00061 
00063         void increase() { ++_height; }
00064 
00066         uint32_t getHeight() const { return _height; }
00068 
00077         CO_API void enter();
00079 
00080     protected:
00081         virtual void attach( const base::UUID& id, 
00082                              const uint32_t instanceID );
00083 
00084         virtual ChangeType getChangeType() const { return DELTA; }
00085 
00086         virtual void getInstanceData( DataOStream& os );
00087         virtual void applyInstanceData( DataIStream& is );
00088         virtual void pack( DataOStream& os );
00089         virtual void unpack( DataIStream& is );
00090 
00091     private:
00093         NodeID   _masterID;
00094 
00096         uint32_t _height;
00097 
00099         NodePtr _master;
00100 
00102         std::map< uint128_t, Nodes > _enteredNodes;
00103         
00105         base::Monitor< uint32_t > _leaveNotify;
00106 
00107         /* The command handlers. */
00108         bool _cmdEnter( Command& command );
00109         bool _cmdEnterReply( Command& command );
00110 
00111         EQ_TS_VAR( _thread );
00112     };
00113 }
00114 
00115 #endif // CO_BARRIER_H
00116 
Generated on Sun May 8 2011 19:11:04 for Equalizer 1.0 by  doxygen 1.7.3