OCDM.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  *  OCDM.h:                                                                  *
00003  * ----------------------                                                    *
00004  *  This file contains the definition of the object oriented CDM             *
00005  *  Public API.                                                              *
00006  *  CDM is the Collection and Document Manager and the core component of the *
00007  *  Ellogon Text Engineering Platform.                                       *
00008  *  CDM was designed and implemented by Georgios Petasis,                    *
00009  *  e-mail: petasis@iit.demokritos.gr                                        *
00010  *  URL:    http://www.iit.demokritos.gr/~petasis                            *
00011  *                                                                           *
00012  *  Copyright 1998-2004 by:                                                  *
00013  *  Georgios Petasis,                                                        *
00014  *  Software and Knowledge Engineering Laboratory,                           *
00015  *  Institute of Informatics and Telecommunications,                         *
00016  *  National Center for Scientific Research (N.C.S.R.) "Demokritos",         *
00017  *  Athens, Greece.                                                          *
00018  *  E-mail: petasis@iit.demokritos.gr                                        *
00019  *                                                                           *
00020  *  This file is part of the "Ellogon" Text Engineering Platform.            *
00021  *  For licencing information, please refer to the licence conditions of     *
00022  *  "Ellogon" Text Engineering Platform.                                     *
00023  *****************************************************************************/
00024 
00025 #ifdef SWIG
00026 #undef  CDM_EXPORT
00027 #define CDM_EXPORT
00028 %{
00029 #include "OCDM.h"
00030 %}
00031 // %newobject   operator[];
00032 // %newobject   get;
00033 // %newobject   GetValue;
00034 // %newobject   GetAttribute;
00035 // %newobject   GetAttributes;
00036 // %newobject   GetFirstSpan;
00037 // %newobject   GetSpans;
00038 // %newobject   AnnotationsAt;
00039 // %newobject   AnnotationsContaining;
00040 // %newobject   AnnotationsInRange;
00041 // %newobject   AnnotationsMatchingRange;
00042 // %newobject   FirstAnnotationContaining;
00043 // %newobject   GetAnnotation;
00044 // %newobject   SelectAnnotations;
00045 // %newobject   SelectAnnotationsSorted;
00046 // %newobject   NextAnnotations;
00047 // %newobject   GetAnnotation;
00048 // %newobject   GetFirstAnnotatedTextRange;
00049 // %newobject   GetAnnotatedTextRanges;
00050 // %newobject   ByteSequenceInsertString;
00051 // %newobject   ByteSequenceReplace;
00052 // %newobject   ByteSequenceReplaceCharacters;
00053 // %newobject   GetAnnotations;
00054 // %newobject   GetByteSequence(void);
00055 // %newobject   GetFirstAnnotation;
00056 // %newobject   GetNextAnnotation;
00057 // %newobject   GetParent;
00058 // %newobject   GetRawData(void);
00059 // %newobject   Status;
00060 // %newobject   RawDataReplace;
00061 // %newobject   RawDataInsertString;
00062 // %newobject   RawDataReplaceCharacters;
00063 // %newobject   FirstDocument;
00064 // %newobject   GetByExternalId;
00065 // %newobject   GetDocument;
00066 // %newobject   NextDocument;
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 // Language independent exception handler
00090 %include exception.i
00091 // STL support...
00092 %include stl.i
00093 
00094 %exception {
00095   try {
00096     $action
00097   } catch (OCDM_Exception e) {
00098     SWIG_exception(SWIG_RuntimeError, e.what());
00099  /* SWIG_exception(SWIG_ValueError, e.what()); */
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 /* When running under Java, OCDM can be accessed by various threads. As a
00115  * result, we need to serialise all access to OCDM. For this purpose we
00116  * declare a Mutex... */
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  /* SWIG_exception(SWIG_ValueError, e.what()); */
00128   }
00129 }
00130 
00131 #ifdef SWIG
00132 
00133 /* Define how destructors will be produced for Java shadow classes */
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  * Typemaps for correct handling of temporary object references returned by
00152  * all functions of OCDM that return a new object.
00153  */
00154 //%typemap(out) const OCDM_AnnotationSet & %{
00155 //    $1_basetype *newObj = new $1_basetype();
00156 //    newObj = $1;
00157 //    printf("obj = %p -> %p\n", _result_ref, $1);
00158 //    *($&1_ltype)&$result = $1;
00159 //%}
00160 
00161 /*
00162  * Macro to help handle references.
00163  */
00164 // %define reference(type, name)
00165 // %inline %{
00166 // static type &var_##name = initial_value_##name;
00167 // type setref_##name(type &x) {
00168 //     var_##name = x;
00169 //     return var_##name;
00170 // }
00171 // type& createref_##name(type x) {
00172 //     return *new type(x);
00173 // }
00174 // type value_##name(type &x) {
00175 //     return x;
00176 // }
00177 // %}
00178 // %enddef
00179 // reference(const OCDM_AnnotationSet, OCDM_AnnotationSet);
00180 
00181 //%typemap(jni)    long "jlong"
00182 //%typemap(jtype)  long "long"
00183 //%typemap(jstype) long "long"
00184 #endif /* SWIG */
00185 
00186 %{
00187 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
00188   /*
00189    * It is absolutelly safe to always call CDM_Initialise:
00190    * If this library is loaded under Ellogon, CDM is already initialised, thus
00191    * this call has no effect. But if we are called from plain Java, we will
00192    * initialise CDM...
00193    */
00194   CDM_GET_LIBRARY_FUNCTION_POINTERS;
00195   CDM_Initialise("Java");
00196   return JNI_VERSION_1_4;
00197 } /* JNI_OnLoad */
00198 %}
00199 #endif /* SWIGJAVA */
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  /* LOG_THREAD_INFO */
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 /* LOG_THREAD_INFO */
00282 #else  /* LOG_CONSTRUCTOR_CALLS */
00283 #ifdef LOG_DESTRUCTOR_CALLS 
00284 #define OCDM_COMMON_CONSTRUCTOR_CODE className = objectType();
00285 #else  /* LOG_DESTRUCTOR_CALLS */
00286 #define OCDM_COMMON_CONSTRUCTOR_CODE
00287 #endif /* LOG_DESTRUCTOR_CALLS */
00288 #endif /* LOG_CONSTRUCTOR_CALLS */
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  /* LOG_DESTRUCTOR_CALLS */
00294 #define OCDM_COMMON_DESTRUCTOR_CODE
00295 #endif /* LOG_DESTRUCTOR_CALLS */
00296 
00297 #include <exception>
00298 #include <string>
00299 #include <vector>
00300 #include "CDM.h"
00301 
00302 //class CDM_EXPORT OCDM_Object;
00303 //class CDM_EXPORT OCDM_ByteSequence;
00304 //class CDM_EXPORT OCDM_ByteSequenceSet;
00305 //class CDM_EXPORT OCDM_RawData;
00306 //class CDM_EXPORT OCDM_RawDataSet;
00307 //class CDM_EXPORT OCDM_Span;
00308 //class CDM_EXPORT OCDM_SpanSet;
00309 //class CDM_EXPORT OCDM_AttributeValue;
00310 //class CDM_EXPORT OCDM_Attribute;
00311 //class CDM_EXPORT OCDM_AttributeSet;
00312 //class CDM_EXPORT OCDM_Annotation;
00313 //class CDM_EXPORT OCDM_AnnotationSet;
00314 //class CDM_EXPORT OCDM_Document;
00315 //class CDM_EXPORT OCDM_Collection;
00316 
00317 /*
00318  * CDM Defined Constants
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  * Class OCDM_Exception:
00333  * This is the class that will be thrown by OCDM when an error occurs.
00334  * The caller that catches this exception can call "what" to get a string
00335  * describing the error.
00336  */
00337 class CDM_EXPORT OCDM_Exception /* : public std::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 }; /* class OCDM_Exception */
00348 #endif /* SWIG */
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 /* LOG_CONSTRUCTOR_CALLS || LOG_DESTRUCTOR_CALLS */
00365   public:
00366     void ensureValidity(void) const {
00367       if (cdmObj == NULL) throw OCDM_Exception("Uninitialised object!");
00368     }
00369     /* Constructors */
00370     OCDM_Object();
00371 #ifndef SWIG
00372     OCDM_Object(const CDM_Object);
00373 #endif /* SWIG */
00374     OCDM_Object(const class OCDM_Object&);
00375     /* Destructor */
00376     ~OCDM_Object();
00377     /* Operators */
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 /* ENABLE_INDEX_OPERATOR_ON_ALL_OBJECTS */
00383 #ifndef SWIG
00384     /* Private Helper functions */
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 /* SWIG */
00394     /* Public  Helper functions */
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     /* Friend class that can access private memebers */
00403 #ifdef    SWIGPYTHON
00404     /* The following definitions provide a better integration of our objects
00405      * with Python. */
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     /* Support for Python special methods.
00412      * __iter__ allows code like 'for item in obj:'
00413      * __getitem__ allows code like 'obj[index]'
00414      * Code for these methods contributed by
00415      * Steven Bethard <steven.bethard@colorado.edu>. */
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 /* SWIG */
00428 #endif /* SWIGPYTHON */
00429 }; /* class OCDM_Object */
00430 
00431 #if 0
00432 
00440 class CDM_EXPORT OCDM_StringObject : public OCDM_Object {
00441   public:
00442     /* Constructors */
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 /* SWIG */
00448     OCDM_StringObject(const class OCDM_StringObject& obj) : OCDM_Object(obj)
00449                                         {OCDM_COMMON_CONSTRUCTOR_CODE};
00450     /* Operators */
00451     class OCDM_StringObject& operator= (const class OCDM_Object& obj) {
00452       OCDM_Object::operator= (obj); return *this;
00453     };
00454 
00455     /* Public functions: we try to implement as much as possible form the STL
00456      * string container... */
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     /* Friend class that can access private members */
00484 }; /* class OCDM_StringObject */
00485 #endif
00486 
00487 #if 0
00488 
00495 class CDM_EXPORT OCDM_ObjectSet : public OCDM_Object {
00496   private:
00497   protected:
00498   public:
00499     /* Constructors */
00500     OCDM_ObjectSet();
00501 #ifndef SWIG
00502     OCDM_ObjectSet(const CDM_ObjectSet);
00503 #endif /* SWIG */
00504     OCDM_ObjectSet(const class OCDM_ObjectSet&);
00505     /* Destructor */
00506     ~OCDM_ObjectSet();
00507     /* Operators */
00508 #ifdef ENABLE_INDEX_OPERATOR_ON_ALL_OBJECTS
00509     virtual OCDM_INDEX_OPERATOR_REF(OCDM_Object) operator[] (const long index)
00510                                                                           const;
00511 #endif /* ENABLE_INDEX_OPERATOR_ON_ALL_OBJECTS */
00512 
00513     /* Set manipulation operators */
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     /* Get manipulation operators */
00519 }; /* class OCDM_ObjectSet */
00520 #endif
00521 
00530 class CDM_EXPORT OCDM_ByteSequence : public OCDM_Object {
00531   public:
00532     /* Constructors */
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 /* SWIG */
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     /* Destructor */
00543     //~OCDM_ByteSequence() {deleteObject();}
00544     /* Operators */
00545     class OCDM_ByteSequence& operator= (const class OCDM_Object& obj) {
00546       OCDM_Object::operator= (obj); return *this;
00547     };
00548     /* Public  Helper functions */
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 }; /* class OCDM_ByteSequence */
00557 
00562 class CDM_EXPORT OCDM_ByteSequenceSet : public OCDM_ByteSequence {
00563   public:
00564     /* Constructors */
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 /* SWIG */
00570     OCDM_ByteSequenceSet(const class OCDM_ByteSequenceSet& obj) :
00571                           OCDM_ByteSequence(obj) {OCDM_COMMON_CONSTRUCTOR_CODE};
00572     /* Destructor */
00573     //~OCDM_ByteSequenceSet() {deleteObject();}
00574     /* Operators */
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     /* Set manipulation operators */
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     /* Get manipulation operators */
00586     
00587     /* Public  Helper functions */
00588     const char *objectType(void) const {return "OCDM_ByteSequenceSet";}
00589 }; /* class OCDM_ByteSequenceSet */
00590 
00599 class CDM_EXPORT OCDM_RawData : public OCDM_Object {
00600   public:
00601     /* Constructors */
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 /* SWIG */
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     /* Destructor */
00612     //~OCDM_RawData() {deleteObject();}
00613     /* Operators */
00614     class OCDM_RawData& operator= (const class OCDM_Object& obj) {
00615       return static_cast<OCDM_RawData&>(OCDM_Object::operator= (obj));
00616     };
00617     /* Public  Helper functions */
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 }; /* class OCDM_RawData */
00626 
00631 class CDM_EXPORT OCDM_RawDataSet : public OCDM_RawData {
00632   public:
00633     /* Constructors */
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 /* SWIG */
00639     OCDM_RawDataSet(const class OCDM_RawDataSet& obj) : OCDM_RawData(obj)
00640                                        {OCDM_COMMON_CONSTRUCTOR_CODE};
00641     /* Destructor */
00642     //~OCDM_RawDataSet() {deleteObject();}
00643     /* Operators */
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     /* Set manipulation operators */
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     /* Public  Helper functions */
00654     const char *objectType(void) const {return "OCDM_RawDataSet";}
00655 }; /* class OCDM_RawDataSet */
00656 
00661 class CDM_EXPORT OCDM_Span : public OCDM_Object {
00662   public:
00663     /* Constructors */
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 /* SWIG */
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     /* Destructor */
00673     //~OCDM_Span() {deleteObject();}
00674     /* Operators */
00675     class OCDM_Span& operator= (const class OCDM_Object& obj) {
00676       OCDM_Object::operator= (obj); return *this;
00677     };
00678     /* Public  Helper functions */
00679     long GetStart(void) const;
00680     long GetEnd(void) const;
00681 #ifndef SWIG
00682     int GetSpanOffsets(long &start, long &end) const;
00683 #endif /* SWIG */
00684     const char *objectType(void) const {return "OCDM_Span";}
00685 }; /* class OCDM_Span */
00686 
00695 class CDM_EXPORT OCDM_SpanSet : public OCDM_Object {
00696   public:
00697     /* Constructors */
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 /* SWIG */ 
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     /* Destructor */
00707     //~OCDM_SpanSet() {deleteObject();}
00708     /* Operators */
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     /* Public  Helper functions */
00714     void AddSpan(const OCDM_Span& Span);
00715     const char *objectType(void) const {return "OCDM_SpanSet";}
00716 }; /* class OCDM_SpanSet */
00717 
00722 class CDM_EXPORT OCDM_AttributeValue : public OCDM_Object {
00723   public:
00724     /* Constructors */
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 /* SWIG */
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     /* Destructor */
00734     //~OCDM_AttributeValue() {deleteObject();}
00735     /* Operators */
00736     class OCDM_AttributeValue& operator= (const class OCDM_Object& obj) {
00737       OCDM_Object::operator= (obj); return *this;
00738     };
00739     /* Public  Helper functions */
00740     const char *objectType(void) const {return "OCDM_AttributeValue";}
00741 }; /* class OCDM_AttributeValue */
00742 
00747 class CDM_EXPORT OCDM_Attribute : public OCDM_Object {
00748   public:
00749     /* Constructors */
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 /* SWIG */
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     /* Destructor */
00760     //~OCDM_Attribute() {deleteObject();}
00761     /* Operators */
00762     class OCDM_Attribute& operator= (const class OCDM_Object& obj) {
00763       OCDM_Object::operator= (obj); return *this;
00764     };
00765     /* Public  Helper functions */
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 /* SWIG */
00775     const char *objectType(void) const {return "OCDM_Attribute";}
00776 }; /* class OCDM_Attribute */
00777 
00784 class CDM_EXPORT OCDM_AttributeSet : public OCDM_Object {
00785   public:
00786     /* Constructors */
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 /* SWIG */
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     /* Destructor */
00796     //~OCDM_AttributeSet() {deleteObject();}
00797     /* Operators */
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     /* Public  Helper functions */
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     /* The following definitions provide a better integration of our objects
00810      * with Python. */
00811 #ifdef    SWIG
00812     /* Support for Python special methods.
00813      * __getitem__ allows code like 'obj[index]' or 'obj[attr_name]'
00814      * __setitem__ allows code like 'obj[attr_name] = AttributeValue(...)'
00815      * __contains__ allows code like 'attr_name in obj'
00816      * Code for these methods contributed by
00817      * Steven Bethard <steven.bethard@colorado.edu>. */
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 /* SWIG */
00832 #endif /* SWIGPYTHON */
00833 }; /* class OCDM_AttributeSet */
00834 
00840 class CDM_EXPORT OCDM_Annotation : public OCDM_Object {
00841   public:
00842     /* Constructors */
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 /* SWIG */
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     /* Destructor */
00855     //~OCDM_Annotation() {deleteObject();}
00856     /* Operators */
00857     class OCDM_Annotation& operator= (const class OCDM_Object& obj) {
00858       OCDM_Object::operator= (obj); return *this;
00859     };
00860     /* Public  Helper functions */
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 /* SWIG */
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     /* The following definitions provide a better integration of our objects
00883      * with Python. */
00884 #ifdef    SWIG
00885     /* Support for Python special methods.
00886      * __getitem__ allows code like 'obj[index]' or 'obj[attr_name]'
00887      * __setitem__ allows code like 'obj[attr_name] = AttributeValue(...)'
00888      * __contains__ allows code like 'attr_name in obj'
00889      * Code for these methods contributed by
00890      * Steven Bethard <steven.bethard@colorado.edu>. */
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 /* SWIG */
00905 #endif /* SWIGPYTHON */
00906 }; /* class OCDM_Annotation */
00907 
00914 class CDM_EXPORT OCDM_AnnotationSet : public OCDM_Object {
00915   public:
00916     /* Constructors */
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 /* SWIG */
00922     OCDM_AnnotationSet(const class OCDM_AnnotationSet& obj) :
00923                                 OCDM_Object(obj) {OCDM_COMMON_CONSTRUCTOR_CODE};
00924     /* Destructor */
00925     //~OCDM_AnnotationSet() {deleteObject();}
00926     /* Operators */
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     /* Public  Helper functions */
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 }; /* class OCDM_AnnotationSet */
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     /* Constructors */
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     /* Destructor */
00994     ~OCDM_Document();
00995     /* Close */
00996     void Close(void);
00997     /* Operators */
00998     class OCDM_Document& operator= (const class OCDM_Document& obj);
00999     /* Private Helper functions */
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     /* Public  Helper functions */
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     /* The following definitions provide a better integration of our objects
01084      * with Python. */
01085     const char *__str__()  const {return toString();};
01086     const char *__repr__() const {return toString();};
01087 #ifdef    SWIG
01088     /* Support for Python special methods.
01089      * __getitem__ allows code like 'obj[attr_name]'
01090      * __setitem__ allows code like 'obj[attr_name] = AttributeValue(...)'
01091      * __contains__ allows code like 'attr_name in obj'
01092      * Code for these methods contributed by
01093      * Steven Bethard <steven.bethard@colorado.edu>. */
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 /* SWIG */
01103 #endif /* SWIGPYTHON */
01104     friend class OCDM_Macros;
01105 }; /* class OCDM_Document */
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     /* Constructors */
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     /* Destructor */
01140     ~OCDM_Collection();
01141     /* Operators */
01142     class OCDM_Collection& operator= (const class OCDM_Collection& obj);
01143     /* Private Helper functions */
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     /* Public  Helper functions */
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     /* The following definitions provide a better integration of our objects
01187      * with Python. */
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     /* Support for Python special methods.
01194      * __getitem__ allows code like 'obj[attr_name]'
01195      * __setitem__ allows code like 'obj[attr_name] = AttributeValue(...)'
01196      * __contains__ allows code like 'attr_name in obj'
01197      * Code for these methods contributed by
01198      * Steven Bethard <steven.bethard@colorado.edu>. */
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 /* SWIG */
01208 #endif /* SWIGPYTHON */
01209     friend class OCDM_Macros;
01210 }; /* class OCDM_Collection */
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 }; /* class OCDM_Tcl */
01228 
01234 /* Under Windows Perl, the symbol DeleteFile is defined and interferes with
01235  * our class, leading to unresolved symbol... */
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 }; /* class OCDM_Utilities */
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     /* Private Helper functions */
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     /* Public functions */
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 /* SWIG */
01306 }; /* class OCDM_Macros */
01307 
01308 #endif /* _OCDM_H_ */

Generated on Tue Jun 26 17:40:44 2007 for OCDM by  doxygen 1.5.2