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

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2012-2016, Stefan Eilemann <eile@eyescale.ch>
       3             :  *
       4             :  * This file is part of Collage <https://github.com/Eyescale/Collage>
       5             :  *
       6             :  * This library is free software; you can redistribute it and/or modify it under
       7             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       8             :  * by the Free Software Foundation.
       9             :  *
      10             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      11             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      12             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      13             :  * details.
      14             :  *
      15             :  * You should have received a copy of the GNU Lesser General Public License
      16             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      17             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      18             :  */
      19             : 
      20             : #ifndef CO_OBJECTHANDLER_H
      21             : #define CO_OBJECTHANDLER_H
      22             : 
      23             : #include <co/api.h>
      24             : #include <co/types.h>
      25             : 
      26             : namespace co
      27             : {
      28             : /** Interface for entities which map and register objects. */
      29             : class ObjectHandler
      30             : {
      31             : public:
      32             :     /**
      33             :      * Register a distributed object.
      34             :      *
      35             :      * Registering a distributed object makes this object the master
      36             :      * version. The object's identifier is used to map slave instances of the
      37             :      * object. Master versions of objects are typically writable and can commit
      38             :      * new versions of the distributed object.
      39             :      *
      40             :      * @param object the object instance.
      41             :      * @return true if the object was registered, false otherwise.
      42             :      * @version 1.0
      43             :      */
      44             :     virtual bool registerObject(Object* object) = 0;
      45             : 
      46             :     /**
      47             :      * Deregister a distributed object.
      48             :      *
      49             :      * @param object the object instance.
      50             :      * @version 1.0
      51             :      */
      52             :     virtual void deregisterObject(Object* object) = 0;
      53             : 
      54             :     /**
      55             :      * Start mapping a distributed object.
      56             :      *
      57             :      * @param object the object to map.
      58             :      * @param id the object identifier
      59             :      * @param version the version to map.
      60             :      * @param master the master node, may be invalid/0.
      61             :      * @return the request identifier for mapObjectSync().
      62             :      * @version 1.0
      63             :      */
      64             :     virtual uint32_t mapObjectNB(Object* object, const uint128_t& id,
      65             :                                  const uint128_t& version, NodePtr master) = 0;
      66             : 
      67             :     /** Finalize the mapping of a distributed object. @version 1.0 */
      68             :     virtual bool mapObjectSync(const uint32_t requestID) = 0;
      69             : 
      70             :     /** Unmap a mapped object. @version 1.0 */
      71             :     virtual void unmapObject(Object* object) = 0;
      72             : 
      73             :     /** Convenience method to deregister or unmap an object. @version 1.0 */
      74             :     CO_API void releaseObject(Object* object);
      75             : 
      76             :     /**
      77             :      * Synchronize the local object with a remote object.
      78             :      *
      79             :      * The object is synchronized to the newest version of the first attached
      80             :      * object on the given master node matching the instanceID. No mapping is
      81             :      * established. When no master node is given, connectObjectMaster() is used
      82             :      * to find the node with the master instance. When CO_INSTANCE_ALL is given,
      83             :      * the first instance is used. Before a successful return,
      84             :      * applyInstanceData() is called on the calling thread to synchronize the
      85             :      * given object.
      86             :      *
      87             :      * @param object The local object instance to synchronize.
      88             :      * @param id the object identifier.
      89             :      * @param master The node where the synchronizing object is attached.
      90             :      * @param instanceID the instance identifier of the synchronizing
      91             :      *                   object.
      92             :      * @return A lunchbox::Future which will deliver the success status of
      93             :      *         the operation on evaluation.
      94             :      * @version 1.1.1
      95             :      */
      96             :     virtual f_bool_t syncObject(
      97             :         Object* object, const uint128_t& id, NodePtr master,
      98             :         const uint32_t instanceID = CO_INSTANCE_ALL) = 0;
      99             : 
     100             : protected:
     101             :     /** Construct a new object handler. @version 1.0 */
     102          53 :     ObjectHandler() {}
     103             :     /** Destroy this object handler. @version 1.0 */
     104          51 :     virtual ~ObjectHandler() {}
     105             : };
     106             : }
     107             : #endif // CO_OBJECTHANDLER_H

Generated by: LCOV version 1.11