Geddei::SignalType Class Reference
[Geddei's core classes.]

Base class for describing a signal that may be transferred in a Connection. More...

#include <signaltype.h>

Inheritance diagram for Geddei::SignalType:

Inheritance graph
[legend]
List of all members.

Public Member Functions

const uint elementsFromSamples (const uint samples) const
const uint elementsFromSeconds (const float seconds) const
const float frequency () const
const uint samples (const uint elements) const
const uint scope () const
const float seconds (const uint elements) const
void setFrequency (const float frequency)
void setScope (const uint scope)
virtual ~SignalType ()

Protected Member Functions

 SignalType (const uint scope=1, const float frequency=0)
Virtual methods for mandatory reimplementation.
These methods must be reimplemented in any new classes that are derived, no matter how distantly, from this class.

virtual SignalTypecopyBE () const =0
virtual void deserialise (QSocketSession &source)
virtual const uint id () const =0
virtual const bool sameAsBE (const SignalType *comp) const
virtual void serialise (QSocketSession &sink) const

Protected Attributes

float theFrequency
uint theScope

Friends

class Buffer
class DRCoupling
class LLConnection
class LMConnection
class LRConnection
class LxConnection
class LxConnectionNull
class MLConnection
class Processor
class RLConnection
class RSCoupling
class SignalTypeRef
class SignalTypeRefs
class Splitter
class SubProcessor

Detailed Description

Base class for describing a signal that may be transferred in a Connection.

Author:
Gav Wood <gav@cs.york.ac.uk>
Class encapsulating description of a signal. The base class includes attributes for all signals (i.e. scope and frequency). On derivation, several helper methods must be reimplemented: serialise(), deserialise(), id(), copy() and sameAs(). Other than that you are free to add whatever you feel neccesssary to the class to best describe (and help with decoding) the signal.

Usually a derived class adds little more than some extra attributes and the methods for extracting these attributes.

The final thing that all derived types must (currently) do is add a line in the static method create() for creation of the new class. This is quite self-explanatory.

As good practise for future expansion and derivation you should leave all useful data members in the protected area of the class. Helper methods should all be reimplemented in the private to avoid adding unnecessary bulk to the documentation.


Constructor & Destructor Documentation

Geddei::SignalType::SignalType ( const uint  scope = 1,
const float  frequency = 0 
) [protected]

Basic constructor.

Parameters:
scope The scope of the signal. That is, how many elements (single values) is takes to adequatly define a single reading, or sample. For a simple time-based offset single, this will be 1, but for more complex signals such as spectra, matrices or whatever, this will be more.
frequency The sampling frequency of the signal. That is, the inverse of the delay between each sample. e.g. CD audio has a sample frequency of 44100, i.e. each sample represents a reading in time of 1/44100th of a second later than the last.

virtual Geddei::SignalType::~SignalType (  )  [inline, virtual]

Virtual destructor.


Member Function Documentation

void Geddei::SignalType::serialise ( QSocketSession sink  )  const [protected, virtual]

Send this SignalType down the given QSocketSession, sink . This must be reimplemented along with its partner, deserialise() if any data members are added.

See QSocketSession for reference, but you'll generally just want to use the method QSocketSession::safeSendWord(). This method only works for int members natively, so you'll have to cast float members appropriately:

 sink.safeSendWord(theIntMember);
 sink.safeSendWord(theFloatMember);

Note:
You MUST call the parent class's serialise before anything else. Failure to do this will result in the parent's members going unsaved.
Parameters:
sink The QSocketSession object into which they will be saved.

void Geddei::SignalType::deserialise ( QSocketSession source  )  [protected, virtual]

Retrieve and repopulate this SignalType object from the given QSocketSession source . This must be symmetrical to serialise(). It must therefore be reimplemented when any data members are added to the inheritance heirarchy.

See QSocketSession for reference, but you'll generally only need to use QSocketSession::safeReceiveWord(). Like serialise() this only actually works for ints as standard so float will have to be casted by hand:

 theIntMember = source.safeReceiveWord<int>();
 theFloatMember = source.safeReceiveWord<float>();

Note:
You MUST call the parent class's deserialise() before anything else. Failure to do so will result in the parent's members going unsaved.
Parameters:
source The QSocketSession object from which this object will load.

virtual const uint Geddei::SignalType::id (  )  const [protected, pure virtual]

Retrieve the numeric identity of this class. This is to easily identify each derivative of SignalType. This must be unique to each class, thus it must ALWAYS be REIMPLEMENTED.

When subclassing SignalType (or one of its children), make sure you reimplement this method. return from this method a previously unused number.

Returns:
The unique identity of the new class.

virtual SignalType* Geddei::SignalType::copyBE (  )  const [protected, pure virtual]

Duplicate this SignalType object.

In this reimplementation you must simply create a new object of this class and populate it with this object's parameters. This method must therefore ALWAYS be REIMPLEMENTED in order for the virtual methods to work correctly.

Note this is a backend method to be reimplmented. The front-end, public- visible method is copy(). You should use that in any interface code.

Returns:
A duplicate of this object.

virtual const bool Geddei::SignalType::sameAsBE ( const SignalType comp  )  const [inline, protected, virtual]

Compare two SignalType objects for equivalency. This must be reimplemented if any new members are added to the class heirarchy.

The reimplementation will generally utilise the parent class's implementation as such:

 return Parent::sameAsBE(comp) &&
        theNewMember == dynamic_cast<ClassName *>(comp)->theNewMember;

Note this is a backend method to be reimplmented. The front-end, public- visible method is sameAs(). You should use that in any interface code.

Parameters:
comp The object to be compared to this.
Returns:
true iff they are equivalent.

const uint Geddei::SignalType::scope (  )  const [inline]

Returns:
The scope, or number of single value elements per sample of the data represented by this SignalType.

const float Geddei::SignalType::frequency (  )  const [inline]

Returns:
The frequency, or number of samples per Signal-time second of the data represented by this SignalType.

void Geddei::SignalType::setScope ( const uint  scope  )  [inline]

Sets the scope of this SignalType.

Parameters:
scope The new scope.

void Geddei::SignalType::setFrequency ( const float  frequency  )  [inline]

Sets the frequency of this SignalType.

Parameters:
frequency The new frequency.

const uint Geddei::SignalType::samples ( const uint  elements  )  const [inline]

Get the number of samples represented by the given number of elements.

Parameters:
elements The number of elements.
Returns:
The number of samples that elements constitute. This will be less than or equal to elements .

const float Geddei::SignalType::seconds ( const uint  elements  )  const [inline]

Get the number of seconds represented by the given number of elements.

Parameters:
elements The number of elements.
Returns:
The number of Signal-time seconds that elements constitute.

const uint Geddei::SignalType::elementsFromSamples ( const uint  samples  )  const [inline]

Get the number of elements a number of samples represents.

Parameters:
samples The number of samples.
Returns:
The number of elements represented by samples . This will be greater than or equal to samples .

const uint Geddei::SignalType::elementsFromSeconds ( const float  seconds  )  const [inline]

Get the number of elements a Signal-time length of seconds represents.

Parameters:
seconds The length of Signal-time.
Returns:
The number of elements.


Member Data Documentation

uint Geddei::SignalType::theScope [protected]

Number of individual observation elements that this datum contains.

float Geddei::SignalType::theFrequency [protected]

Reciprocal of the amount of time between this sample and the next.


The documentation for this class was generated from the following files:
Generated on Thu Jul 13 06:56:44 2006 for Exscalibar by  doxygen 1.4.7