00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef FSF_CHAR_BUFFER_H
00030 #define FSF_CHAR_BUFFER_H
00031
00032 #include "FsfNode.h"
00033 #include "FsfTypeCellBase.h"
00034
00035 namespace fsf{
00036
00039 class CCharBuffer : public CNode {
00040 private:
00041 CMutex m_csData;
00042 long m_nSize;
00043 char *m_pData;
00044
00045
00046 protected:
00049
00050
00051 void deleteData() { delete [] m_pData; m_pData=NULL; }
00053
00054 public:
00055
00057
00058
00059 CCharBuffer()
00060 : CNode(), m_nSize(0), m_pData(NULL) {}
00062 CCharBuffer(fsf::CNode *pParent, Time tTime=0)
00063 : CNode(pParent,tTime), m_nSize(0), m_pData(NULL) {}
00065 CCharBuffer(const std::string &strName, fsf::CNode *pParent=NULL, Time tTime=0)
00066 : CNode(strName,pParent,tTime), m_nSize(0), m_pData(NULL) {}
00068 CCharBuffer(long nSize, fsf::CNode *pParent=NULL, Time tTime=0);
00070 CCharBuffer(const std::string &strName, long nSize, fsf::CNode *pParent=NULL, Time tTime=0);
00072 CCharBuffer(const CCharBuffer& rhs);
00074 virtual ~CCharBuffer();
00076 virtual CNode *clone() const { return new CCharBuffer(*this); }
00078
00080
00081
00082 CCharBuffer& operator=(const CCharBuffer& rhs);
00083
00085 void setSize(long n) { m_nSize=n; }
00086
00088
00089
00091
00092
00093 virtual void getTypeID(std::string &str) const { str.assign("FSF_CHAR_BUFFER"); }
00095 long getSize() const { return m_nSize; }
00097
00098
00101
00102
00103 char *data() const { return m_pData; }
00105 void lockData() { m_csData.lock(); }
00107 void unlockData() { m_csData.unlock(); }
00108
00111 void allocateBuffer(long n=-1);
00114 void copyData(const CCharBuffer &rhs);
00116 char *detachData();
00118
00119 };
00120
00128
00129
00132 class CCharBufferSize : public CTypeCellBase {
00133 protected:
00134 public:
00136
00137
00138 CCharBufferSize();
00140
00142
00143
00144 virtual void getTypeID(std::string &str) { str.assign("FSF_CHAR_BUFFER_SIZE"); }
00146
00148
00149
00150 virtual void process(CPassiveHandle *pPassiveHandle, CActiveHandle *pActiveHandle, CActivePulse *pActivePulse);
00152 };
00153
00155
00156 }
00157
00158 #endif // FSF_CHAR_BUFFER_H
00159