DraWin.h
Go to the documentation of this file.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
00032
00033 #ifndef __DRA_WIN_H_
00034 #define __DRA_WIN_H_
00035
00036 #ifdef MIP_HOST_APPLE
00037 #include <applePatch.h>
00038 #endif
00039
00040 #include <assert.h>
00041
00042 #include <Thread.h>
00043 #include "Resource.h"
00044 #include "DraWinObj.h"
00045
00046
00075
00076 using namespace std;
00077 using namespace MipBaselib;
00078
00079 namespace MipResources{
00081
00082
00083
00086 class DraWinVar{
00087 private:
00088 static const unsigned int DRA_WIN_DEFAULT_WIDTH = 300;
00089 static const unsigned int DRA_WIN_DEFAULT_HEIGHT = 300;
00090 public:
00091 unsigned int _width;
00092 unsigned int _height;
00093 DraWinBoundBox BB;
00094
00095 DraWinVar(){
00096 _width = DRA_WIN_DEFAULT_WIDTH;
00097 _height = DRA_WIN_DEFAULT_HEIGHT;
00098 }
00099 };
00100
00104 class DraWin : public Resource{
00105
00106 private:
00107 static const unsigned int DRA_WIN_RES_LIST_SIZE=5000;
00108 pthread_mutex_t _listsMutEx;
00109 protected:
00111 vector<DraWinList*> _draWinLists;
00113 vector<DraWinList*> _draWinListsA;
00115 vector<DraWinList*> _draWinListsB;
00116
00117 vector<unsigned int> _indexA;
00118 vector<unsigned int> _indexB;
00119
00123 int _listsTrylock() {
00124 return pthread_mutex_trylock(&_listsMutEx);
00125 }
00126
00130 int _listsUnlock(){
00131 return pthread_mutex_unlock(&_listsMutEx);
00132 }
00133
00134
00135 public:
00136 DraWinVar _draWinVar;
00137
00140 DraWin(){
00141
00142
00143
00144 pthread_mutex_init(&_listsMutEx,NULL);
00145
00146 DraWinList* _defaultDWListA = new DraWinList();
00147 _draWinListsA.push_back(_defaultDWListA);
00148
00149 DraWinList* _defaultDWListB = new DraWinList();
00150 _draWinListsB.push_back(_defaultDWListB);
00151
00152 _draWinLists.push_back(_defaultDWListA);
00153 }
00154
00156 ~DraWin(){
00157 unsigned int listNum = _draWinLists.size();
00158 for(unsigned int i=0;i<listNum;i++){
00159 clearList(Time(10,0),i);
00160 delete _draWinLists[i];
00161 }
00162 }
00163
00166 virtual ResourcePlate getPlate() const =0;
00167
00173 bool addList(Time timeout,unsigned int& listNum);
00174
00179 bool swapList(Time timeout,unsigned int listNum);
00180
00189 bool pushObj(DraWinObj* draWinObj,Time timeout,unsigned int listNum=0);
00190
00201 bool overlapObj(DraWinObj* draWinObj,Time timeout,unsigned int listNum=0);
00202
00208 bool clearList(Time timeout,unsigned int listNum){
00209 return swapList(timeout,listNum);
00210 }
00211
00217 bool accuList(Time timeout,unsigned int listNum){
00218 return swapList(timeout,listNum);
00219 }
00220 };
00221
00225
00226
00227
00228
00229 };
00230
00231
00232 #endif
00233
00234
00235
00236
00237