#include <signaltype.h>
Inheritance diagram for Geddei::SignalType:
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 SignalType * | copyBE () 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 |
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.
Geddei::SignalType::SignalType | ( | const uint | scope = 1 , |
|
const float | frequency = 0 | |||
) | [protected] |
Basic constructor.
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.
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);
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>();
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.
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.
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.
comp | The object to be compared to this. |
const uint Geddei::SignalType::scope | ( | ) | const [inline] |
const float Geddei::SignalType::frequency | ( | ) | const [inline] |
void Geddei::SignalType::setScope | ( | const uint | scope | ) | [inline] |
void Geddei::SignalType::setFrequency | ( | const float | frequency | ) | [inline] |
const uint Geddei::SignalType::samples | ( | const uint | elements | ) | const [inline] |
Get the number of samples represented by the given number of elements.
elements | The number of elements. |
const float Geddei::SignalType::seconds | ( | const uint | elements | ) | const [inline] |
Get the number of seconds represented by the given number of elements.
elements | The number of elements. |
const uint Geddei::SignalType::elementsFromSamples | ( | const uint | samples | ) | const [inline] |
Get the number of elements a number of samples represents.
samples | The number of samples. |
const uint Geddei::SignalType::elementsFromSeconds | ( | const float | seconds | ) | const [inline] |
Get the number of elements a Signal-time length of seconds represents.
seconds | The length of Signal-time. |
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.