Equalizer  1.2.1
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 
00101         EQFABRIC_INL virtual void backup(); 
00102         EQFABRIC_INL virtual void restore(); 
00103         void create( P** pipe ); 
00104         void release( P* pipe ); 
00105         virtual void output( std::ostream& ) const {} 
00106         EQFABRIC_INL virtual uint128_t commit( const uint32_t incarnation =
00107                                                CO_COMMIT_NEXT );
00109 
00110     protected:
00112         Node( C* parent );
00114         EQFABRIC_INL virtual ~Node();
00115 
00117         EQFABRIC_INL virtual void serialize( co::DataOStream& os,
00118                                                 const uint64_t dirtyBits );
00120         EQFABRIC_INL virtual void deserialize( co::DataIStream& is, 
00121                                                const uint64_t dirtyBits );
00122         
00123         EQFABRIC_INL virtual void notifyDetach(); 
00124 
00126         EQFABRIC_INL virtual void setDirty( const uint64_t bits );
00127 
00129         virtual ChangeType getChangeType() const { return UNBUFFERED; }
00130 
00131         enum DirtyBits
00132         {
00133             DIRTY_ATTRIBUTES      = Object::DIRTY_CUSTOM << 0,
00134             DIRTY_PIPES           = Object::DIRTY_CUSTOM << 1,
00135             DIRTY_MEMBER          = Object::DIRTY_CUSTOM << 2,
00136             DIRTY_NODE_BITS =
00137                 DIRTY_ATTRIBUTES | DIRTY_PIPES | DIRTY_MEMBER |
00138                 DIRTY_OBJECT_BITS
00139         };
00140 
00142         virtual uint64_t getRedistributableBits() const
00143             { return DIRTY_NODE_BITS; }
00144 
00145     private:
00147         Pipes _pipes;
00148 
00150         C* const _config;
00151 
00152         struct BackupData
00153         {
00154             BackupData();
00156             int32_t iAttributes[IATTR_ALL];
00157         }
00158             _data, _backup;
00159 
00160         bool _isAppNode; 
00161 
00162         struct Private;
00163         Private* _private; // placeholder for binary-compatible changes
00164 
00165         template< class, class, class, class > friend class Pipe;
00166         void _addPipe( P* pipe );
00167         bool _removePipe( P* pipe );
00168 
00170         bool _mapNodeObjects() { return _config->mapNodeObjects(); }
00171     };
00172 
00173     template< class C, class N, class P, class V > EQFABRIC_INL
00174     std::ostream& operator << ( std::ostream&, const Node< C, N, P, V >& );
00175 }
00176 }
00177 
00178 #endif // EQFABRIC_NODE_H
00179 
Generated on Fri Jun 8 2012 15:44:31 for Equalizer 1.2.1 by  doxygen 1.8.0