Isis 3 Programmer Reference
CubeDataThread.h
1 #ifndef CubeDataThread_h
2 #define CubeDataThread_h
3 
4 #include <QThread>
5 
6 template<typename T> class QList;
7 
8 template<typename A, typename B> struct QPair;
9 template<typename A, typename B> class QMap;
10 
11 class QReadWriteLock;
12 class QMutex;
13 
14 namespace Isis {
15  class Cube;
16  class FileName;
17  class Brick;
18  class UniversalGroundMap;
19 
53  class CubeDataThread : public QThread {
54  Q_OBJECT
55 
56  public:
58  virtual ~CubeDataThread();
59 
60  int AddCube(const FileName &fileName,
61  bool mustOpenReadWrite = false);
62  int AddCube(Cube *cube);
63 
64  void RemoveCube(int cubeId);
65 
66  void AddChangeListener();
67  void RemoveChangeListener();
68 
69  int BricksInMemory();
70 
71  UniversalGroundMap *GetUniversalGroundMap(int cubeId) const;
72 
73  const Cube *GetCube(int cubeId) const;
74  int FindCubeId(const Cube *) const;
75 
76  public slots:
77  void ReadCube(int cubeId, int startSample, int startLine,
78  int endSample, int endLine, int band, void *caller);
79  void ReadWriteCube(int cubeId, int startSample, int startLine,
80  int endSample, int endLine, int band, void *caller);
81 
82  void DoneWithData(int, const Isis::Brick *);
83 
84  signals:
85 
97  void ReadReady(void *requester, int cubeId, const Isis::Brick *data);
98 
110  void ReadWriteReady(void *requester, int cubeId, Isis::Brick *data);
111 
124  void BrickChanged(int cubeId, const Isis::Brick *data);
125 
126  private:
135  CubeDataThread(const CubeDataThread &cdt);
136 
147 
148  int OverlapIndex(const Brick *initial, int cubeId,
149  int instanceNum, bool &exact);
150 
151  void GetCubeData(int cubeId, int ss, int sl, int es, int el, int band,
152  void *caller, bool sharedLock);
153 
154  void AcquireLock(QReadWriteLock *lockObject, bool readLock);
155 
156  bool FreeBrick(int brickIndex);
157 
166 
169 
194 
197 
200 
202  unsigned int p_currentId;
203 
206 
211  unsigned int p_currentLocksWaiting;
212  };
213 
214 };
215 
216 
217 #endif
QMutex * p_threadSafeMutex
This locks the member variable p_managedCubes and p_managedData itself.
void GetCubeData(int cubeId, int ss, int sl, int es, int el, int band, void *caller, bool sharedLock)
This helper method reads in cube data and handles the locking of similar bricks appropriately.
void RemoveCube(int cubeId)
Removes a cube from this lock manager.
int FindCubeId(const Cube *) const
Given a Cube pointer, return the cube ID associated with it.
File name manipulation and expansion.
Definition: FileName.h:116
Universal Ground Map.
void DoneWithData(int, const Isis::Brick *)
When done processing with a brick (reading or writing) this slot needs to be signalled to free locks ...
int p_numChangeListeners
This is the number of shaded locks to put on a brick when changes made.
unsigned int p_currentId
This is the unique id counter for cubes.
Buffer for containing a three dimensional section of an image.
Definition: Brick.h:61
QList< QPair< QReadWriteLock *, Brick * > > * p_managedData
This is a list of bricks in memory and their locks.
QList< int > * p_managedDataSources
This is the associated cube ID with each brick.
void ReadReady(void *requester, int cubeId, const Isis::Brick *data)
This signal will be emitted when ReadCube has finished processing.
void AcquireLock(QReadWriteLock *lockObject, bool readLock)
This method is exclusively used to acquire locks.
unsigned int p_currentLocksWaiting
Number of locks being attempted that re-entered the event loop.
virtual ~CubeDataThread()
This class is a self-contained thread, so normally it would be bad to simply delete it...
int AddCube(const FileName &fileName, bool mustOpenReadWrite=false)
This method is designed to be callable from any thread before data is requested, though no known side...
UniversalGroundMap * GetUniversalGroundMap(int cubeId) const
This returns a new Universal Ground Map given a Cube ID.
const CubeDataThread & operator=(CubeDataThread rhs)
Assigning CubeDataThreads to eachother is bad, so this has been intentionally not implemented! ...
Encapsulation of Cube I/O with Change Notifications.
void AddChangeListener()
You must call this method after connecting to the BrickChanged signal, otherwise you are not guarante...
void ReadWriteReady(void *requester, int cubeId, Isis::Brick *data)
This signal will be emitted when ReadWriteCube has finished processing.
QMap< int, QPair< bool, Cube *> > * p_managedCubes
This is a list of the opened cubes.
void ReadCube(int cubeId, int startSample, int startLine, int endSample, int endLine, int band, void *caller)
This slot should be connected to and upon receiving a signal it will begin the necessary cube I/O to ...
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
void RemoveChangeListener()
You must call this method after disconnecting from the BrickChanged signal, otherwise bricks cannot b...
void BrickChanged(int cubeId, const Isis::Brick *data)
DO NOT CONNECT TO THIS SIGNAL WITHOUT CALLING AddChangeListener().
void ReadWriteCube(int cubeId, int startSample, int startLine, int endSample, int endLine, int band, void *caller)
This slot should be connected to and upon receiving a signal it will begin the necessary cube I/O to ...
int OverlapIndex(const Brick *initial, int cubeId, int instanceNum, bool &exact)
This is a searching method used to identify overlapping data already in memory.
int BricksInMemory()
This is a helper method for both testing/debugging and general information that provides the current ...
bool p_stopping
This is set to help the shutdown process when deleted.
CubeDataThread()
This constructs a CubeDataThread().
const Cube * GetCube(int cubeId) const
This returns a constant pointer to a Cube at the given Cube ID.
IO Handler for Isis Cubes.
Definition: Cube.h:170
bool FreeBrick(int brickIndex)
This is used internally to delete bricks when possible.