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

SampledMemoryAttribute< T > Class Template Reference

MemoryAttribute for remembering values of other attributes of the parent aggregate. More...

#include <MemoryAttribute.h>

Inheritance diagram for SampledMemoryAttribute< T >:

MemoryAttribute< T > AlarmListener ArrayAttribute< T > Attribute FilteredPacketListener PacketListener List of all members.

Public Member Functions

 SampledMemoryAttribute (const std::string &ident, uint32_t aType, uint32_t memSize, const Timeval &delta, bool scroll=true)
 create a SampledMemoryAttribute
 SampledMemoryAttribute (const PacketFilter &filter, const std::string &ident, uint32_t aType, uint32_t memSize, const Timeval &delta, bool scroll=true)
 create a filtered SampledMemoryAttribute
 SampledMemoryAttribute (const std::string &ident, uint32_t aType, const Timeval &window, const Timeval &delta, bool scroll=true)
 create a SampledMemoryAttribute that functions as a time window
 SampledMemoryAttribute (const PacketFilter &filter, const std::string &ident, uint32_t aType, const Timeval &window, const Timeval &delta, bool scroll=true)
 create a filtered SampledMemoryAttribute that functions as a time window
 SampledMemoryAttribute (const SampledMemoryAttribute< T > &toCopy)
SampledMemoryAttribute< T > * clone (void) const
virtual void handlePassedPacket (TraceIterator &packet)
 Notify the attribute of a new packet to be included in the computation.
virtual void handleAlarm (void)
virtual void update (void)
 update the attribute to the given time
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 >::iterator begin (void)
 get an 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 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 SampledMemoryAttribute< T >

MemoryAttribute for remembering values of other attributes of the parent aggregate.

This mainly just wraps an implementation for getInstanceValue; MemoryAttribute itself does most of the work. This one does include support for 'autonomous' updating - i.e. updating driven by a clock rather than by a packet arrival.

Examples:

profile_streams_thesis.cc.


Member Function Documentation

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

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, inherited]
 

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, inherited]
 

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, inherited]
 

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, inherited]
 

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, inherited]
 

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, inherited]
 

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>
void SampledMemoryAttribute< T >::handlePassedPacket TraceIterator packet  )  [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)

Implements MemoryAttribute< 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 >.

template<class T>
void SampledMemoryAttribute< T >::update void   )  [virtual]
 

update the attribute to the given time

Note:
idempotent - if it's called n times with the same value for tick, the state is the same as if it'd just been called once with that tick value.

Implements MemoryAttribute< T >.


Member Data Documentation

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

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, inherited]
 

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