OpenAB  1.0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
OpenAB_Sync::SyncMetadata Class Reference

Documentation for class SyncMetadata. This class is designed to store and keep track of synchronization metadata information. More...

#include <Sync.hpp>

Public Types

enum  SyncMetadataState { NotPresent = 0, NotChanged, Modified }
 

Public Member Functions

 SyncMetadata ()
 
 ~SyncMetadata ()
 
void addItem (const std::string &remoteId, const std::string &remoteRevision, const std::string &localId, const std::string &localRevision)
 Adds new record to metadata. It will bind remote and local items, detected as identical. More...
 
void removeItem (const std::string &remoteId, const std::string &localId)
 Removes record from metadata. It will remove information about remote and local items binding. More...
 
void updateRemoteRevision (const std::string &uid, const std::string &revision)
 Updates revision of remote item. More...
 
void updateLocalRevision (const std::string &uid, const std::string &revision)
 Updates revision of local item. More...
 
std::string getRemoteRevision (const std::string &uid) const
 Returns revision of remote item. More...
 
std::string getLocalRevision (const std::string &uid) const
 Returns revision of local item. More...
 
bool hasLocalId (const std::string &uid) const
 Checks if there is metadata information for local item with given id. More...
 
bool hasRemoteId (const std::string &uid) const
 Checks if there is metadata information for remote item with given id. More...
 
std::string toJSON () const
 Converts metadata into JSON format, so it can be passed around as string. More...
 
bool fromJSON (const std::string &json)
 Load metadata from JSON format. More...
 
void resetRemoteState (SyncMetadataState st)
 Resets state of all remote items. More...
 
void resetLocalState (SyncMetadataState st)
 Resets state of all local items. More...
 
void setRemoteState (const std::string &uid, SyncMetadataState state)
 Sets state of remote item. More...
 
void setLocalState (const std::string &uid, SyncMetadataState state)
 Sets state of remote item. More...
 
std::map< std::string,
std::string > 
getItemsWithState (SyncMetadataState localState, SyncMetadataState remoteState)
 Queries all metadata record which items are in given states. More...
 
std::string getLocalSyncToken () const
 Returns sync token of local storage after last synchronization. More...
 
void setLocalSyncToken (const std::string &token)
 Sets sync token of local storage to be stored in metadata. More...
 
std::string getRemoteSyncToken () const
 Returns sync token of remote storage after last synchronization. More...
 
void setRemoteSyncToken (const std::string &token)
 Sets sync token of remote storage to be stored in metadata. More...
 

Detailed Description

Documentation for class SyncMetadata. This class is designed to store and keep track of synchronization metadata information.

Member Enumeration Documentation

Enumerator
NotPresent 

Item is no longer present in local/remote source/storage

NotChanged 

Item is present in local/remote source/storage and its content has not been changed

Modified 

Item is present in local/remote source/storage, but its content has been changed

Constructor & Destructor Documentation

OpenAB_Sync::SyncMetadata::SyncMetadata ( )
OpenAB_Sync::SyncMetadata::~SyncMetadata ( )

Member Function Documentation

void OpenAB_Sync::SyncMetadata::addItem ( const std::string &  remoteId,
const std::string &  remoteRevision,
const std::string &  localId,
const std::string &  localRevision 
)

Adds new record to metadata. It will bind remote and local items, detected as identical.

Parameters
remoteIdid of remote item
remoteRevisionrevision of remote item
localIdid of local item
localRevisionrevision of local item
bool OpenAB_Sync::SyncMetadata::fromJSON ( const std::string &  json)

Load metadata from JSON format.

Parameters
jsonjson encoded metadata.
Returns
true if metadata was read correctly from JSON, false otherwise.
std::map< std::string, std::string > OpenAB_Sync::SyncMetadata::getItemsWithState ( SyncMetadataState  localState,
SyncMetadataState  remoteState 
)

Queries all metadata record which items are in given states.

Parameters
localStatestate of local item
remoteStatestate of remote item
Returns
map of remote items ids with associated to them local items ids.
std::string OpenAB_Sync::SyncMetadata::getLocalRevision ( const std::string &  uid) const

Returns revision of local item.

Parameters
uidid of local item.
Returns
revision of local item, or empty string if there is no metadata information about item with given id.
std::string OpenAB_Sync::SyncMetadata::getLocalSyncToken ( ) const

Returns sync token of local storage after last synchronization.

Returns
sync token or empty string if not available.
std::string OpenAB_Sync::SyncMetadata::getRemoteRevision ( const std::string &  uid) const

Returns revision of remote item.

Parameters
uidid of remote item.
Returns
revision of remote item, or empty string if there is no metadata information about item with given id.
std::string OpenAB_Sync::SyncMetadata::getRemoteSyncToken ( ) const

Returns sync token of remote storage after last synchronization.

Returns
sync token or empty string if not available.
bool OpenAB_Sync::SyncMetadata::hasLocalId ( const std::string &  uid) const

Checks if there is metadata information for local item with given id.

Parameters
uidid of local item.
Returns
true if there is metadata for given item, false otherwise.
bool OpenAB_Sync::SyncMetadata::hasRemoteId ( const std::string &  uid) const

Checks if there is metadata information for remote item with given id.

Parameters
uidif of remote item.
Returns
true if there is metadata for given item, false otherwise.
void OpenAB_Sync::SyncMetadata::removeItem ( const std::string &  remoteId,
const std::string &  localId 
)

Removes record from metadata. It will remove information about remote and local items binding.

Parameters
remoteIdid of remote item
localIdid of local item
void OpenAB_Sync::SyncMetadata::resetLocalState ( enum SyncMetadata::SyncMetadataState  state)

Resets state of all local items.

Parameters
[in]ststate to be set for all local items.
void OpenAB_Sync::SyncMetadata::resetRemoteState ( enum SyncMetadata::SyncMetadataState  state)

Resets state of all remote items.

Parameters
[in]ststate to be set for all remote items.
void OpenAB_Sync::SyncMetadata::setLocalState ( const std::string &  uid,
SyncMetadata::SyncMetadataState  state 
)

Sets state of remote item.

Parameters
uidid of remote item
statenew state of item
void OpenAB_Sync::SyncMetadata::setLocalSyncToken ( const std::string &  token)

Sets sync token of local storage to be stored in metadata.

Parameters
tokensync token to be set
void OpenAB_Sync::SyncMetadata::setRemoteState ( const std::string &  uid,
SyncMetadata::SyncMetadataState  state 
)

Sets state of remote item.

Parameters
uidid of remote item
statenew state of item
void OpenAB_Sync::SyncMetadata::setRemoteSyncToken ( const std::string &  token)

Sets sync token of remote storage to be stored in metadata.

Parameters
tokensync token to be set
std::string OpenAB_Sync::SyncMetadata::toJSON ( ) const

Converts metadata into JSON format, so it can be passed around as string.

Returns
JSON formatted metadata
void OpenAB_Sync::SyncMetadata::updateLocalRevision ( const std::string &  uid,
const std::string &  revision 
)

Updates revision of local item.

Parameters
uidid of local item
revisionnew revision of local item
void OpenAB_Sync::SyncMetadata::updateRemoteRevision ( const std::string &  uid,
const std::string &  revision 
)

Updates revision of remote item.

Parameters
uidid of remote item
revisionnew revision of remote item

The documentation for this class was generated from the following files: