LCOV - code coverage report
Current view: top level - src/libs/tools/include/merging - metamergestrategy.hpp (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 2 2 100.0 %
Date: 2019-09-12 12:28:41 Functions: 1 2 50.0 %

          Line data    Source code
       1             : /**
       2             :  * @file
       3             :  *
       4             :  * @brief Applies a MergeConflictStrategy on the metakeys
       5             :  *
       6             :  * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
       7             :  *
       8             :  */
       9             : 
      10             : #ifndef METAMERGESTRATEGY_HPP_
      11             : #define METAMERGESTRATEGY_HPP_
      12             : 
      13             : #include <merging/mergeconflictstrategy.hpp>
      14             : #include <merging/threewaymerge.hpp>
      15             : 
      16             : namespace kdb
      17             : {
      18             : 
      19             : namespace tools
      20             : {
      21             : 
      22             : namespace merging
      23             : {
      24             : // The MetaMergeStrategy differs from other MergeConflictStrategies because
      25             : // it does not resolve conflicts by itself. Instead it uses the supplied ThreeWayMerger
      26             : // instance and applies it to the MetaKeys of conflicting Keys.
      27             : // Only if both conflict operations are META (i.e. if both sides modified only the MetaKeys of a key) and
      28             : // the supplied ThreeWayMerger is able to successfully merge the metakeys, the
      29             : // MetaMergeStrategy will mark the conflict as resolved.
      30             : // If the supplied merger is not able to resolve all conflicts
      31             : // in the MetaKeys this strategy won't resolve even a META <--> META conflict.
      32             : // If the conflict operations are anything else than META the MetaMergeStrategy will also
      33             : // not resolve the conflict, although the MetaKeys might be merged successul. This allows
      34             : // strategies later in the chain to resolve the value conflict of the conflicting key.
      35          84 : class MetaMergeStrategy : public MergeConflictStrategy
      36             : {
      37             : 
      38             : public:
      39             :         ThreeWayMerge & innerMerger;
      40             : 
      41          84 :         explicit MetaMergeStrategy (ThreeWayMerge & _innerStrategy) : innerMerger (_innerStrategy)
      42             :         {
      43             :         }
      44             : 
      45             :         virtual void resolveConflict (const MergeTask & task, Key & conflictKey, MergeResult & result) override;
      46             : 
      47             : private:
      48             :         KeySet getMetaKeys (Key & key);
      49             : };
      50             : } // namespace merging
      51             : } // namespace tools
      52             : } // namespace kdb
      53             : 
      54             : #endif /* METAMERGESTRATEGY_HPP_ */

Generated by: LCOV version 1.13