signaltyperefs.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_SIGNALTYPEPTRS_H
00011 #define _GEDDEI_SIGNALTYPEPTRS_H
00012 
00013 #include <cassert>
00014 #include <iostream>
00015 using namespace std;
00016 
00017 #include <qptrlist.h>
00018 
00019 #ifdef __GEDDEI_BUILD
00020 #include "signaltyperef.h"
00021 #else
00022 #include <geddei/signaltyperef.h>
00023 #endif
00024 using namespace Geddei;
00025 
00026 namespace Geddei
00027 {
00028 
00029 class SignalType;
00030 
00047 class SignalTypeRefs
00048 {
00049  friend class Processor;
00050  friend class DRCoupling;
00051  friend class RSCoupling;
00052  friend class SubProcessor;
00053  friend class xSCoupling;
00054  friend class DomProcessor;
00055  friend class Combination;
00056 
00057  uint theCount;
00058  const SignalType **theData;
00059  const bool theImplicitCopying;
00060 
00069  void copyInto(QPtrList<SignalType> &dest);
00070 
00077  explicit SignalTypeRefs(QPtrList<SignalType> &src);
00078 
00085  SignalTypeRefs(const SignalTypeRefs &src);
00086 
00096  explicit SignalTypeRefs(const uint count = 0, const bool implicitCopying = true);
00097 
00098  const bool populated(const uint i) const
00099  {
00100   return theData[i];
00101  }
00102  
00128  void setData(const uint i, const SignalType *d);
00129 
00153  void copyData(const uint i, const SignalType *d);
00154 
00162  const SignalType *ptrAt(const uint i) const
00163  {
00164 #ifdef EDEBUG
00165   if(i >= theCount)
00166   { qDebug("Asked for %d th element when count=%d", i, theCount);
00167    return (((SignalType **)theData)[0]);
00168   }
00169 #endif
00170   return theData[i];
00171  }
00172 
00200  SignalType *&mutablePtrAt(const uint i)
00201  {
00202 #ifdef EDEBUG
00203   if(i >= theCount)
00204   { qDebug("Asked for %d th element when count=%d", i, theCount);
00205    return (((SignalType **)theData)[0]);
00206   }
00207   if(theData[i])
00208    qWarning("*** WARNING: You're probably attempting to write over an existing SignalType *.\n"
00209             "             Doing so will likely cause a memory leak. Delete this entry first.");
00210 #endif
00211   return (((SignalType **)theData)[i]);
00212  }
00213 
00220  void resize(const uint count);
00221 
00240  void setFill(const SignalType *d, const bool replaceExisting = true);
00241  
00242 public:
00243  const SignalTypeRef operator[](const uint i) const { return SignalTypeRef((SignalType *&)(theData[i])); }
00244  SignalTypeRef operator[](const uint i) { return SignalTypeRef((SignalType *&)(theData[i])); }
00245 
00251  const uint count() const { return theCount; }
00252 
00261  const bool allSame() const;
00262 
00275  SignalTypeRefs &operator=(const SignalTypeRefs &src);
00276 
00283  SignalTypeRefs &operator=(const SignalTypeRef &src);
00284 
00291  SignalTypeRefs &operator=(const SignalType &src);
00292 
00296  ~SignalTypeRefs();
00297 };
00298 
00299 }
00300 
00301 #endif

Generated on Thu Jul 13 06:56:33 2006 for Exscalibar by  doxygen 1.4.7