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 #ifdef SWIG
00026 #undef CDM_EXPORT
00027 #define CDM_EXPORT
00028 %{
00029 #include "OCDM.h"
00030 %}
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 %rename(get) operator[];
00069 %rename(set) operator=;
00070 %rename(base_get) OCDM_Object::operator[];
00071 %rename(base_set) OCDM_Object::operator=;
00072 %rename(get) OCDM_ByteSequenceSet::operator[];
00073 %rename(get) OCDM_RawDataSet::operator[];
00074 %rename(get) OCDM_SpanSet::operator[];
00075 %rename(get) OCDM_AttributeSet::operator[];
00076 %rename(get) OCDM_AnnotationSet::operator[];
00077 %rename(set) OCDM_ByteSequence::operator=;
00078 %rename(_set) OCDM_ByteSequenceSet::operator=;
00079 %rename(set) OCDM_RawData::operator=;
00080 %rename(_set) OCDM_RawDataSet::operator=;
00081 %rename(set) OCDM_Span::operator=;
00082 %rename(set) OCDM_SpanSet::operator=;
00083 %rename(set) OCDM_AttributeValue::operator=;
00084 %rename(set) OCDM_Attribute::operator=;
00085 %rename(set) OCDM_AttributeSet::operator=;
00086 %rename(set) OCDM_Annotation::operator=;
00087 %rename(set) OCDM_AnnotationSet::operator=;
00088
00089
00090 %include exception.i
00091
00092 %include stl.i
00093
00094 %exception {
00095 try {
00096 $action
00097 } catch (OCDM_Exception e) {
00098 SWIG_exception(SWIG_RuntimeError, e.what());
00099
00100 }
00101 }
00102
00103 #ifndef SWIGJAVA
00104 %init {
00105 CDM_GET_LIBRARY_FUNCTION_POINTERS;
00106 CDM_Initialise("swig");
00107 }
00108 #endif
00109 #endif
00110
00111 #ifdef SWIGJAVA
00112
00113 %{
00114
00115
00116
00117 TCL_DECLARE_MUTEX(OCDM_Mutex);
00118 %}
00119
00120 %exception {
00121 try {
00122 Tcl_MutexLock(&OCDM_Mutex);
00123 $action
00124 Tcl_MutexUnlock(&OCDM_Mutex);
00125 } catch (OCDM_Exception e) {
00126 SWIG_exception(SWIG_RuntimeError, e.what());
00127
00128 }
00129 }
00130
00131 #ifdef SWIG
00132
00133
00134 %typemap(javadestruct, methodname="delete") SWIGTYPE {
00135 if(swigCPtr != 0 && swigCMemOwn) {
00136 $jnicall;
00137 swigCMemOwn = false;
00138 }
00139 swigCPtr = 0;
00140 }
00141 %typemap(javadestruct_derived, methodname="delete") SWIGTYPE {
00142 if(swigCPtr != 0 && swigCMemOwn) {
00143 $jnicall;
00144 swigCMemOwn = false;
00145 }
00146 swigCPtr = 0;
00147 super.delete();
00148 }
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 #endif
00185
00186 %{
00187 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
00188
00189
00190
00191
00192
00193
00194 CDM_GET_LIBRARY_FUNCTION_POINTERS;
00195 CDM_Initialise("Java");
00196 return JNI_VERSION_1_4;
00197 }
00198 %}
00199 #endif
00200
00201 #ifdef SWIGPERL
00202 #ifdef SWIG
00203 %rename(ByteSequence) OCDM_ByteSequence;
00204 %rename(ByteSequenceSet) OCDM_ByteSequenceSet;
00205 %rename(RawData) OCDM_RawData;
00206 %rename(RawDataSet) OCDM_RawDataSet;
00207 %rename(Span) OCDM_Span;
00208 %rename(SpanSet) OCDM_SpanSet;
00209 %rename(AttributeValue) OCDM_AttributeValue;
00210 %rename(Attribute) OCDM_Attribute;
00211 %rename(AttributeSet) OCDM_AttributeSet;
00212 %rename(Annotation) OCDM_Annotation;
00213 %rename(AnnotationSet) OCDM_AnnotationSet;
00214 %rename(Document) OCDM_Document;
00215 %rename(Collection) OCDM_Collection;
00216
00217 %rename(STRING) OCDM_STRING;
00218 %rename(STRING_SET) OCDM_STRING_SET;
00219 %rename(IMAGE) OCDM_IMAGE;
00220 %rename(BASE64_IMAGE) OCDM_BASE64_IMAGE;
00221 %rename(OK) OCDM_OK;
00222 %rename(ERROR) OCDM_ERROR;
00223 %rename(RETURN) OCDM_RETURN;
00224 %rename(BREAK) OCDM_BREAK;
00225 %rename(CONTINUE) OCDM_CONTINUE;
00226
00227 #endif
00228 #endif
00229
00230 #ifdef SWIGPYTHON
00231 #ifdef SWIG
00232 %rename(execute) exec;
00233 %rename(ByteSequence) OCDM_ByteSequence;
00234 %rename(ByteSequenceSet) OCDM_ByteSequenceSet;
00235 %rename(RawData) OCDM_RawData;
00236 %rename(RawDataSet) OCDM_RawDataSet;
00237 %rename(Span) OCDM_Span;
00238 %rename(SpanSet) OCDM_SpanSet;
00239 %rename(AttributeValue) OCDM_AttributeValue;
00240 %rename(Attribute) OCDM_Attribute;
00241 %rename(AttributeSet) OCDM_AttributeSet;
00242 %rename(Annotation) OCDM_Annotation;
00243 %rename(AnnotationSet) OCDM_AnnotationSet;
00244 %rename(Document) OCDM_Document;
00245 %rename(Collection) OCDM_Collection;
00246
00247 %rename(STRING) OCDM_STRING;
00248 %rename(STRING_SET) OCDM_STRING_SET;
00249 %rename(IMAGE) OCDM_IMAGE;
00250 %rename(BASE64_IMAGE) OCDM_BASE64_IMAGE;
00251 %rename(OK) OCDM_OK;
00252 %rename(ERROR) OCDM_ERROR;
00253 %rename(RETURN) OCDM_RETURN;
00254 %rename(BREAK) OCDM_BREAK;
00255 %rename(CONTINUE) OCDM_CONTINUE;
00256
00257 #endif
00258 #endif
00259
00260 #ifndef _OCDM_H_
00261 #define _OCDM_H_
00262 #define OCDM_PRESENT
00263 #define OCDM_BOOL int
00264 #define OCDM_REF(type) const class type
00265 #define OCDM_INDEX_OPERATOR_REF(type) const class type
00266
00267 #ifdef LOG_CONSTRUCTOR_CALLS
00268 #ifdef LOG_THREAD_INFO
00269 #define OCDM_COMMON_CONSTRUCTOR_CODE \
00270 className = objectType();\
00271 CDM_Log(" %s.cdmObj = (%p); ", className, getObject()); \
00272 CDM_Log("Reference Count = %d\n", \
00273 (getObject() == NULL)? -100 : getObject()->refCount); \
00274 CDM_Log("CurrentThread Id = %p\n", Tcl_GetCurrentThread());
00275 #else
00276 #define OCDM_COMMON_CONSTRUCTOR_CODE \
00277 className = objectType();\
00278 CDM_Log(" %s.cdmObj = (%p); ", className, getObject()); \
00279 CDM_Log("Reference Count = %d\n", \
00280 (getObject() == NULL)? -100 : getObject()->refCount);
00281 #endif
00282 #else
00283 #ifdef LOG_DESTRUCTOR_CALLS
00284 #define OCDM_COMMON_CONSTRUCTOR_CODE className = objectType();
00285 #else
00286 #define OCDM_COMMON_CONSTRUCTOR_CODE
00287 #endif
00288 #endif
00289
00290 #if defined(LOG_DESTRUCTOR_CALLS) && defined(LOG_THREAD_INFO)
00291 #define OCDM_COMMON_DESTRUCTOR_CODE \
00292 CDM_Log("CurrentThread Id = %p\n", Tcl_GetCurrentThread());
00293 #else
00294 #define OCDM_COMMON_DESTRUCTOR_CODE
00295 #endif
00296
00297 #include <exception>
00298 #include <string>
00299 #include <vector>
00300 #include "CDM.h"
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320 #define OCDM_STRING 1
00321 #define OCDM_STRING_SET 2
00322 #define OCDM_IMAGE 10
00323 #define OCDM_BASE64_IMAGE 11
00324 #define OCDM_OK 0
00325 #define OCDM_ERROR 1
00326 #define OCDM_RETURN 2
00327 #define OCDM_BREAK 3
00328 #define OCDM_CONTINUE 4
00329
00330 #ifndef SWIG
00331
00332
00333
00334
00335
00336
00337 class CDM_EXPORT OCDM_Exception {
00338 private:
00339 Tcl_Obj *errorObj;
00340 public:
00341 OCDM_Exception(const class OCDM_Exception& obj);
00342 class OCDM_Exception& operator= (const class OCDM_Exception& obj);
00343 OCDM_Exception() throw();
00344 OCDM_Exception(const char *msg) throw();
00345 ~OCDM_Exception() throw();
00346 const char *what() const throw();
00347 };
00348 #endif
00349
00357 class CDM_EXPORT OCDM_Object {
00358 private:
00359 mutable CDM_Object cdmObj;
00360 mutable const class OCDM_Object *storedObj;
00361 protected:
00362 #if defined (LOG_CONSTRUCTOR_CALLS) || defined (LOG_DESTRUCTOR_CALLS)
00363 mutable const char *className;
00364 #endif
00365 public:
00366 void ensureValidity(void) const {
00367 if (cdmObj == NULL) throw OCDM_Exception("Uninitialised object!");
00368 }
00369
00370 OCDM_Object();
00371 #ifndef SWIG
00372 OCDM_Object(const CDM_Object);
00373 #endif
00374 OCDM_Object(const class OCDM_Object&);
00375
00376 ~OCDM_Object();
00377
00378 virtual class OCDM_Object& operator= (const class OCDM_Object&);
00379 #ifdef ENABLE_INDEX_OPERATOR_ON_ALL_OBJECTS
00380 virtual OCDM_INDEX_OPERATOR_REF(OCDM_Object) operator[] (const long index)
00381 const;
00382 #endif
00383 #ifndef SWIG
00384
00385 void initObject(const CDM_Object) const;
00386 void setObject(const CDM_Object) const;
00387 const CDM_Object getObject(void) const;
00388 void releaseObject(void) const;
00389 void deleteObject(void) const;
00390 void storeObject(const class OCDM_Object *objPtr) const;
00391 const class OCDM_Object *getStoredObject(void) const;
00392 void releaseStoredObject(void) const;
00393 #endif
00394
00395 void Log(const char *str, ...) const;
00396 long size(void) const;
00397 bool empty(void) const {return (size()==0);};
00398 bool isEmpty(void) const {return (size()==0);};
00399 OCDM_BOOL Valid(void) const;
00400 const char *toString(void) const;
00401 virtual const char *objectType(void) const;
00402
00403 #ifdef SWIGPYTHON
00404
00405
00406 long __len__() {return size();};
00407 bool __nonzero__() {return (size()!=0);};
00408 const char *__str__() {return toString();};
00409 const char *__repr__() {return toString();};
00410 #ifdef SWIG
00411
00412
00413
00414
00415
00416 %pythoncode %{
00417 def __getitem__(self, index):
00418 if not (0 <= index < len(self)):
00419 raise IndexError(index)
00420 return self.get(index)
00421 def __iter__(self):
00422 for i in range(len(self)):
00423 yield self[i]
00424 def __unicode__(self):
00425 return str(self).decode('utf-8')
00426 %}
00427 #endif
00428 #endif
00429 };
00430
00431 #if 0
00432
00440 class CDM_EXPORT OCDM_StringObject : public OCDM_Object {
00441 public:
00442
00443 OCDM_StringObject() : OCDM_Object() {OCDM_COMMON_CONSTRUCTOR_CODE};
00444 #ifndef SWIG
00445 OCDM_StringObject(const CDM_Object obj) : OCDM_Object(obj)
00446 {OCDM_COMMON_CONSTRUCTOR_CODE};
00447 #endif
00448 OCDM_StringObject(const class OCDM_StringObject& obj) : OCDM_Object(obj)
00449 {OCDM_COMMON_CONSTRUCTOR_CODE};
00450
00451 class OCDM_StringObject& operator= (const class OCDM_Object& obj) {
00452 OCDM_Object::operator= (obj); return *this;
00453 };
00454
00455
00456
00457
00461 long size(void) const;
00462
00466 long length(void) const;
00467
00471 const char *operator[] (const long index) const;
00472 operator+=
00476 const char *at(const long index) const;
00477 const char *c_str() const;
00478 OCDM_BOOL toUpper(void) const;
00479 OCDM_BOOL toLower(void) const;
00480 OCDM_BOOL toTitle(void) const;
00481 const char *objectType(void) const {return "OCDM_StringObject";}
00482
00483
00484 };
00485 #endif
00486
00487 #if 0
00488
00495 class CDM_EXPORT OCDM_ObjectSet : public OCDM_Object {
00496 private:
00497 protected:
00498 public:
00499
00500 OCDM_ObjectSet();
00501 #ifndef SWIG
00502 OCDM_ObjectSet(const CDM_ObjectSet);
00503 #endif
00504 OCDM_ObjectSet(const class OCDM_ObjectSet&);
00505
00506 ~OCDM_ObjectSet();
00507
00508 #ifdef ENABLE_INDEX_OPERATOR_ON_ALL_OBJECTS
00509 virtual OCDM_INDEX_OPERATOR_REF(OCDM_Object) operator[] (const long index)
00510 const;
00511 #endif
00512
00513
00514 void add(const OCDM_Object&);
00515 void add(const char *);
00516 void push_back(const OCDM_Object&);
00517 void push_back(const char *);
00518
00519 };
00520 #endif
00521
00530 class CDM_EXPORT OCDM_ByteSequence : public OCDM_Object {
00531 public:
00532
00533 OCDM_ByteSequence() : OCDM_Object() {OCDM_COMMON_CONSTRUCTOR_CODE};
00534 #ifndef SWIG
00535 OCDM_ByteSequence(const CDM_Object obj) : OCDM_Object(obj)
00536 {OCDM_COMMON_CONSTRUCTOR_CODE};
00537 #endif
00538 OCDM_ByteSequence(const class OCDM_ByteSequence& obj) : OCDM_Object(obj)
00539 {OCDM_COMMON_CONSTRUCTOR_CODE};
00540 OCDM_ByteSequence(const char *str);
00541 OCDM_ByteSequence(const char *str, const int len);
00542
00543
00544
00545 class OCDM_ByteSequence& operator= (const class OCDM_Object& obj) {
00546 OCDM_Object::operator= (obj); return *this;
00547 };
00548
00549 void Set(const char *str);
00550 void Set(const char *str, const int len);
00551 long length(void) const;
00552 OCDM_BOOL toUpper(void) const;
00553 OCDM_BOOL toLower(void) const;
00554 OCDM_BOOL toTitle(void) const;
00555 const char *objectType(void) const {return "OCDM_ByteSequence";}
00556 };
00557
00562 class CDM_EXPORT OCDM_ByteSequenceSet : public OCDM_ByteSequence {
00563 public:
00564
00565 OCDM_ByteSequenceSet() : OCDM_ByteSequence() {OCDM_COMMON_CONSTRUCTOR_CODE};
00566 #ifndef SWIG
00567 OCDM_ByteSequenceSet(const CDM_Object obj) : OCDM_ByteSequence(obj)
00568 {OCDM_COMMON_CONSTRUCTOR_CODE};
00569 #endif
00570 OCDM_ByteSequenceSet(const class OCDM_ByteSequenceSet& obj) :
00571 OCDM_ByteSequence(obj) {OCDM_COMMON_CONSTRUCTOR_CODE};
00572
00573
00574
00575 class OCDM_ByteSequenceSet& operator= (const class OCDM_Object& obj) {
00576 OCDM_Object::operator= (obj); return *this;
00577 };
00578 OCDM_INDEX_OPERATOR_REF(OCDM_ByteSequence) operator[] (const long index)
00579 const;
00580
00581 void add(const OCDM_ByteSequence&);
00582 void add(const char *);
00583 void push_back(const OCDM_ByteSequence& obj) {add(obj);};
00584 void push_back(const char *obj) {add(obj);};
00585
00586
00587
00588 const char *objectType(void) const {return "OCDM_ByteSequenceSet";}
00589 };
00590
00599 class CDM_EXPORT OCDM_RawData : public OCDM_Object {
00600 public:
00601
00602 OCDM_RawData() : OCDM_Object() {OCDM_COMMON_CONSTRUCTOR_CODE};
00603 #ifndef SWIG
00604 OCDM_RawData(const CDM_Object obj) : OCDM_Object(obj)
00605 {OCDM_COMMON_CONSTRUCTOR_CODE};
00606 #endif
00607 OCDM_RawData(const class OCDM_RawData& obj) : OCDM_Object(obj)
00608 {OCDM_COMMON_CONSTRUCTOR_CODE};
00609 OCDM_RawData(const char *str);
00610 OCDM_RawData(const char *str, const int len);
00611
00612
00613
00614 class OCDM_RawData& operator= (const class OCDM_Object& obj) {
00615 return static_cast<OCDM_RawData&>(OCDM_Object::operator= (obj));
00616 };
00617
00618 void Set(const char *str);
00619 void Set(const char *str, const int len);
00620 long length(void) const;
00621 OCDM_BOOL toUpper(void) const;
00622 OCDM_BOOL toLower(void) const;
00623 OCDM_BOOL toTitle(void) const;
00624 const char *objectType(void) const {return "OCDM_RawData";}
00625 };
00626
00631 class CDM_EXPORT OCDM_RawDataSet : public OCDM_RawData {
00632 public:
00633
00634 OCDM_RawDataSet() : OCDM_RawData() {OCDM_COMMON_CONSTRUCTOR_CODE};
00635 #ifndef SWIG
00636 OCDM_RawDataSet(const CDM_Object obj) : OCDM_RawData(obj)
00637 {OCDM_COMMON_CONSTRUCTOR_CODE};
00638 #endif
00639 OCDM_RawDataSet(const class OCDM_RawDataSet& obj) : OCDM_RawData(obj)
00640 {OCDM_COMMON_CONSTRUCTOR_CODE};
00641
00642
00643
00644 class OCDM_RawDataSet& operator= (const class OCDM_Object& obj) {
00645 OCDM_Object::operator= (obj); return *this;
00646 };
00647 OCDM_INDEX_OPERATOR_REF(OCDM_RawData) operator[] (const long index) const;
00648
00649 void add(const OCDM_RawData&);
00650 void add(const char *);
00651 void push_back(const OCDM_RawData& obj) {add(obj);};
00652 void push_back(const char *obj) {add(obj);};
00653
00654 const char *objectType(void) const {return "OCDM_RawDataSet";}
00655 };
00656
00661 class CDM_EXPORT OCDM_Span : public OCDM_Object {
00662 public:
00663
00664 OCDM_Span() : OCDM_Object() {OCDM_COMMON_CONSTRUCTOR_CODE};
00665 #ifndef SWIG
00666 OCDM_Span(const CDM_Object obj) : OCDM_Object(obj)
00667 {OCDM_COMMON_CONSTRUCTOR_CODE};
00668 #endif
00669 OCDM_Span(const class OCDM_Span& obj) : OCDM_Object(obj)
00670 {OCDM_COMMON_CONSTRUCTOR_CODE};
00671 OCDM_Span(const long start, const long end);
00672
00673
00674
00675 class OCDM_Span& operator= (const class OCDM_Object& obj) {
00676 OCDM_Object::operator= (obj); return *this;
00677 };
00678
00679 long GetStart(void) const;
00680 long GetEnd(void) const;
00681 #ifndef SWIG
00682 int GetSpanOffsets(long &start, long &end) const;
00683 #endif
00684 const char *objectType(void) const {return "OCDM_Span";}
00685 };
00686
00695 class CDM_EXPORT OCDM_SpanSet : public OCDM_Object {
00696 public:
00697
00698 OCDM_SpanSet() : OCDM_Object() {OCDM_COMMON_CONSTRUCTOR_CODE};
00699 #ifndef SWIG
00700 OCDM_SpanSet(const CDM_Object obj) : OCDM_Object(obj)
00701 {OCDM_COMMON_CONSTRUCTOR_CODE};
00702 #endif
00703 OCDM_SpanSet(const class OCDM_SpanSet& obj) : OCDM_Object(obj)
00704 {OCDM_COMMON_CONSTRUCTOR_CODE};
00705 OCDM_SpanSet(const long start, const long end);
00706
00707
00708
00709 class OCDM_SpanSet& operator= (const class OCDM_Object& obj) {
00710 OCDM_Object::operator= (obj); return *this;
00711 };
00712 OCDM_INDEX_OPERATOR_REF(OCDM_Span) operator[] (const long index) const;
00713
00714 void AddSpan(const OCDM_Span& Span);
00715 const char *objectType(void) const {return "OCDM_SpanSet";}
00716 };
00717
00722 class CDM_EXPORT OCDM_AttributeValue : public OCDM_Object {
00723 public:
00724
00725 OCDM_AttributeValue() : OCDM_Object() {OCDM_COMMON_CONSTRUCTOR_CODE};
00726 #ifndef SWIG
00727 OCDM_AttributeValue(const CDM_Object obj) : OCDM_Object(obj)
00728 {OCDM_COMMON_CONSTRUCTOR_CODE};
00729 #endif
00730 OCDM_AttributeValue(const class OCDM_AttributeValue& obj) :
00731 OCDM_Object(obj) {OCDM_COMMON_CONSTRUCTOR_CODE};
00732 OCDM_AttributeValue(const int Type, const char *Value);
00733
00734
00735
00736 class OCDM_AttributeValue& operator= (const class OCDM_Object& obj) {
00737 OCDM_Object::operator= (obj); return *this;
00738 };
00739
00740 const char *objectType(void) const {return "OCDM_AttributeValue";}
00741 };
00742
00747 class CDM_EXPORT OCDM_Attribute : public OCDM_Object {
00748 public:
00749
00750 OCDM_Attribute() : OCDM_Object() {OCDM_COMMON_CONSTRUCTOR_CODE};
00751 #ifndef SWIG
00752 OCDM_Attribute(const CDM_Object obj) : OCDM_Object(obj)
00753 {OCDM_COMMON_CONSTRUCTOR_CODE};
00754 #endif
00755 OCDM_Attribute(const class OCDM_Attribute& obj) : OCDM_Object(obj)
00756 {OCDM_COMMON_CONSTRUCTOR_CODE};
00757 OCDM_Attribute(const char *name, const OCDM_AttributeValue& AttrVal);
00758 OCDM_Attribute(const char *name, const int Type, const char *Value);
00759
00760
00761
00762 class OCDM_Attribute& operator= (const class OCDM_Object& obj) {
00763 OCDM_Object::operator= (obj); return *this;
00764 };
00765
00766 const char *GetName(void) const;
00767 const char *GetValueString(void) const;
00768 OCDM_REF(OCDM_AttributeValue) GetValue(void) const;
00769 int GetValueType(void) const;
00770 const char *GetValueValue(void) const;
00771 void ReconstructAttribute(void) const;
00772 #ifndef SWIG
00773 void ReconstructAttribute(int* type) const;
00774 #endif
00775 const char *objectType(void) const {return "OCDM_Attribute";}
00776 };
00777
00784 class CDM_EXPORT OCDM_AttributeSet : public OCDM_Object {
00785 public:
00786
00787 OCDM_AttributeSet() : OCDM_Object() {OCDM_COMMON_CONSTRUCTOR_CODE};
00788 #ifndef SWIG
00789 OCDM_AttributeSet(const CDM_Object obj) : OCDM_Object(obj)
00790 {OCDM_COMMON_CONSTRUCTOR_CODE};
00791 #endif
00792 OCDM_AttributeSet(const class OCDM_AttributeSet& obj) : OCDM_Object(obj)
00793 {OCDM_COMMON_CONSTRUCTOR_CODE};
00794 OCDM_AttributeSet(const char *name, const OCDM_AttributeValue& AttrVal);
00795
00796
00797
00798 class OCDM_AttributeSet& operator= (const class OCDM_Object& obj) {
00799 OCDM_Object::operator= (obj); return *this;
00800 };
00801 OCDM_INDEX_OPERATOR_REF(OCDM_Attribute) operator[] (const long index) const;
00802
00803 void AddAttribute(const OCDM_Attribute& Attr);
00804 OCDM_BOOL AttributeExists(const char *name) const;
00805 OCDM_REF(OCDM_Attribute) GetAttribute(const char *name) const;
00806 int RemoveAttribute(const char *name);
00807 const char *objectType(void) const {return "OCDM_AttributeSet";}
00808 #ifdef SWIGPYTHON
00809
00810
00811 #ifdef SWIG
00812
00813
00814
00815
00816
00817
00818 %pythoncode %{
00819 def __getitem__(self, item):
00820 if isinstance(item, int):
00821 if not (0 <= item < len(self)):
00822 raise IndexError(item)
00823 return self.get(item)
00824 else:
00825 return self.GetAttribute(item)
00826 def __setitem__(self, attr_name, attr_value):
00827 self.AddAttribute(Attribute(attr_name, attr_value))
00828 def __contains__(self, attr_name):
00829 return self.AttributeExists(attr_name)
00830 %}
00831 #endif
00832 #endif
00833 };
00834
00840 class CDM_EXPORT OCDM_Annotation : public OCDM_Object {
00841 public:
00842
00843 OCDM_Annotation() : OCDM_Object() {OCDM_COMMON_CONSTRUCTOR_CODE};
00844 #ifndef SWIG
00845 OCDM_Annotation(const CDM_Object obj) : OCDM_Object(obj)
00846 {OCDM_COMMON_CONSTRUCTOR_CODE};
00847 #endif
00848 OCDM_Annotation(const class OCDM_Annotation& obj) : OCDM_Object(obj)
00849 {OCDM_COMMON_CONSTRUCTOR_CODE};
00850 OCDM_Annotation(const char* type, const OCDM_SpanSet& Spans,
00851 const OCDM_AttributeSet& Attributes);
00852 OCDM_Annotation(const char* type, const long start, const long end,
00853 const OCDM_AttributeSet& Attributes);
00854
00855
00856
00857 class OCDM_Annotation& operator= (const class OCDM_Object& obj) {
00858 OCDM_Object::operator= (obj); return *this;
00859 };
00860
00861 OCDM_BOOL AnnotationContainsPosition(const long Position) const;
00862 OCDM_BOOL AnnotationMatchesRange(const long Start, const long End) const;
00863 OCDM_BOOL AttributeExists(const char *name) const;
00864 int CompareAnnotations(const OCDM_Annotation &Ann) const;
00865 void DisplaceAnnotation(const long offset, const long displacement);
00866 OCDM_REF(OCDM_Attribute) GetAttribute(const char *name) const;
00867 OCDM_REF(OCDM_AttributeSet) GetAttributes(void) const;
00868 OCDM_REF(OCDM_Span) GetFirstSpan(void) const;
00869 #ifndef SWIG
00870 int GetFirstSpanOffsets(long &start, long &end) const;
00871 #endif
00872 OCDM_REF(OCDM_SpanSet) GetSpans(void) const;
00873 void PutAttribute(const OCDM_Attribute &Attr);
00874 const char *GetType(void) const;
00875 void ReconstructAnnotation(void) const;
00876 void RemoveAttribute(const char *name);
00877 void AddSpan(const OCDM_Span &span);
00878 void RemoveSpan(const long start, const long end);
00879 long GetId(void) const;
00880 const char *objectType(void) const {return "OCDM_Annotation";}
00881 #ifdef SWIGPYTHON
00882
00883
00884 #ifdef SWIG
00885
00886
00887
00888
00889
00890
00891 %pythoncode %{
00892 def __getitem__(self, item):
00893 if isinstance(item, int):
00894 if not (0 <= item < len(self)):
00895 raise IndexError(item)
00896 return self.get(item)
00897 else:
00898 return self.GetAttribute(item)
00899 def __setitem__(self, attr_name, attr_value):
00900 self.PutAttribute(Attribute(attr_name, attr_value))
00901 def __contains__(self, attr_name):
00902 return attr_name in self.GetAttributes()
00903 %}
00904 #endif
00905 #endif
00906 };
00907
00914 class CDM_EXPORT OCDM_AnnotationSet : public OCDM_Object {
00915 public:
00916
00917 OCDM_AnnotationSet() : OCDM_Object() {OCDM_COMMON_CONSTRUCTOR_CODE};
00918 #ifndef SWIG
00919 OCDM_AnnotationSet(const CDM_Object obj) : OCDM_Object(obj)
00920 {OCDM_COMMON_CONSTRUCTOR_CODE};
00921 #endif
00922 OCDM_AnnotationSet(const class OCDM_AnnotationSet& obj) :
00923 OCDM_Object(obj) {OCDM_COMMON_CONSTRUCTOR_CODE};
00924
00925
00926
00927 class OCDM_AnnotationSet& operator= (const class OCDM_Object& obj) {
00928 OCDM_Object::operator= (obj); return *this;
00929 };
00930 OCDM_INDEX_OPERATOR_REF(OCDM_Annotation) operator[] (const long index) const;
00931
00932 void AddAnnotation(const OCDM_Annotation& Ann);
00933 int CompareAnnotations(const OCDM_Annotation &Ann1,
00934 const OCDM_Annotation &Ann2) const;
00935 void MergeAnnotations(OCDM_AnnotationSet &AnnSet);
00936 OCDM_REF(OCDM_AnnotationSet) AnnotationsAt(const long position) const;
00937 OCDM_REF(OCDM_AnnotationSet) AnnotationsContaining(const long position)
00938 const;
00939 OCDM_REF(OCDM_AnnotationSet) AnnotationsContaining(const long position1,
00940 const long position2) const;
00941 OCDM_REF(OCDM_AnnotationSet) AnnotationsInRange(const long Start,
00942 const long End) const;
00943 OCDM_REF(OCDM_AnnotationSet) AnnotationsInRange(const OCDM_Annotation& Ann)
00944 const;
00945 OCDM_REF(OCDM_AnnotationSet) AnnotationsMatchingRange(long Start, long End)
00946 const;
00947 OCDM_REF(OCDM_AnnotationSet) AnnotationsMatchingRange(const
00948 OCDM_Annotation& Ann) const;
00949 OCDM_REF(OCDM_Annotation) FirstAnnotationContaining(const long Position)
00950 const;
00951 OCDM_REF(OCDM_Annotation) FirstAnnotationContaining(const long Position1,
00952 const long Position2) const;
00953 OCDM_REF(OCDM_Annotation) GetAnnotation(const long Id) const;
00954 void RemoveAnnotation(const long Id);
00955 OCDM_REF(OCDM_AnnotationSet) SelectAnnotations(const char* Type) const;
00956 OCDM_REF(OCDM_AnnotationSet) SelectAnnotations(const char* Type,
00957 const char* Constraints) const;
00958 OCDM_REF(OCDM_AnnotationSet) SelectAnnotationsSorted(const char* Type)
00959 const;
00960 OCDM_REF(OCDM_AnnotationSet) SelectAnnotationsSorted(const char* Type,
00961 const char* Constraints) const;
00962 void SortAnnotationSet(void);
00963 void DisplaceAnnotations(const long offset,
00964 const long displacement);
00965 OCDM_REF(OCDM_AnnotationSet) NextAnnotations(const long Position) const;
00966 const char *objectType(void) const {return "OCDM_AnnotationSet";}
00967 };
00968
00975 class CDM_EXPORT OCDM_Document {
00976 private:
00977 CDM_Document Document;
00978 mutable const class OCDM_Object *storedObj;
00979 mutable const class OCDM_Collection *storedCollectionObj;
00980
00981 int CheckStatus(const int status) const;
00982 void ensureValidity(void) const;
00983 const char *ReturnString(const char *str) const;
00984 public:
00985
00986 OCDM_Document();
00987 OCDM_Document(const char *TclCmdName);
00988 OCDM_Document(const class OCDM_Document& obj);
00989 #ifndef SWIG
00990 OCDM_Document(const Tcl_Obj *TclCmdName);
00991 OCDM_Document(const CDM_Document);
00992 #endif
00993
00994 ~OCDM_Document();
00995
00996 void Close(void);
00997
00998 class OCDM_Document& operator= (const class OCDM_Document& obj);
00999
01000 void storeObject(const class OCDM_Object *objPtr) const;
01001 void storeObject(const class OCDM_Collection *objPtr)
01002 const;
01003 const class OCDM_Object *getStoredObject(void) const;
01004 void releaseStoredObject(void) const;
01005
01006 long AddAnnotation(const OCDM_Annotation &Ann);
01007 OCDM_REF(OCDM_AnnotationSet) AnnotationsAt(const long position) const;
01008 OCDM_REF(OCDM_AnnotationSet) AnnotationsContaining(const long position)
01009 const;
01010 OCDM_REF(OCDM_AnnotationSet) AnnotationsContaining(const long position1,
01011 const long position2) const;
01012 OCDM_REF(OCDM_AnnotationSet) AnnotationsInRange(const long Start,
01013 const long End) const;
01014 OCDM_REF(OCDM_AnnotationSet) AnnotationsInRange(const OCDM_Annotation& Ann)
01015 const;
01016 OCDM_REF(OCDM_AnnotationSet) AnnotationsMatchingRange(const long Start,
01017 const long End) const;
01018 OCDM_REF(OCDM_AnnotationSet) AnnotationsMatchingRange(const
01019 OCDM_Annotation& Ann) const;
01020 OCDM_BOOL AttributeExists(const char *name) const;
01021 int DisplaceAnnotations(long offset,
01022 long displacement);
01023 OCDM_REF(OCDM_Annotation) FirstAnnotationContaining(const long Position)
01024 const;
01025 OCDM_REF(OCDM_Annotation) FirstAnnotationContaining(const long Position1,
01026 const long Position2) const;
01027 OCDM_REF(OCDM_RawDataSet) GetAnnotatedTextRanges(const
01028 OCDM_Annotation& Ann) const;
01029 OCDM_REF(OCDM_Annotation) GetAnnotation(const long Id) const;
01030 OCDM_REF(OCDM_Attribute) GetAttribute(const char *name) const;
01031 OCDM_REF(OCDM_AttributeSet) GetAttributes(void) const;
01032 OCDM_REF(OCDM_ByteSequence) GetFirstAnnotatedTextRange(
01033 const OCDM_Annotation& Ann) const;
01034 OCDM_REF(OCDM_AnnotationSet) NextAnnotations(const long Position) const;
01035 int PutAttribute(const OCDM_Attribute &Attr);
01036 int RemoveAnnotation(const long Id);
01037 const char *GetId(void) const;
01038 int RemoveAttribute(const char *name);
01039 OCDM_REF(OCDM_AnnotationSet) SelectAnnotations(const char* Type) const;
01040 OCDM_REF(OCDM_AnnotationSet) SelectAnnotations(const char* Type,
01041 const char* Constraints) const;
01042 OCDM_REF(OCDM_AnnotationSet) SelectAnnotationsSorted(const char* Type)
01043 const;
01044 OCDM_REF(OCDM_AnnotationSet) SelectAnnotationsSorted(const char* Type,
01045 const char* Constraints) const;
01046 OCDM_REF(OCDM_ByteSequence) ByteSequenceInsertString(const long pos,
01047 const char *string);
01048 OCDM_REF(OCDM_ByteSequence) ByteSequenceReplace(const long first,
01049 const long last, const char *newstring);
01050 OCDM_REF(OCDM_ByteSequence) ByteSequenceReplaceCharacters(const long first,
01051 const long last, const char *string);
01052 int DeleteAnnotations(const char *Type);
01053 int DeleteAnnotations(const char *Type,
01054 const char *Constraints);
01055 long FindMaxUsedAnnotationId(void) const;
01056 OCDM_REF(OCDM_AnnotationSet) GetAnnotations(void) const;
01057 OCDM_REF(OCDM_ByteSequence) GetByteSequence(void) const;
01058 const char *GetByteSequence(const char *encoding) const;
01059 const char *GetEncoding(void) const;
01060 const char *GetExternalId(void) const;
01061 OCDM_REF(OCDM_Annotation) GetFirstAnnotation(const char *Type) const;
01062 OCDM_REF(OCDM_Annotation) GetNextAnnotation(void) const;
01063 OCDM_REF(OCDM_Collection) GetParent(void) const;
01064 OCDM_REF(OCDM_RawData) GetRawData(void) const;
01065 const char *GetRawData(const char *encoding) const;
01066 int SetByteSequence(const OCDM_ByteSequence &Text);
01067 void SetProcessStatus(const int value) const;
01068 const char *SetEncoding(const char *encoding);
01069 const char *SetExternalId(const char *ExternalId);
01070 OCDM_REF(OCDM_ByteSequence) Status(void) const;
01071 int Sync(void) const;
01072 OCDM_REF(OCDM_RawData) RawDataReplace(const long first,
01073 const long last, const char *newstring);
01074 OCDM_REF(OCDM_RawData) RawDataInsertString(const long pos,
01075 const char *string);
01076 OCDM_REF(OCDM_RawData) RawDataReplaceCharacters(const long first,
01077 const int characters, const char *string);
01078 void Log(const char *str, ...) const;
01079 OCDM_BOOL Valid(void) const;
01080 const char *toString(void) const;
01081 const char *objectType(void) const {return "OCDM_Document";}
01082 #ifdef SWIGPYTHON
01083
01084
01085 const char *__str__() const {return toString();};
01086 const char *__repr__() const {return toString();};
01087 #ifdef SWIG
01088
01089
01090
01091
01092
01093
01094 %pythoncode %{
01095 def __getitem__(self, attr_name):
01096 return self.GetAttribute(attr_name)
01097 def __setitem__(self, attr_name, attr_value):
01098 self.PutAttribute(Attribute(attr_name, attr_value))
01099 def __contains__(self, attr_name):
01100 return attr_name in self.GetAttributes()
01101 %}
01102 #endif
01103 #endif
01104 friend class OCDM_Macros;
01105 };
01106
01120 class CDM_EXPORT OCDM_Collection {
01121 private:
01122 CDM_Collection Collection;
01123 mutable const class OCDM_Object *storedObj;
01124 mutable const class OCDM_Document *storedDocumentObj;
01125
01126 int CheckStatus(const int status) const;
01127 void ensureValidity(void) const;
01128 const char *ReturnString(const char *str) const;
01129 public:
01130
01131 OCDM_Collection();
01132 OCDM_Collection(const char *name);
01133 OCDM_Collection(const class OCDM_Collection& obj);
01134 OCDM_Collection(const char* name, const OCDM_AttributeSet &AttrSet,
01135 const char* encoding);
01136 #ifndef SWIG
01137 OCDM_Collection(const CDM_Collection);
01138 #endif
01139
01140 ~OCDM_Collection();
01141
01142 class OCDM_Collection& operator= (const class OCDM_Collection& obj);
01143
01144 void storeObject(const class OCDM_Object *objPtr) const;
01145 void storeObject(const class OCDM_Document *objPtr)
01146 const;
01147 const class OCDM_Object *getStoredObject(void) const;
01148 void releaseStoredObject(void) const;
01149
01150 OCDM_BOOL AttributeExists(const char *name) const;
01151 void CreateDocument(const char *XID, const OCDM_ByteSequence &RawData,
01152 const OCDM_AnnotationSet &Annotations,
01153 const OCDM_AttributeSet &Attributes,
01154 const char *encoding);
01155 void CreateDocument(const char *XID, const OCDM_ByteSequence &RawData,
01156 const OCDM_AnnotationSet &Annotations,
01157 const OCDM_AttributeSet &Attributes);
01158 int Length(void) const;
01159 OCDM_REF(OCDM_Attribute) GetAttribute(const char *name) const;
01160 OCDM_REF(OCDM_AttributeSet) GetAttributes(void) const;
01161 int PutAttribute(const OCDM_Attribute &Attr);
01162 const char *GetName(void) const;
01163 int RemoveAttribute(const char *name);
01164 const char *GetEncoding(void) const;
01165 const char *SetEncoding(const char *encoding);
01166 OCDM_REF(OCDM_ByteSequence) Status(void) const;
01167 int Sync(void) const;
01168 int AnnotateColection(void);
01169 int Destroy(const char *name);
01170 OCDM_REF(OCDM_Document) FirstDocument(void) const;
01171 OCDM_REF(OCDM_Document) GetByExternalId(const char *XID) const;
01172 OCDM_REF(OCDM_Document) GetDocument(const char *ID) const;
01173 OCDM_REF(OCDM_Document) NextDocument(void) const;
01174 const char *GetOwner(void) const;
01175 int RemoveDocument(const char *Id);
01176 const char *SetName(const char *Name);
01177 const char *SetOwner(const char *Owner);
01178 int SetAssociatedInfo(
01179 const OCDM_ByteSequence& Info);
01180 void Log(const char *str, ...) const;
01181 long size(void) const;
01182 OCDM_BOOL Valid(void) const;
01183 const char *toString(void) const;
01184 const char *objectType(void) const {return "OCDM_Collection";}
01185 #ifdef SWIGPYTHON
01186
01187
01188 long __len__() const {return Length();};
01189 bool __nonzero__() const {return (Length()!=0);};
01190 const char *__str__() const {return toString();};
01191 const char *__repr__() const {return toString();};
01192 #ifdef SWIG
01193
01194
01195
01196
01197
01198
01199 %pythoncode %{
01200 def __getitem__(self, attr_name):
01201 return self.GetAttribute(attr_name)
01202 def __setitem__(self, attr_name, attr_value):
01203 self.PutAttribute(Attribute(attr_name, attr_value))
01204 def __contains__(self, attr_name):
01205 return attr_name in self.GetAttributes()
01206 %}
01207 #endif
01208 #endif
01209 friend class OCDM_Macros;
01210 };
01211
01218 class CDM_EXPORT OCDM_Tcl {
01219 private:
01220 mutable Tcl_Obj *resultObj;
01221 public:
01222 OCDM_Tcl();
01223 ~OCDM_Tcl();
01224 int eval(const char *tcl_code) const;
01225 int exec(const char *command) const;
01226 const char *GetResult(void) const;
01227 };
01228
01234
01235
01236 #undef DeleteFile
01237 class CDM_EXPORT OCDM_Utilities {
01238 private:
01239 mutable Tcl_Obj *resultObj;
01240 public:
01241 OCDM_Utilities();
01242 ~OCDM_Utilities();
01243 int DeleteFile(const char *path) const;
01244 int FileExists(const char *path) const;
01245 int MakeDirectory(const char *directory) const;
01246 const char *GetIP(void) const;
01247 const char *GetTempDir(void) const;
01248 void Panic(const char *error) const;
01249 void Log(const char *fmt) const;
01250 const char *GetResult(void) const;
01251 };
01252
01258 class CDM_EXPORT OCDM_Macros {
01259 private:
01260 mutable CDM_MACRO_SYSTEM system;
01261 mutable CDM_MACRO_SYSTEM_COLLECTION token;
01262 mutable const class OCDM_Document *storedDocumentObj;
01263 mutable const class OCDM_Collection *storedCollectionObj;
01264 public:
01265 OCDM_Macros();
01266 OCDM_Macros(const OCDM_Collection &col);
01267 ~OCDM_Macros();
01268
01269
01270 void storeObject(const class OCDM_Document *objPtr) const;
01271 void storeObject(const class OCDM_Collection *objPtr) const;
01272 void releaseStoredObject(void) const;
01273
01274
01275 void OpenSystem(const char *name, const char *folder = "/") const;
01276 void EditSystem(const char *name, const char *folder = "/") const;
01277 void OpenInSystem(const char *collection_name,
01278 const char *document_id) const;
01279 void OpenInSystem(const char *collection_name) const;
01280 OCDM_REF(OCDM_Collection) GetOpenedCollection(void) const;
01281 OCDM_REF(OCDM_Document) GetOpenedDocument(void) const;
01282 int RunSystemComponent(const char *Annotator) const;
01283 int RunSystemComponent(const char *Annotator,
01284 const bool force) const;
01285 int RunSystemTool(const char *Annotator) const;
01286 int RunSystemTool(const char *Annotator,
01287 const bool force) const;
01288 int DisplayViewer(const char *viewer_name,
01289 const OCDM_Document &doc,
01290 const char *parameter1,
01291 const char *parameter2) const;
01292 int NFoldExecution(OCDM_Collection col,
01293 const int folds,
01294 OCDM_ByteSequenceSet TrainingCommands,
01295 OCDM_ByteSequenceSet EvaluationCommands) const;
01296 int NFoldExecution(OCDM_Collection col,
01297 const int folds,
01298 OCDM_RawDataSet TrainingCommands,
01299 OCDM_RawDataSet EvaluationCommands) const;
01300 #ifndef SWIG
01301 int NFoldExecution(OCDM_Collection col,
01302 const int folds,
01303 const std::vector<std::string>& TrainingCommands,
01304 const std::vector<std::string>& EvaluationCommands) const;
01305 #endif
01306 };
01307
01308 #endif