Equalizer  1.4.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 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_HINT_AFFINITY,
00085             IATTR_LAST,
00086             IATTR_ALL = IATTR_LAST + 5
00087         };
00088 
00090         EQFABRIC_INL void setIAttribute( const IAttribute attr,
00091                                             const int32_t value );
00092 
00094         EQFABRIC_INL int32_t getIAttribute( const IAttribute attr ) const;
00095 
00097         static const std::string& getIAttributeString( const IAttribute attr );
00099 
00102         EQFABRIC_INL virtual void backup(); 
00103         EQFABRIC_INL virtual void restore(); 
00104         void create( P** pipe ); 
00105         void release( P* pipe ); 
00106         virtual void output( std::ostream& ) const {} 
00107         EQFABRIC_INL virtual uint128_t commit( const uint32_t incarnation =
00108                                                CO_COMMIT_NEXT );
00110 
00111     protected:
00113         Node( C* parent );
00115         EQFABRIC_INL virtual ~Node();
00116 
00118         EQFABRIC_INL virtual void serialize( co::DataOStream& os,
00119                                                 const uint64_t dirtyBits );
00121         EQFABRIC_INL virtual void deserialize( co::DataIStream& is, 
00122                                                const uint64_t dirtyBits );
00123         
00124         EQFABRIC_INL virtual void notifyDetach(); 
00125 
00127         EQFABRIC_INL virtual void setDirty( const uint64_t bits );
00128 
00130         virtual ChangeType getChangeType() const { return UNBUFFERED; }
00131 
00132         enum DirtyBits
00133         {
00134             DIRTY_ATTRIBUTES      = Object::DIRTY_CUSTOM << 0,
00135             DIRTY_PIPES           = Object::DIRTY_CUSTOM << 1,
00136             DIRTY_MEMBER          = Object::DIRTY_CUSTOM << 2,
00137             DIRTY_NODE_BITS =
00138                 DIRTY_ATTRIBUTES | DIRTY_PIPES | DIRTY_MEMBER |
00139                 DIRTY_OBJECT_BITS
00140         };
00141 
00143         virtual uint64_t getRedistributableBits() const
00144             { return DIRTY_NODE_BITS; }
00145 
00146     private:
00148         Pipes _pipes;
00149 
00151         C* const _config;
00152 
00153         struct BackupData
00154         {
00155             BackupData();
00157             int32_t iAttributes[IATTR_ALL];
00158         }
00159             _data, _backup;
00160 
00161         bool _isAppNode; 
00162 
00163         struct Private;
00164         Private* _private; // placeholder for binary-compatible changes
00165 
00166         template< class, class, class, class > friend class Pipe;
00167         void _addPipe( P* pipe );
00168         bool _removePipe( P* pipe );
00169 
00171         bool _mapNodeObjects() { return _config->mapNodeObjects(); }
00172     };
00173 
00174     template< class C, class N, class P, class V > EQFABRIC_INL
00175     std::ostream& operator << ( std::ostream&, const Node< C, N, P, V >& );
00176 }
00177 }
00178 
00179 #endif // EQFABRIC_NODE_H
00180 
Generated on Mon Nov 26 2012 14:41:49 for Equalizer 1.4.1 by  doxygen 1.7.6.1