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 #if !defined(_DATASAMPLE_H_)
00028 #define _DATASAMPLE_H_
00029
00030 #if _MSC_VER > 1000
00031 #pragma once
00032 #endif // _MSC_VER > 1000
00033
00034 #include "Object.h"
00035 #include "JString.h"
00036 #include "JTime.h"
00037 #include "Collections.h"
00038 #include "XMLParser.h"
00039
00040 namespace cmlabs {
00041
00042 class DataSample;
00043 class Bitmap;
00044 class HTMLPage;
00045
00046 class DataSample : public Object
00047 {
00048 public:
00049 DataSample(const JString& type = "Raw", const JString& samplename = "");
00050 DataSample(XMLNode* node);
00051 virtual ~DataSample();
00052
00053 virtual Object* clone() const;
00054 virtual DataSample* cloneWithoutData();
00055
00056 virtual unsigned long getPayloadSize() const;
00057
00058 virtual JString print();
00059 virtual bool unitTest();
00060
00061 virtual JString toHTML();
00062 virtual HTMLPage* toHTMLBitmap();
00063 virtual JString toXML();
00064 virtual bool fromXML(XMLNode* node);
00065
00066 JString getType();
00067 bool setType(const JString& type);
00068
00069 bool isInUse();
00070 bool isLocked();
00071 bool setInUseBy(const JString& user, int timeout = 0);
00072 bool removeInUseBy(const JString& user);
00073 bool lockBy(const JString& locker);
00074
00075 bool setTimestamp(const JTime& time);
00076 bool setParameters(Dictionary& dict);
00077 bool setDuration(long durationMS);
00078 bool giveData(char* sampledata, long datasize, long durationMS = 0);
00079 bool setDataCopy(char* sampledata, long datasize, long durationMS = 0);
00080 bool setDataLink(char* sampledata, long datasize, long durationMS = 0);
00081
00082 JString getName();
00083 JTime getTimestamp();
00084 JTime getStartTime();
00085 JTime getEndTime();
00086 long getDuration();
00087 Dictionary getAllParameters();
00088 long getDataSize();
00089 long getDataMemUse();
00090 char* getDataCopy();
00091 char* getDataLink();
00092 bool clearDataFields();
00093
00094 bool equals(const Object* o2) const;
00095 bool equals( const DataSample &s2 ) const;
00096 int compare(const Object* o2) const;
00097 int compareTo( const DataSample &s2 ) const;
00098
00099 JString getParam(const JString& param);
00100 int getParamInt(const JString& param);
00101 double getParamFloat(const JString& param);
00102
00103 bool setParam(const JString& param, const JString& value);
00104 bool setParamInt(const JString& param, int value);
00105 bool setParamFloat(const JString& param, double value);
00106
00107 int getWidth();
00108 int getHeight();
00109 bool setWidth(int w);
00110 bool setHeight(int h);
00111
00112 Object* getObject();
00113 bool setObject(Object* obj);
00114
00115 bool readFromFile(const JString& filename);
00116 bool writeToFile(const JString& filename);
00117
00118
00119
00120
00121
00122
00123 long getBinarySize(int chunk);
00124
00125 int getBinaryChunkCount();
00126
00127 char* getBinaryDataPointer(int chunk);
00128
00129 bool setBinaryChunk(int chunk, long binsize, char* data);
00130
00131 long toBinaryBuffer(int chunk, char* buffer, int maxlen);
00132 bool fromBinaryBuffer(int chunk, char* buffer, long len);
00133
00134 long getLongFromBytes(char* buffer);
00135 bool writeLongToBytes(char* buffer, long val);
00136
00137 bool markForDeletion();
00138 bool isMarkedForDeletion();
00139
00140 JString id;
00141 JString name;
00142 JString type;
00143 JTime timestamp;
00144 Dictionary params;
00145 char* data;
00146 char* link;
00147 long size;
00148 long duration;
00149 int width;
00150 int height;
00151 bool markedForDeletion;
00152 double sortfield;
00153 ObjectDictionary* channels;
00154
00155 Object* object;
00156 Object* aux;
00157
00158 protected:
00159
00160 ObjectDictionary users;
00161 JString lockedBy;
00162 };
00163
00164 }
00165
00166 #include "HTML.h"
00167
00168 #endif // _DATASAMPLE_H_