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

A container for a SignalType-derived object. More...

#include <signaltyperef.h>

Collaboration diagram for Geddei::SignalTypeRef:

Collaboration graph
[legend]
List of all members.

Public Member Functions

template<class T>
T & asA ()
template<class T>
const T & asA () const
const float frequency () const
template<class T>
const bool isA () const
SignalTypeRefoperator= (const SignalTypeRef &p)
SignalTypeRefoperator= (const SignalType &p)
const bool operator== (const SignalTypeRef &p)
const bool operator== (const SignalType &p)
const uint scope () const
 SignalTypeRef (const SignalTypeRef &src)

Friends

class LMConnection
class LRConnection
class LxConnection
class LxConnectionNull
class MLConnection
class Processor
class SignalTypeRefs
class Splitter
class xLConnection
class xLConnectionReal

Detailed Description

A container for a SignalType-derived object.

Author:
Gav Wood <gav@cs.york.ac.uk>
This is a fairly unusual class; it is designed to be as simple to use as possible but the simplicity does somewhat make light of the ownership semantics. This object is used as (a reference to) a container for a SignalType -based object. The side effect of this is that you cannot create your own instances of this class; you use it to access the SignalType it contains only.

This class provides functionality to get at that object directly with the asA() methods. You can also query what type the held object is with the isA() method. It also provides some conveniece methods that just relay queries to the contained object, such as scope() and frequency().

Generally that's all you really need to know. Assigning another SignalType to this object does what you would expect---it just puts that type into us, the container. Likewise when assigning another SignalTypeRef to us. The following code is completely valid:

 aSignalTypeRef = Wave(44100.0);
 // ...
 aSignalTypeRef = anotherSignalTypeRef;
 // ...
 aSignalTypeRef = Value();

If you assign from a SignalTypeRef, then cunningly, the actual class is copied not just the SignalType class; so if the source SignalTypeRef is actually referencing Spectrum, then that is what this class will reference now.

If you need to make a copy of an object for private use, then use asA() to get the real instance of the object and make a copy of it that way:

 // WRONG:
 SignalTypeRef mySignalType = aSignalTypeRef;
 
 // Right:
 Spectrum mySignalType;
 mySignalType = aSignalTypeRef.asA<Spectrum>();


Member Function Documentation

template<class T>
const bool Geddei::SignalTypeRef::isA (  )  const [inline]

Check to see if the SignalType-based object we reference is actually an instance of some particular type (T).

Returns:
true iff we reference an object of type T.

template<class T>
const T& Geddei::SignalTypeRef::asA (  )  const [inline]

Return a const reference of class T that we represent. If we cannot represent such a class then this will cause Geddei to exit immediately. To prevent this from happening, always make sure isA() returns true first.

Returns:
A "real" const reference to our instance of T.

template<class T>
T& Geddei::SignalTypeRef::asA (  )  [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Return a reference of class T that we represent. If we cannot represent such a class then this will cause Geddei to exit immediately. To prevent this from happening, always make sure isA() returns true first.

Returns:
A "real" reference to our instance of T.

const uint Geddei::SignalTypeRef::scope (  )  const

Convenience function to go through the reference and retrieve the scope of the SignalType.

This is equivalent to:

 (*this).asA(SignalType).scope();

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

const float Geddei::SignalTypeRef::frequency (  )  const

Convenience function to go through the reference and retrieve the frequency of the SignalType.

This is equivalent to:

 (*this).asA(SignalType).frequency();

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

SignalTypeRef & Geddei::SignalTypeRef::operator= ( const SignalType p  ) 

Assignment operator. This will turn us into a copy of the SignalType given. We will automatically become the true class of p, not just a copy of whatever class it happens to be currently casted as.

Parameters:
p A SignalType instance, it will be left untouched. A copy will be made and adopted.
Returns:
A reference to this object.

SignalTypeRef & Geddei::SignalTypeRef::operator= ( const SignalTypeRef p  ) 

Assignment operator. This will turn us into a copy of the SignalTypeRef given. We will automatically become the true class of p, not just a copy of whatever class it happens to be currently casted as.

Parameters:
p A SignalTypeRef instance, it will be left untouched. A copy will be made and adopted.
Returns:
A reference to this object.

const bool Geddei::SignalTypeRef::operator== ( const SignalType p  ) 

Check to see if we are the same as some other SignalType. This not only checks that we are the same type but also checks that our parameters are the same.

Parameters:
p The type against which to be compared.
Returns:
true iff we are completely equivalent.

const bool Geddei::SignalTypeRef::operator== ( const SignalTypeRef p  ) 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Check to see if we are the same as some other SignalType. This not only checks that we are the same type but also checks that our parameters are the same.

Parameters:
p The type against which to be compared.
Returns:
true iff we are completely equivalent.


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