libAlgAudio  v1.99-440-g08538e5-dirty
The development library for AlgAudio framework.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AlgAudio::CanvasXML Class Reference

#include <CanvasXML.hpp>

Inheritance diagram for AlgAudio::CanvasXML:

Public Member Functions

LateReturn< std::shared_ptr
< Canvas > > 
ApplyToCanvas (std::shared_ptr< Canvas > c)
 
void CloneToAnotherXMLTree (rapidxml::xml_node<> *node, rapidxml::xml_document<> *doc)
 
LateReturn< std::shared_ptr
< Canvas > > 
CreateNewCanvas (std::shared_ptr< Canvas > parent)
 
std::string GetXMLAsString ()
 
void SaveToFile (std::string path)
 
 ~CanvasXML ()
 

Static Public Member Functions

static std::shared_ptr< CanvasXMLCreateFromCanvas (std::shared_ptr< Canvas > canvas)
 
static std::shared_ptr< CanvasXMLCreateFromFile (std::string path)
 
static std::shared_ptr< CanvasXMLCreateFromNode (rapidxml::xml_node<> *node)
 
static std::shared_ptr< CanvasXMLCreateFromString (std::string string)
 

Detailed Description

An instanceable class that exports canvas state to an XML document, and vice versa. A CanvasXML maintains an XML document, which can be loaded from a file or created according to canvas state, as well as saved to file or applied to a Canvas.

To open a file to a new Canvas, you would usually cretate a CanvasXML with CreateFromFile(), and then use CreateNewCanvas() member function.

To save a Canvas to file, you should create a CanvasXML with CreateFromCanvas, and then use SaveToFile() member function.

Constructor & Destructor Documentation

AlgAudio::CanvasXML::~CanvasXML ( )

Member Function Documentation

LateReturn<std::shared_ptr<Canvas> > AlgAudio::CanvasXML::ApplyToCanvas ( std::shared_ptr< Canvas c)

Applies the data in stored document to a given Canvas, creating new modules, setting params, adding connections etc. On success, latereturns the same canvas pointer. Never returns a nullptr. May latethrow Exceptions::XMLParse.

Warning
ApplyToCanvas() is strictly NOT late-reentrant! (it shall not be invoked again before the previous call latereturns).
void AlgAudio::CanvasXML::CloneToAnotherXMLTree ( rapidxml::xml_node<> *  node,
rapidxml::xml_document<> *  doc 
)
inline

Puts the stored XML document as a subtree of some other rapidxml document. All data is fully cloned, so it's safe to destruct this CanvasXML instance and continue using the parent xml document.

Parameters
nodeThe subtree node the stored document shall be placed at.
docThe xml_document the node is in.
static std::shared_ptr<CanvasXML> AlgAudio::CanvasXML::CreateFromCanvas ( std::shared_ptr< Canvas canvas)
static

Creates a new CanvasXML which has data corresponding to the given canvas' current state. Modifying the Canvas afterwards will not result in any changes in the CanvasXML.

static std::shared_ptr<CanvasXML> AlgAudio::CanvasXML::CreateFromFile ( std::string  path)
static

Opens the file at the given path, reads the contents, parses the XML document, and creates a new CanvasXML using that data.

Parameters
pathThe path to file to load.
static std::shared_ptr<CanvasXML> AlgAudio::CanvasXML::CreateFromNode ( rapidxml::xml_node<> *  node)
static

Uses the given rapidxml XML node to create a new CanvasXML. The node data will be fully cloned, so it's safe to delete the node afterwards.

static std::shared_ptr<CanvasXML> AlgAudio::CanvasXML::CreateFromString ( std::string  string)
static

Parses the given string as an XML document, and creates a new CanvasXML which uses that data.

LateReturn<std::shared_ptr<Canvas> > AlgAudio::CanvasXML::CreateNewCanvas ( std::shared_ptr< Canvas parent)

Creates a new canvas basing on the stored document. Never returns a nullptr. May latethrow Exceptions::XMLParse.

Warning
CreateNewCanvas() is strictly NOT late-reentrant! (it shall not be invoked again before the previous call latereturns)
std::string AlgAudio::CanvasXML::GetXMLAsString ( )

Returns the stored XML document as a string.

void AlgAudio::CanvasXML::SaveToFile ( std::string  path)

Stores the XML document in a file.

Parameters
pathThe path to file the XML document shall be saved to.

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