You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by ea...@apache.org on 2007/02/03 17:57:15 UTC

svn commit: r503250 [1/9] - /incubator/uima/uimacpp/trunk/src/framework/

Author: eae
Date: Sat Feb  3 08:57:13 2007
New Revision: 503250

URL: http://svn.apache.org/viewvc?view=rev&rev=503250
Log:
Initial entry

Added:
    incubator/uima/uimacpp/trunk/src/framework/
    incubator/uima/uimacpp/trunk/src/framework/Makefile.am   (with props)
    incubator/uima/uimacpp/trunk/src/framework/annotator.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/annotator_context.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/annotator_mgr.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/casdefinition.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/casiterator.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/caspool.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/config_param.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/consoleui.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/cp2ucnvrt.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/dottypesystemwriter.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/engine.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/exceptions.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/ftools.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/internal_aggregate_engine.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/internal_capability_container.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/internal_engine_base.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/internal_jedii_engine.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/internal_primitive_engine.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/language.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/log.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/res_abase.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/res_annotator.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/resmgr.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/strtools.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/taemetadata.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/taespecifier.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/taespecifierbuilder.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/timedatetools.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/token_properties.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/typesystemdescription.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/u2cpcnvrt.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/framework/unistrref.cpp   (with props)

Added: incubator/uima/uimacpp/trunk/src/framework/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/framework/Makefile.am?view=auto&rev=503250
==============================================================================
--- incubator/uima/uimacpp/trunk/src/framework/Makefile.am (added)
+++ incubator/uima/uimacpp/trunk/src/framework/Makefile.am Sat Feb  3 08:57:13 2007
@@ -0,0 +1,118 @@
+# -*- makefile -*-
+
+lib_LTLIBRARIES = libuima.la
+
+include_HEADERS =
+include_HEADERS += uima/*.h
+include_HEADERS += uima/*.hpp
+include_HEADERS += ../cas/uima/*.hpp
+include_HEADERS += ../cas/uima/*.inl
+
+uima_tgt: libuima.la
+
+clean:
+	rm -f libuima.la $(libuima_la_OBJECTS)
+
+install-data-local:
+if APPLE
+	$(INSTALL) ../../data/resourceSpecifierSchema.xsd $(DESTDIR)$(prefix)/data/resourceSpecifierSchema.xsd
+else
+	$(INSTALL) -D ../../data/resourceSpecifierSchema.xsd $(DESTDIR)$(prefix)/data/resourceSpecifierSchema.xsd
+endif
+
+INCLUDES  = -I.
+INCLUDES += -I../cas
+INCLUDES += -I../jni
+INCLUDES += $(UIMA_XERCES_INCLUDE)
+INCLUDES += $(UIMA_APR_INCLUDE)
+INCLUDES += $(UIMA_ICU_INCLUDE)
+INCLUDES += $(UIMACPP_HOME_INCLUDE)
+INCLUDES += $(UIMA_JDK_INCLUDE)
+INCLUDES += $(UIMA_JDK_INCLUDE)/genunix
+INCLUDES += $(UIMA_JDK_INCLUDE)/linux
+
+AM_LDFLAGS = -release $(LIB_VERSION)
+
+if DEBUG_UIMA
+AM_CPPFLAGS = -g -DDEBUG
+else
+AM_CPPFLAGS = -O3 -DNDEBUG -DTRACEOFF
+endif
+
+libuima_la_CPPFLAGS = $(AM_CPPFLAGS)
+libuima_la_CPPFLAGS += -DUIMA_PREFIX=$(PFX)
+libuima_la_CPPFLAGS += -DUIMA_VERSION=$(LIB_VERSION)
+libuima_la_CPPFLAGS += -D_UIMA_LIBRARY_
+# APR flags from apr_rules.mk
+libuima_la_CPPFLAGS += -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE
+
+libuima_la_SOURCES  = annotator_context.cpp				   
+libuima_la_SOURCES += annotator.cpp					   
+libuima_la_SOURCES += annotator_mgr.cpp				   
+libuima_la_SOURCES += casdefinition.cpp				   
+libuima_la_SOURCES += casiterator.cpp					   
+libuima_la_SOURCES += caspool.cpp					   
+libuima_la_SOURCES += config_param.cpp				   
+libuima_la_SOURCES += consoleui.cpp					   
+libuima_la_SOURCES += cp2ucnvrt.cpp					   
+libuima_la_SOURCES += dottypesystemwriter.cpp				   
+libuima_la_SOURCES += engine.cpp					   
+libuima_la_SOURCES += exceptions.cpp					   
+libuima_la_SOURCES += ftools.cpp					   
+libuima_la_SOURCES += internal_aggregate_engine.cpp			   
+libuima_la_SOURCES += internal_capability_container.cpp		   
+libuima_la_SOURCES += internal_engine_base.cpp			   
+libuima_la_SOURCES += internal_jedii_engine.cpp			   
+libuima_la_SOURCES += internal_primitive_engine.cpp			   
+libuima_la_SOURCES += language.cpp					   
+libuima_la_SOURCES += log.cpp						   
+libuima_la_SOURCES += res_abase.cpp					   
+libuima_la_SOURCES += res_annotator.cpp				   
+libuima_la_SOURCES += resmgr.cpp					   
+libuima_la_SOURCES += strtools.cpp					   
+libuima_la_SOURCES += taemetadata.cpp					   
+libuima_la_SOURCES += taespecifierbuilder.cpp				   
+libuima_la_SOURCES += taespecifier.cpp				      
+libuima_la_SOURCES += timedatetools.cpp				   
+libuima_la_SOURCES += token_properties.cpp				   
+libuima_la_SOURCES += typesystemdescription.cpp			   
+libuima_la_SOURCES += u2cpcnvrt.cpp					   
+libuima_la_SOURCES += unistrref.cpp                                      
+libuima_la_SOURCES += ../cas/arrayfs.cpp				       
+libuima_la_SOURCES += ../cas/cas.cpp					       
+libuima_la_SOURCES += ../cas/casexception.cpp				       
+libuima_la_SOURCES += ../cas/caswriter_abase.cpp			       
+libuima_la_SOURCES += ../cas/featurestructure.cpp			       
+libuima_la_SOURCES += ../cas/fsfilterbuilder.cpp			       
+libuima_la_SOURCES += ../cas/fsindex.cpp				       
+libuima_la_SOURCES += ../cas/fsindexrepository.cpp			       
+libuima_la_SOURCES += ../cas/fsiterator.cpp				       
+libuima_la_SOURCES += ../cas/internal_casdeserializer.cpp		       
+libuima_la_SOURCES += ../cas/internal_casimpl.cpp			       
+libuima_la_SOURCES += ../cas/internal_casserializer.cpp		       
+libuima_la_SOURCES += ../cas/internal_fspromoter.cpp			       
+libuima_la_SOURCES += ../cas/internal_serializedcas.cpp		       
+libuima_la_SOURCES += ../cas/internal_typeshortcuts.cpp		       
+libuima_la_SOURCES += ../cas/internal_xmlconstants.cpp		       
+libuima_la_SOURCES += ../cas/listfs.cpp				       
+libuima_la_SOURCES += ../cas/lowlevel_fsheap.cpp			       
+libuima_la_SOURCES += ../cas/lowlevel_indexcomparator.cpp		       
+libuima_la_SOURCES += ../cas/lowlevel_index.cpp			       
+libuima_la_SOURCES += ../cas/lowlevel_indexdefinition.cpp		       
+libuima_la_SOURCES += ../cas/lowlevel_indexrepository.cpp		       
+libuima_la_SOURCES += ../cas/lowlevel_internal_indexes.cpp		       
+libuima_la_SOURCES += ../cas/lowlevel_typesystem.cpp			       
+libuima_la_SOURCES += ../cas/sofastream.cpp				       
+libuima_la_SOURCES += ../cas/typenamespace.cpp			       
+libuima_la_SOURCES += ../cas/typesystem.cpp				       
+libuima_la_SOURCES += ../cas/xcasdeserializer.cpp			       
+libuima_la_SOURCES += ../cas/xcasdeserializer_handler.cpp		       
+libuima_la_SOURCES += ../cas/xmlerror_handler.cpp			       
+libuima_la_SOURCES += ../cas/xmltypesystemreader.cpp			       
+libuima_la_SOURCES += ../cas/xmltypesystemwriter.cpp			       
+libuima_la_SOURCES += ../cas/xmlwriter.cpp                                   
+libuima_la_SOURCES += ../jni/jni.cpp
+libuima_la_SOURCES += ../jni/jni_utils.cpp
+libuima_la_SOURCES += ../jni/jni_string.cpp
+
+libuima_la_LIBADD = $(UIMA_XERCES_LIB) $(UIMA_APR_LIB) $(UIMA_ICU_LIB) $(UIMACPP_HOME_LIB)

Propchange: incubator/uima/uimacpp/trunk/src/framework/Makefile.am
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/uima/uimacpp/trunk/src/framework/annotator.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/framework/annotator.cpp?view=auto&rev=503250
==============================================================================
--- incubator/uima/uimacpp/trunk/src/framework/annotator.cpp (added)
+++ incubator/uima/uimacpp/trunk/src/framework/annotator.cpp Sat Feb  3 08:57:13 2007
@@ -0,0 +1,649 @@
+/** @name annotator.cpp
+-----------------------------------------------------------------------------
+
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+
+-----------------------------------------------------------------------------
+
+   Description:
+
+-----------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------- */
+
+//lint -e625
+
+/* ----------------------------------------------------------------------- */
+/*       Interface dependencies                                            */
+/* ----------------------------------------------------------------------- */
+
+#include "uima/annotator.hpp"
+#include "uima/cas.hpp"
+
+#include "uima/msg.h"
+#include "uima/annotator_context.hpp"
+
+
+/* ----------------------------------------------------------------------- */
+/*       Implementation dependencies                                       */
+/* ----------------------------------------------------------------------- */
+
+//#define DEBUG_VERBOSE
+#include "uima/trace.hpp"
+#ifndef NDEBUG
+#include "uima/envvar.hpp"                              /* for debugIndicateProcessHasBeenPerformed(); */
+#include "uima/envvars.h"                               /* for debugIndicateProcessHasBeenPerformed(); */
+#endif
+
+#include "uima/comp_ids.h"
+#include "uima/resmgr.hpp"
+
+#include "uima/capability.hpp"
+#include "uima/log.hpp"
+
+/* ----------------------------------------------------------------------- */
+/*       Constants                                                         */
+/* ----------------------------------------------------------------------- */
+#define UIMA_ANNOTATOR_DELAYED_INFO_NOT_AVAILABLE _TEXT("Information not available for delayed loaded annotator")
+
+#define UIMA_ANNOTATOR_DEFAULT_UNSPECIFIED_TERRITORY  true
+#define UIMA_CONFIG_ANNOTATOR_PROCESS_UNSPECIFIED_TERRITORIES  _TEXT("ProcessUnspecifiedTerritories")
+
+/***
+#ifndef NDEBUG
+   #define UIMA_ANNOTATOR_INDICATE_PROCESS_FILE_EXTENSION _TEXT(".ind")
+#endif
+***/
+/* ----------------------------------------------------------------------- */
+/*       Types / Classes                                                   */
+/* ----------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+/*       Globals                                                           */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/*       Function declarations                                             */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/*       Macro definitions                                                 */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/*       Private Implementation                                            */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/*       Public implementation                                             */
+/* ----------------------------------------------------------------------- */
+namespace uima {
+  UIMA_EXC_CLASSIMPLEMENT(ExcEnumerationOverflow, ExcIllFormedInputError);
+
+
+  AnnotatorProxy::AnnotatorProxy(const util::Filename & crclFilename,
+                                 const TCHAR * cpszSymbolicName,
+                                 bool  bDelayLoad) :
+      iv_clFilename(crclFilename),
+      iv_strSymbolicName(cpszSymbolicName),
+      iv_cpclFile(0),
+      iv_bProcessUnspecifiedTerritories(UIMA_ANNOTATOR_DEFAULT_UNSPECIFIED_TERRITORY),
+      iv_hUserData(0),
+      iv_pAnnotatorContext(NULL)
+#ifdef DEBUG_ANNOTATOR_TIMING
+      ,iv_clTimerLoad()
+      ,iv_clTimerInit()
+      ,iv_clTimerDeInit()
+      ,iv_clTimerConfig()
+      ,iv_clTimerProcessDocument()
+      ,iv_clTimerBatchProcessComplete()
+      ,iv_clTimerCollectionProcessComplete()
+#endif
+      /* ----------------------------------------------------------------------- */
+  {
+    ;
+  }
+
+  AnnotatorProxy::~AnnotatorProxy(void)
+  /* ----------------------------------------------------------------------- */
+  {
+
+
+    if (!isLoadedDelayed()) {
+      unload();
+    }
+    /* make sure that unload() was performed before call to destructor */
+    assert(iv_cpclFile == 0);
+    assert(iv_hUserData == (uima::TyHandle) 0);
+
+  }  //lint !e1740: pointer member 'iv_cpclFile' 'iv_hUserData' not directly freed or zero'ed by destructor
+
+  bool AnnotatorProxy::isValid(void) const
+  /* ----------------------------------------------------------------------- */
+  {
+    assert(EXISTS(iv_cpclFile));
+    return(iv_cpclFile->isValid());
+  }
+
+  const util::Filename & AnnotatorProxy::getFilename(void) const
+  /* ----------------------------------------------------------------------- */
+  {
+    if (EXISTS(iv_cpclFile)) {
+      assert(iv_cpclFile->getFilename().matchesBase(iv_clFilename));
+
+      return(iv_cpclFile->getFilename());
+    } else {
+      return(iv_clFilename);
+    }
+  }
+
+
+  TyErrorId AnnotatorProxy::load(void)
+  /* ----------------------------------------------------------------------- */
+  {
+    util::Trace                 clTrace(util::enTraceDetailHigh, UIMA_TRACE_ORIGIN, UIMA_TRACE_COMPID_ANNOTATOR_MGR);
+    UIMA_ANNOTATOR_TIMING(iv_clTimerLoad.start());
+
+    clTrace.dump(_TEXT("Annotator"), getSymbolicName().c_str());
+    iv_cpclFile = ResourceManager::getInstance().requestAnnotatorFile(iv_clFilename);
+    assert(EXISTS(iv_cpclFile));
+
+    // (Dropped code that set iv_clFilename to name of annotator file without path & extension
+    //  as it is not used ... and the filename is no longer changed during the load.)
+    UIMA_ANNOTATOR_TIMING(iv_clTimerLoad.stop());
+
+    if (!(EXISTS(iv_cpclFile)) || iv_cpclFile->getErrorId() !=  UIMA_ERR_NONE) {
+      std::string err = "AnnotatorProxy::load() failed to load ";
+      err += iv_clFilename.getAsCString();
+      ResourceManager::getInstance().getLogger().logError(err);
+	}
+    return iv_cpclFile->getErrorId();
+	
+  }
+
+  TyErrorId AnnotatorProxy::loadDelayed(void)
+  /* ----------------------------------------------------------------------- */
+  {
+    iv_bDelayLoad = false;
+    return(load());
+  }
+
+  void AnnotatorProxy::unload(void)
+  /* ----------------------------------------------------------------------- */
+  {
+    util::Trace                 clTrace(util::enTraceDetailHigh, UIMA_TRACE_ORIGIN, UIMA_TRACE_COMPID_ANNOTATOR_MGR);
+
+    if (isLoadedDelayed()) {
+      return;
+    }
+    clTrace.dump(_TEXT("Annotator"), getSymbolicName().c_str());
+    clTrace.dump("unload...");
+
+    assert(EXISTS(iv_cpclFile));
+    /* make sure that deInit() was performed before call to unload() */
+    assert(NOTEXISTS(iv_hUserData));
+    iv_cpclFile = 0;
+  }
+
+  const char* AnnotatorProxy::getErrorMsg() const
+  /* ----------------------------------------------------------------------- */
+  {
+    if (EXISTS(iv_cpclFile))
+      return(iv_cpclFile->getErrorMsg());
+    else
+      return NULL;
+  }
+
+  TyErrorId AnnotatorProxy::init(AnnotatorContext & rAnnContext)
+  /* ----------------------------------------------------------------------- */
+  {
+    if (isLoadedDelayed()) {
+      return(init_delayed(rAnnContext));
+    } else {
+      return(init_now(rAnnContext));
+    }
+  }
+
+  TyErrorId AnnotatorProxy::init_delayed(AnnotatorContext & rAnnContext)
+  /* ----------------------------------------------------------------------- */
+  {
+    assertWithMsg(false, "Never tried");
+    return UIMA_ERR_NOT_YET_IMPLEMENTED;
+
+#ifdef DELAYED_LOADING_ENABLED
+    assert(isLoadedDelayed());
+    iv_pTCAS = & rTCAS;
+    iv_pAnnotatorContext = & rAnnContext;
+    util::Trace              clTrace(util::enTraceDetailHigh, UIMA_TRACE_ORIGIN, UIMA_TRACE_COMPID_ANNOTATOR_MGR);
+
+    // remember address of config control for a later call to init_now
+    // Note: we can't remember the rclConfig itself since it will go out of scope
+    iv_pclDelayConfigCtrl    = &rclConfig.getConfigCtrl();
+    // remember symbolic name for a later call to init_now
+    iv_strDelaySectionHeader = rclConfig.getSymbolicName();
+
+    /* Since we can't access the annotator to get enumeration of types/languages
+       etc. we have to assume this info has been specified in the ini file.
+    */
+    TyErrorId               utRetVal = UIMA_ERR_NONE;
+
+    // the ini value was a comma separated list of type names
+    iv_vecDelayLoadGeneratedTypes.clear();
+    rclConfig.delayLoadGeneratedTypes(iv_vecDelayLoadGeneratedTypes);
+    // To allow for easier configuration we assume that each type generated
+    // is supported for the "Unspecified-Language"
+    // That way the user has less to specify in the SupportedLanguagesForDelayedLoad
+    // option
+    TyTypenameContainer::iterator itTy1;
+    STL_FOR_EACH(itTy1, iv_vecDelayLoadGeneratedTypes) {
+      vector< Language > & rvecLanguages = iv_vecDelayLoadSupportedLanguages[(*itTy1)];
+      assert(rvecLanguages.size() == 0);
+      rvecLanguages.push_back(Language(Language::UNSPECIFIED));
+    }
+
+    // the ini value was a comma separated list of type names
+    iv_vecDelayLoadRequiredTypes.clear();
+    rclConfig.delayLoadRequiredTypes(iv_vecDelayLoadRequiredTypes);
+
+    // the ini value was a comma separated list of type names
+    iv_vecDelayLoadRecommendedTypes.clear();
+    rclConfig.delayLoadRecommendedTypes(iv_vecDelayLoadRecommendedTypes);
+
+    TyTypenameContainer vecTemp1;
+    // the ini value was a comma separated list of <type>:<lang>[:<lang>] expressions
+    rclConfig.delayLoadSupportedLanguages(vecTemp1);
+    // now look at each string of the form <type>:<lang>[:<lang>] and parse them
+    // into type and language-list part
+    TyTypenameContainer::const_iterator it1;
+    TyTypenameContainer vecTemp2;
+    TyTypenameContainer::iterator it2;
+    Language clLang(Language::INVALID);
+    STL_FOR_EACH(it1, vecTemp1) {
+      // parse colon (:) delimited list into separate strings
+      vecTemp2.clear();
+      delimitedString2Vector(vecTemp2,   // output vector
+                             (*it1),     // input string
+                             ":",        //lint !e918 delimiters : Prototype coercion of pointers
+                             true,       // trim string flag
+                             false       // insert empty strings flag
+                            );
+
+      it2 = vecTemp2.begin();
+      if (it2 == vecTemp2.end()) {
+        rAnnContext.getLogger().logError(UIMA_ERR_CONFIG_INVALID_OPTION_VALUE, UIMA_CONFIG_ANNOTATOR_DELAY_LOAD_SUPPORTED_LANGUAGES);
+        utRetVal = (TyErrorId)UIMA_ERR_CONFIG_INVALID_OPTION_VALUE;
+        break;
+      }
+      // get a reference to an either an existing entry (created above from
+      // delayLoadGeneratedTypes entries) or create a new and empty one.
+      vector< Language > & rvecLangList = iv_vecDelayLoadSupportedLanguages[(*it2)];
+      // if it existed as default from above throw away default value and
+      // overwrite with specified stuff from here
+      rvecLangList.clear();
+      ++it2;
+      for (; it2 != vecTemp2.end(); ++it2) {
+        clLang = Language((*it2));
+        if (!clLang.isValid()) {
+          rAnnContext.getLogger().logError(UIMA_ERR_CONFIG_INVALID_OPTION_VALUE, UIMA_CONFIG_ANNOTATOR_DELAY_LOAD_SUPPORTED_LANGUAGES);
+          utRetVal = (TyErrorId)UIMA_ERR_CONFIG_INVALID_OPTION_VALUE;
+          break;
+        }
+        rvecLangList.push_back(clLang);
+      }
+      if (utRetVal != UIMA_ERR_NONE) {
+        break;
+      }
+    }
+    clTrace.dump(_TEXT("rc"), utRetVal);
+
+    return(utRetVal);
+#endif
+  }
+
+  TyErrorId AnnotatorProxy::init_now(AnnotatorContext & rAnnotatorContext)
+  /* ----------------------------------------------------------------------- */
+  {
+    iv_pAnnotatorContext = & rAnnotatorContext;
+    assert(!isLoadedDelayed());
+    util::Trace                 clTrace(util::enTraceDetailHigh, UIMA_TRACE_ORIGIN, UIMA_TRACE_COMPID_ANNOTATOR_MGR);
+
+    clTrace.dump(_TEXT("Annotator"), getSymbolicName().c_str());
+    assert(EXISTS(iv_cpclFile));
+    assert(iv_cpclFile->isValid());
+
+    if (rAnnotatorContext.isParameterDefined(UIMA_CONFIG_ANNOTATOR_PROCESS_UNSPECIFIED_TERRITORIES)) {
+      /* optionally, check whether AnnotatorProxy should be processed for unspecified territories */
+      (void) rAnnotatorContext.extractValue(UIMA_CONFIG_ANNOTATOR_PROCESS_UNSPECIFIED_TERRITORIES, iv_bProcessUnspecifiedTerritories);
+    }
+    if (iv_bProcessUnspecifiedTerritories) {
+      clTrace.dump(UIMA_CONFIG_ANNOTATOR_PROCESS_UNSPECIFIED_TERRITORIES _TEXT(" enabled!"));
+    }
+
+    TyAnnotatorSignatureMakeAE procMaker  = (TyAnnotatorSignatureMakeAE) iv_cpclFile->getProcedure("makeAE");
+    assert(EXISTS(procMaker));
+    if (NOTEXISTS(procMaker)) {
+      ResourceManager::getInstance().getLogger().logError("AnnotatorProxy::init_now() Could not get procedure makeAE() ");
+      return (UIMA_ERR_ANNOTATOR_MISSING_CREATE);
+    }
+    /* first we need to trigger the creation of the AnnotatorProxy's object ... */
+    clTrace.dump("CreateAnnotator...");
+    UIMA_ANNOTATOR_TIMING(iv_clTimerInit.start());
+    iv_hUserData= (procMaker) ();
+    UIMA_ANNOTATOR_TIMING(iv_clTimerInit.stop());
+    clTrace.dumpAdrs(_TEXT("Annotator Handle"), (const void *) iv_hUserData);   //lint !e911
+    if (NOTEXISTS(iv_hUserData)) {
+      ResourceManager::getInstance().getLogger().logError("AnnotatorProxy::init_now() Could not instantiate annotator ");
+      return(UIMA_ERR_ANNOTATOR_COULD_NOT_CREATE);
+    }
+    /* ... then we initialize the AnnotatorProxy */
+    clTrace.dump("InitializeAnnotator...");
+    UIMA_ANNOTATOR_TIMING(iv_clTimerInit.start());
+    //? AnnotatorContext & rclAnnotatorContext = REINTERPRET_CAST(AnnotatorContext &, rclEngine);
+//      AnnotatorContext & rclAnnotatorContext = (AnnotatorContext &) rclEngine;
+    ///utRetVal = (procInit)(rAnnotatorContext, iv_hUserData);
+    iv_hUserData->setAnnotatorContext(rAnnotatorContext);
+    TyErrorId utRetVal = iv_hUserData->initialize(rAnnotatorContext);
+
+    UIMA_ANNOTATOR_TIMING(iv_clTimerInit.stop());
+    clTrace.dump(_TEXT("rc"), utRetVal);
+    return(utRetVal);
+  }
+
+  TyErrorId AnnotatorProxy::deInit(void)
+  /* ----------------------------------------------------------------------- */
+  {
+    util::Trace                 clTrace(util::enTraceDetailHigh, UIMA_TRACE_ORIGIN, UIMA_TRACE_COMPID_ANNOTATOR_MGR);
+
+    clTrace.dump(_TEXT("Annotator"), getSymbolicName().c_str());
+
+    if (isLoadedDelayed()) {
+      // if we have been delayed until now we have nothing to deinit
+      return(TyErrorId)UIMA_ERR_NONE;
+    }
+    assert(EXISTS(iv_cpclFile));
+    assert(iv_cpclFile->isValid());
+    assert(EXISTS(iv_hUserData));
+    clTrace.dump("DestroyAnnotator...");
+    UIMA_ANNOTATOR_TIMING(iv_clTimerDeInit.start());
+    TyErrorId utRetVal = iv_hUserData->destroy();
+
+    UIMA_ANNOTATOR_TIMING(iv_clTimerDeInit.stop());
+    clTrace.dump(_TEXT("rc"), utRetVal);
+    /* at this point, the user data may not be used any more */
+    iv_hUserData = 0;
+    return(utRetVal);
+  }
+
+  TyErrorId AnnotatorProxy::typeSystemInit(uima::TypeSystem const & typeSystem) {
+    util::Trace             clTrace(util::enTraceDetailMedium, UIMA_TRACE_ORIGIN, UIMA_TRACE_COMPID_ANNOTATOR_MGR);
+    TyErrorId               utRetVal = UIMA_ERR_NONE;
+    utRetVal = iv_hUserData->typeSystemInit(typeSystem);
+    return utRetVal;
+  }
+
+
+  TyErrorId AnnotatorProxy::reConfig()
+  /* ----------------------------------------------------------------------- */
+  {
+    util::Trace             clTrace(util::enTraceDetailMedium, UIMA_TRACE_ORIGIN, UIMA_TRACE_COMPID_ANNOTATOR_MGR);
+    TyErrorId               utRetVal = UIMA_ERR_NONE;
+
+    // if we are not loaded yet we have nothing to do: the annotator will access
+    // modified configuration once/if it is finaly loaded
+    if (isLoadedDelayed()) {
+      clTrace.dump(_TEXT("rc"), utRetVal);
+      return((TyErrorId) utRetVal);
+    }
+    assert(EXISTS(iv_cpclFile));
+    assert(iv_cpclFile->isValid());
+    assert( EXISTS(iv_pAnnotatorContext) );
+    if (iv_pAnnotatorContext->isParameterDefined(UIMA_CONFIG_ANNOTATOR_PROCESS_UNSPECIFIED_TERRITORIES)) {
+      /* optionally, check whether Annotator should be processed for unspecified territories */
+      (void) iv_pAnnotatorContext->extractValue(UIMA_CONFIG_ANNOTATOR_PROCESS_UNSPECIFIED_TERRITORIES, iv_bProcessUnspecifiedTerritories);
+    }
+    clTrace.dump("ReconfigureAnnotator...");
+    UIMA_ANNOTATOR_TIMING(iv_clTimerConfig.start());
+    utRetVal = iv_hUserData->reconfigure();
+    UIMA_ANNOTATOR_TIMING(iv_clTimerConfig.stop());
+    clTrace.dump(_TEXT("rc"), utRetVal);
+    return(utRetVal);
+  }
+
+  TyErrorId AnnotatorProxy::doProcessDocument(CAS & cas, AnnotatorContext & rAnnContext, ResultSpecification const & crResultSpec)
+  /* ----------------------------------------------------------------------- */
+  {
+    util::Trace             clTrace(util::enTraceDetailMedium, UIMA_TRACE_ORIGIN, UIMA_TRACE_COMPID_ANNOTATOR_MGR);
+    TyErrorId               utErrorId = UIMA_ERR_NONE;
+
+    clTrace.dump(_TEXT("Annotator"), getSymbolicName().c_str());
+
+    if (isLoadedDelayed()) {
+      assertWithMsg(false, "Delayed loading could result in errors due to already committed type system!");
+#ifdef DELAYED_LOADING_ENABLED
+      utErrorId = loadDelayed();
+      clTrace.dump(_TEXT("Delayed Load:"), (long)utErrorId);
+      /* could be loaded? */
+      if (utErrorId != UIMA_ERR_NONE) {
+        rAnnContext.getLogger().logError(utErrorId, getFilename().getAsCString());   //lint !e713: Loss of precision (arg. no. 1) (unsigned long to long)
+        clTrace.dump(_TEXT("Delayed load error"), (long) utErrorId);
+        /****
+        #ifndef NDEBUG
+                    debugIndicateProcessHasBeenPerformed(rTCAS, rAnnContext, utErrorId);
+        #endif
+        ***/
+        return(utErrorId);
+      }
+      assert(EXISTS(iv_pclDelayConfigCtrl));
+      /* extract annotator info for symbolic name */
+      ConfigAnnotator clConfigAnnotator(*iv_pclDelayConfigCtrl, iv_strDelaySectionHeader);
+      utErrorId = clConfigAnnotator.init();
+      if (utErrorId != UIMA_ERR_NONE) {
+        rAnnContext.getLogger().logError(utErrorId, getFilename().getAsCString());   //lint !e713: Loss of precision (arg. no. 1) (unsigned long to long)
+        clTrace.dump(_TEXT("Delayed config access error"), (long) utErrorId);
+        /***
+        #ifndef NDEBUG
+                    debugIndicateProcessHasBeenPerformed(rTCAS, rAnnContext, utErrorId);
+        #endif
+        ***/
+        return(utErrorId);
+      }
+
+      utErrorId = init_now(rAnnContext, clConfigAnnotator);
+      /* could be initialized? */
+      if (utErrorId != UIMA_ERR_NONE) {
+        rAnnContext.getLogger().logError(utErrorId, getFilename().getAsCString());   //lint !e713: Loss of precision (arg. no. 1) (unsigned long to long)
+        clTrace.dump(_TEXT("Delayed init error"), (long) utErrorId);
+        /***
+        #ifndef NDEBUG
+                    debugIndicateProcessHasBeenPerformed(cas, rAnnContext, utErrorId);
+        #endif
+        ***/
+        return(utErrorId);
+      }
+#endif
+    }
+    clTrace.dump("ProcessDocument????");
+
+    assert(EXISTS(iv_cpclFile));
+    assert(iv_cpclFile->isValid());
+    assert(EXISTS(iv_hUserData));
+    utErrorId = iv_hUserData->process(cas, crResultSpec);
+    clTrace.dump(_TEXT("rc"), utErrorId);
+    return(utErrorId);
+  }
+
+  TyErrorId AnnotatorProxy::processDocument(CAS & cas, ResultSpecification const & crResultSpec)
+  /* ----------------------------------------------------------------------- */
+  {
+    util::Trace            clTrace(util::enTraceDetailMedium, UIMA_TRACE_ORIGIN, UIMA_TRACE_COMPID_ANNOTATOR_MGR);
+    TyErrorId utErrorId = UIMA_ERR_NONE;
+
+    UIMA_ANNOTATOR_TIMING(iv_clTimerProcessDocument.start());
+    assert( EXISTS(iv_pAnnotatorContext) );
+    utErrorId = doProcessDocument(cas, *iv_pAnnotatorContext, crResultSpec);
+    UIMA_ANNOTATOR_TIMING(iv_clTimerProcessDocument.stop());
+    return utErrorId;
+  }
+
+
+
+  TyErrorId AnnotatorProxy::batchProcessComplete()
+  /* ----------------------------------------------------------------------- */
+  {
+    util::Trace             clTrace(util::enTraceDetailMedium, UIMA_TRACE_ORIGIN, UIMA_TRACE_COMPID_ANNOTATOR_MGR);
+    TyErrorId               utRetVal = UIMA_ERR_NONE;
+
+    // if we are not loaded yet we have nothing to do: the annotator will access
+    // modified configuration once/if it is finaly loaded
+    if (isLoadedDelayed()) {
+      clTrace.dump(_TEXT("rc"), utRetVal);
+      return((TyErrorId) utRetVal);
+    }
+    assert(EXISTS(iv_cpclFile));
+    assert(iv_cpclFile->isValid());
+    assert(EXISTS(iv_hUserData));
+    assert( EXISTS(iv_pAnnotatorContext) );
+    if (iv_pAnnotatorContext->isParameterDefined(UIMA_CONFIG_ANNOTATOR_PROCESS_UNSPECIFIED_TERRITORIES)) {
+      /* optionally, check whether Annotator should be processed for unspecified territories */
+      (void) iv_pAnnotatorContext->extractValue(UIMA_CONFIG_ANNOTATOR_PROCESS_UNSPECIFIED_TERRITORIES, iv_bProcessUnspecifiedTerritories);
+    }
+    /* pass control to the Annotator */
+    clTrace.dump("BatchprocessingcompleteAnnotator...");
+    UIMA_ANNOTATOR_TIMING(iv_clTimerBatchProcessComplete.start());
+    utRetVal = iv_hUserData->batchProcessComplete();
+    UIMA_ANNOTATOR_TIMING(iv_clTimerBatchProcessComplete.stop());
+    clTrace.dump(_TEXT("rc"), utRetVal);
+    return(utRetVal);
+  }
+
+  TyErrorId AnnotatorProxy::collectionProcessComplete()
+  /* ----------------------------------------------------------------------- */
+  {
+    util::Trace             clTrace(util::enTraceDetailMedium, UIMA_TRACE_ORIGIN, UIMA_TRACE_COMPID_ANNOTATOR_MGR);
+    TyErrorId               utRetVal = UIMA_ERR_NONE;
+
+    // if we are not loaded yet we have nothing to do: the annotator will access
+    // modified configuration once/if it is finaly loaded
+    if (isLoadedDelayed()) {
+      clTrace.dump(_TEXT("rc"), utRetVal);
+      return((TyErrorId) utRetVal);
+    }
+    assert(EXISTS(iv_cpclFile));
+    assert(iv_cpclFile->isValid());
+    assert(EXISTS(iv_hUserData));
+    assert( EXISTS(iv_pAnnotatorContext) );
+    if (iv_pAnnotatorContext->isParameterDefined(UIMA_CONFIG_ANNOTATOR_PROCESS_UNSPECIFIED_TERRITORIES)) {
+      /* optionally, check whether Annotator should be processed for unspecified territories */
+      (void) iv_pAnnotatorContext->extractValue(UIMA_CONFIG_ANNOTATOR_PROCESS_UNSPECIFIED_TERRITORIES, iv_bProcessUnspecifiedTerritories);
+    }
+    clTrace.dump("CollectionprocessingcompleteAnnotator...");
+    UIMA_ANNOTATOR_TIMING(iv_clTimerCollectionProcessComplete.start());
+    utRetVal = iv_hUserData->collectionProcessComplete();
+    UIMA_ANNOTATOR_TIMING(iv_clTimerCollectionProcessComplete.stop());
+    clTrace.dump(_TEXT("rc"), utRetVal);
+    return(utRetVal);
+  }
+
+
+  bool AnnotatorProxy::hasNext()
+  /* ----------------------------------------------------------------------- */
+  {
+    util::Trace              clTrace(util::enTraceDetailMedium, UIMA_TRACE_ORIGIN, UIMA_TRACE_COMPID_ANNOTATOR_MGR);
+
+    // if we are not loaded yet we have nothing to do: the annotator will access
+    // modified configuration once/if it is finaly loaded
+    if (isLoadedDelayed()) {
+      return false;
+    }
+    assert(EXISTS(iv_cpclFile));
+    assert(iv_cpclFile->isValid());
+    assert(EXISTS(iv_hUserData));
+    assert( EXISTS(iv_pAnnotatorContext) );
+    if (iv_pAnnotatorContext->isParameterDefined(UIMA_CONFIG_ANNOTATOR_PROCESS_UNSPECIFIED_TERRITORIES)) {
+      /* optionally, check whether Annotator should be processed for unspecified territories */
+      (void) iv_pAnnotatorContext->extractValue(UIMA_CONFIG_ANNOTATOR_PROCESS_UNSPECIFIED_TERRITORIES, iv_bProcessUnspecifiedTerritories);
+    }
+    clTrace.dump("HasnextAnnotator...");
+    UIMA_ANNOTATOR_TIMING(iv_clTimerHasNext.start());
+    bool hasNext = iv_hUserData->hasNext();
+    UIMA_ANNOTATOR_TIMING(iv_clTimerHasNext.stop());
+
+    return(hasNext);
+  }
+
+
+  CAS &  AnnotatorProxy::next()
+  /* ----------------------------------------------------------------------- */
+  {
+    util::Trace              clTrace(util::enTraceDetailMedium, UIMA_TRACE_ORIGIN, UIMA_TRACE_COMPID_ANNOTATOR_MGR);
+
+    // if we are not loaded yet we have nothing to do: the annotator will access
+    // modified configuration once/if it is finaly loaded
+    /** why do this check (bi)
+       if (isLoadedDelayed()) {
+          return NULL;
+       } **/
+
+    assert(EXISTS(iv_cpclFile));
+    assert(iv_cpclFile->isValid());
+    assert(EXISTS(iv_hUserData));
+    assert( EXISTS(iv_pAnnotatorContext) );
+    if (iv_pAnnotatorContext->isParameterDefined(UIMA_CONFIG_ANNOTATOR_PROCESS_UNSPECIFIED_TERRITORIES)) {
+      /* optionally, check whether Annotator should be processed for unspecified territories */
+      (void) iv_pAnnotatorContext->extractValue(UIMA_CONFIG_ANNOTATOR_PROCESS_UNSPECIFIED_TERRITORIES, iv_bProcessUnspecifiedTerritories);
+    }
+    clTrace.dump("NextAnnotator...");
+    UIMA_ANNOTATOR_TIMING(iv_clTimerHasNext.start());
+    CAS & cas = iv_hUserData->next();
+    UIMA_ANNOTATOR_TIMING(iv_clTimerHasNext.stop());
+
+    return(cas);
+  }
+
+  int  AnnotatorProxy::getCasInstancesRequired()
+  /* ----------------------------------------------------------------------- */
+  {
+    util::Trace              clTrace(util::enTraceDetailMedium, UIMA_TRACE_ORIGIN, UIMA_TRACE_COMPID_ANNOTATOR_MGR);
+
+    // if we are not loaded yet we have nothing to do: the annotator will access
+    // modified configuration once/if it is finaly loaded
+    if (isLoadedDelayed()) {
+
+      return 0;
+    }
+    assert(EXISTS(iv_cpclFile));
+    assert(iv_cpclFile->isValid());
+    assert(EXISTS(iv_hUserData));
+    assert( EXISTS(iv_pAnnotatorContext) );
+    if (iv_pAnnotatorContext->isParameterDefined(UIMA_CONFIG_ANNOTATOR_PROCESS_UNSPECIFIED_TERRITORIES)) {
+      /* optionally, check whether Annotator should be processed for unspecified territories */
+      (void) iv_pAnnotatorContext->extractValue(UIMA_CONFIG_ANNOTATOR_PROCESS_UNSPECIFIED_TERRITORIES, iv_bProcessUnspecifiedTerritories);
+    }
+    clTrace.dump("GetcasinstancesrequiredAnnotator...");
+    UIMA_ANNOTATOR_TIMING(iv_clTimerHasNext.start());
+    int max = iv_hUserData->getCasInstancesRequired();
+    UIMA_ANNOTATOR_TIMING(iv_clTimerHasNext.stop());
+
+    return(max);
+  }
+
+}
+/* <EOF> */
+

