Ditto  1.0.19
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
ditto::Ditto Class Reference

The entrypoint to the Ditto SDK. More...

Public Member Functions

 Ditto (Identity identity=Identity::OfflinePlayground(), std::string persistence_dir="")
 Initializes a new Ditto instance. More...
 
 Ditto (Ditto const &other)=delete
 
 Ditto (Ditto &&other) noexcept
 
Dittooperator= (Ditto const &other)=delete
 
Dittooperator= (Ditto &&other) noexcept
 
Storeget_store ()
 Provides access to the SDK's store functionality. More...
 
void set_license_token (std::string license_token)
 Activate a Ditto instance by setting a license token. You cannot sync with Ditto before you have activated it. More...
 
void set_access_license (std::string license_str) DITTO_DEPRECATED
 Activate a Ditto instance by setting a license token. You cannot sync with Ditto before you have activated it. More...
 
void try_start_sync ()
 Starts the network transports. Ditto will connect to other devices and sync with them where appropriate. More...
 
void start_sync () DITTO_DEPRECATED
 Starts the network transports. Ditto will connect to other devices and sync with them where appropriate. More...
 
void stop_sync ()
 Stops all network transports. More...
 
void set_transport_config (TransportConfig config)
 Assign a new transports configuration. More...
 
void run_garbage_collection ()
 Removes all sync metadata for any remote peers which aren't currently connected. More...
 

Static Public Member Functions

static std::string get_sdk_version ()
 Returns a string identifying the version of the Ditto SDK. More...
 
static bool get_logging_enabled ()
 Gets whether or not logging is enabled for Ditto. More...
 
static void set_logging_enabled (bool enabled)
 Sets whether or not logging is enabled for Ditto. More...
 
static bool get_emoji_log_level_headings_enabled ()
 Gets whether or not emoji log level headings are enabled for Ditto. More...
 
static void set_emoji_log_level_headings_enabled (bool enabled)
 Sets whether or not emoji log level headings are enabled for Ditto. More...
 
static LogLevel get_minimum_log_level ()
 Gets the minimum log level at which logs will be emitted for Ditto. More...
 
static void set_minimum_log_level (LogLevel log_level)
 Sets the minimum log level at which logs should be emitted for Ditto. More...
 

Public Attributes

Store store
 
std::shared_ptr< Authenticatorauth
 Provides access to authentication information and methods for logging on to Ditto Cloud.
 

Detailed Description

The entrypoint to the Ditto SDK.

For a Ditto instance to continue to connect to other devices it must be kept in scope.

Constructor & Destructor Documentation

◆ Ditto()

ditto::Ditto::Ditto ( Identity  identity = Identity::OfflinePlayground(),
std::string  persistence_dir = "" 
)
explicit

Initializes a new Ditto instance.

Parameters
[in]identitythe identity of the entity that will be interacting with Ditto.
[in]directorythe directory that will be used to persist Ditto data.

Member Function Documentation

◆ get_emoji_log_level_headings_enabled()

bool ditto::Ditto::get_emoji_log_level_headings_enabled ( )
static

Gets whether or not emoji log level headings are enabled for Ditto.

Returns
a bool representing whether or not emoji log level headings are enabled for Ditto.

◆ get_logging_enabled()

bool ditto::Ditto::get_logging_enabled ( )
static

Gets whether or not logging is enabled for Ditto.

Returns
a bool representing whether or not logging is enabled for Ditto.

◆ get_minimum_log_level()

LogLevel ditto::Ditto::get_minimum_log_level ( )
static

Gets the minimum log level at which logs will be emitted for Ditto.

Returns
the minimum log level at which logs will be emitted for Ditto.

◆ get_sdk_version()

std::string ditto::Ditto::get_sdk_version ( )
static

Returns a string identifying the version of the Ditto SDK.

Returns
a string identifying the version of the Ditto SDK.

◆ get_store()

Store & ditto::Ditto::get_store ( )

Provides access to the SDK's store functionality.

Deprecated:
You can directly access the store property now.
Returns
a Store object.

◆ run_garbage_collection()

void ditto::Ditto::run_garbage_collection ( )

Removes all sync metadata for any remote peers which aren't currently connected.

This method shouldn't usually be called. Manually running garbage collection often will result in slower sync times. Ditto automatically runs a garbage a collection process in the background at optimal times.

Manually running garbage collection is typically only useful during testing if large amounts of data are being generated. Alternatively, if an entire data set is to be evicted and it's clear that maintaining this metadata isn't necessary, then garbage collection could be run after evicting the old data.

◆ set_access_license()

void ditto::Ditto::set_access_license ( std::string  license_str)

Activate a Ditto instance by setting a license token. You cannot sync with Ditto before you have activated it.

Deprecated:
Deprecated in favor of set_license_token.
Parameters
[in]license_strthe license token to activate the Ditto instance with, which you can find on the Ditto portal (https://portal.ditto.live).

◆ set_emoji_log_level_headings_enabled()

void ditto::Ditto::set_emoji_log_level_headings_enabled ( bool  enabled)
static

Sets whether or not emoji log level headings are enabled for Ditto.

Parameters
[in]enableda bool representing whether or not emoji log level headings are enabled for Ditto.

◆ set_license_token()

void ditto::Ditto::set_license_token ( std::string  license_token)

Activate a Ditto instance by setting a license token. You cannot sync with Ditto before you have activated it.

Parameters
[in]license_strthe license token to activate the Ditto instance with, which you can find on the Ditto portal (https://portal.ditto.live).

◆ set_logging_enabled()

void ditto::Ditto::set_logging_enabled ( bool  enabled)
static

Sets whether or not logging is enabled for Ditto.

Parameters
[in]enableda bool representing whether or not logging is enabled for Ditto.

◆ set_minimum_log_level()

void ditto::Ditto::set_minimum_log_level ( LogLevel  log_level)
static

Sets the minimum log level at which logs should be emitted for Ditto.

Parameters
[in]log_levelthe minimum log level at which logs should be emitted for Ditto.

◆ set_transport_config()

void ditto::Ditto::set_transport_config ( TransportConfig  config)

Assign a new transports configuration.

By default peer-to-peer transports (Bluetooth and WiFi, where available) are enabled.

You may use this method to alter the configuration at any time. Sync will not begin until try_start_sync is called.

◆ start_sync()

void ditto::Ditto::start_sync ( )

Starts the network transports. Ditto will connect to other devices and sync with them where appropriate.

Deprecated:
Deprecated in favor of try_start_sync.

By default Ditto will enable all peer-to-peer transport types. The network configuration can be customized using set_transport_config.

Exceptions
DittoErrorthrown if the Ditto instance hasn't been activated by a successful call to set_license_token.

◆ stop_sync()

void ditto::Ditto::stop_sync ( )

Stops all network transports.

You may continue to use the database locally but no data will sync to or from other devices.

◆ try_start_sync()

void ditto::Ditto::try_start_sync ( )

Starts the network transports. Ditto will connect to other devices and sync with them where appropriate.

By default Ditto will enable all peer-to-peer transport types. The network configuration can be customized using set_transport_config.

Exceptions
DittoErrorthrown if the Ditto instance hasn't been activated by a successful call to set_license_token.

Member Data Documentation

◆ store

Store ditto::Ditto::store

Provides access to the SDK's store functionality.

Returns
a Store object.