OXY-SYNC-CONTAINER 1.0
OXY-SYNC-CONTAINER Library Documentation
Loading...
Searching...
No Matches
oxy::sync Namespace Reference

This namespace contains synchronization-related functionality for the oxy library. More...

Namespaces

namespace  api
 This namespace contains API types and operations for the oxy sync container library.
namespace  service
 This namespace contains service-related functionality for the oxy sync container library.
namespace  settings
 This namespace contains configuration settings for the oxy sync container library.

Classes

struct  merge_commit_fn
 Function object for performing a merge commit operation. More...

Typedefs

using merge_callback
 Callback to resolve potential conflict.

Functions

template<typename K, typename V>
std::map< K, V > merge_maps (const std::map< K, V > &ancestor, const std::map< K, V > &left, const std::map< K, V > &right, std::function< V(const K &, const std::optional< V > &ancestor_val, const std::optional< V > &left_val, const std::optional< V > &right_val)> conflict_callback)
 Performs a three-way merge of three maps using an ancestor (base) version to detect and resolve conflicts.

Variables

constexpr merge_commit_fn merge_commit
 A constexpr instance of the merge_commit_fn function object for use in functional programming.

Detailed Description

This namespace contains synchronization-related functionality for the oxy library.

Typedef Documentation

◆ merge_callback

Initial value:
std::function<oid_t(oid_t const &our, oid_t const &other, oid_t const &ancestor)>

Callback to resolve potential conflict.

Parameters
our- Identifier of the current commit.
other- Identifier of the other commit.
ancestor- Identifier of the common ancestor commit.
Returns
Identifier of the merge commit.

Function Documentation

◆ merge_maps()

template<typename K, typename V>
std::map< K, V > oxy::sync::merge_maps ( const std::map< K, V > & ancestor,
const std::map< K, V > & left,
const std::map< K, V > & right,
std::function< V(const K &, const std::optional< V > &ancestor_val, const std::optional< V > &left_val, const std::optional< V > &right_val)> conflict_callback )

Performs a three-way merge of three maps using an ancestor (base) version to detect and resolve conflicts.

Template Parameters
KThe key type of the maps.
VThe value type of the maps.
Parameters
ancestorThe common ancestor (base) map used to determine which changes were made in the left and right branches.
leftThe left branch map containing potential modifications from the ancestor.
rightThe right branch map containing potential modifications from the ancestor.
conflict_callbackA callback function invoked when both left and right branches modified the same key differently. It receives the key and optional values from all three maps, and must return the resolved value to use in the result.
Returns
A merged map containing the resolved combination of all three input maps. Non-conflicting changes from both branches are automatically applied, while conflicts are resolved using the callback function.