#include <signaltyperef.h>
Collaboration diagram for Geddei::SignalTypeRef:
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 |
SignalTypeRef & | operator= (const SignalTypeRef &p) |
SignalTypeRef & | operator= (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 |
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>();
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).
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.
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.
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();
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();
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.
p | A SignalType instance, it will be left untouched. A copy will be made and adopted. |
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.
p | A SignalTypeRef instance, it will be left untouched. A copy will be made and adopted. |
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.
p | The type against which to be compared. |
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.
p | The type against which to be compared. |