libcrn
3.9.5
A document image processing library
|
complex base abstract class More...
#include <CRNSavable.h>
Public Member Functions | |
Savable (const String &s=U"") | |
Default constructor. More... | |
virtual | ~Savable () |
Destructor. More... | |
Savable (const Savable &)=delete | |
No copy construction allowed. More... | |
Savable & | operator= (const Savable &)=delete |
No assignment allowed. More... | |
Savable (Savable &&) noexcept | |
Savable & | operator= (Savable &&c) |
const String & | GetName () const |
Returns the name of the object. More... | |
void | SetName (const String &s) |
Sets the name of the object. More... | |
void | SetName (String &&s) noexcept |
Sets the name of the object. More... | |
void | SetUserData (const String &key, SObject value) |
Adds or replaces a user data. More... | |
bool | IsUserData (const String &key) const |
Tests if a user data key exists. More... | |
SObject | GetUserData (const String &key) |
Gets a user data by key. More... | |
String | GetUserDataKey (const SObject &value) const |
Gets a user data key by value. More... | |
const SObject | GetUserData (const String &key) const |
Gets a user data by key. More... | |
void | DeleteUserData (const String &key) |
Deletes a user data entry and frees the value. More... | |
void | ClearUserData () |
Deletes all user data entries. More... | |
Savable (const String &s, const Path &fname) | |
Constructor from file name. More... | |
void | Load (const Path &fname) |
Loads the object from an XML file (Safe) More... | |
void | Save (const Path &fname) |
Saves the object to an XML file (Safe) More... | |
void | Save () |
Saves the object to an already set XML file. More... | |
const Path & | GetFilename () const noexcept |
Returns the file name of the object. More... | |
void | deserialize_internal_data (xml::Element &el) |
Initializes some internal data from an XML element. More... | |
void | serialize_internal_data (xml::Element &el) const |
Dumps some internal data to an XML element. More... | |
![]() | |
virtual | ~Object ()=default |
Protected Member Functions | |
void | setFilename (const Path &fname) |
Overwrites the filename. More... | |
void | setFilename (Path &&fname) noexcept |
Overwrites the filename. More... | |
Protected Attributes | |
std::unique_ptr< std::mutex > | filelock |
complex base abstract class
A more complex base abstract class.
This class offers several informal protocols. If an informal protocal's method is called without having been implemented, an exception will be thrown. The overloadable methods are the following (in parenthesis, the flag to activate in CRNProtocols.h):
Definition at line 58 of file CRNSavable.h.
Savable::Savable | ( | const String & | s = U"" | ) |
Default constructor.
Default constructor
[in] | s | the name of the object |
Definition at line 36 of file CRNSavable.cpp.
|
virtual |
|
delete |
No copy construction allowed.
|
defaultnoexcept |
Constructor from file name.
Constructor from file name. Does not load the file!
[in] | s | the name of the object |
[in] | fname | the file name |
Definition at line 170 of file CRNSavable.cpp.
void Savable::ClearUserData | ( | ) |
Deletes all user data entries.
Deletes all user data entries
Definition at line 155 of file CRNSavable.cpp.
void Savable::DeleteUserData | ( | const String & | key | ) |
Deletes a user data entry and frees the value.
Deletes a user data entry and frees the value
ExceptionNotFound | key not found |
[in] | key | The data key |
Definition at line 132 of file CRNSavable.cpp.
void Savable::deserialize_internal_data | ( | xml::Element & | el | ) |
Initializes some internal data from an XML element.
Internal. Initializes some internal data from an XML element.
[in] | el | the element that contains the serialized object |
Definition at line 282 of file CRNSavable.cpp.
|
inlinenoexcept |
Returns the file name of the object.
Definition at line 116 of file CRNSavable.h.
|
inline |
Returns the name of the object.
Definition at line 78 of file CRNSavable.h.
SObject Savable::GetUserData | ( | const String & | key | ) |
Gets a user data by key.
Gets a user data by key
[in] | key | The data key |
Definition at line 78 of file CRNSavable.cpp.
const SObject Savable::GetUserData | ( | const String & | key | ) | const |
Gets a user data by key.
Gets a user data by key
[in] | key | The data key |
Definition at line 114 of file CRNSavable.cpp.
String Savable::GetUserDataKey | ( | const SObject & | value | ) | const |
Gets a user data key by value.
Gets a user data key by value
[in] | value | The value to search |
Definition at line 95 of file CRNSavable.cpp.
bool Savable::IsUserData | ( | const String & | key | ) | const |
Tests if a user data key exists.
Tests if a user data key exists
[in] | key | The data key |
Definition at line 61 of file CRNSavable.cpp.
void Savable::Load | ( | const Path & | fname | ) |
Loads the object from an XML file (Safe)
Loads the object from an XML file. Safe.
ExceptionIO | cannot read file |
ExceptionUninitialized | empty file |
ExceptionNotFound | invalid file |
ExceptionProtocol | load unimplemented |
[in] | fname | the file name |
Definition at line 188 of file CRNSavable.cpp.
void Savable::Save | ( | const Path & | fname | ) |
Saves the object to an XML file (Safe)
Saves the object to an XML file. Safe.
ExceptionIO | cannot write file |
ExceptionProtocol | save unimplemented |
[in] | fname | the file name |
Definition at line 208 of file CRNSavable.cpp.
void Savable::Save | ( | ) |
Saves the object to an already set XML file.
Saves the object to an already set XML file.
ExceptionUninitialized | no filename |
ExceptionIO | cannot write file |
ExceptionProtocol | save unimplemented |
Definition at line 227 of file CRNSavable.cpp.
void Savable::serialize_internal_data | ( | xml::Element & | el | ) | const |
Dumps some internal data to an XML element.
Internal. Dumps some internal data to an XML element.
[in] | el | the element that contains the serialized object |
Definition at line 316 of file CRNSavable.cpp.
|
inlineprotected |
Overwrites the filename.
Definition at line 119 of file CRNSavable.h.
|
inlineprotectednoexcept |
Overwrites the filename.
Definition at line 121 of file CRNSavable.h.
|
inline |
Sets the name of the object.
Definition at line 80 of file CRNSavable.h.
|
inlinenoexcept |
Sets the name of the object.
Definition at line 82 of file CRNSavable.h.
void Savable::SetUserData | ( | const String & | key, |
SObject | value | ||
) |
Adds or replaces a user data.
Adds an object to the user data
[in] | key | the (unique) key of the data |
[in] | value | the data to add |
Definition at line 145 of file CRNSavable.cpp.
|
protected |
Protection to avoid multiple access to the file at the same time
Definition at line 122 of file CRNSavable.h.