GVectors::VStoreItem Class Reference

Class used to store a VisualVector in a VectorStore. More...

#include <vstoreitem.h>

List of all members.

Protected Member Functions

void set_origin_on_children ()
 Set the origin of the children.
 VStoreItem (vv_ptr_t v, std::list< gvid_t > &dr, VStoreItem *p, bool m=true)
 Constructor.
virtual ~VStoreItem ()
 Destructor.
gvid_t get_id () const
 Retrieve the id associated with the item.
vv_ptr_t get_vector () const
 Get the pointer to the VisualVector associated with the item.
void replace (vv_ptr_t v, bool m=true)
 Replace the VisualVector of the item.
void replace (vv_ref_t v)
 Replace the VisualVector of the item.
void set_origin (const Coordinates &c)
 Set the origin of the VisualVector.
void set_scale (double sc)
 Set the scale of the VisualVector.
void set_arrow_length (double arl)
 Set the arrow length of the VisualVector.
void set_rotation (const Rotation &r)
 Set the rotation of the VisualVector.
void draw (Drawer &d)
 Draw the VisualVector.
VStoreItemadd_child (vv_ptr_t v, bool m=true)
 Add a child to this item.
VStoreItemget_parent () const
 Get the parent of this item.
void child_gone (const VStoreItem *child)
 (this) of the disapearance of the child.
void count_items (CountItems &ci) const
 Count the items.
void save_items (vslevel_t level, FileWriter &fw) const
 Save the items.
void sum_up (GVector &vec) const
 Sum up vectors from this up to the top most.
void dimension (GetMinMax &gmm) const
 Find out the minimum and maximum x and y value.

Private Attributes

VStoreItemparent
 Pointer to its parent.
gvid_t id
 The id associated with this item.
bool ismanaged
 Flag indicating whether or not the memory occupied by the VisualVector is managed.
vv_ptr_t vector
 The VisualVector associated with the item.
std::list< VStoreItem * > children
 List of children.
std::list< gvid_t > & ref_deleted
 Reference to the list holding the deleted items.

Friends

class VectorStore
class FindTopLevel
class VDelete
class VSetOrigin
class VSetArrowLength
class VSetScale
class VSetRotation
class VDraw
class ForEachMinMax
class CountItems
class SaveItems


Detailed Description

This class is used to store a VisualVector in a VectorStore. It has no public members since it is not intended to come into touch with the user of a vector store.


Constructor & Destructor Documentation

VStoreItem::VStoreItem ( vv_ptr_t  v,
std::list< gvid_t > &  dr,
VStoreItem p,
bool  m = true 
) [protected]

Constructor.

Parameters:
v A pointer to a VisualVector which gets associated with this item.
dr A reference to a list where deletions are recorded in order to keep the lookup map of VectorStore in sync.
p The pointer to the parent of this items or zero, if it does not have a parent.
m Indicates whether or not the VisualVector is managed by the item (true) or the user (false).

VStoreItem::~VStoreItem (  )  [protected, virtual]

Destructor. Releases the memory occupied by the VisualVector if it has been added in managed mode. Notify the VectorStore about the disappearance of this->id and delete the children.


Member Function Documentation

void VStoreItem::set_origin_on_children (  )  [protected]

Sets the origin on the children using the 2D plane head of the vector associated with this item as the origin for the children.

gvid_t VStoreItem::get_id (  )  const [protected]

Get the id associated with this VStoreItem.

Returns:
The id associated with the VStoreItem.

vv_ptr_t VStoreItem::get_vector (  )  const [protected]

Returns the pointer to the VisualVector associated with this VStoreItem.

Returns:
A pointer to a VisualVector.

void VStoreItem::replace ( vv_ptr_t  v,
bool  m = true 
) [protected]

Replace the VisualVector associated with this VStoreItem. If the former VisualVector has been added in managed mode, then the memory occupied is released.

Parameters:
v A pointer to the VisualVector replacing the old one.
m Indicates whether or not the new VisualVector is added in managed mode (true) and thus is freed by the destructor of this item, or in non-managed mode (false) and the user is reponsible of freeing the memory occupied by the VisualVector.

