00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _GEDDEI_BUFFERINFO_H
00011 #define _GEDDEI_BUFFERINFO_H
00012
00013 #include <iostream>
00014
00015 #ifdef __GEDDEI_BUILD
00016 #include "qcounter.h"
00017 #else
00018 #include <qtextra/qcounter.h>
00019 #endif
00020
00021 namespace Geddei
00022 {
00023
00024 class Auxilliary;
00025 class BufferData;
00026
00032 class BufferInfo
00033 {
00034 friend std::ostream &operator<<(std::ostream &out, const BufferData &me);
00035
00036 public:
00037 enum Access { Read, Write };
00038 enum Payload { Managed, Foreign };
00039 enum Legacy { Ignore = 0, Forget, Activate };
00040
00041 private:
00042
00043 QCounter theCounter;
00044
00045
00046 bool theResident;
00047
00048 void retire(BufferData &client);
00049 void destruct(BufferData &client);
00050
00051 public:
00052
00053 uint theMask, theAccessibleSize, theScope;
00054 mutable Auxilliary *theAux;
00055 bool theValid;
00056 Access theType;
00057 Payload theLife;
00058 Legacy theEndType;
00059
00060
00061 float *theData;
00062 bool thePlunger;
00063
00064 public:
00065
00080 const bool isLive() const
00081 {
00082 bool ret = (theLife == Foreign);
00083 #ifdef EDEBUG
00084 if(ret) assert(theValid);
00085 #endif
00086 return ret;
00087 }
00088
00103 const bool isActive() const
00104 {
00105 bool ret = (theLife == Foreign && theCounter > 0);
00106 #ifdef EDEBUG
00107 if(ret) assert(theValid);
00108 #endif
00109 return ret;
00110 }
00111
00112 const bool isReferenced() const { return theCounter > 0; }
00113 void reference();
00114 void unreference(BufferData &client);
00115
00122 void ignore() { theEndType = Ignore; }
00123
00133 void invalidateAndIgnore()
00134 {
00135 #ifdef EDEBUG
00136 assert(theLife == Foreign);
00137 #endif
00138 theEndType = Ignore;
00139 theValid = false;
00140 }
00141
00150 void jettison();
00151
00152 BufferInfo(float *data, Auxilliary *aux, const uint mask, const Payload life, const Access type):
00153 theCounter(0), theResident(true), theMask(mask), theAux(aux), theType(type), theLife(life), theData(data) {}
00154 BufferInfo(const uint accessibleSize, const uint scope, float *data, Auxilliary *aux, const Legacy endType,
00155 const uint mask, const bool valid, const Access type, const Payload life, const bool plunger):
00156 theCounter(1), theResident(false), theMask(mask), theAccessibleSize(accessibleSize), theScope(scope), theAux(aux),
00157 theValid(valid), theType(type), theLife(life), theEndType(endType), theData(data), thePlunger(plunger) {}
00158 };
00159
00160 }
00161
00162 #endif