Equalizer 1.0

include/eq/fabric/node.h

00001 
00002 /* Copyright (c) 2010-2011, Stefan Eilemann <eile@eyescale.ch>
00003  *               2010, Cedric Stalder<cedric.stalder@gmail.com>
00004  *
00005  * This library is free software; you can redistribute it and/or modify it under
00006  * the terms of the GNU Lesser General Public License version 2.1 as published
00007  * by the Free Software Foundation.
00008  *  
00009  * This library is distributed in the hope that it will be useful, but WITHOUT
00010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00012  * details.
00013  * 
00014  * You should have received a copy of the GNU Lesser General Public License
00015  * along with this library; if not, write to the Free Software Foundation, Inc.,
00016  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00017  */
00018 
00019 #ifndef EQFABRIC_NODE_H
00020 #define EQFABRIC_NODE_H
00021 
00022 #include <eq/fabric/object.h>        // base class
00023 #include <eq/fabric/types.h>
00024 #include <eq/fabric/visitorResult.h> // enum
00025 
00026 namespace eq
00027 {
00028 namespace fabric
00029 {
00031     template< class C, class N, class P, class V > class Node : public Object
00032     {
00033     public:
00035         typedef std::vector< P* > Pipes;
00036 
00040         C*       getConfig()       { return _config; }
00041 
00043         const C* getConfig() const { return _config; }
00044 
00046         const Pipes& getPipes() const { return _pipes; }
00047 
00053         bool isApplicationNode() const { return _isAppNode; }
00054 
00056         EQFABRIC_INL void setApplicationNode( const bool isAppNode );
00057 
00059         EQFABRIC_INL NodePath getPath() const;
00060         P* findPipe( const co::base::UUID& id ); 
00061 
00069         EQFABRIC_INL VisitorResult accept( V& visitor );
00070 
00072         EQFABRIC_INL VisitorResult accept( V& visitor ) const;
00074 
00077         // Note: also update string array initialization in node.ipp
00079         enum IAttribute
00080         {
00082             IATTR_THREAD_MODEL,
00083             IATTR_LAUNCH_TIMEOUT, 
00084             IATTR_LAST,
00085             IATTR_ALL = IATTR_LAST + 5
00086         };
00087 
00089         EQFABRIC_INL void setIAttribute( const IAttribute attr,
00090                                             const int32_t value );
00091 
00093         EQFABRIC_INL int32_t getIAttribute( const IAttribute attr ) const;
00094 
00096         static const std::string& getIAttributeString( const IAttribute attr );
00098 
00099         EQFABRIC_INL virtual void backup(); 
00100         EQFABRIC_INL virtual void restore(); 
00101         void create( P** pipe ); 
00102         void release( P* pipe ); 
00103         virtual void output( std::ostream& ) const {} 
00104 
00105     protected:
00107         Node( C* parent );
00109         EQFABRIC_INL virtual ~Node();
00110 
00112         EQFABRIC_INL virtual void serialize( co::DataOStream& os,
00113                                                 const uint64_t dirtyBits );
00115         EQFABRIC_INL virtual void deserialize( co::DataIStream& is, 
00116                                                const uint64_t dirtyBits );
00117         
00118         EQFABRIC_INL virtual void notifyDetach(); 
00119 
00121         EQFABRIC_INL virtual void setDirty( const uint64_t bits );
00122 
00124         virtual ChangeType getChangeType() const { return UNBUFFERED; }
00125 
00126         enum DirtyBits
00127         {
00128             DIRTY_ATTRIBUTES      = Object::DIRTY_CUSTOM << 0,
00129             DIRTY_PIPES           = Object::DIRTY_CUSTOM << 1,
00130             DIRTY_MEMBER          = Object::DIRTY_CUSTOM << 2,
00131             DIRTY_NODE_BITS =
00132                 DIRTY_ATTRIBUTES | DIRTY_PIPES | DIRTY_MEMBER |
00133                 DIRTY_OBJECT_BITS
00134         };
00135 
00137         virtual uint64_t getRedistributableBits() const
00138             { return DIRTY_NODE_BITS; }
00139 
00140     private:
00142         Pipes _pipes;
00143 
00145         C* const _config;
00146 
00147         struct BackupData
00148         {
00149             BackupData();
00151             int32_t iAttributes[IATTR_ALL];
00152         }
00153             _data, _backup;
00154 
00155         bool _isAppNode; 
00156 
00157         struct Private;
00158         Private* _private; // placeholder for binary-compatible changes
00159 
00160         template< class, class, class, class > friend class Pipe;
00161         void _addPipe( P* pipe );
00162         bool _removePipe( P* pipe );
00163 
00165         EQFABRIC_INL virtual uint32_t commitNB( const uint32_t incarnation );
00166         bool _mapNodeObjects() { return _config->mapNodeObjects(); }
00167     };
00168 
00169     template< class C, class N, class P, class V > EQFABRIC_INL
00170     std::ostream& operator << ( std::ostream&, const Node< C, N, P, V >& );
00171 }
00172 }
00173 
00174 #endif // EQFABRIC_NODE_H
00175 
Generated on Sun May 8 2011 19:11:07 for Equalizer 1.0 by  doxygen 1.7.3