#include <vectorstore.h>
Public Member Functions | |
| VectorStore (bool use_e=true) | |
| Constructor. | |
| ~VectorStore () | |
| Destructor. | |
| void | use_exceptions (bool ue) |
| Set the use of exceptions. | |
| vv_ptr_t | id_get (gvid_t id) |
| id. | |
| vv_ptr_t | operator[] (gvid_t id) |
| id. | |
| gvid_t | add (const vv_ref_t v) |
| Add a VisualVector to the VectorStore. | |
| gvid_t | add (vv_ptr_t v, bool managed=true) |
| Add a VisualVector to the VectorStore. | |
| void | replace (gvid_t id, vv_ptr_t v, bool managed=true) |
| vector store id. | |
| void | replace (gvid_t id, vv_ref_t v) |
| vector store id. | |
| gvid_t | add_child (gvid_t id, const vv_ref_t v) |
| Add a child to the given vector store id. | |
| gvid_t | add_child (gvid_t id, vv_ptr_t v, bool managed=true) |
| Add a child to the given vector store id. | |
| void | remove (gvid_t id) |
| Remove the given id from store. | |
| void | clear () |
| Clear the store. | |
| vssize_t | size () const |
| Get the size of the store in terms of items stored. | |
| void | set_origin (const Coordinates &co) |
| Set the origin of the top level VisualVectors. | |
| void | set_scale (double sc) |
| Set the scale of the VisualVectors. | |
| void | set_arrow_length (double arl) |
| Set the arrow length of all VisualVectors. | |
| void | set_rotation (const Rotation &r) |
| Set the rotation of all VisualVectors. | |
| void | draw (Drawer &d) |
| Draw all VisualVectors. | |
| void | save (FileWriter &fw) const |
| Save all VisualVectors using the given FileWriter. | |
| void | sum_up (gvid_t id, GVector &vec) const |
| associated with the given id. | |
| void | dimension (Coordinates &min, Coordinates &max) const |
| plane. | |
Protected Member Functions | |
| vsi_ptr_t | get_item (gvid_t id) const |
| Retrieves a VStoreItem by its id. | |
Private Attributes | |
| std::map< gvid_t, vsi_ptr_t > | lookup |
| Map used for fast access to vector store items. | |
| std::list< vsi_ptr_t > | vector_items |
| List used to represent the item tree. | |
| std::list< gvid_t > | removed |
| Used to keep lookup map in sync. | |
| bool | useexceptions |
| Flag indicating whether or not exceptions should be used for indicating error conditions. | |
A VectorStore can be drawn and written to disk.
It allows to set a common origin, rotation, and scale to all items stored.
Children will take the head of the parent VisualVector as their tail.
| VectorStore::VectorStore | ( | bool | use_e = true |
) |
Constructor.
| use_e | Flag indicating whether or not exceptions should be used to indicate error conditions. Pass true to enable exceptions, false to disable exceptions (see also VectorStore::use_exceptions()). |
| VectorStore::~VectorStore | ( | ) |
Destructor. Removes the items from memory.
Retrieves the pointer to the VStoreItem associated with the given id.
| id | The id of the VStoreItem to be retrieved. |
| 0 | If the id could not be found, and use of exceptions has been disabled (see VectorStore::use_exceptions()). |
| GVEItemNotFound | if the id could not be found, and the use of exceptions has been enabled (see VectorStore::use_exceptions()). |
| void VectorStore::use_exceptions | ( | bool | ue | ) |
Enables or disables the use exceptions when error conditions occur. If enabled, exceptions are thrown upon error condition. If disabled, the return value of the method is used, where possible, to indicate error conditions.
| ue | Pass true to enable the use of exceptions. If false is passed, the use of exceptions is disabled. |
Retrieves the pointer to the VisualVector associated with the item matching the id provided.
| id | The id to look up. |
| 0 | if the id could not be found and the use of exceptions has been disabled. |
| GVEItemNotFound | if the id could not be found and the use of exceptions has been enabled. |
Adds the given VisualVector to the vector store. A copy of it is made, so there is no need to keep the original VisualVector.
| v | A const reference to the VisualVector to be added to the store. |
Adds the given VisualVector to the vector store. Depending on the value passed to managed, the VisualVector is either destroyed upon the destruction of the vector store, or the user is responsible for released the memory occupied by the visual vector.
| v | The pointer to the VisualVector to be added to the store. | |
| managed | If this is set to true, then the memory occupied by the VisualVector is released by VectorStore upon destruction, thus it is managed by VectorStore. If it is set to false, the user is responsible for releasing the memory occupied by the VisualVector. |
Replaces the VisualVector associated with the id id. If the VisualVector was previously added as managed, the memory is released, else the user is responsible for releasing the memory.
| id | The id of the VisualVector to be replaced by a new one. | |
| v | The pointer to the VisualVector replacing the current VisualVector associated with the id. | |
| managed | If this is set to true, then the memory occupied by the VisualVector is released by VectorStore upon destruction, thus it is managed by VectorStore. If it is set to false, the user is responsible for releasing the memory occupied by the VisualVector. |
Replaces the VisualVector associated with the id id. Memory management is taken care of by VectorStore.
| id | The id of the VisualVector to be replaced by a new one. | |
| v | A reference to the VisualVector replacing the current VisualVector. A copy of the VisualVector referenced is made, and the memory management is taken care of by VectorStore. |
Adds a child to the VisualVector associated with the id id. Children of a VisualVector have the head of the parent as their start point.
| id | The id of the parent VisualVector. | |
| v | A reference to the VisualVector to be added as child. A copy of the VisualVector referenced is made, and the memory management is taken care of by VectorStore. |
| GVID_NONE | if the given id of the parent could not be found, and the use of exceptions has been disabled. |
| GVEItemNotFound | if the given id of the parent could not be found, and the use of exceptions has been enabled. |
Adds a child to the VisualVector associated with the id id. Children of a VisualVector have the head of the parent as their start point.
| id | The id of the parent VisualVector. | |
| v | The pointer to the VisualVector to be added as child. | |
| managed | If this is set to true, then the memory occupied by the VisualVector is released by VectorStore upon destruction, thus it is managed by VectorStore. If it is set to false, the user is responsible for releasing the memory occupied by the VisualVector. |
| GVID_NONE | if the given id of the parent could not be found, and the use of exceptions has been disabled. |
| GVEItemNotFound | if the given id of the parent could not be found, and the use of exceptions has been enabled. |
| void VectorStore::remove | ( | gvid_t | id | ) |
Removes the VisualVector with the given id from the store. Depending on the method used to add it to the store, the memory occupied by the VisualVector will be released, e.g. if it was added as 'managed', else the user is responsible for freeing the memory occupied by the VisualVector. In any case, the VisualVector and its id are no longer known to the VectorStore.
If the use of exceptions has been disabled in VectorStore, there is no way of knowing whether or not the item has been successfully removed, e.g. the id has been found.
| id | The id to be removed from the VectorStore. |
| GVEItemNotFound | if the id provided is not associated with a VisualVector, and the use of exceptions has been enabled. |
| void VectorStore::clear | ( | ) |
Removes all VisualVectorS from the store and release the memory of those added as 'managed'.
| vssize_t VectorStore::size | ( | ) | const |
Returns the size of the VectorStore in terms of items stored.
As a side effect, it compares the number of item referenced in the lookup map with the count of items obtained by recursively traveling the tree. If those numbers do not match, and the use of exceptions is enabled, it throws an exception.
| GVEStoreCorrupt | if the number of items referenced in the lookup map do not match the number of items obtained by traveling the tree. This is only thrown, if the use of exceptions has been enabled. |
| void VectorStore::set_origin | ( | const Coordinates & | co | ) |
Sets the origin of the top level items. The origins of the children are calculated based on the head of the parents.
| co | A const reference to the two dimensional coordinate serving as origin for the top level VisualVectorS. |
| void VectorStore::set_scale | ( | double | sc | ) |
Sets the scale of all VisualVectorS.
| sc | The scale to set. |
| void VectorStore::set_arrow_length | ( | double | arl | ) |
Sets the length of the arrow to indicate the head of the VisualVectorS.
| arl | The length of the arrow. |
| void VectorStore::set_rotation | ( | const Rotation & | r | ) |
| void VectorStore::draw | ( | Drawer & | d | ) |
| void VectorStore::save | ( | FileWriter & | fw | ) | const |
Save the VectorStore using the FileWriter provided.
| fw | A reference to a FileWriter used to save to VectorStore. |
Sums up all VisualVectorS leading to and including the one specified by id.
| id | The id of the VisualVector. | |
| vec | The GVector referenced will receive the sum. |
| void VectorStore::dimension | ( | Coordinates & | min, | |
| Coordinates & | max | |||
| ) | const |
Gets the dimension of the 2D projection.
| min | A reference to the Coordinates receiving the minimum x and y values. | |
| max | A reference to the Coordinates receiving the maximum x and y values. |
std::map<gvid_t, vsi_ptr_t> GVectors::VectorStore::lookup [private] |
The map is used for fast access to vector store items. It keeps all pointers to vector store items.
Because it serves only for lookup purpose, it has to kept explicitely in sync with the actual vector store items stored.
std::list<vsi_ptr_t> GVectors::VectorStore::vector_items [private] |
This list holds the pointers to the top level items of the vector store. Each item can hold further pointers to items in turen, thus forming a tree.
std::list<gvid_t> GVectors::VectorStore::removed [private] |
Since the lookup map is not the primary data structure for storing pointers to items, it has to explicitely kept in sync with the tree, when items are removed.
Every method removing items is expected to keep track of the removed items by putting their pointers into this list.
bool GVectors::VectorStore::useexceptions [private] |
This flag determines whether or not exceptions are used when error conditions are encountered. Alternatively, when no exceptions are used, the return value of certain methods indicate an error condition.
1.4.7