LCOV - code coverage report
Current view: top level - eq/fabric - node.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 7 8 87.5 %
Date: 2017-12-16 05:07:20 Functions: 11 24 45.8 %

          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>
      32             : class Node : public Object
      33             : {
      34             : public:
      35             :     /** A vector of pointers to pipes. @version 1.0 */
      36             :     typedef std::vector<P*> Pipes;
      37             : 
      38             :     /** @name Data Access */
      39             :     //@{
      40             :     /** @return the config of this node. @version 1.0 */
      41        2500 :     C* getConfig() { return _config; }
      42             :     /** @return the config of this node. @version 1.0 */
      43          10 :     const C* getConfig() const { return _config; }
      44             :     /** @return the vector of child pipes. @version 1.0 */
      45       20949 :     const Pipes& getPipes() const { return _pipes; }
      46             :     /**
      47             :      * @internal
      48             :      * @return true if all render tasks for this node are executed by the
      49             :      *         application process, false otherwise.
      50             :      */
      51         840 :     bool isApplicationNode() const { return _isAppNode; }
      52             :     /** @internal */
      53             :     EQFABRIC_INL void setApplicationNode(const bool isAppNode);
      54             : 
      55             :     /** @internal @return the index path to this node. */
      56             :     EQFABRIC_INL NodePath getPath() const;
      57             :     P* findPipe(const uint128_t& id); //!< @internal
      58             : 
      59             :     /**
      60             :      * Perform a depth-first traversal of this node.
      61             :      *
      62             :      * @param visitor the visitor.
      63             :      * @return the result of the visitor traversal.
      64             :      * @version 1.0
      65             :      */
      66             :     EQFABRIC_INL VisitorResult accept(V& visitor);
      67             : 
      68             :     /** Const-version of accept(). @version 1.0 */
      69             :     EQFABRIC_INL VisitorResult accept(V& visitor) const;
      70             :     //@}
      71             : 
      72             :     /** @name Attributes */
      73             :     //@{
      74             :     // Note: also update string array initialization in node.ipp
      75             :     /** Integer attributes. */
      76             :     enum IAttribute
      77             :     {
      78             :         /** <a
      79             :            href="http://www.equalizergraphics.com/documents/design/threads.html#sync">Threading
      80             :            model</a> */
      81             :         IATTR_THREAD_MODEL,
      82             :         IATTR_LAUNCH_TIMEOUT, //!< Timeout when auto-launching the node
      83             :         IATTR_HINT_AFFINITY,
      84             :         IATTR_LAST,
      85             :         IATTR_ALL = IATTR_LAST + 5
      86             :     };
      87             : 
      88             :     /** @internal Set a node integer attribute. */
      89             :     EQFABRIC_INL void setIAttribute(const IAttribute attr, const int32_t value);
      90             : 
      91             :     /** @return the value of a node integer attribute. @version 1.0 */
      92             :     EQFABRIC_INL int32_t getIAttribute(const IAttribute attr) const;
      93             : 
      94             :     /** @internal @return the name of a node integer attribute. */
      95             :     static const std::string& getIAttributeString(const IAttribute attr);
      96             :     //@}
      97             : 
      98             :     /** @internal */
      99             :     //@{
     100             :     EQFABRIC_INL virtual void backup();         //!< @internal
     101             :     EQFABRIC_INL virtual void restore();        //!< @internal
     102             :     void create(P** pipe);                      //!< @internal
     103             :     void release(P* pipe);                      //!< @internal
     104           0 :     virtual void output(std::ostream&) const {} //!< @internal
     105             :     EQFABRIC_INL virtual uint128_t commit(
     106             :         const uint32_t incarnation = CO_COMMIT_NEXT);
     107             :     //@}
     108             : 
     109             : protected:
     110             :     /** @internal Construct a new node. */
     111             :     explicit Node(C* parent);
     112             : 
     113             :     /** @internal Destruct the node. */
     114             :     EQFABRIC_INL virtual ~Node();
     115             : 
     116             :     /** @internal */
     117             :     EQFABRIC_INL virtual void serialize(co::DataOStream& os,
     118             :                                         const uint64_t dirtyBits);
     119             :     /** @internal */
     120             :     EQFABRIC_INL virtual void deserialize(co::DataIStream& is,
     121             :                                           const uint64_t dirtyBits);
     122             : 
     123             :     EQFABRIC_INL virtual void notifyDetach(); //!< @internal
     124             : 
     125             :     /** @sa Serializable::setDirty() @internal */
     126             :     EQFABRIC_INL virtual void setDirty(const uint64_t bits);
     127             : 
     128             :     /** @internal */
     129           4 :     virtual ChangeType getChangeType() const { return UNBUFFERED; }
     130             :     enum DirtyBits
     131             :     {
     132             :         DIRTY_ATTRIBUTES = Object::DIRTY_CUSTOM << 0,
     133             :         DIRTY_PIPES = Object::DIRTY_CUSTOM << 1,
     134             :         DIRTY_MEMBER = Object::DIRTY_CUSTOM << 2,
     135             :         DIRTY_NODE_BITS =
     136             :             DIRTY_ATTRIBUTES | DIRTY_PIPES | DIRTY_MEMBER | DIRTY_OBJECT_BITS
     137             :     };
     138             : 
     139             :     /** @internal @return the bits to be re-committed by the master. */
     140           2 :     virtual uint64_t getRedistributableBits() const { return DIRTY_NODE_BITS; }
     141             : private:
     142             :     /** Pipe children. */
     143             :     Pipes _pipes;
     144             : 
     145             :     /** The parent config. */
     146             :     C* const _config;
     147             : 
     148             :     struct BackupData
     149             :     {
     150             :         BackupData();
     151             :         /** Integer attributes. */
     152             :         int32_t iAttributes[IATTR_ALL];
     153             :     } _data, _backup;
     154             : 
     155             :     bool _isAppNode; //!< execute render tasks in application process
     156             : 
     157             :     template <class, class, class, class>
     158             :     friend class Pipe;
     159             :     void _addPipe(P* pipe);
     160             :     bool _removePipe(P* pipe);
     161             : 
     162             :     /** @internal */
     163          49 :     bool _mapNodeObjects() { return _config->mapNodeObjects(); }
     164             : };
     165             : 
     166             : template <class C, class N, class P, class V>
     167             : EQFABRIC_INL std::ostream& operator<<(std::ostream&, const Node<C, N, P, V>&);
     168             : }
     169             : }
     170             : 
     171             : #endif // EQFABRIC_NODE_H

Generated by: LCOV version 1.11