LCOV - code coverage report
Current view: top level - co - iCommand.h (source / functions) Hit Total Coverage
Test: Collage Lines: 3 3 100.0 %
Date: 2018-01-09 16:37:03 Functions: 11 13 84.6 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2006-2017, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                          Daniel Nachbaur <danielnachbaur@gmail.com>
       4             :  *
       5             :  * This file is part of Collage <https://github.com/Eyescale/Collage>
       6             :  *
       7             :  * This library is free software; you can redistribute it and/or modify it under
       8             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       9             :  * by the Free Software Foundation.
      10             :  *
      11             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      12             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      13             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      14             :  * details.
      15             :  *
      16             :  * You should have received a copy of the GNU Lesser General Public License
      17             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      18             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      19             :  */
      20             : 
      21             : #ifndef CO_ICOMMAND_H
      22             : #define CO_ICOMMAND_H
      23             : 
      24             : #include <co/api.h>
      25             : #include <co/commands.h>    // for enum CommandType
      26             : #include <co/dataIStream.h> // base class
      27             : 
      28             : namespace co
      29             : {
      30             : namespace detail
      31             : {
      32             : class ICommand;
      33             : }
      34             : 
      35             : /**
      36             :  * A class managing received commands.
      37             :  *
      38             :  * This class is used by the LocalNode to pass received buffers to the
      39             :  * Dispatcher and ultimately command handler functions. It is not intended to be
      40             :  * instantiated by applications. The derivates of this ICommand have to be
      41             :  * instaniated by the application if the command type requires it. The data
      42             :  * retrieval is possible with the provided DataIStream methods or with the
      43             :  * templated get() function.
      44             :  */
      45             : class ICommand : public DataIStream
      46             : {
      47             : public:
      48             :     CO_API ICommand(); //!< @internal
      49             :     CO_API ICommand(LocalNodePtr local, NodePtr remote,
      50             :                     ConstBufferPtr buffer); //!<@internal
      51             :     CO_API ICommand(const ICommand& rhs);   //!< @internal
      52             : 
      53             :     CO_API virtual ~ICommand(); //!< @internal
      54             : 
      55             :     CO_API ICommand& operator=(const ICommand& rhs); //!< @internal
      56             : 
      57             :     CO_API void clear(); //!< @internal
      58             : 
      59             :     /** @name Data Access */
      60             :     //@{
      61             :     /** @return the command type. @version 1.0 */
      62             :     CO_API uint32_t getType() const;
      63             : 
      64             :     /** @return the command. @version 1.0 */
      65             :     CO_API uint32_t getCommand() const;
      66             : 
      67             :     /** @return the command payload size. @version 1.0 */
      68             :     CO_API uint64_t getSize() const;
      69             : 
      70             :     /** @deprecated use read() */
      71             :     template <typename T>
      72       83692 :     T get()
      73             :     {
      74       83692 :         return read<T>();
      75             :     }
      76             : 
      77             :     /** @deprecated use getRemoteNode() */
      78      216431 :     NodePtr getNode() const { return getRemoteNode(); }
      79             :     /** @return the sending node proxy instance. @version 1.1.1 */
      80             :     CO_API NodePtr getRemoteNode() const override;
      81             : 
      82             :     /** @return the receiving node. @version 1.0 */
      83             :     CO_API LocalNodePtr getLocalNode() const override;
      84             : 
      85             :     /** @return true if the command has valid data. @version 1.0 */
      86             :     CO_API bool isValid() const;
      87             : 
      88             :     /** @internal @return the buffer */
      89             :     CO_API ConstBufferPtr getBuffer() const;
      90             :     //@}
      91             : 
      92             :     /** @internal @name Command dispatch */
      93             :     //@{
      94             :     /** @internal Change the command type for subsequent dispatching. */
      95             :     CO_API void setType(const CommandType type);
      96             : 
      97             :     /** @internal Change the command for subsequent dispatching. */
      98             :     CO_API void setCommand(const uint32_t cmd);
      99             : 
     100             :     /** @internal Set the function to which the command is dispatched. */
     101             :     void setDispatchFunction(const Dispatcher::Func& func);
     102             : 
     103             :     /** @internal Invoke and clear the command function. */
     104             :     CO_API bool operator()();
     105             :     //@}
     106             : 
     107             : private:
     108             :     detail::ICommand* const _impl;
     109             : 
     110             :     friend CO_API std::ostream& operator<<(std::ostream&, const ICommand&);
     111             : 
     112             :     /** @internal @name DataIStream functions */
     113             :     //@{
     114             :     CO_API size_t nRemainingBuffers() const override;
     115             :     CO_API uint128_t getVersion() const override;
     116             :     CO_API bool getNextBuffer(CompressorInfo&, uint32_t&, const void*&,
     117             :                               uint64_t&) override;
     118             :     //@}
     119             : 
     120             :     void _skipHeader(); //!< @internal
     121             : };
     122             : 
     123             : CO_API std::ostream& operator<<(std::ostream& os, const ICommand&);
     124             : }
     125             : #endif // CO_ICOMMAND_H

Generated by: LCOV version 1.11