Main Page | Modules | Class Hierarchy | Class List | Directories | Class Members | Related Pages | Examples

MemoryAttribute< T > Class Template Reference

Attribute for remembering values of other Attributes or PacketAttributes. More...

#include <MemoryAttribute.h>

Inheritance diagram for MemoryAttribute< T >:

ArrayAttribute< T > Attribute FilteredPacketListener PacketListener PacketDrivenMemoryAttribute< T > SampledMemoryAttribute< T > List of all members.

Public Member Functions

 MemoryAttribute (const PacketFilter &filter, const std::string &ident, uint32_t aType, uint32_t memSize=0, bool scroll=true)
 create a new MemoryAttribute
 MemoryAttribute (const std::string &ident, uint32_t aType, uint32_t memSize=0, bool scroll=true)
 MemoryAttribute (const PacketFilter &filter, const std::string &ident, uint32_t aType, const Timeval &memSize, bool scroll=true)
 create a new MemoryAttribute that acts as a time-based window
 MemoryAttribute (const std::string &ident, uint32_t aType, const Timeval &memSize, bool scroll=true)
 MemoryAttribute (const MemoryAttribute< T > &toCopy)
virtual MemoryAttribute< T > * clone (void) const =0
virtual void handlePassedPacket (TraceIterator &packet)=0
 Notify the attribute of a new packet to be included in the computation.
virtual void update (void)=0
virtual T getInstanceValue (void) const throw ( UnknownAttributeException )
 get the current value of the attribute to remember
virtual T getInstanceValue (TraceIterator &packet) const throw ( UnknownAttributeException )
 get the current value of the attribute to remember
virtual const AttributegetAttrib (const std::string &ident) const throw ( UnknownAttributeException )
 get an attribute of the attribute
virtual T getSum (void) const throw ( InvalidDataTypeException )
 get the sum of the elements in the memory if they are of an appropriate data type
virtual T getMax (void) const throw ( InvalidDataTypeException )
 get the maximum element in the memory if they are of an appropriate data type
virtual T getMin (void) const throw ( InvalidDataTypeException )
 get the minimum element in the memory if they are of an appropriate data type
std::vector< T >::const_iterator begin (void) const
 get a const iterator pointing to the first (oldest) element of the window
std::vector< T >::const_iterator end (void) const
 get a const iterator pointing to the last (newest) element of the window
std::vector< T >::iterator begin (void)
 get an iterator pointing to the first (oldest) element of the window
std::vector< T >::iterator end (void)
 get an iterator pointing to the last (newest) element of the window
int getType (void)
virtual void linkToAggregate (Aggregate &parent)
 Notify the Attribute that it is being linked to a particular aggregate.
virtual void compute (void)
 Compute the value of the attribute.
virtual void reset (void) throw ( NotResettableException )
 Reset the value of the attribute.
virtual std::string toString (void) const
virtual void handlePacket (TraceIterator &newPkt)

Static Public Attributes

static const uint32_t ATTRIB_TYPE_AGGREGATE = 1
 types of attributes that can be remembered
static const uint32_t ATTRIB_TYPE_PACKET = 2
static const int TYPE_UNKNOWN = 0
static const int TYPE_SCALAR = 1
static const int TYPE_DISTRIB = 17
static const int TYPE_HISTOGRAM = 25
static const int TYPE_ARRAY = 33
static const int TYPE_SET = 34

Protected Member Functions

void append (const Timeval &time, T val)
 add a value to the end of the queue
void remove (uint32_t count=1)
 remove the n first/earliest values from the queue, defaults to removing the first one
void buildVector (void) const
 build or rebuild the vector copy of q
void prune (void)
 remove values from the queue based on max size or time window
uint32_t size (void) const
 return the number of values in the memory

Protected Attributes

Aggregateaggr

Friends

std::ostream & operator<< (std::ostream &os, const Attribute &attrib)

Detailed Description

template<class T>
class MemoryAttribute< T >

Attribute for remembering values of other Attributes or PacketAttributes.

MemoryAttribute has several functions:

Note:
Currently the memory size is limited either by count of items or by time window; it's not possible to limit the memory by both.

Iterators into a MemoryAttribute iterate over a copy of the queue that is created when begin() or end() are called, and may be invalidated if handlePassedPacket() or update() are called.

Examples:

profile_streams_thesis.cc.


Constructor & Destructor Documentation

template<class T>
MemoryAttribute< T >::MemoryAttribute const PacketFilter filter,
const std::string &  ident,
uint32_t  aType,
uint32_t  memSize = 0,
bool  scroll = true
 

create a new MemoryAttribute

Parameters:
filter optional, indicates that we want to filter the packets that this attribute considers
ident identifier indicating the attribute to be tracked
attribType type value indicating where to find the attribute, e.g. if it's a packet attribute; see description of uint32_t for full list
memSize maximum number of values to be remembered; 0 for infinite
scroll true if the values are to be updated after reaching the maximum; a value of false for this means that the first memSize values are remembered, true means that the most recent memSize values are to be remembered. This value is meaningless for an infinite memSize.

template<class T>
MemoryAttribute< T >::MemoryAttribute const PacketFilter filter,
const std::string &  ident,
uint32_t  aType,
const Timeval memSize,
bool  scroll = true
 

create a new MemoryAttribute that acts as a time-based window