Propchange: incubator/uima/uimacpp/trunk/src/framework/annotator.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/uima/uimacpp/trunk/src/framework/annotator_context.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/framework/annotator_context.cpp?view=auto&rev=503250
==============================================================================
--- incubator/uima/uimacpp/trunk/src/framework/annotator_context.cpp (added)
+++ incubator/uima/uimacpp/trunk/src/framework/annotator_context.cpp Sat Feb  3 08:57:13 2007
@@ -0,0 +1,619 @@
+/** \file annotator_context.cpp .
+-----------------------------------------------------------------------------
+
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------- */
+#include "uima/pragmas.hpp" //must be included first to disable warnings
+#include "uima/err_ids.h"
+#include "uima/msg.h"
+#include "uima/log.hpp"
+#include "uima/annotator_context.hpp"
+#include "uima/taespecifier.hpp"
+#include "uima/config_param.hpp"
+#include "uima/taespecifierbuilder.hpp"
+#include "uima/internal_casimpl.hpp"
+
+namespace uima {
+
+#define CTX_DEFAULT_TEXT_SOFA_NAME  "_DefaultTextSofaName"
+
+  AnnotatorContext::AnnotatorContext(AnalysisEngineDescription * delegateSpec,
+                                     AnnotatorContext * parent,
+                                     const icu::UnicodeString & ancKey)
+      :iv_pParentAnC(parent), iv_AnCKey(ancKey),
+      iv_pTaeSpecifier(delegateSpec), iv_mapDelegateAncs(), iv_pCasPool(NULL)  {
+    buildDelegateAnCs();
+    iv_pLogger = new LogFacility( delegateSpec->getAnalysisEngineMetaData()->getName() );
+    assert(EXISTS(iv_pLogger) );
+    bOwnsTaeSpecifier=false;
+  }
+
+  AnnotatorContext::AnnotatorContext(AnalysisEngineDescription * taeSpec)
+      :iv_pParentAnC(NULL), iv_AnCKey(""), iv_pTaeSpecifier(taeSpec),
+      iv_mapDelegateAncs(), iv_pCasPool(NULL) {
+    buildDelegateAnCs();
+    iv_pLogger = new LogFacility( taeSpec->getAnalysisEngineMetaData()->getName() );
+    assert(EXISTS(iv_pLogger) );
+    bOwnsTaeSpecifier=false;
+  }
+
+
+
+  AnnotatorContext::AnnotatorContext(AnalysisEngineDescription * delegateSpec,
+                                     AnnotatorContext * parent,
+                                     const icu::UnicodeString & ancKey,
+                                     const AnalysisEngineDescription::TyVecpSofaMappings & vecSofaMappings)
+      :iv_pParentAnC(parent), iv_AnCKey(ancKey),
+      iv_pTaeSpecifier(delegateSpec), iv_mapDelegateAncs(), iv_pCasPool(NULL) {
+    //process the sofa mappings
+    AnalysisEngineDescription::TyVecpSofaMappings::const_iterator iter;
+
+    for (iter = vecSofaMappings.begin(); iter != vecSofaMappings.end(); ++iter) {
+      SofaMapping * sofamap = * iter;
+      //if this sofamapping is for this context
+      if (sofamap->getComponentKey().compare(ancKey) == 0) {
+        // add mapping to this context sofa mapping
+        // where component sofa name is the key and
+        // aggregate sofaname is the value
+        // if component sofa name is not set,
+        // set it to the default for tcas sofas.
+        if (sofamap->getComponentSofaName().length() == 0) {
+          icu::UnicodeString ustr(CAS::NAME_DEFAULT_TEXT_SOFA);
+          sofamap->setComponentSofaName(ustr);
+        }
+        SofaID * pSofaid = new SofaID();
+        pSofaid->setSofaId(sofamap->getAggregateSofaName());
+        pSofaid->setComponentSofaName(sofamap->getComponentSofaName());
+        icu::UnicodeString astr = sofamap->getComponentSofaName();
+        iv_mapSofaMappings[astr] = pSofaid;
+
+        //if this delegate is an aggregate and has sofamapping
+        //check if somponent sofaname is specified as the
+        //aggregate sofa name in this delegate specifier
+        //if so update that aggregate sofa name
+        if (!delegateSpec->isPrimitive()) {
+          AnalysisEngineDescription::TyVecpSofaMappings delegateSofaMappings = delegateSpec->getSofaMappings();
+          if (delegateSofaMappings.size() > 0 ) {
+            AnalysisEngineDescription::TyVecpSofaMappings::const_iterator iter;
+
+            for (iter = delegateSofaMappings.begin(); iter != delegateSofaMappings.end(); ++iter) {
+              SofaMapping  * delsofamap = * iter;
+              if (delsofamap->getAggregateSofaName().compare(astr)==0) {
+                delsofamap->setAggregateSofaName(pSofaid->getSofaId());
+              }
+            }
+
+
+          }
+        }
+
+
+      }
+
+    }
+
+    buildDelegateAnCs();
+
+    iv_pLogger = new LogFacility( delegateSpec->getAnalysisEngineMetaData()->getName() );
+    assert(EXISTS(iv_pLogger) );
+    bOwnsTaeSpecifier=false;
+  }
+
+
+  AnnotatorContext::~AnnotatorContext(void) {
+    TyMapDelegateAnCs::iterator ite;
+    for (ite=iv_mapDelegateAncs.begin(); ite != iv_mapDelegateAncs.end(); ite++) {
+      delete (ite->second);
+    }
+    //BSI
+    TyMapSofaMappings::iterator ite2;
+    for (ite2=iv_mapSofaMappings.begin(); ite2 != iv_mapSofaMappings.end(); ite2++) {
+      delete (ite2->second);
+    }
+
+    if (EXISTS(iv_pLogger) )
+      delete iv_pLogger;
+
+    if (bOwnsTaeSpecifier) {
+      delete iv_pTaeSpecifier;
+    }
+
+    if (iv_pCasPool != NULL) {
+      delete iv_pCasPool;
+    }
+  }
+
+
+  CAS & AnnotatorContext::getEmptyCAS()  {
+
+    if (iv_pCasPool)
+      return iv_pCasPool->getCAS();
+    else {
+      UIMA_EXC_THROW_NEW(CASPoolException,
+                         UIMA_ERR_CASPOOL_CREATE_CAS,
+                         UIMA_MSG_ID_EXC_CREATE_CASPOOL,
+                         UIMA_MSG_ID_EXC_CREATE_CASPOOL,
+                         ErrorInfo::unrecoverable);
+    }
+  }
+
+  void AnnotatorContext::releaseCAS(CAS & aCas) {
+    if (iv_pCasPool)
+      iv_pCasPool->releaseCAS(aCas);
+  }
+
+  TyErrorId AnnotatorContext::defineCASPool(size_t numInstances) {
+    iv_pCasPool = new CASPool(getTaeSpecifier(),numInstances);
+    if (iv_pCasPool == NULL) {
+      return UIMA_ERR_USER_ANNOTATOR_OUT_OF_MEMORY;
+    }
+    return UIMA_ERR_NONE;
+  }
+
+  AnnotatorContext * AnnotatorContext::getDelegate(const icu::UnicodeString & key) const {
+    TyMapDelegateAnCs::const_iterator ite = iv_mapDelegateAncs.find(key);
+    if (ite != iv_mapDelegateAncs.end()) {
+      return ite->second;
+    } else {
+      return NULL;
+    }
+  }
+
+  AnnotatorContext * AnnotatorContext::extractDelegate(const icu::UnicodeString & key) {
+    TyMapDelegateAnCs::iterator ite = iv_mapDelegateAncs.find(key);
+    if (ite != iv_mapDelegateAncs.end()) {
+      AnnotatorContext * anCon = ite->second;
+      iv_mapDelegateAncs.erase(ite);
+      return anCon;
+    } else {
+      return NULL;
+    }
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & paramName,
+                                          const bool & value) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::BOOLEAN, ConfigurationParameter::SINGLE_VALUE);
+    nvPair.setValue(value);
+    return setNameValuePair(nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & paramName,
+                                          const vector< bool > & values) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::BOOLEAN, ConfigurationParameter::MULTIPLE_VALUES);
+    for (size_t i=0; i < values.size(); i++) {
+      nvPair.addValue(values[i]);
+    }
+    return setNameValuePair(nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & paramName,
+                                          const int & value) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::INTEGER, ConfigurationParameter::SINGLE_VALUE);
+    nvPair.setValue(value);
+    return setNameValuePair(nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & paramName,
+                                          const vector< int > & values) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::INTEGER, ConfigurationParameter::MULTIPLE_VALUES);
+    for (size_t i=0; i < values.size(); i++) {
+      nvPair.addValue(values[i]);
+    }
+    return setNameValuePair(nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & paramName,
+                                          const size_t & value) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::INTEGER, ConfigurationParameter::SINGLE_VALUE);
+    nvPair.setValue((int)value);
+    return setNameValuePair(nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & paramName,
+                                          const vector< size_t > & values) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::INTEGER, ConfigurationParameter::MULTIPLE_VALUES);
+    for (size_t i=0; i < values.size(); i++) {
+      nvPair.addValue((int)values[i]);
+    }
+    return setNameValuePair(nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & paramName,
+                                          const float & value) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::FLOAT, ConfigurationParameter::SINGLE_VALUE);
+    nvPair.setValue(value);
+    return setNameValuePair(nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & paramName,
+                                          const vector< float > & values) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::FLOAT, ConfigurationParameter::MULTIPLE_VALUES);
+    for (size_t i=0; i < values.size(); i++) {
+      nvPair.addValue(values[i]);
+    }
+    return setNameValuePair(nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & paramName,
+                                          const double & value) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::FLOAT, ConfigurationParameter::SINGLE_VALUE);
+    nvPair.setValue((float)value);
+    return setNameValuePair(nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & paramName,
+                                          const vector< double > & values) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::FLOAT, ConfigurationParameter::MULTIPLE_VALUES);
+    for (size_t i=0; i < values.size(); i++) {
+      nvPair.addValue((float)values[i]);
+    }
+    return setNameValuePair(nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & paramName,
+                                          const icu::UnicodeString & value) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::STRING, ConfigurationParameter::SINGLE_VALUE);
+    nvPair.setValue(value);
+    return setNameValuePair(nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & paramName,
+                                          const vector< icu::UnicodeString > & values) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::STRING, ConfigurationParameter::MULTIPLE_VALUES);
+    for (size_t i=0; i <values.size(); i++) {
+      nvPair.addValue(values[i]);
+    }
+    return setNameValuePair(nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & groupName,
+                                          const icu::UnicodeString & paramName,
+                                          const bool & value) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::BOOLEAN, ConfigurationParameter::SINGLE_VALUE);
+    nvPair.setValue(value);
+    return setNameValuePair(groupName, nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & groupName,
+                                          const icu::UnicodeString & paramName,
+                                          const vector< bool > & values) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::BOOLEAN, ConfigurationParameter::MULTIPLE_VALUES);
+    for (size_t i=0; i < values.size(); i++) {
+      nvPair.addValue(values[i]);
+    }
+    return setNameValuePair(groupName, nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & groupName,
+                                          const icu::UnicodeString & paramName,
+                                          const int & value) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::INTEGER, ConfigurationParameter::SINGLE_VALUE);
+    nvPair.setValue(value);
+    return setNameValuePair(groupName, nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & groupName,
+                                          const icu::UnicodeString & paramName,
+                                          const vector< int > & values) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::INTEGER, ConfigurationParameter::MULTIPLE_VALUES);
+    for (size_t i=0; i < values.size(); i++) {
+      nvPair.addValue(values[i]);
+    }
+    return setNameValuePair(groupName, nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & groupName,
+                                          const icu::UnicodeString & paramName,
+                                          const size_t & value) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::INTEGER, ConfigurationParameter::SINGLE_VALUE);
+    nvPair.setValue((int)value);
+    return setNameValuePair(groupName, nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & groupName,
+                                          const icu::UnicodeString & paramName,
+                                          const vector< size_t > & values) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::INTEGER, ConfigurationParameter::MULTIPLE_VALUES);
+    for (size_t i=0; i < values.size(); i++) {
+      nvPair.addValue((int)values[i]);
+    }
+    return setNameValuePair(groupName, nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & groupName,
+                                          const icu::UnicodeString & paramName,
+                                          const float & value) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::FLOAT, ConfigurationParameter::SINGLE_VALUE);
+    nvPair.setValue(value);
+    return setNameValuePair(groupName, nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & groupName,
+                                          const icu::UnicodeString & paramName,
+                                          const vector< float > & values) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::FLOAT, ConfigurationParameter::MULTIPLE_VALUES);
+    for (size_t i=0; i < values.size(); i++) {
+      nvPair.addValue(values[i]);
+    }
+    return setNameValuePair(groupName, nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & groupName,
+                                          const icu::UnicodeString & paramName,
+                                          const double & value) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::FLOAT, ConfigurationParameter::SINGLE_VALUE);
+    nvPair.setValue((float)value);
+    return setNameValuePair(groupName, nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & groupName,
+                                          const icu::UnicodeString & paramName,
+                                          const vector< double > & values) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::FLOAT, ConfigurationParameter::MULTIPLE_VALUES);
+    for (size_t i=0; i < values.size(); i++) {
+      nvPair.addValue((float)values[i]);
+    }
+    return setNameValuePair(groupName, nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & groupName,
+                                          const icu::UnicodeString & paramName,
+                                          const icu::UnicodeString & value) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::STRING, ConfigurationParameter::SINGLE_VALUE);
+    nvPair.setValue(value);
+    return setNameValuePair(groupName, nvPair);
+  }
+
+  TyErrorId AnnotatorContext::assignValue(const icu::UnicodeString & groupName,
+                                          const icu::UnicodeString & paramName,
+                                          const vector< icu::UnicodeString > & values) {
+    NameValuePair nvPair;
+    nvPair.setName(paramName);
+    nvPair.define(ConfigurationParameter::STRING, ConfigurationParameter::MULTIPLE_VALUES);
+    for (size_t i=0; i <values.size(); i++) {
+      nvPair.addValue(values[i]);
+    }
+    return setNameValuePair(groupName, nvPair);
+  }
+
+  const AnalysisEngineMetaData::TyVecpFSIndexDescriptions AnnotatorContext::getFSIndexDescriptions() const {
+    AnalysisEngineMetaData::TyVecpFSIndexDescriptions allDescs;
+    const AnalysisEngineMetaData::TyVecpFSIndexDescriptions & myDescs =
+      iv_pTaeSpecifier->getAnalysisEngineMetaData()->getFSIndexDescriptions();
+    size_t i;
+    for (i=0; i < myDescs.size(); i++) {
+      allDescs.push_back(myDescs[i]);
+    }
+    TyMapDelegateAnCs::const_iterator ite;
+    for (ite=iv_mapDelegateAncs.begin(); ite != iv_mapDelegateAncs.end(); ite++) {
+      const AnalysisEngineMetaData::TyVecpFSIndexDescriptions & delDesc = ite->second->getFSIndexDescriptions();
+      for (i=0; i < delDesc.size(); i++) {
+        allDescs.push_back(delDesc[i]);
+      }
+    }
+    return allDescs;
+  }
+
+  NameValuePair const *
+  AnnotatorContext::findNameValuePair(const icu::UnicodeString & groupName,
+                                      const icu::UnicodeString & paramName,
+                                      AnalysisEngineMetaData::EnSearchStrategy strategy,
+                                      const icu::UnicodeString & ancKey) const {
+    NameValuePair const * pValueLocal = iv_pTaeSpecifier->getNameValuePair(groupName, paramName, strategy, ancKey);
+
+    // the request was invalid we got an exception we leave to others to catch
+
+    //now check whether the parent has the value as well
+    if (EXISTS(iv_pParentAnC)) {//if it's not the top-most AnC
+      //if the parent has the value, errId and nvPair will be set correctly
+      NameValuePair const * pValueParent = NULL;
+      try {
+        pValueParent = iv_pParentAnC->findNameValuePair(groupName, paramName, strategy, iv_AnCKey);
+      } catch (ConfigException e) {
+        // a parameter may not even be defined at our parent AnC
+        // but this is not an error - so we just continue
+        assert(pValueParent == NULL);
+      }
+      if (pValueParent != NULL) {
+        return pValueParent;
+      }
+      //otherwise, nvPair will still contain the NameValuePair found in this AnC
+      //(or is still not set, if this AnC doesn't have the value)
+    }
+    return pValueLocal;
+  }
+
+  /**
+  * Almost clone of <code>findNameValuePair</code> with 4 params.
+  * Reason for cloning: we have to call a different <code>findNameValuePair</code> of the
+  * parent than in the other version, i.e. one that returns the default value of the parent, not
+  * the value in the parent of the default group of this AnC.
+  **/
+  NameValuePair const * AnnotatorContext::findNameValuePair(const icu::UnicodeString & paramName,
+      const icu::UnicodeString & ancKey) const {
+    /*       return findNameValuePair(getGroupNameWhenNotSpec(), paramName, iv_pTaeSpecifier->getSearchStrategy()); */
+    NameValuePair const * pValueLocal = pValueLocal = iv_pTaeSpecifier->getNameValuePair(paramName, ancKey);
+
+    // the request was invalid we got an exception we leave to others to catch
+
+    //now check whether the parent has the value as well
+    if (EXISTS(iv_pParentAnC)) {//if it's not the top-most AnC
+      //if the parent has the value, errId and nvPair will be set correctly
+      NameValuePair const * pValueParent = NULL;
+      try {
+        pValueParent = iv_pParentAnC->findNameValuePair(paramName, iv_AnCKey);
+      } catch (ConfigException e) {
+        // a parameter may not even be defined at our parent AnC
+        // but this is not an error - so we just continue
+        assert(pValueParent == NULL);
+      }
+      if (pValueParent != NULL) {
+        return pValueParent;
+      }
+      //otherwise, nvPair will still contain the NameValuePair found in this AnC
+      //(or is still not set, if this AnC doesn't have the value)
+    }
+    return pValueLocal;
+  }
+
+  TyErrorId AnnotatorContext::setNameValuePair(const NameValuePair & nvPair) {
+
+    TyErrorId errId=UIMA_ERR_CONFIG_INVALID_PARAM_NAME;
+    if (EXISTS(iv_pParentAnC)) {
+      errId = iv_pParentAnC->setNameValuePair(nvPair);
+    }
+
+    if (errId != UIMA_ERR_NONE) {//there's either no parent or the nvPair couldn't be set at the parent
+      errId = iv_pTaeSpecifier->setNameValuePair(nvPair);
+    }
+    return errId;
+  }
+
+  TyErrorId AnnotatorContext::setNameValuePair(const icu::UnicodeString & groupName,
+      const NameValuePair & nvPair) {
+
+    TyErrorId errId=UIMA_ERR_CONFIG_INVALID_PARAM_NAME;
+    if (EXISTS(iv_pParentAnC)) {
+      errId = iv_pParentAnC->setNameValuePair(groupName, nvPair);
+    }
+
+    if (errId != UIMA_ERR_NONE) {//there's either no parent or the nvPair couldn't be set at the parent
+      errId = iv_pTaeSpecifier->setNameValuePair(groupName, nvPair);
+    }
+    return errId;
+  }
+
+  void AnnotatorContext::buildDelegateAnCs() {
+
+    assert(EXISTS(iv_pTaeSpecifier));
+    const AnalysisEngineDescription::TyMapDelegateSpecs & delegateTaes = iv_pTaeSpecifier->getDelegates();
+    AnalysisEngineDescription::TyMapDelegateSpecs::const_iterator ite;
+
+    vector < icu::UnicodeString > delegateNames;
+    for (ite = delegateTaes.begin(); ite != delegateTaes.end(); ite++) {
+      delegateNames.push_back(ite->first);
+    }
+
+    size_t i;
+    for (i=0; i < delegateNames.size(); i++) {
+      //AnalysisEngineDescription * delSpec = iv_pTaeSpecifier->extractDelegate(delegateNames[i]);
+      AnalysisEngineDescription * delSpec = iv_pTaeSpecifier->getDelegate(delegateNames[i]);
+      //BSI: AnnotatorContext * delegateAnc =  new AnnotatorContext(delSpec, this, delegateNames[i]);
+      AnnotatorContext * delegateAnc =  new AnnotatorContext(delSpec, this,
+                                        delegateNames[i],
+                                        iv_pTaeSpecifier->getSofaMappings());
+      iv_mapDelegateAncs [delegateNames[i]] = delegateAnc;
+    }
+  }
+
+  bool AnnotatorContext::isParameterDefined(const icu::UnicodeString & paramName) const {
+    AnalysisEngineMetaData const * pMetaData = getTaeSpecifier().getAnalysisEngineMetaData();
+
+    assert(EXISTS(pMetaData));
+    return pMetaData->isParameterDefined(paramName, "");
+  }
+
+  bool AnnotatorContext::isParameterDefined(const icu::UnicodeString & groupName,
+      const icu::UnicodeString & paramName) const {
+    AnalysisEngineMetaData const * pMetaData = getTaeSpecifier().getAnalysisEngineMetaData();
+    assert(EXISTS(pMetaData));
+    return pMetaData->isParameterDefined(groupName, paramName, "");
+  }
+
+
+  const set <icu::UnicodeString> AnnotatorContext::getGroupNamesForParameter(const icu::UnicodeString & paramName) const {
+      set <icu::UnicodeString> groupNames;
+      AnalysisEngineMetaData const * pMetaData = getTaeSpecifier().getAnalysisEngineMetaData();
+
+      assert(EXISTS(pMetaData));
+
+      if (EXISTS(iv_pParentAnC) && pMetaData->hasGroups()) {
+        groupNames = iv_pParentAnC->getGroupNamesForParameter(paramName);
+      }
+      vector <icu::UnicodeString> localGroups = pMetaData->getGroupNamesForParameter(paramName);
+      vector <icu::UnicodeString>::const_iterator ite;
+      for (ite = localGroups.begin(); ite != localGroups.end(); ite++) {
+        groupNames.insert(*ite);
+      }
+      return groupNames;
+    }
+
+  // These 2 are not inlined so they'll use the uima library's heap which is what
+  // the extractValue methods appear to use, even though they are declared inline.
+
+  void AnnotatorContext::release(std::string & value) const {
+    value.clear();
+  }
+
+  void AnnotatorContext::release(vector<std::string*> & returnValues) const {
+    returnValues.clear();
+  }
+
+} // namespace uima

Propchange: incubator/uima/uimacpp/trunk/src/framework/annotator_context.cpp
------------------------------------------------------------------------------
    svn:eol-style = native