LCOV - code coverage report
Current view: top level - eq/fabric - node.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 8 9 88.9 %
Date: 2016-07-30 05:04:55 Functions: 10 24 41.7 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2010-2014, Stefan Eilemann <eile@eyescale.ch>
       3             :  *               2010, Cedric Stalder<cedric.stalder@gmail.com>
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or modify it under
       6             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       7             :  * by the Free Software Foundation.
       8             :  *
       9             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      10             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      11             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      12             :  * details.
      13             :  *
      14             :  * You should have received a copy of the GNU Lesser General Public License
      15             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      16             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      17             :  */
      18             : 
      19             : #ifndef EQFABRIC_NODE_H
      20             : #define EQFABRIC_NODE_H
      21             : 
      22             : #include <eq/fabric/object.h>        // base class
      23             : #include <eq/fabric/types.h>
      24             : 
      25             : namespace eq
      26             : {
      27             : namespace fabric
      28             : {
      29             : /** Base data transport class for nodes. @sa eq::Node */
      30             : // cppcheck-suppress noConstructor
      31             : template< class C, class N, class P, class V > class Node : public Object
      32             : {
      33             : public:
      34             :     /** A vector of pointers to pipes. @version 1.0 */
      35             :     typedef std::vector< P* > Pipes;
      36             : 
      37             :     /** @name Data Access */
      38             :     //@{
      39             :     /** @return the config of this node. @version 1.0 */
      40        2445 :     C*       getConfig()       { return _config; }
      41             : 
      42             :     /** @return the config of this node. @version 1.0 */
      43          92 :     const C* getConfig() const { return _config; }
      44             : 
      45             :     /** @return the vector of child pipes. @version 1.0 */
      46       20803 :     const Pipes& getPipes() const { return _pipes; }
      47             : 
      48             :     /**
      49             :      * @internal
      50             :      * @return true if all render tasks for this node are executed by the
      51             :      *         application process, false otherwise.
      52             :      */
      53         868 :     bool isApplicationNode() const { return _isAppNode; }
      54             : 
      55             :     /** @internal */
      56             :     EQFABRIC_INL void setApplicationNode( const bool isAppNode );
      57             : 
      58             :     /** @internal @return the index path to this node. */
      59             :     EQFABRIC_INL NodePath getPath() const;
      60             :     P* findPipe( const uint128_t& id ); //!< @internal
      61             : 
      62             :     /**
      63             :      * Perform a depth-first traversal of this node.
      64             :      *
      65             :      * @param visitor the visitor.
      66             :      * @return the result of the visitor traversal.
      67             :      * @version 1.0
      68             :      */
      69             :     EQFABRIC_INL VisitorResult accept( V& visitor );
      70             : 
      71             :     /** Const-version of accept(). @version 1.0 */
      72             :     EQFABRIC_INL VisitorResult accept( V& visitor ) const;
      73             :     //@}
      74             : 
      75             :     /** @name Attributes */
      76             :     //@{
      77             :     // Note: also update string array initialization in node.ipp
      78             :     /** Integer attributes. */
      79             :     enum IAttribute
      80             :     {
      81             :         /** <a href="http://www.equalizergraphics.com/documents/design/threads.html#sync">Threading model</a> */
      82             :         IATTR_THREAD_MODEL,
      83             :         IATTR_LAUNCH_TIMEOUT, //!< Timeout when auto-launching the node
      84             :         IATTR_HINT_AFFINITY,
      85             :         IATTR_LAST,
      86             :         IATTR_ALL = IATTR_LAST + 5
      87             :     };
      88             : 
      89             :     /** @internal Set a node integer attribute. */
      90             :     EQFABRIC_INL void setIAttribute( const IAttribute attr,
      91             :                                      const int32_t value );
      92             : 
      93             :     /** @return the value of a node integer attribute. @version 1.0 */
      94             :     EQFABRIC_INL int32_t getIAttribute( const IAttribute attr ) const;
      95             : 
      96             :     /** @internal @return the name of a node integer attribute. */
      97             :     static const std::string& getIAttributeString( const IAttribute attr );
      98             :     //@}
      99             : 
     100             :     /** @internal */
     101             :     //@{
     102             :     EQFABRIC_INL virtual void backup(); //!< @internal
     103             :     EQFABRIC_INL virtual void restore(); //!< @internal
     104             :     void create( P** pipe ); //!< @internal
     105             :     void release( P* pipe ); //!< @internal
     106           0 :     virtual void output( std::ostream& ) const {} //!< @internal
     107             :     EQFABRIC_INL virtual uint128_t commit( const uint32_t incarnation =
     108             :                                            CO_COMMIT_NEXT );
     109             :     //@}
     110             : 
     111             : protected:
     112             :     /** @internal Construct a new node. */
     113             :     explicit Node( C* parent );
     114             : 
     115             :     /** @internal Destruct the node. */
     116             :     EQFABRIC_INL virtual ~Node();
     117             : 
     118             :     /** @internal */
     119             :     EQFABRIC_INL virtual void serialize( co::DataOStream& os,
     120             :                                          const uint64_t dirtyBits );
     121             :     /** @internal */
     122             :     EQFABRIC_INL virtual void deserialize( co::DataIStream& is,
     123             :                                            const uint64_t dirtyBits );
     124             : 
     125             :     EQFABRIC_INL virtual void notifyDetach(); //!< @internal
     126             : 
     127             :     /** @sa Serializable::setDirty() @internal */
     128             :     EQFABRIC_INL virtual void setDirty( const uint64_t bits );
     129             : 
     130             :     /** @internal */
     131           6 :     virtual ChangeType getChangeType() const { return UNBUFFERED; }
     132             : 
     133             :     enum DirtyBits
     134             :     {
     135             :         DIRTY_ATTRIBUTES      = Object::DIRTY_CUSTOM << 0,
     136             :         DIRTY_PIPES           = Object::DIRTY_CUSTOM << 1,
     137             :         DIRTY_MEMBER          = Object::DIRTY_CUSTOM << 2,
     138             :         DIRTY_NODE_BITS =
     139             :         DIRTY_ATTRIBUTES | DIRTY_PIPES | DIRTY_MEMBER |
     140             :         DIRTY_OBJECT_BITS
     141             :     };
     142             : 
     143             :     /** @internal @return the bits to be re-committed by the master. */
     144           2 :     virtual uint64_t getRedistributableBits() const
     145           2 :     { return DIRTY_NODE_BITS; }
     146             : 
     147             : private:
     148             :     /** Pipe children. */
     149             :     Pipes _pipes;
     150             : 
     151             :     /** The parent config. */
     152             :     C* const _config;
     153             : 
     154             :     struct BackupData
     155             :     {
     156             :         BackupData();
     157             :         /** Integer attributes. */
     158             :         int32_t iAttributes[IATTR_ALL];
     159             :     }
     160             :         _data, _backup;
     161             : 
     162             :     bool _isAppNode; //!< execute render tasks in application process
     163             : 
     164             :     template< class, class, class, class > friend class Pipe;
     165             :     void _addPipe( P* pipe );
     166             :     bool _removePipe( P* pipe );
     167             : 
     168             :     /** @internal */
     169           9 :     bool _mapNodeObjects() { return _config->mapNodeObjects(); }
     170             : };
     171             : 
     172             : template< class C, class N, class P, class V > EQFABRIC_INL
     173             : std::ostream& operator << ( std::ostream&, const Node< C, N, P, V >& );
     174             : }
     175             : }
     176             : 
     177             : #endif // EQFABRIC_NODE_H

Generated by: LCOV version 1.11