Parameters:
filter - optional, indicates that we want to filter the packets that this attribute considers
memLength Timeval indicating how wide in seconds the window is
scroll true if the values are to be updated after reaching the maximum; a value of false for this means that the first memSize timewindow worth of values are remembered, true means that the most recent memSize timewindow worth of values are to be remembered.


Member Function Documentation

template<class T>
vector< T >::const_iterator MemoryAttribute< T >::begin void   )  const [virtual]
 

get a const iterator pointing to the first (oldest) element of the window

Note:
Should alias vector<T>::const_iterator to MemoryAttribute<T>::const_iterator for future flexibility
Todo:
should push all the iterator stuff up to ArrayAttribute, there's no need for it to be here.

Implements ArrayAttribute< T >.

template<class T>
void MemoryAttribute< T >::buildVector void   )  const [protected]
 

build or rebuild the vector copy of q

Note:
Yes, this changes a data member, but in order to use it in a const context, it needs to be const - therefore it uses const_cast to muck around with what it's not technically supposed to be mucking around with.

void Attribute::compute void   )  [virtual, inherited]
 

Compute the value of the attribute.

Used to update an offline attribute.

Reimplemented in ArithmeticAttribute< lType, rType, resType >, ByteCountAttribute, DurationAttribute, and SumAttribute< T >.

template<class T>
const Attribute & MemoryAttribute< T >::getAttrib const std::string &  ident  )  const throw ( UnknownAttributeException ) [virtual]
 

get an attribute of the attribute

Todo:
actually implement this, e.g. first and last - will need to template-ize StaticScalarAttribute, though

Reimplemented from Attribute.

template<class T>
T MemoryAttribute< T >::getInstanceValue TraceIterator packet  )  const throw ( UnknownAttributeException ) [virtual]
 

get the current value of the attribute to remember

Parameters:
packet current packet - needed for getting packet attributes

template<class T>
double MemoryAttribute< T >::getMax void   )  const throw ( InvalidDataTypeException ) [virtual]
 

get the maximum element in the memory if they are of an appropriate data type

Exceptions:
InvalidDataTypeException if the data type can't be compared

template<class T>
double MemoryAttribute< T >::getMin void   )  const throw ( InvalidDataTypeException ) [virtual]
 

get the minimum element in the memory if they are of an appropriate data type

Exceptions:
InvalidDataTypeException if the data type can't be compared

template<class T>
double MemoryAttribute< T >::getSum void   )  const throw ( InvalidDataTypeException ) [virtual]
 

get the sum of the elements in the memory if they are of an appropriate data type

Exceptions:
InvalidDataTypeException if the data type can't be summed
Todo:
this functionality should be implemented in ArrayAttribute. Will need to find a good way to do getAttrib hierarchically first, though, e.g. always call super::getAttrib() before throwing an UnknownAttributeException if you don't know the ident.

void FilteredPacketListener::handlePacket TraceIterator newPkt  )  [virtual, inherited]
 

checks the packet against the filter and calls handlePassedPacket if it passes or if the filter is NULL

Implements PacketListener.

template<class T>
virtual void MemoryAttribute< T >::handlePassedPacket TraceIterator packet  )  [pure virtual]
 

Notify the attribute of a new packet to be included in the computation.

For an online attribute, update the attribute. For an offline attribute, set the dirty bit. (default)

Reimplemented from Attribute.

Implemented in PacketDrivenMemoryAttribute< T >, and SampledMemoryAttribute< T >.

void Attribute::linkToAggregate Aggregate parent  )  [virtual, inherited]
 

Notify the Attribute that it is being linked to a particular aggregate.

Parameters:
parent New parent aggregate - will supplant any previous parent
Note:
If an Attribute subclass is only intended for use with a particular subtype of aggregate, override this method and add type checking. e.g.: Trace *trace = dynamic_cast<Trace*>(parent); if( NULL != trace ) {...} else throw InvalidAggregateException(...);

Reimplemented in ArithmeticAttribute< lType, rType, resType >, and SumAttribute< T >.

void Attribute::reset void   )  throw ( NotResettableException ) [virtual, inherited]
 

Reset the value of the attribute.

Exceptions:
NotResettableException if the Attribute cannot be properly reset, e.g. if it is a wrapper for a subattribute.

Reimplemented in SumAttribute< T >.


Member Data Documentation

template<class T>
const uint32_t MemoryAttribute< T >::ATTRIB_TYPE_AGGREGATE = 1 [static]
 

types of attributes that can be remembered

Specifically these indicate where the MemoryAttribute needs to look to find the identifier. identifier refers to an attribute attached to the aggregate

template<class T>
const uint32_t MemoryAttribute< T >::ATTRIB_TYPE_PACKET = 2 [static]
 

identifier refers to an attribute of the packets seen

const int Attribute::TYPE_ARRAY = 33 [static, inherited]
 

array

const int Attribute::TYPE_DISTRIB = 17 [static, inherited]
 

statistical distribution

const int Attribute::TYPE_HISTOGRAM = 25 [static, inherited]
 

histogram

const int Attribute::TYPE_SCALAR = 1 [static, inherited]
 

single-valued type

const int Attribute::TYPE_SET = 34 [static, inherited]
 

set

const int Attribute::TYPE_UNKNOWN = 0 [static, inherited]
 

unknown type


The documentation for this class was generated from the following files:
Generated on Thu Apr 5 01:02:38 2007 for ANTARES by  doxygen 1.4.2