Krotos Modules 3
Loading...
Searching...
No Matches
krotos::Serialiser Class Reference

#include <Serialiser.h>

Inheritance diagram for krotos::Serialiser:
krotos::JsonFile

Classes

struct  Action
 
struct  SerialiserTags
 

Public Member Functions

 Serialiser (File serialiserFile)
 
void addAction (std::unique_ptr< Action > action)
 Add an action object to the serialiser which will be executed. Create your own subclass of Action overriding execute() to create your action. Run the actions using executeActions().
 
void executeActions ()
 Execute the serialiser. This will parse actions from the serialiser file, executing all added actions that don't exist or are not marked as done. When completed, the file is updated with the action execution result and info.
 
bool isActionDone (String actionName)
 Returns true if the action has been executed.
 

Private Types

using PSTags = SerialiserTags
 

Private Member Functions

void createActionQueue ()
 
void writeActionData ()
 
- Private Member Functions inherited from krotos::JsonFile
 JsonFile (File jsonFile, const Identifier &defaultProperty, const String &defaultFormat)
 Simple helper class for handling json files. It will attempt to create a json file with the given default property and format, or if the given json file already exists, it will attempt to parse it and check it has the default property.
 
var getDefaultProperty () const
 Get the variant for the default property.
 
const String & getDefaultFormat () const
 Gets the underlying default formatted json, this is used as a fallback when an invalid input is passed to the JSON file.
 
void initialise ()
 Parse the file if it exists, or create it if it doesn't. Data is parsed to m_data;.
 
void save ()
 Call save internal.
 
void createJsonFromDefaultFormat ()
 Generate the JSON file using the default format - used in cases where JSON fails to load.
 

Private Attributes

std::vector< Action * > m_actionQueue
 
std::vector< Action * > m_executedActions
 
std::map< String, std::unique_ptr< Action > > m_actionMap
 
- Private Attributes inherited from krotos::JsonFile
var m_data
 The parsed json data.
 
File m_jsonFile
 The json file.
 

Static Private Attributes

static const String DEFAULT_FORMAT
 

Member Typedef Documentation

◆ PSTags

Constructor & Destructor Documentation

◆ Serialiser()

krotos::Serialiser::Serialiser ( File serialiserFile)

Member Function Documentation

◆ addAction()

void krotos::Serialiser::addAction ( std::unique_ptr< Action > action)

Add an action object to the serialiser which will be executed. Create your own subclass of Action overriding execute() to create your action. Run the actions using executeActions().

◆ createActionQueue()

void krotos::Serialiser::createActionQueue ( )
private

◆ executeActions()

void krotos::Serialiser::executeActions ( )

Execute the serialiser. This will parse actions from the serialiser file, executing all added actions that don't exist or are not marked as done. When completed, the file is updated with the action execution result and info.

◆ isActionDone()

bool krotos::Serialiser::isActionDone ( String actionName)

Returns true if the action has been executed.

Parameters
actionNameThe name of the action to lookup.

◆ writeActionData()

void krotos::Serialiser::writeActionData ( )
private

Member Data Documentation

◆ DEFAULT_FORMAT

const String krotos::Serialiser::DEFAULT_FORMAT
staticprivate
Initial value:
{"{"
"\"serialiser_version\": \"1\","
"\"actions\" : []}"}

◆ m_actionMap

std::map<String, std::unique_ptr<Action> > krotos::Serialiser::m_actionMap
private

◆ m_actionQueue

std::vector<Action*> krotos::Serialiser::m_actionQueue
private

◆ m_executedActions

std::vector<Action*> krotos::Serialiser::m_executedActions
private

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