OFFIS DCMTK  Version 3.6.0
dcmqrdbi.h
1 /*
2  *
3  * Copyright (C) 1993-2010, OFFIS e.V.
4  * All rights reserved. See COPYRIGHT file for details.
5  *
6  * This software and supporting documentation were developed by
7  *
8  * OFFIS e.V.
9  * R&D Division Health
10  * Escherweg 2
11  * D-26121 Oldenburg, Germany
12  *
13  *
14  * Module: dcmqrdb
15  *
16  * Author: Andrew Hewett, Marco Eichelberg
17  *
18  * Purpose: class DcmQueryRetrieveIndexDatabaseHandle
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2010-10-14 13:16:41 $
22  * CVS/RCS Revision: $Revision: 1.8 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 #ifndef DCMQRDBI_H
30 #define DCMQRDBI_H
31 
32 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
33 #include "dcmtk/dcmqrdb/dcmqrdba.h" /* for class DcmQueryRetrieveDatabaseHandle */
34 
35 #include "dcmtk/dcmnet/dicom.h"
36 #include "dcmtk/dcmnet/dimse.h"
37 #include "dcmtk/ofstd/offname.h"
38 
39 struct StudyDescRecord;
40 struct DB_Private_Handle;
41 struct DB_SmallDcmElmt;
42 struct IdxRecord;
43 struct DB_ElementList;
45 
46 #define DBINDEXFILE "index.dat"
47 
48 #ifndef _WIN32
49 /* we lock image files on all platforms except Win32 where it does not work
50  * due to the different semantics of LockFile/LockFileEx compared to flock.
51  */
52 #define LOCK_IMAGE_FILES
53 #endif
54 
57 enum DB_LEVEL
58 {
60  PATIENT_LEVEL,
62  STUDY_LEVEL,
64  SERIE_LEVEL,
66  IMAGE_LEVEL
67 };
68 
76 enum DVIFhierarchyStatus
77 {
79  DVIF_objectIsNotNew,
81  DVIF_objectIsNew,
83  DVIF_objectContainsNewSubobjects
84 };
85 
87 #define DB_UpperMaxStudies 500
88 
90 #define DB_UpperMaxBytesPerStudy 0x40000000L
91 
92 
98 {
99 public:
100 
111  const char *storageArea,
112  long maxStudiesPerStorageArea,
113  long maxBytesPerStudy,
114  OFCondition& result);
115 
121 
127  void setIdentifierChecking(OFBool checkFind, OFBool checkMove);
128 
139  const char *SOPClassUID,
140  const char *SOPInstanceUID,
141  char *newImageFileName);
142 
155  const char *SOPClassUID,
156  const char *SOPInstanceUID,
157  const char *imageFileName,
159  OFBool isNew = OFTrue );
160 
175  const char *SOPClassUID,
176  DcmDataset *findRequestIdentifiers,
178 
191  DcmDataset **findResponseIdentifiers,
193 
201 
216  const char *SOPClassUID,
217  DcmDataset *moveRequestIdentifiers,
219 
240  char *SOPClassUID,
241  char *SOPInstanceUID,
242  char *imageFileName,
243  unsigned short *numberOfRemainingSubOperations,
245 
253 
258 
259  // methods not inherited from the base class
260 
264  void enableQuotaSystem(OFBool enable);
265 
269  static void printIndexFile (char *storeArea);
270 
276  OFCondition deleteImageFile(char* imgFile);
277 
282  OFCondition DB_lock(OFBool exclusive);
283 
287 
293  OFCondition DB_IdxGetNext(int *idx, IdxRecord *idxRec);
294 
299  OFCondition DB_IdxInitLoop(int *idx);
300 
306  OFCondition DB_IdxRead(int idx, IdxRecord *idxRec);
307 
313 
319 
324  OFCondition DB_IdxRemove(int idx);
325 
330  OFCondition instanceReviewed(int idx);
331 
333  const char *getStorageArea() const;
334 
336  const char *getIndexFilename() const;
337 
338 
339 private:
340 
341  OFCondition removeDuplicateImage(
342  const char *SOPInstanceUID, const char *StudyInstanceUID,
343  StudyDescRecord *pStudyDesc, const char *newImageFileName);
344  int deleteOldestStudy(StudyDescRecord *pStudyDesc);
345  OFCondition deleteOldestImages(StudyDescRecord *pStudyDesc, int StudyNum, char *StudyUID, long RequiredSize);
346  int matchDate (DB_SmallDcmElmt *mod, DB_SmallDcmElmt *elt);
347  int matchTime (DB_SmallDcmElmt *mod, DB_SmallDcmElmt *elt);
348  int matchUID (DB_SmallDcmElmt *mod, DB_SmallDcmElmt *elt);
349  int matchStrings (DB_SmallDcmElmt *mod, DB_SmallDcmElmt *elt);
350  int matchOther (DB_SmallDcmElmt *mod, DB_SmallDcmElmt *elt);
351  int dbmatch (DB_SmallDcmElmt *mod, DB_SmallDcmElmt *elt);
352  void makeResponseList(DB_Private_Handle *phandle, IdxRecord *idxRec);
353  int matchStudyUIDInStudyDesc (StudyDescRecord *pStudyDesc, char *StudyUID, int maxStudiesAllowed);
354  OFCondition checkupinStudyDesc(StudyDescRecord *pStudyDesc, char *StudyUID, long imageSize);
355 
356  OFCondition hierarchicalCompare (
357  DB_Private_Handle *phandle,
358  IdxRecord *idxRec,
359  DB_LEVEL level,
360  DB_LEVEL infLevel,
361  int *match);
362 
363  OFCondition testFindRequestList (
364  DB_ElementList *findRequestList,
365  DB_LEVEL queryLevel,
366  DB_LEVEL infLevel,
367  DB_LEVEL lowestLevel);
368 
369  OFCondition testMoveRequestList (
370  DB_ElementList *findRequestList,
371  DB_LEVEL queryLevel,
372  DB_LEVEL infLevel,
373  DB_LEVEL lowestLevel);
374 
377 
380 
383 
386 
389 
390 };
391 
392 
397 {
398 public:
399 
404 
407 
417  const char *callingAETitle,
418  const char *calledAETitle,
419  OFCondition& result) const;
420 
421 private:
422 
425 };
426 
427 #endif
428 
429 /*
430  * CVS Log
431  * $Log: dcmqrdbi.h,v $
432  * Revision 1.8 2010-10-14 13:16:41 joergr
433  * Updated copyright header. Added reference to COPYRIGHT file.
434  *
435  * Revision 1.7 2009-11-24 10:10:42 uli
436  * Switched to logging mechanism provided by the "new" oflog module.
437  *
438  * Revision 1.6 2009-08-21 09:50:07 joergr
439  * Replaced tabs by spaces and updated copyright date.
440  *
441  * Revision 1.5 2008-04-15 15:43:37 meichel
442  * Fixed endless recursion bug in the index file handling code when
443  * the index file does not exist
444  *
445  * Revision 1.4 2005/12/08 16:04:22 meichel
446  * Changed include path schema for all DCMTK header files
447  *
448  * Revision 1.3 2005/04/22 15:36:34 meichel
449  * Passing calling aetitle to DcmQueryRetrieveDatabaseHandleFactory::createDBHandle
450  * to allow configuration retrieval based on calling aetitle.
451  *
452  * Revision 1.2 2005/04/04 10:04:45 meichel
453  * Added public declarations for index file functions that are
454  * used from module dcmpstat
455  *
456  * Revision 1.1 2005/03/30 13:34:50 meichel
457  * Initial release of module dcmqrdb that will replace module imagectn.
458  * It provides a clear interface between the Q/R DICOM front-end and the
459  * database back-end. The imagectn code has been re-factored into a minimal
460  * class structure.
461  *
462  *
463  */
~DcmQueryRetrieveIndexDatabaseHandle()
Destructor.
OFCondition nextMoveResponse(char *SOPClassUID, char *SOPInstanceUID, char *imageFileName, unsigned short *numberOfRemainingSubOperations, DcmQueryRetrieveDatabaseStatus *status)
Constructs the information required for the next available C-MOVE sub-operation (the image SOP class ...
DcmQueryRetrieveIndexDatabaseHandle(const char *storageArea, long maxStudiesPerStorageArea, long maxBytesPerStudy, OFCondition &result)
Constructor.
OFCondition DB_unlock()
release lock on database
this struct defines the structure of each "Study Record" in the index.dat file maintained by this mod...
Definition: dcmqridx.h:244
OFCondition startMoveRequest(const char *SOPClassUID, DcmDataset *moveRequestIdentifiers, DcmQueryRetrieveDatabaseStatus *status)
initiate MOVE operation using the given SOP class UID (which identifies the retrieve model) and DICOM...
OFCondition DB_GetStudyDesc(StudyDescRecord *pStudyDesc)
get study descriptor record from start of index file
const DcmQueryRetrieveConfig * config_
pointer to system configuration
Definition: dcmqrdbi.h:424
OFCondition nextFindResponse(DcmDataset **findResponseIdentifiers, DcmQueryRetrieveDatabaseStatus *status)
return the next available FIND response as a new DICOM dataset.
OFCondition deleteImageFile(char *imgFile)
deletes the given file only if the quota mechanism is enabled.
const char * getStorageArea() const
return name of storage area
OFCondition instanceReviewed(int idx)
clear the "is new" flag for the instance with the given index
virtual ~DcmQueryRetrieveIndexDatabaseHandleFactory()
destructor
abstract base class for database handles.
Definition: dcmqrdba.h:51
OFCondition startFindRequest(const char *SOPClassUID, DcmDataset *findRequestIdentifiers, DcmQueryRetrieveDatabaseStatus *status)
initiate FIND operation using the given SOP class UID (which identifies the query model) and DICOM da...
Index database factory class.
Definition: dcmqrdbi.h:396
DcmQueryRetrieveIndexDatabaseHandleFactory(const DcmQueryRetrieveConfig *config)
constructor
OFFilenameCreator fnamecreator
helper object for file name creation
Definition: dcmqrdbi.h:388
This class maintains database handles based on the classical "index.dat" file.
Definition: dcmqrdbi.h:97
void enableQuotaSystem(OFBool enable)
enable/disable the DB quota system (default: enabled) which causes images to be deleted if certain bo...
virtual DcmQueryRetrieveDatabaseHandle * createDBHandle(const char *callingAETitle, const char *calledAETitle, OFCondition &result) const
this method creates a new database handle instance on the heap and returns a pointer to it...
OFCondition DB_lock(OFBool exclusive)
create lock on database
abstract factory class.
Definition: dcmqrdba.h:207
OFCondition DB_IdxInitLoop(int *idx)
seek to beginning of image records in index file
OFBool doCheckMoveIdentifier
flag indicating whether or not the check function for MOVE requests is enabled
Definition: dcmqrdbi.h:385
this class provides a primitive interface for handling a list of flat DICOM elements, similar to DcmItem, but only for use within the database module
Definition: dcmqridx.h:161
OFCondition cancelFindRequest(DcmQueryRetrieveDatabaseStatus *status)
cancel the ongoing FIND request, stop and reset every running operation associated with this request...
a class handling the DICOM dataset format (files without meta header)
Definition: dcdatset.h:46
OFCondition makeNewStoreFileName(const char *SOPClassUID, const char *SOPInstanceUID, char *newImageFileName)
create a filename under which a DICOM object that is currently being received through a C-STORE opera...
const char * getIndexFilename() const
return path to index file
this class provides a primitive interface for handling a flat DICOM element, similar to DcmElement...
Definition: dcmqridx.h:136
this class manages an instance entry of the index file.
Definition: dcmqridx.h:326
OFCondition DB_StudyDescChange(StudyDescRecord *pStudyDesc)
write study descriptor record to start of index file
DB_Private_Handle * handle_
database handle
Definition: dcmqrdbi.h:376
OFCondition storeRequest(const char *SOPClassUID, const char *SOPInstanceUID, const char *imageFileName, DcmQueryRetrieveDatabaseStatus *status, OFBool isNew=OFTrue)
register the given DICOM object, which has been received through a C-STORE operation and stored in a ...
OFCondition DB_IdxRemove(int idx)
deactivate index record at given index by setting an empty filename
A class for automatically creating unique pseudo-random filenames.
Definition: offname.h:39
this class describes configuration settings for a Query/Retrieve SCP Service
Definition: dcmqrcnf.h:133
OFCondition DB_IdxGetNext(int *idx, IdxRecord *idxRec)
Get next Index record that is in use (i.e.
this class describes the result of a database operation (for an incoming C-FIND, C-MOVE, C-GET or C-STORE request) in a format that can directly be communicated to the remote SCU in a DIMSE RSP message.
Definition: dcmqrdbs.h:43
OFCondition cancelMoveRequest(DcmQueryRetrieveDatabaseStatus *status)
cancel the ongoing MOVE request, stop and reset every running operation associated with this request...
OFCondition DB_IdxRead(int idx, IdxRecord *idxRec)
read index record at given index
static void printIndexFile(char *storeArea)
dump database index file to stdout.
OFBool quotaSystemEnabled
flag indicating whether or not the quota system is enabled
Definition: dcmqrdbi.h:379
OFBool doCheckFindIdentifier
flag indicating whether or not the check function for FIND requests is enabled
Definition: dcmqrdbi.h:382
OFCondition pruneInvalidRecords()
Prune invalid records from the database.
General purpose class for condition codes.
Definition: ofcond.h:305
void setIdentifierChecking(OFBool checkFind, OFBool checkMove)
Configure the DB module to perform (or not perform) checking of FIND and MOVE request identifiers...


Generated on Wed Jan 4 2017 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.6