signaltyperef.h

00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Gav Wood                                        *
00003  *   gav@cs.york.ac.uk                                                     *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Library General Public License as       *
00007  *   published by the Free Software Foundation; either version 2 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  ***************************************************************************/
00010 #ifndef GEDDEI_SIGNALTYPEREF_H
00011 #define GEDDEI_SIGNALTYPEREF_H
00012 
00013 #ifdef EDEBUG
00014 #include <typeinfo>
00015 #endif
00016 
00017 #include <qstring.h>
00018 
00019 namespace Geddei
00020 {
00021 
00022 class SignalType;
00023 
00070 class SignalTypeRef
00071 {
00072  SignalType *&thePtr;
00073 
00074  friend class SignalTypeRefs;
00075  friend class xLConnectionReal;
00076  friend class LxConnectionNull;
00077  friend class xLConnection;
00078  friend class LxConnection;
00079  friend class LMConnection;
00080  friend class MLConnection;
00081  friend class LRConnection;
00082  friend class Splitter;
00083  friend class Processor;
00084 
00090  SignalTypeRef(SignalType *&ptr) : thePtr(ptr) {}
00091  
00092 public:
00099  template<class T>
00100  const bool isA() const { return dynamic_cast<const T *>(thePtr); }
00101  
00110  template<class T>
00111  const T &asA() const
00112  {
00113 #ifdef EDEBUG
00114   if(!isA<T>())
00115    qFatal("*** FATAL: Attempting to attain a SignalType %s from an object of type %s.\n"
00116           "           Bailing.", typeid(T).name(), typeid(*thePtr).name());
00117 #endif
00118   return *(dynamic_cast<const T *>(thePtr));
00119  }
00120  
00129  template<class T>
00130  T &asA()
00131  {
00132 #ifdef EDEBUG
00133   if(!isA<T>())
00134    qFatal("*** FATAL: Attempting to attain a SignalType %s from an object of type %s.\n"
00135           "           Bailing.", typeid(T).name(), typeid(*thePtr).name());
00136 #endif
00137   return *(dynamic_cast<T *>(thePtr));
00138  }
00139  
00153  const uint scope() const;
00154 
00168  const float frequency() const;
00169  
00179  SignalTypeRef &operator=(const SignalType &p);
00180 
00190  SignalTypeRef &operator=(const SignalTypeRef &p);
00191  
00200  const bool operator==(const SignalType &p);
00201  
00210  const bool operator==(const SignalTypeRef &p);
00211  
00220  SignalTypeRef(const SignalTypeRef &src) : thePtr(src.thePtr) {} 
00221 };
00222 
00223 }
00224 
00225 #endif

Generated on Fri Nov 10 21:58:26 2006 for Exscalibar by  doxygen 1.5.1