Creating the Client
std::pair<ReturnCode, std::shared_ptr<Client>>
SmartCapture::Client::make_client(const std::string & triggers_json_path,
const std::string & device_settings_json_path);This is the default factory method to create a Smart Capture client object from a string path of a JSON file that encodes the Smart Capture Query Language (SCQL) triggers and other user-specified configuration options (e.g. sample rate).
This method instantiates the Smart Capture Client object and runs reload_triggers for the first time. If there are any errors, it returns an error code as and a null pointer as the returning pair. Otherwise, returns a success code and a shared pointer to the client .
Returns
std::pair<ReturnCode, std::shared_ptr<Client>>: SmartCapture::ReturnCode return code, and shared pointer to the created client object
Parameters
string triggers_JSON_path: local string path for the location of triggers to load
string device_settings_JSON_path: local string path for device settings to load
- 101: PathNotFound
- 102: UnreadableFile
- 201: MalformedJSON
- 202: InvalidSCQLSyntax
- 203: UnsupportedSCQLVersion
std::pair<ReturnCode, std::shared_ptr<Client>>
SmartCapture::Client::make_client_serial(const char * serialized_triggers,
const char * serialized_device_settings)This is a secondary factory method to create a Smart Capture client object from a serialized string JSON that encodes the Smart Capture Query Language (SCQL) triggers and other user-specified configuration options (e.g. sample rate).
This method essentially instantiates the Smart Capture Client object and runs reload_triggers for the first time. If there are any errors, it returns an error code as and a null pointer as the returning pair. Otherwise, returns a shared pointer to the created client object.
Returns
std::pair<ReturnCode, std::shared_ptr<Client>>: SmartCapture::ReturnCode error code, and shared pointer to the created client object
Parameters
char_ serialized_triggers: serialized string for the trigger json
char_ serialized_device_settings: serialized string for device settings
- 201: MalformedJSON
- 202: InvalidSCQLSyntax
- 203: UnsupportedSCQLVersion
std::pair<ErrorCode, int>
SmartCapture::Client::reload(const char* serialized_triggers,
const char* serialized_device_settings) noexcept;Sample trigger.json
Sample device_settings.json
This method reloads the triggers and the device configuration from the respective, serialized JSONs. Running this method also instantiates empty internal state for each field referenced in each applicable trigger.
NoteField names used inside of these trigger definitions all have a certain type (e.g. int, float, image) – if a user then calls
update_statewith a different type but same name as a field in a trigger, a non-zero ReturnCode will be returned.
If any triggers fail to load, the entire method exits without reloading any of the updated triggers. Previously reloaded triggers will remain intact. This method, along with all other logging from the SDK, will be written to a managed log file. The on-device update service is expected to access these logs and transmit them off-device and ultimately to the Smart Capture Web Server.
Returns
std::pair<ReturnCode, int>: SmartCapture::ReturnCode return code, and int number of triggers that were successfully loaded if the load was successful
Parameters
char* serialized_triggers: serialized string for the trigger json
char8 serialized_device_settings: serialized string for device settings
- 101: PathNotFound
- 102: UnreadableFile
- 201: MalformedJSON
- 202: InvalidSCQLSyntax
- 203: UnsupportedSCQLVersion
std::vector<shared_ptr<Trigger>> SmartCapture::Client::get_triggers() const noexcept;
This method returns a list of class pointers of all triggers that have been loaded on the client
Returns
vector<shared_ptr<Trigger>>: vector of triggers
Updated 10 months ago