NAP
Public Member Functions | Protected Attributes | List of all members
Clipboard Class Reference

#include <sequenceeditorguiclipboard.h>

Public Member Functions

 Clipboard (const rttr::type &trackType)
 
virtual ~Clipboard ()=default
 
void addObject (const rtti::Object *object, const std::string &sequenceName, utility::ErrorState &errorState)
 
void addObject (const rtti::Object *object, utility::ErrorState &errorState)
 
template<typename T >
std::vector< T * > deserialize (std::vector< std::unique_ptr< rtti::Object >> &createdObjects, utility::ErrorState &errorState)
 
template<typename T >
bool isClipboard ()
 
template<typename T >
T * getDerived ()
 
std::vector< std::string > getObjectIDs () const
 
bool containsObject (const std::string &objectID, const std::string &sequenceName) const
 
void removeObject (const std::string &objectID)
 
int getObjectCount () const
 
rttr::type getTrackType () const
 
bool save (const std::string &filePath, utility::ErrorState &errorState)
 
bool load (const std::string &filePath, utility::ErrorState &errorState)
 

Protected Attributes

std::map< std::string, std::string > mSerializedObjects
 
rttr::type mTrackType
 
std::string mSequenceName
 

Description

Clipboard is a class that can contain a serialized object related to the Sequencer The state of the gui can contain a clipboard, that can be de-serialized at a certain point Typically, the clipboard contains a certain curve segment or event segment, and that segment can be pasted at a certain location in a certain Track

Inheritance diagram for Clipboard:
[legend]

Constructor & Destructor Documentation

◆ Clipboard()

Clipboard ( const rttr::type &  trackType)
explicit

Constructor

Parameters
trackTypeexpects tracktype

◆ ~Clipboard()

virtual ~Clipboard ( )
virtualdefault

Default decontructor

Member Function Documentation

◆ addObject() [1/2]

void addObject ( const rtti::Object object,
const std::string &  sequenceName,
utility::ErrorState errorState 
)

Serialize an object

Parameters
objectpointer object to serialize
sequenceNamesequence name currently used, if sequence name is different from previous, clears previously added objects
errorStateholds information about any errors

◆ addObject() [2/2]

void addObject ( const rtti::Object object,
utility::ErrorState errorState 
)

Serialize an object

Parameters
objectpointer object to serialize
errorStateholds information about any errors

◆ containsObject()

bool containsObject ( const std::string &  objectID,
const std::string &  sequenceName 
) const

returns true when clipboard holds serialized object of specified id

Parameters
objectIDthe object id of serialized object
sequenceNamename of the sequence
Returns
true if clipboard contains serialized object

◆ deserialize()

std::vector< T * > deserialize ( std::vector< std::unique_ptr< rtti::Object >> &  createdObjects,
utility::ErrorState errorState 
)

Deserialize clipboard content to object of type T

Template Parameters
Tthe object type to deserialze
Parameters
createdObjectsvector containing created objects
errorStateholds information about any errors
Returns
pointer to root object, can be null and must be of type T

◆ getDerived()

T* getDerived ( )

returns raw pointer to derived class T of this clipboard performs static cast, exception on fail, always use isClipboard<T> to check for type

Template Parameters
Tthe derived type
Returns
pointer to T

◆ getObjectCount()

int getObjectCount ( ) const

returns amount of stored serialized objects

Returns
amount of stored serialized objects

◆ getObjectIDs()

std::vector<std::string> getObjectIDs ( ) const

returns object ids of serialized objects

Returns
vector of object ids

◆ getTrackType()

rttr::type getTrackType ( ) const

returns rtti track type info that was passed to clipboard upon construction

Returns
rtti track type info

◆ isClipboard()

bool isClipboard ( )

returns true when clipboard is clipboard of derived type T

Template Parameters
Tthe derived type
Returns
true when T is of derived type

◆ load()

bool load ( const std::string &  filePath,
utility::ErrorState errorState 
)

Loads serialized segments to clipboard, return true on success, errorState contains any errors

Parameters
filePathpath of file to load relative to application data folder
errorStatecontains any errors that may occur during this operation
Returns
true on success

◆ removeObject()

void removeObject ( const std::string &  objectID)

removes specified object from clipboard when it is contained, no assert when not present

Parameters
objectIDthe object id of the object to remove

◆ save()

bool save ( const std::string &  filePath,
utility::ErrorState errorState 
)

Writes current serialized segments to disk, return true on success, errorState contains any errors FilePath is relative to application data folder

Parameters
filePathpath of file to write relative to application data folder
errorStatecontains any errors that may occur during this operation
Returns
true on success

Member Data Documentation

◆ mSequenceName

std::string mSequenceName
protected

◆ mSerializedObjects

std::map<std::string, std::string> mSerializedObjects
protected

◆ mTrackType

rttr::type mTrackType
protected