void VStoreItem::replace ( vv_ref_t  v  )  [protected]

Replace the VisualVector associated with this VStoreItem. If the former VisualVector has been added in managed mode, then the memory occupied is released.

This method adds a copy of the referenced VisualVector in managed mode to this item.

Parameters:
v A reference to the VisualVector replacing the existing one. A copy of the referenced VisualVector is added in managed mode to this item.

void VStoreItem::set_origin ( const Coordinates c  )  [protected]

Sets the given orign on the VisualVector associated and on all children.

Parameters:
c A const reference to the origin Coordinates.

void VStoreItem::set_scale ( double  sc  )  [protected]

Sets the given scale on the VisualVector associated and on all children.

Parameters:
sc Scale value.

void VStoreItem::set_arrow_length ( double  arl  )  [protected]

Sets the length of the arrow on the VisualVector associated and on all children.

Parameters:
arl Length of the arrow.

void VStoreItem::set_rotation ( const Rotation r  )  [protected]

Sets the rotation of the VisualVector associated and on all children.

Parameters:
r A const reference to a Rotation object.

void VStoreItem::draw ( Drawer d  )  [protected]

Draws the VisualVector and all children.

Parameters:
d A reference to the Drawer used to draw the vectors.

vsi_ptr_t VStoreItem::add_child ( vv_ptr_t  v,
bool  m = true 
) [protected]

Adds a child to this VStoreItem.

To get the child's id, use the pointer returned and call get_id().

Parameters:
v A pointer to the VisualVector to be associated with the child.
m Indicates whether or not the VisualVector is added in managed mode (true) and thus is freed by the destructor of the child, or in non-managed mode (false) and the user is reponsible of freeing the memory occupied by the VisualVector.
Returns:
A pointer to the newly created VStoreItem serving as child.

VStoreItem* GVectors::VStoreItem::get_parent (  )  const [inline, protected]

Gets the parent of this item.

Returns:
The address of the parent.
Return values:
0 If this item has no parent.

void VStoreItem::child_gone ( const VStoreItem child  )  [protected]

The child of this calls this method to notify its parent (this) that it has gone. This is necessary to keep the list of children up to date.

Parameters:
child The address of the child which has to be removed from the children list.

void VStoreItem::count_items ( CountItems ci  )  const [protected]

Count child items.

Parameters:
ci A reference to a CountItems object.

void VStoreItem::save_items ( vslevel_t  level,
FileWriter fw 
) const [protected]

Saves the VisualVector associated and saves the child items.

Parameters:
level The level of this item (the level is provided and managed by the SaveItems class)
fw A reference to the FileWriter used to store the items.

void VStoreItem::sum_up ( GVector vec  )  const [protected]

Sums up the vectors leading to and including this vector.

Parameters:
vec A reference to a GVector receiving the sum.

void VStoreItem::dimension ( GetMinMax gmm  )  const [protected]

Gets the dimension of this item and the children.

Parameters:
gmm A reference to a GetMinMax object.


Member Data Documentation

VStoreItem* GVectors::VStoreItem::parent [private]

Pointer to its parent. It has to be zero if there is not parent, e.g. this item is a top level item.

gvid_t GVectors::VStoreItem::id [private]

The id associated with this item.

bool GVectors::VStoreItem::ismanaged [private]

If this flag is set to true, the item does release the memory occupied by the VisualVector upon its destruction. If set to false, the memory is not released upon destruction of the item.

vv_ptr_t GVectors::VStoreItem::vector [private]

Pointer to a VisualVector associated with the item.

std::list<VStoreItem*> GVectors::VStoreItem::children [private]

The list of the children this item has.

std::list<gvid_t>& GVectors::VStoreItem::ref_deleted [private]

This is a reference to the 'global' list holding the addresses of the delete items.


The documentation for this class was generated from the following files:
Generated on Sat Sep 8 19:37:31 2007 for libgvectors by  doxygen 1.4.7