ISIS Core Library 0.7.2 (api 3.0.0)
|
This class forms a mapping tree to store all kinds of properties (path : value), where:
#include <propmap.hpp>
Data Structures | |
struct | invalidP |
true when entry is a leaf, needed and empty | |
struct | listP |
true when entry is not a scalar | |
class | NeededsList |
struct | PropPath |
"Path" type used to locate entries in the tree More... | |
struct | treeInvalidP |
true when entry is a leaf, needed and empty of entry is a invalid branch | |
struct | trueP |
allways true | |
struct | walkTree |
Public Types | |
typedef std::map< KeyType, std::pair< PropertyValue, PropertyValue >, key_compare > | DiffMap |
a flat map matching keys to pairs of values | |
typedef std::map< KeyType, PropertyValue > | FlatMap |
a flat map, matching complete paths as keys to the corresponding values | |
typedef std::set< KeyType, key_compare > | KeyList |
a list to store keys only (without the corresponding values) | |
typedef key_type | KeyType |
type of the keys forming a path | |
Public Member Functions | |
PropertyMap & | branch (const PropPath &path) |
Access the branch referenced by the path, create it if its not there. | |
const PropertyMap & | branch (const PropPath &path) const |
Access the branch referenced by the path. | |
KeyType | find (KeyType key, bool allowProperty=true, bool allowBranch=false) const |
Search for a property/branch in the whole Tree. | |
KeyList | findLists () const |
find all non scalar entries | |
DiffMap | getDifference (const PropertyMap &second) const |
Get a difference map of this tree and another. | |
FlatMap | getFlatMap () const |
const KeyList | getKeys () const |
Get a list of the paths of all properties. | |
const KeyList | getMissing () const |
Get a list of missing properties. | |
template<typename T > | |
T | getPropertyAs (const PropPath &path) const |
Request a property via the given key in the given type. | |
bool | hasBranch (const PropPath &path) const |
check if branch of the tree is available | |
bool | hasProperty (const PropPath &path) const |
check if a property is available | |
bool | isEmpty () const |
bool | isValid () const |
Check if every property marked as needed is set. | |
PropertyMap::KeyList | join (const PropertyMap &other, bool overwrite=false) |
Add Properties from another tree. | |
bool | operator== (const PropertyMap &src) const |
std::ostream & | print (std::ostream &out, bool label=false) const |
"Print" the property tree. | |
PropertyMap () | |
PropertyMap (const Container &src) | |
const PropertyValue & | propertyValue (const PropPath &path) const |
Access the property referenced by the path. | |
PropertyValue & | propertyValue (const PropPath &path) |
Access the property referenced by the path, create it if its not there. | |
bool | remove (const PropertyMap &removeMap, bool keep_needed=false) |
remove every property which is also in the given tree (regardless of the value) | |
bool | remove (const PropPath &path) |
Remove the property adressed by the path. | |
bool | remove (const KeyList &removeList, bool keep_needed=false) |
remove every property which is also in the given list (regardless of the value) | |
bool | rename (const PropPath &from, const PropPath &to) |
Rename a given property/branch. | |
template<typename T > | |
PropertyValue & | setPropertyAs (const PropPath &path, const T &val) |
Set the given property to a given value/type. | |
bool | transform (const PropPath &from, const PropPath &to, int dstID, bool delSource=true) |
Transform an existing property into another. | |
template<typename DST > | |
bool | transform (const PropPath &from, const PropPath &to, bool delSource=true) |
Transform an existing property into another (statically typed version). | |
Protected Member Functions | |
void | addNeeded (const PropPath &path) |
Adds a property with status needed. | |
template<class Predicate > | |
const KeyList | genKeyList () const |
create a list of keys for every entry for which the given scalar predicate is true. | |
void | makeFlatMap (FlatMap &out, KeyType key_prefix="") const |
copy the tree into a flat key/property-map | |
std::vector< PropertyValue > & | propertyValueVec (const PropPath &path) |
Access the property vector referenced by the path-key, create it if its not there. | |
const std::vector < PropertyValue > & | propertyValueVec (const PropPath &path) const |
Access the property vector referenced by the path. | |
void | removeEqual (const PropertyMap &other, bool removeNeeded=false) |
Remove every PropertyValue which is also in the other PropertyMap and where operator== returns true. | |
void | toCommonUnique (PropertyMap &common, std::set< KeyType > &uniques, bool init) const |
Get common and unique properties from the tree. |
This class forms a mapping tree to store all kinds of properties (path : value), where:
Nevertheless there are separate access functions for branches and properties. Trying to access a branch as a property value,or to access a property value as a branch will cause error messages and give empty results.
Paths can be created from other paths and from strings (c-strings and util::istring, but not std::string). So both can be used for functions which expect paths, but the usage of c-strings is slower.
To describe the minimum of needed metadata needed by specific data structures / subclasses properties can be marked as "needed" and there are functions to verify that they are not empty.
Definition at line 52 of file propmap.hpp.
typedef std::map<KeyType, std::pair<PropertyValue, PropertyValue>, key_compare> isis::util::PropertyMap::DiffMap |
a flat map matching keys to pairs of values
Definition at line 60 of file propmap.hpp.
typedef std::map<KeyType, PropertyValue> isis::util::PropertyMap::FlatMap |
a flat map, matching complete paths as keys to the corresponding values
Definition at line 62 of file propmap.hpp.
typedef std::set<KeyType, key_compare> isis::util::PropertyMap::KeyList |
a list to store keys only (without the corresponding values)
Definition at line 58 of file propmap.hpp.
typedef key_type isis::util::PropertyMap::KeyType |
type of the keys forming a path
Definition at line 56 of file propmap.hpp.
API_EXCLUDE_BEGIN _internal API_EXCLUDE_END isis::util::PropertyMap::PropertyMap | ( | const Container & | src | ) |
Definition at line 58 of file propmap.cpp.
isis::util::PropertyMap::PropertyMap | ( | ) |
Definition at line 66 of file propmap.cpp.
void isis::util::PropertyMap::addNeeded | ( | const PropPath & | path | ) | [protected] |
Adds a property with status needed.
path | identifies the property to be added or if already existsing to be flagged as needed |
Definition at line 492 of file propmap.cpp.
PropertyMap & isis::util::PropertyMap::branch | ( | const PropPath & | path | ) |
Access the branch referenced by the path, create it if its not there.
path | the path to the branch |
Definition at line 209 of file propmap.cpp.
const PropertyMap & isis::util::PropertyMap::branch | ( | const PropPath & | path | ) | const |
Access the branch referenced by the path.
If the branch does not exist, an empty dummy will returned.
path | the path to the branch |
Definition at line 196 of file propmap.cpp.
PropertyMap::KeyType isis::util::PropertyMap::find | ( | PropertyMap::KeyType | key, |
bool | allowProperty = true , |
||
bool | allowBranch = false |
||
) | const |
Search for a property/branch in the whole Tree.
key | the single key for the branch/property to search for (paths will be stripped to the rightmost key) |
allowProperty | if false the search will ignore properties |
allowBranch | if false the search will ignore branches (it will still search into the branches, but the branches themself won't be considered a valid finding) |
Definition at line 504 of file propmap.cpp.
PropertyMap::KeyList isis::util::PropertyMap::findLists | ( | ) | const |
find all non scalar entries
Definition at line 476 of file propmap.cpp.
const KeyList isis::util::PropertyMap::genKeyList | ( | ) | const [inline, protected] |
create a list of keys for every entry for which the given scalar predicate is true.
Definition at line 130 of file propmap.hpp.
PropertyMap::DiffMap isis::util::PropertyMap::getDifference | ( | const PropertyMap & | second | ) | const |
Get a difference map of this tree and another.
Out of the names of differing properties a mapping from paths to std::pair<PropertyValue,PropertyValue> is created with following rules:
second | the other tree to compare with |
Definition at line 280 of file propmap.cpp.
PropertyMap::FlatMap isis::util::PropertyMap::getFlatMap | ( | ) | const |
Definition at line 433 of file propmap.cpp.
const PropertyMap::KeyList isis::util::PropertyMap::getKeys | ( | ) | const |
Get a list of the paths of all properties.
Definition at line 469 of file propmap.cpp.
const PropertyMap::KeyList isis::util::PropertyMap::getMissing | ( | ) | const |
Get a list of missing properties.
Definition at line 484 of file propmap.cpp.
T isis::util::PropertyMap::getPropertyAs | ( | const PropPath & | path | ) | const |
Request a property via the given key in the given type.
If the requested type is not equal to type the property is stored with, an automatic conversion is done. If that conversion failes an error is send to Runtime.
getPropertyAs<fvector4>( "MyPropertyName" );
path | the path to the property |
Definition at line 514 of file propmap.hpp.
bool isis::util::PropertyMap::hasBranch | ( | const PropPath & | path | ) | const |
check if branch of the tree is available
path | the path to the branch |
Definition at line 538 of file propmap.cpp.
bool isis::util::PropertyMap::hasProperty | ( | const PropPath & | path | ) | const |
check if a property is available
path | the path to the property |
Definition at line 498 of file propmap.cpp.
bool isis::util::PropertyMap::isEmpty | ( | ) | const |
Reimplemented in isis::data::Image.
Definition at line 275 of file propmap.cpp.
bool isis::util::PropertyMap::isValid | ( | ) | const |
Check if every property marked as needed is set.
Definition at line 268 of file propmap.cpp.
PropertyMap::KeyList isis::util::PropertyMap::join | ( | const PropertyMap & | other, |
bool | overwrite = false |
||
) |
Add Properties from another tree.
other | the other tree to join with |
overwrite | if existing properties shall be replaced |
Definition at line 383 of file propmap.cpp.
void isis::util::PropertyMap::makeFlatMap | ( | FlatMap & | out, |
KeyType | key_prefix = "" |
||
) | const [protected] |
copy the tree into a flat key/property-map
Definition at line 420 of file propmap.cpp.
bool isis::util::PropertyMap::operator== | ( | const PropertyMap & | src | ) | const |
Definition at line 60 of file propmap.cpp.
std::ostream & isis::util::PropertyMap::print | ( | std::ostream & | out, |
bool | label = false |
||
) | const |
"Print" the property tree.
Will send the name and the result of PropertyValue->toString(label) to the given ostream. Is equivalent to common streaming operation but has the option to print the type of the printed properties.
out | the output stream to use |
label | print the type of the property (see Value::toString()) |
Definition at line 577 of file propmap.cpp.
const PropertyValue & isis::util::PropertyMap::propertyValue | ( | const PropPath & | path | ) | const |
Access the property referenced by the path.
If the property does not exist, an empty dummy will returned.
path | the path to the property |
Definition at line 184 of file propmap.cpp.
PropertyValue & isis::util::PropertyMap::propertyValue | ( | const PropPath & | path | ) |
Access the property referenced by the path, create it if its not there.
path | the path to the property |
Definition at line 189 of file propmap.cpp.
const std::vector< PropertyValue > & isis::util::PropertyMap::propertyValueVec | ( | const PropPath & | path | ) | const [protected] |
Access the property vector referenced by the path.
If the property does not exist, an empty dummy will be returned.
path | the path to the property |
Definition at line 163 of file propmap.cpp.
std::vector< PropertyValue > & isis::util::PropertyMap::propertyValueVec | ( | const PropPath & | path | ) | [protected] |
Access the property vector referenced by the path-key, create it if its not there.
path | the path to the property |
Definition at line 176 of file propmap.cpp.
bool isis::util::PropertyMap::remove | ( | const PropPath & | path | ) |
Remove the property adressed by the path.
This actually only removes properties. Non-empty branches are not deleted. And if an branch becomes empty after deletion of its last entry, it is deleted automatically.
path | the path to the property |
Definition at line 215 of file propmap.cpp.
bool isis::util::PropertyMap::remove | ( | const KeyList & | removeList, |
bool | keep_needed = false |
||
) |
remove every property which is also in the given list (regardless of the value)
removeList | a list of paths naming the properties to be removed |
keep_needed | when true needed properties are kept even if they would be removed otherwise |
Definition at line 220 of file propmap.cpp.
bool isis::util::PropertyMap::remove | ( | const PropertyMap & | removeMap, |
bool | keep_needed = false |
||
) |
remove every property which is also in the given tree (regardless of the value)
removeMap | the tree of properties to be removed |
keep_needed | when true needed properties are kept even if they would be removed otherwise |
Definition at line 234 of file propmap.cpp.
void isis::util::PropertyMap::removeEqual | ( | const PropertyMap & | other, |
bool | removeNeeded = false |
||
) | [protected] |
Remove every PropertyValue which is also in the other PropertyMap and where operator== returns true.
other | the other property tree to compare to |
removeNeeded | if a property should also be deleted it is needed |
Definition at line 344 of file propmap.cpp.
Rename a given property/branch.
This is implemented as copy+delete and can also be used between branches.
from | the path of the existing property to be moved |
to | the destinaton path of the move |
Definition at line 544 of file propmap.cpp.
PropertyValue& isis::util::PropertyMap::setPropertyAs | ( | const PropPath & | path, |
const T & | val | ||
) | [inline] |
Set the given property to a given value/type.
The needed flag (if set) will be kept. If the property is already set to a value of another type an error is send to Runtime and nothing will be set. But a property of the same type will be overwritten.
setPropertyAs("MyPropertyName", isis::util::fvector4(1,0,1,0))
path | the path to the property |
val | the value to set of type T |
Definition at line 364 of file propmap.hpp.
void isis::util::PropertyMap::toCommonUnique | ( | PropertyMap & | common, |
std::set< KeyType > & | uniques, | ||
bool | init | ||
) | const [protected] |
Get common and unique properties from the tree.
For every entry of the tree this checks if it is common/unique and removes/adds it accordingly. This is done by:
common | reference of the common-tree |
uniques | reference of the unique-tree |
init | if initialisation shall be done instead of normal seperation |
Definition at line 561 of file propmap.cpp.
bool isis::util::PropertyMap::transform | ( | const PropPath & | from, |
const PropPath & | to, | ||
int | dstID, | ||
bool | delSource = true |
||
) |
Transform an existing property into another.
Converts the value of the given property into the requested type and stores it with the given new path.
from | the path of the property to be transformed |
to | the path for the new property |
dstID | the type-ID of the new property value |
delSource | if the original property shall be deleted after the tramsformation was done |
Definition at line 441 of file propmap.cpp.
bool isis::util::PropertyMap::transform | ( | const PropPath & | from, |
const PropPath & | to, | ||
bool | delSource = true |
||
) | [inline] |
Transform an existing property into another (statically typed version).
Converts the value of the given property into the requested type and stores it with the given new path. A compile-time check is done to test if the requested type is available.
from | the path of the property to be transformed |
to | the path for the new property |
delSource | if the original property shall be deleted after the tramsformation was done |
Definition at line 342 of file propmap.hpp.