DataElementGroup Class Reference

Provides for associations of DataElements. More...

#include <DataElementGroup.h>

Inheritance diagram for DataElementGroup:

Inheritance graph

List of all members.

Public Member Functions

virtual bool insertElement (DataElement *pElement)=0
virtual bool insertElements (const std::vector< DataElement * > &elements)=0
virtual bool hasElement (DataElement *pElement) const =0
virtual unsigned int getNumElements () const =0
virtual const std::vector
< DataElement * > & 
getElements () const =0
virtual bool removeElement (DataElement *pElement, bool bDelete=false)=0
virtual bool removeElements (const std::vector< DataElement * > &elements, bool bDelete=false)=0
virtual void clear (bool bDelete=false)=0
virtual bool enforceUniformity (bool enforce)=0
virtual bool isUniform () const =0

Static Public Member Functions

static const std::string & signalElementDeleted ()

Protected Member Functions

virtual ~DataElementGroup ()


Detailed Description

Provides for associations of DataElements.

A data element group stores a list of DataElements. It assumes ownership of the elements added to it, meaning that when the group is destroyed, all elements currently contained in the group will also be destroyed.

If a DataElement that has been added to the group is destroyed via ModelServices, the group will be notified and will remove the element from its internal tracking. This will trigger a notification of a change to the group.

This subclass of Subject will notify upon the following conditions:

See also:
DataElement

Definition at line 37 of file DataElementGroup.h.


Constructor & Destructor Documentation

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

This should be destroyed by calling ModelServices::destroyElement.

Definition at line 203 of file DataElementGroup.h.


Member Function Documentation

static const std::string& DataElementGroup::signalElementDeleted (  )  [static]

Emitted with any<DataElement*> when a member element is externally deleted.

Definition at line 43 of file DataElementGroup.h.

virtual bool DataElementGroup::insertElement ( DataElement pElement  )  [pure virtual]

Adds an element to the group.

It is possible to add the same element to the group multiple times. If uniformity is being enforced and the element is of a different type from the elements already in the group, the method will fail. The method will also fail if pElement is NULL.

Parameters:
pElement A pointer to the element to add to the group
Returns:
true if the element was added to the group, otherwise false.
Subject Notifications:
Subject::signalModified
See also:
enforceUniformity()

virtual bool DataElementGroup::insertElements ( const std::vector< DataElement * > &  elements  )  [pure virtual]

Add several elements to the group.

It is possible to add the same element to the group multiple times.

This method adds several elements to the group. If any of the elements to add are NULL, the method will fail, having done nothing. If uniformity is being enforced and any of the elements to add are of a different type from the elements in the group or each other, the method will fail, having done nothing.

Parameters:
elements A vector of elements to add to the group
Returns:
true if the elements were added, otherwise false.
Subject Notifications:
Subject::signalModified after the elements are done being added to the list. Only one notification will be done. No notification will be done if elements is empty.
See also:
enforceUniformity()

virtual bool DataElementGroup::hasElement ( DataElement pElement  )  const [pure virtual]

Checks to see if an element is in the group.

Parameters:
pElement The element to check for.
Returns:
true if the specified element is in the group, otherwise false.

virtual unsigned int DataElementGroup::getNumElements (  )  const [pure virtual]

Counts the elements in the group.

Returns:
the number of elements in the group.

virtual const std::vector<DataElement*>& DataElementGroup::getElements (  )  const [pure virtual]

Gets the list of elements in the group.

The elements are not guaranteed to be in any particular order.

Returns:
the list of elements in the group.

virtual bool DataElementGroup::removeElement ( DataElement pElement,
bool  bDelete = false 
) [pure virtual]

Removes an element from the group, optionally deleting it as well.

Parameters:
pElement A pointer to the element to remove from the group
bDelete Specifies if the element should be destroyed as well as being removed from the group. If the element is not found in the group it will not be deleted, regardless of the value of this parameter.
Returns:
true if the element was in the group, otherwise false.
Subject Notifications:
Subject::signalModified after the element is removed from the list.

virtual bool DataElementGroup::removeElements ( const std::vector< DataElement * > &  elements,
bool  bDelete = false 
) [pure virtual]

Removes several elements from the group.

This method removes several elements from the group, optionally deleting them in the process. If the list of elements to remove contains elements not in the group, those elements will be ignored.

Parameters:
elements A vector of elements to remove from the group
bDelete Specifies if the elements should be destroyed as well as being removed from the group. Elements not found in the group will not be deleted regardless of the value of this parameter.
Returns:
Returns true if the list of elements to remove was not empty and all of the specified elements were found in the group; otherwise returns false.
Subject Notifications:
Subject::signalModified after the elements are done being removed from the list. Only one notification will be done.

virtual void DataElementGroup::clear ( bool  bDelete = false  )  [pure virtual]

Removes all of the elements from the group.

This method removes all of the elements from the group, optionally deleting them in the process.

Parameters:
bDelete Specifies if the elements should be destroyed as well as being removed from the group.
Subject Notifications:
Subject::signalModified after the elements are done being removed from the group if the group was not empty. At most one notification will be done.

virtual bool DataElementGroup::enforceUniformity ( bool  enforce  )  [pure virtual]

Specifies whether all elements added to a group must be of the same type.

This method specifies whether all elements in a group must be of the same type. If the group already has elements of varying types in it when this method is called to turn on enforcement, it will fail to turn on enforcement. When uniformity is enforced, addElement and addElements will fail to add elements of types different from the type of the elements already in the group. The default for a new DataElementGroup is for enforcement of uniformity to be off.

Parameters:
enforce Specifies if enforcement is being turned on or off
Returns:
true if the enforcement setting was successfully set. It will always succeed in turning uniformity enforcement off. If enforcement is being turned on and there are already elements of varying types in the group, it will fail and return false.

virtual bool DataElementGroup::isUniform (  )  const [pure virtual]

Indicates if all of the elements in the group are of the same type.

Returns:
true if the group is empty or all elements in the group are of the same type, false otherwise.


Software Development Kit - Opticks 4.9.0 Build 16218