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:54:51 UTC
svn commit: r503249 [5/6] - /incubator/uima/uimacpp/trunk/src/cas/uima/
Added: incubator/uima/uimacpp/trunk/src/cas/uima/lowlevel_internal_indexes.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/uima/lowlevel_internal_indexes.hpp?view=auto&rev=503249
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/uima/lowlevel_internal_indexes.hpp (added)
+++ incubator/uima/uimacpp/trunk/src/cas/uima/lowlevel_internal_indexes.hpp Sat Feb 3 08:54:50 2007
@@ -0,0 +1,430 @@
+#ifndef UIMA_LOWLEVEL_INTERNAL_INDEXES_HPP
+#define UIMA_LOWLEVEL_INTERNAL_INDEXES_HPP
+/** \file lowlevel_internal_indexes.hpp .
+-----------------------------------------------------------------------------
+
+
+
+
+ * 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:
+
+-----------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+/* Include dependencies */
+/* ----------------------------------------------------------------------- */
+#include "uima/pragmas.hpp" // must be first file to be included to get pragmas
+#include <algorithm>
+#include <set>
+
+#include "uima/lowlevel_index.hpp"
+#include "uima/lowlevel_indexcomparator.hpp"
+#include "uima/lowlevel_indexiterator.hpp"
+#include "uima/types.h"
+#include "uima/macros.h"
+
+/* ----------------------------------------------------------------------- */
+/* Constants */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/* Forward declarations */
+/* ----------------------------------------------------------------------- */
+namespace uima {
+ namespace lowlevel {
+ class IndexIterator;
+ class SingleOrderedIndexIterator;
+ class IndexRepository;
+ class KeyFeatureLexicographicLess;
+ class SingleSetIndex;
+ }
+}
+
+/* ----------------------------------------------------------------------- */
+/* Types / Classes */
+/* ----------------------------------------------------------------------- */
+
+/**
+ * This file containts all different index types, i.e., any implementation
+ * of single and composite indexes for the falvors "ordered", "set", and "FIFO".
+ */
+namespace uima {
+ namespace lowlevel {
+ namespace internal {
+
+ /**
+ * The base class for all single indexes.
+ */
+ class UIMA_LINK_IMPORTSPEC SingleIndex : public IndexABase {
+ protected:
+ SingleIndex(IndexRepository const & aIndexRepository,
+ TyFSType tyType);
+ public:
+ /**
+ * check if a feature structure is contained in the index.
+ * This is different from find() since it always tests for
+ * identity rather equivalence.
+ */
+ virtual bool contains(TyFS) const;
+
+ virtual IndexIterator* createTypeSetIterator(set<uima::lowlevel::TyFSType> const & crType) const {
+ assert( crType.size() <= 1 );
+ if (crType.size() == 1) {
+ assert( *(crType.begin()) == getType() );
+ }
+ return createIterator();
+ }
+ };
+
+
+ /**
+ * A single index with a comparator.
+ */
+ class UIMA_LINK_IMPORTSPEC ComparatorSingleIndex : public SingleIndex {
+ protected:
+ IndexComparator const * iv_cpComparator;
+
+ ComparatorSingleIndex(IndexRepository const & crIndexRepository,
+ uima::lowlevel::TyFSType tyType,
+ IndexComparator const * cpComparator);
+ public:
+ virtual TyFS find(TyFS) const;
+ IndexComparator const * getComparator() const {
+ return iv_cpComparator;
+ }
+ };
+
+
+ /**
+ * A single ordered index. Inserting works fast if the elements
+ * are inserted already in the correct order. Slow otherwise...
+ */
+ class UIMA_LINK_IMPORTSPEC OrderedSingleIndex : public ComparatorSingleIndex {
+ public:
+ typedef vector<TyFS> TyStructures;
+ private:
+ TyStructures iv_tyStructures;
+ protected:
+ void add(TyFS fs);
+ void remove(TyFS fs);
+ void reset();
+ public:
+ OrderedSingleIndex(IndexRepository const & aIndexRepository,
+ TyFSType aType,
+ IndexComparator const * );
+
+ size_t getSize() const {
+ return iv_tyStructures.size();
+ }
+
+ IndexIterator* createIterator() const;
+ TyFS find(TyFS fs) const;
+
+ vector<TyFS> const * getVector() const {
+ return & iv_tyStructures;
+ }
+#ifndef NDEBUG
+ bool debugIsConsistent() const;
+#endif
+ };
+
+
+ /**
+ * This class is a simply adapter to make a binary function out of a
+ * comparator.
+ * @see SetSingleIndex
+ */
+ class UIMA_LINK_IMPORTSPEC IndexComparatorLess : public binary_function<TyFS, TyFS, bool> {
+ private:
+ IndexComparator const * iv_cpclComparator;
+ FSHeap const * iv_heap;
+
+ IndexComparatorLess()
+ : iv_cpclComparator(NULL),
+ iv_heap(NULL) {
+ assertWithMsg(false, "Default constructor for STL compliance only!");
+ };
+ public:
+ IndexComparatorLess(IndexComparator const * aComparator,
+ FSHeap const & heap)
+ : iv_cpclComparator(aComparator),
+ iv_heap(&heap) {
+ assert( EXISTS(iv_cpclComparator) );
+ }
+
+ bool operator()(TyFS fs1, TyFS fs2) const {
+ assert( EXISTS(iv_cpclComparator) );
+ assert( EXISTS(iv_heap) );
+ UIMA_TPRINT("Comparing fs " << (long) fs1 << " with " << (long) fs2 << ". result: " << iv_cpclComparator->compare(*iv_heap, fs1, fs2) );
+ return iv_cpclComparator->compare(*iv_heap, fs1, fs2) > 0;
+ }
+ };
+
+
+ /**
+ * A single set index.
+ */
+ class UIMA_LINK_IMPORTSPEC SetSingleIndex : public ComparatorSingleIndex {
+ public:
+ typedef set<TyFS, IndexComparatorLess> TyStructures;
+ private:
+ // the set is allocated on the heap due to template problems with the Solaris compiler
+ TyStructures * iv_pStructures;
+
+ protected:
+ void add(TyFS fs) {
+ assert( EXISTS(iv_pStructures) );
+ (void) iv_pStructures->insert(fs);
+ }
+ void remove(TyFS fs) {
+ assert( EXISTS(iv_pStructures) );
+ (void) iv_pStructures->erase(fs);
+ }
+
+ void reset();
+ public:
+ SetSingleIndex(IndexRepository const & aIndexRepository,
+ TyFSType aType,
+ IndexComparator const * aComparator);
+ ~SetSingleIndex();
+
+ size_t getSize() const {
+ assert( EXISTS(iv_pStructures) );
+ return iv_pStructures->size();
+ }
+
+ IndexIterator* createIterator() const;
+
+ TyFS find(TyFS fs) const {
+ assert( EXISTS(iv_pStructures) );
+ TyStructures::const_iterator it = iv_pStructures->find(fs);
+ if (it == iv_pStructures->end()) {
+ return 0;
+ }
+ return *it;
+ }
+
+ };
+
+
+ /**
+ * A single index behaving like a FIFO (a vector).
+ * A comparator is not needed here.
+ */
+ class UIMA_LINK_IMPORTSPEC FIFOSingleIndex : public SingleIndex {
+ public:
+ typedef vector<TyFS> TyStructures;
+ private:
+ TyStructures iv_tyFIFO;
+ protected:
+ void add(TyFS fs) {
+ iv_tyFIFO.push_back(fs);
+ }
+ void reset() {
+ iv_tyFIFO.clear();
+ }
+
+ void remove(TyFS tyFS) {
+ TyStructures::iterator it = std::find(iv_tyFIFO.begin(), iv_tyFIFO.end(), tyFS);
+ if (it == iv_tyFIFO.end() ) {
+ return;
+ }
+ iv_tyFIFO.erase(it);
+ }
+ public:
+ FIFOSingleIndex(IndexRepository const & aIndexRepository,
+ TyFSType aType)
+ : SingleIndex(aIndexRepository, aType) {}
+
+ size_t getSize() const {
+ return iv_tyFIFO.size();
+ }
+
+ TyFS find(TyFS fs) const {
+ TyStructures::const_iterator it = std::find(iv_tyFIFO.begin(), iv_tyFIFO.end(), fs);
+ if (it == iv_tyFIFO.end()) {
+ return 0;
+ }
+ return *it;
+ }
+
+ IndexIterator* createIterator() const;
+
+ vector<TyFS> const * getVector() const {
+ return & iv_tyFIFO;
+ }
+
+ };
+
+
+
+ ////////////////////////////////////////////////////////////////////////
+ // Composite indexes
+
+ /**
+ * The base class for all composite indexes. All methods are implemented
+ * but may be overwritten by subclasses.
+ */
+ class UIMA_LINK_IMPORTSPEC CompositeIndex : public IndexABase {
+ public:
+ typedef vector<SingleIndex*> TyComponents;
+ protected:
+ TyComponents iv_tyComponents;
+ void add(TyFS /*fs*/) {
+ assertWithMsg(false, "Add operation not supported on CompositeIndex!");
+ }
+
+ void remove(TyFS /*fs*/) {
+ assertWithMsg(false, "Remove operation not supported on CompositeIndex!");
+ }
+
+ void reset() {
+ assertWithMsg(false, "Reset operation not supported on CompositeIndex!");
+ }
+
+ CompositeIndex(IndexRepository const & aIndexRepository,
+ uima::lowlevel::TyFSType tyType);
+
+ /**
+ * get all the components for the respective types.
+ */
+ void getComponentsForTypes(set<uima::lowlevel::TyFSType> const & crTypes, TyComponents & crResult) const;
+ public:
+ void addComponent(SingleIndex* pclIndex) {
+ assert( iv_crTypeSystem.subsumes( getType(), pclIndex->getType() ) );
+ iv_tyComponents.push_back(pclIndex);
+ }
+ virtual size_t getSize() const;
+ virtual TyFS find(TyFS fs) const;
+
+ };
+
+
+ /**
+ * generic implementation of a composite index with a cache of all feature structures.
+ * This cache maybe used for fast iterating over all feature structures.
+ * The cache type T can either be an STL vector or set.
+ */
+ template <class T>
+ class CachedCompositeIndex : public CompositeIndex {
+ protected:
+ T iv_cache;
+ uima::lowlevel::IndexComparator const * iv_comparator;
+
+ CachedCompositeIndex(IndexRepository const & aIndexRepository,
+ uima::lowlevel::TyFSType tyType,
+ IndexComparator const *);
+
+ // generic implementation of clearAndFillCache, maybe overwritten by subclasses
+ // this method is here because if it is in the cpp file, we get linking problems on Solaris.
+ virtual void clearAndFillCache() {
+ iv_cache.clear();
+ TyComponents::const_iterator cit;
+ for (cit = iv_tyComponents.begin(); cit != iv_tyComponents.end(); ++cit) {
+ SingleIndex const * index = (*cit);
+ auto_ptr<IndexIterator> apit( index->createIterator() );
+ for (apit->moveToFirst(); apit->isValid(); apit->moveToNext()) {
+ iv_cache.insert(iv_cache.end(), apit->get() );
+ }
+ }
+ }
+ public:
+ IndexIterator* createIterator() const;
+ IndexIterator* createTypeSetIterator(set<uima::lowlevel::TyFSType> const & crTypes) const;
+
+ IndexComparator const * getComparator() const {
+ return iv_comparator;
+ }
+ };
+
+
+
+ /**
+ * A composite ordered index. The iterator is different than the one
+ * of the superclass in that a different comparison scheme is used.
+ */
+ class OrderedCompositeIndex : public CachedCompositeIndex<vector<TyFS> > {
+ protected:
+ void clearAndFillCache();
+ public:
+
+ OrderedCompositeIndex(IndexRepository const & aIndexRepository,
+ uima::lowlevel::TyFSType tyType,
+ IndexComparator const * aComparator);
+ virtual ~OrderedCompositeIndex();
+
+ };
+
+
+ /**
+ * A composite set index.
+ */
+ class SetCompositeIndex : public CachedCompositeIndex<set<TyFS> > {
+ protected:
+ public:
+ SetCompositeIndex(IndexRepository const & aIndexRepository,
+ uima::lowlevel::TyFSType tyType,
+ IndexComparator const * aComparator);
+ };
+
+
+ class FIFOCompositeIndex : public CachedCompositeIndex<vector<TyFS> > {
+ protected:
+ public:
+ FIFOCompositeIndex(IndexRepository const & crIndexRepository,
+ uima::lowlevel::TyFSType tyType);
+ };
+
+
+ } //namespace internal
+ } //namespace lowlevel
+} //namespace uima
+
+/* ----------------------------------------------------------------------- */
+/* Implementation */
+/* ----------------------------------------------------------------------- */
+
+namespace uima {
+ namespace lowlevel {
+ namespace internal {
+
+ template<class T>
+ CachedCompositeIndex<T>::CachedCompositeIndex(IndexRepository const & aIndexRepository,
+ uima::lowlevel::TyFSType tyType,
+ IndexComparator const * comparator)
+ : CompositeIndex( aIndexRepository, tyType),
+ iv_comparator(comparator) {
+ }
+
+
+ } //namespace internal
+ } //namespace lowlevel
+} //namespace uima
+/* ----------------------------------------------------------------------- */
+
+
+#endif
+
Propchange: incubator/uima/uimacpp/trunk/src/cas/uima/lowlevel_internal_indexes.hpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/uima/uimacpp/trunk/src/cas/uima/lowlevel_internal_indexfactory.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/uima/lowlevel_internal_indexfactory.hpp?view=auto&rev=503249
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/uima/lowlevel_internal_indexfactory.hpp (added)
+++ incubator/uima/uimacpp/trunk/src/cas/uima/lowlevel_internal_indexfactory.hpp Sat Feb 3 08:54:50 2007
@@ -0,0 +1,204 @@
+#ifndef UIMA_LOWLEVEL_INDEXFACTORY_HPP
+#define UIMA_LOWLEVEL_INDEXFACTORY_HPP
+/** \file lowlevel_indexfactory.hpp .
+-----------------------------------------------------------------------------
+
+
+
+
+ * 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:
+
+-----------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+/* Include dependencies */
+/* ----------------------------------------------------------------------- */
+#include "uima/pragmas.hpp" // must be first file to be included to get pragmas
+#include "uima/lowlevel_typesystem.hpp"
+#include "uima/lowlevel_internal_indexes.hpp"
+#include "uima/lowlevel_indexrepository.hpp"
+
+/* ----------------------------------------------------------------------- */
+/* Constants */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/* Forward declarations */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/* Types / Classes */
+/* ----------------------------------------------------------------------- */
+
+
+namespace uima {
+ namespace lowlevel {
+ namespace internal {
+
+ /**
+ * Base class for all index factories.
+ * Every factory must be able to create a single and a composite index.
+ */
+ class UIMA_LINK_IMPORTSPEC IndexFactory {
+
+ public:
+ IndexFactory() {}
+
+ virtual ~IndexFactory() {}
+
+ virtual SingleIndex* createSingleIndex(IndexRepository const &, TyFSType) const = 0;
+ virtual CompositeIndex* createCompositeIndex(IndexRepository const &, TyFSType) const = 0;
+
+ virtual uima::lowlevel::TyFSType getType() const = 0;
+
+ virtual IndexComparator const * getComparator() const = 0;
+
+ virtual IndexDefinition::EnIndexKind getIndexKind() const = 0;
+
+ };
+
+
+ /**
+ * A factory for creating indexes which use a comparator (ordered and set)
+ */
+ class UIMA_LINK_IMPORTSPEC ComparatorIndexFactory : public IndexFactory {
+ protected:
+ IndexComparator const * iv_cpclComparator;
+ public:
+ ComparatorIndexFactory(IndexComparator const * cpComparator)
+ : IndexFactory(),
+ iv_cpclComparator(cpComparator) {
+ assert( EXISTS(iv_cpclComparator) );
+ }
+
+ virtual uima::lowlevel::TyFSType getType() const {
+ assert( EXISTS(iv_cpclComparator) );
+ return iv_cpclComparator->getType();
+ }
+
+ IndexComparator const * getComparator() const {
+ return iv_cpclComparator;
+ }
+
+ };
+
+ /**
+ * The factory for ordered index.
+ * Uses a comparator, thus inherits from ComparatorIndexFactory
+ */
+ class UIMA_LINK_IMPORTSPEC OrderedIndexFactory : public ComparatorIndexFactory {
+ public:
+ OrderedIndexFactory(IndexComparator const * aComparator)
+ : ComparatorIndexFactory(aComparator) {}
+
+ SingleIndex* createSingleIndex(IndexRepository const & indexRep,
+ TyFSType aType) const {
+ return new OrderedSingleIndex(indexRep, aType, iv_cpclComparator);
+ }
+
+ CompositeIndex* createCompositeIndex(IndexRepository const & indexRep, TyFSType tyFSType) const {
+ return new OrderedCompositeIndex(indexRep, tyFSType, iv_cpclComparator);
+ }
+
+ virtual IndexDefinition::EnIndexKind getIndexKind() const {
+ return IndexDefinition::enOrdered;
+ }
+
+ };
+
+ /**
+ * The factory for set index.
+ * Uses a comparator, thus inherits from ComparatorIndexFactory
+ */
+
+ class UIMA_LINK_IMPORTSPEC SetIndexFactory : public ComparatorIndexFactory {
+ public:
+ SetIndexFactory(IndexComparator const * aComparator)
+ : ComparatorIndexFactory(aComparator) {}
+
+ SingleIndex* createSingleIndex(IndexRepository const & indexRep, TyFSType aType) const {
+ return new SetSingleIndex(indexRep, aType, iv_cpclComparator);
+ }
+
+ CompositeIndex* createCompositeIndex(IndexRepository const & indexRep, TyFSType tyFSType) const {
+ return new SetCompositeIndex(indexRep, tyFSType, iv_cpclComparator);
+ }
+
+ virtual IndexDefinition::EnIndexKind getIndexKind() const {
+ return IndexDefinition::enSet;
+ }
+
+ };
+
+
+ /**
+ * Factory for the FIFO index.
+ * Does not use a comparator, thus inherits directly from IndexFactory.
+ */
+ class UIMA_LINK_IMPORTSPEC FIFOIndexFactory : public IndexFactory {
+ protected:
+ uima::lowlevel::TyFSType iv_tyType;
+ public:
+ FIFOIndexFactory(uima::lowlevel::TyFSType tyType)
+ : IndexFactory(),
+ iv_tyType(tyType) {
+ }
+
+ SingleIndex* createSingleIndex(IndexRepository const & indexRep, TyFSType tyType) const {
+ return new FIFOSingleIndex(indexRep, tyType);
+ }
+
+ CompositeIndex* createCompositeIndex(IndexRepository const & indexRep, TyFSType tyType) const {
+ return new FIFOCompositeIndex(indexRep, tyType);
+ }
+
+ uima::lowlevel::TyFSType getType() const {
+ return iv_tyType;
+ }
+
+ virtual IndexDefinition::EnIndexKind getIndexKind() const {
+ return IndexDefinition::enFIFO;
+ }
+
+ virtual IndexComparator const * getComparator() const {
+ return NULL;
+ }
+
+ };
+
+ }
+ }
+}
+/* ----------------------------------------------------------------------- */
+/* Implementation */
+/* ----------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+
+
+#endif
+
Propchange: incubator/uima/uimacpp/trunk/src/cas/uima/lowlevel_internal_indexfactory.hpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/uima/uimacpp/trunk/src/cas/uima/lowlevel_typedefs.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/uima/lowlevel_typedefs.hpp?view=auto&rev=503249
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/uima/lowlevel_typedefs.hpp (added)
+++ incubator/uima/uimacpp/trunk/src/cas/uima/lowlevel_typedefs.hpp Sat Feb 3 08:54:50 2007
@@ -0,0 +1,77 @@
+#ifndef UIMA_LOWLEVEL_TYPEDEFS_HPP
+#define UIMA_LOWLEVEL_TYPEDEFS_HPP
+/** \file lowlevel_typedefs.hpp .
+-----------------------------------------------------------------------------
+
+
+
+
+ * 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:
+
+-----------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+/* Include dependencies */
+/* ----------------------------------------------------------------------- */
+#include "uima/pragmas.hpp" // must be first file to be included to get pragmas
+#include "uima/types.h"
+#include <stdlib.h>
+
+/* ----------------------------------------------------------------------- */
+/* Constants */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/* Forward declarations */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/* Types / Classes */
+/* ----------------------------------------------------------------------- */
+
+namespace uima {
+ namespace lowlevel {
+ typedef WORD32 TyHeapCell; // a heap cell has int width
+ typedef WORD32 TyFS;
+
+ typedef WORD32 TyFSFeature;
+ typedef WORD32 TyFSType;
+
+ typedef WORD32 TyFeatureOffset;
+ }
+}
+
+
+/* ----------------------------------------------------------------------- */
+/* Implementation */
+/* ----------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+
+
+#endif
+
Propchange: incubator/uima/uimacpp/trunk/src/cas/uima/lowlevel_typedefs.hpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/uima/uimacpp/trunk/src/cas/uima/lowlevel_typesystem.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/uima/lowlevel_typesystem.hpp?view=auto&rev=503249
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/uima/lowlevel_typesystem.hpp (added)
+++ incubator/uima/uimacpp/trunk/src/cas/uima/lowlevel_typesystem.hpp Sat Feb 3 08:54:50 2007
@@ -0,0 +1,558 @@
+#ifndef UIMA_LOWLEVEL_TYPESYSTEM_HPP
+#define UIMA_LOWLEVEL_TYPESYSTEM_HPP
+/** \file lowlevel_typesystem.hpp .
+-----------------------------------------------------------------------------
+
+
+
+
+ * 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:
+
+-----------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+/* Include dependencies */
+/* ----------------------------------------------------------------------- */
+#include "uima/pragmas.hpp"
+
+#include <vector>
+#include <map>
+
+#include "uima/lowlevel_typedefs.hpp"
+
+#include "uima/internal_typeshortcuts.hpp"
+#include "uima/casexception.hpp"
+#include "uima/typesystem.hpp"
+
+/* ----------------------------------------------------------------------- */
+/* Constants */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/* Forward declarations */
+/* ----------------------------------------------------------------------- */
+namespace uima {
+ namespace internal {
+ class CASDefinition;
+ class CASDeserializer;
+ }
+}
+/* ----------------------------------------------------------------------- */
+/* Types / Classes */
+/* ----------------------------------------------------------------------- */
+
+namespace uima {
+ namespace lowlevel {
+
+ UIMA_EXC_CLASSDECLARE(FeatureIntroductionFailedException, CASException);
+ UIMA_EXC_CLASSDECLARE(TypeCreationFailedException, CASException);
+
+ /**
+ * The lowlevel type system.
+ * Inherits from the type system of the OO API.
+ */
+ class UIMA_LINK_IMPORTSPEC TypeSystem : public uima::TypeSystem {
+ friend class uima::internal::CASDefinition;
+ friend class uima::internal::CASDeserializer;
+ protected:
+ bool iv_bIsCommitted;
+ bool iv_bBuiltinTypesCreated;
+
+ TyFSType iv_tyTop;
+
+ // for building the hierarchy
+
+ // tree[t] are the daughters of type t
+ vector<vector<TyFSType> > iv_vecTree;
+ // introducedFeatures[t] are the features introduced at type t
+ vector<vector<TyFSFeature> > iv_vecIntroducedFeatures;
+ // useful map to parents of type t
+ vector<TyFSType> iv_vecParents;
+
+ // iv_vecRangeTypes[f] is the range type for feature f
+ vector<TyFSType> iv_vecRangeTypes;
+
+ // names of types and features
+ vector<icu::UnicodeString> iv_vecTypeNames;
+ vector<icu::UnicodeString> iv_vecTypeCreatorIDs;
+ vector<icu::UnicodeString> iv_vecFeatureBaseNames;
+ vector<icu::UnicodeString> iv_vecFeatureCreatorIDs;
+
+ // string sub types
+ vector<vector<icu::UnicodeString> > iv_enumStrings;
+ map<TyFSType, TyFeatureOffset> iv_stringSubtypeToStringSet;
+
+ // list of priority pairs
+ vector< pair<TyFSType, TyFSType> > iv_typePriorityList;
+
+ // the next fields are computed during commit()
+
+ // featureNumber[t] is the number of features of type t
+ vector<TyFeatureOffset> iv_vecFeatureNumber;
+
+ // featureOffset[f] is the offset of feature f
+ vector< TyFeatureOffset > iv_vecFeatureOffset;
+
+ // iv_vecTypeFeatureOffsetMapping[t][o] is the feature appropriate
+ // for type t with offset o
+ vector< vector<TyFSFeature> > iv_vecTypeFeatureOffsetMapping;
+
+ // approp[t][f] is true if feature f is appropriate for type t
+ vector< vector< bool > > iv_vecApprop;
+
+ // the total order embedding the user defined type priorities
+ map<TyFSType, size_t> iv_mapTypePriority;
+ // use to avoid calling expensive routine if no custom priorities defined
+ bool iv_customTypePrioritySet;
+
+ // find typeToBeFound in the subtree of the hierarchy rooted at root
+ bool findInTree(TyFSType root, TyFSType typeToBeFound) const;
+
+ /**
+ * compute appropriateness conditions on t, in particular,
+ * compute which feature is defined on each type, i.e., introduced
+ * of an ancestor type
+ */
+ void computeApprop(TyFSType t);
+
+ /**
+ * compute the mapping from types and offsets to features.
+ */
+ void computeTypeFeatureOffsetMapping();
+
+ /**
+ * assign a type priority number to all types.
+ */
+ void computeTypePriorityClosure();
+
+ /**
+ * combine the type priorities explictly defined by the configuration
+ * with the the ones of the sibling order (special Talent requirement).
+ */
+ void combineUserDefinedPrioritiesWithSiblingPriority();
+
+ TypeSystem(TypeSystem const &);
+ TypeSystem & operator=(TypeSystem const &);
+
+ TypeSystem();
+ ~TypeSystem();
+
+
+ /**
+ * check if <code>tyType</code> is a builtin type
+ * (int, string, float).
+ */
+ bool isBuiltinType(TyFSType tyType) const {
+ assert( isValidType(tyType) );
+ return ( tyType == uima::internal::gs_tyIntegerType )
+ || ( tyType == uima::internal::gs_tyFloatType )
+ || ( tyType == uima::internal::gs_tyStringType );
+ }
+
+ void createPredefinedCASTypes();
+
+ TyFSType createTypeNoChecks(TyFSType tyParent, icu::UnicodeString const & crName, icu::UnicodeString const & crusCreatorID);
+
+ protected:
+ virtual uima::lowlevel::TypeSystem const & getLowlevelTypeSystem() const {
+ return *this;
+ }
+ public:
+ static uima::lowlevel::TypeSystem const & promoteTypeSystem(uima::TypeSystem const & typeSystem) {
+ return typeSystem.getLowlevelTypeSystem();
+ }
+
+ static uima::lowlevel::TypeSystem & promoteTypeSystem(uima::TypeSystem & typeSystem) {
+ return CONST_CAST(uima::lowlevel::TypeSystem&, typeSystem.getLowlevelTypeSystem() );
+ }
+
+ typedef struct {
+ char const * iv_cpszName;
+ char const * iv_cpszParentName;
+ char const * iv_cpszDescription;
+ }
+ StTypeInfo;
+
+ typedef struct {
+ char const * iv_cpszName;
+ char const * iv_cpszIntroTypeName;
+ char const * iv_cpszRangeTypeName;
+ char const * iv_cpszDescription;
+ }
+ StFeatureInfo;
+
+
+ static const TyFSType INVALID_TYPE;
+ static const TyFSFeature INVALID_FEATURE;
+
+ /*
+ // names of types and features
+ static UIMA_LINK_IMPORTSPEC char const * TYPENAME_INVALID;
+ static UIMA_LINK_IMPORTSPEC char const * TYPENAME_TOP;
+
+ static UIMA_LINK_IMPORTSPEC char const * FEATURENAME_INVALID;
+ */
+
+#ifndef NDEBUG
+ bool debugIsTreeConsistent() const;
+ void printTree(int, TyFSType, ostream&) const;
+#endif
+ // These two are used in test_cas when built debug
+ void print(ostream&) const;
+ bool debugIsConsistent() const;
+
+ /**
+ * call commit() after you added the complete type hierarchy. It compiles
+ * out several tables for faster lookup.
+ */
+ void commit();
+
+ /**
+ * @return true if the type system was already committed.
+ */
+ bool isCommitted() const {
+ return iv_bIsCommitted;
+ }
+
+ /**
+ * resets the type system, all types and features will be deleted.
+ * Advanced use only.
+ */
+ void reset();
+
+ /*@{*/
+ /**
+ * @name Building the Type Hierarchy
+ */
+
+ /**
+ * create a type as a subtype of <code>tyParent</code> with
+ * name <code>crName</code>.
+ */
+ TyFSType createType(TyFSType tyParent, icu::UnicodeString const & crName, icu::UnicodeString const & crusCreatorID);
+
+ TyFSType createStringSubtype(icu::UnicodeString const & crName, vector<icu::UnicodeString> const & crStrings, icu::UnicodeString const & crusCreatorID);
+
+ /**
+ * create a feature on <code>tyIntro</code> with value type <code>tyValueType</code>
+ * and name <code>crName</code>.
+ */
+ TyFSFeature createFeature(TyFSType tyIntro, TyFSType tyValueType, icu::UnicodeString const & crName, icu::UnicodeString const & crusCreatorID);
+
+ /**
+ * create a type from a type info struct.
+ */
+ TyFSType createType( StTypeInfo const & , icu::UnicodeString const & crusCreatorID);
+
+ /**
+ * create a feature from a feature info struct.
+ */
+ TyFSType createFeature( StFeatureInfo const & , icu::UnicodeString const & crusCreatorID);
+
+ /**
+ * Add a type priority between t1 and t2. Returns true if the pair
+ * does not lead to a contradiction, false otherwise.
+ */
+ bool addTypePriority(TyFSType t1, TyFSType t2);
+
+ /**
+ * get the number of the type in an absolute ordering embedding the specified
+ * type priorities, i.e.,
+ * hasPriorityOver(t1, t2) iff getTypePriorityNumber[t1] < getTypePriorityNumber[t2]
+ */
+ size_t getTypePriorityNumber(TyFSType t) const;
+
+ /*@}*/
+
+
+ /**
+ * returns true iff it is allowed to add sub types to tyType.
+ */
+ bool isAllowedToAddSubTypes(TyFSType tyType) const {
+ assert( isValidType(tyType) );
+ // Integer, Float, String, ArrayBase, FSArray, IntArray, FloatArray, StringArray
+ return (!isBuiltinType(tyType))
+ && (tyType != uima::internal::gs_tyArrayBaseType)
+ && (tyType != uima::internal::gs_tyFSArrayType)
+ && (tyType != uima::internal::gs_tyIntArrayType)
+ && (tyType != uima::internal::gs_tyFloatArrayType)
+ && (tyType != uima::internal::gs_tyStringArrayType);
+ }
+
+ /**
+ * returns true iff it is allowed to create new feature on tyType.
+ */
+ bool isAllowedToCreateFeatures(TyFSType tyType) const {
+ assert( isValidType(tyType) );
+ return (isAllowedToAddSubTypes(tyType))
+ && (tyType != iv_tyTop);
+ }
+
+ /**
+ * returns true iff it is allowd to create an object of type tyType.
+ * (Not possible for e.g. integers)
+ */
+ bool isAllowedToBeInstantiated(TyFSType tyType) const {
+ assert( isValidType(tyType) );
+ return (! isBuiltinType(tyType) );
+ }
+
+ /**
+ * check if <code>tyFeature</code> is a valid feature ID.
+ */
+ bool isValidFeature(TyFSFeature tyFeature) const {
+ return( tyFeature>0) && (tyFeature < iv_vecFeatureBaseNames.size());
+ }
+
+ /**
+ * check if <code>tyType</code> is a valid type ID.
+ */
+ bool isValidType(TyFSType tyType) const {
+ return( tyType>0) && (tyType< iv_vecTypeNames.size());
+ }
+
+ /**
+ * check if <code>tyType</code> is maximal, i.e.,
+ * has no subtypes.
+ */
+ bool isMaximalType(TyFSType tyType) const {
+ assert( isValidType(tyType) );
+ return iv_vecTree[tyType].size() == 0;
+ }
+
+ /**
+ * get the number of all types in the type system.
+ */
+ size_t getNumberOfTypes() const {
+ return iv_vecTypeNames.size() - 1;
+ }
+
+ /**
+ * get the number of all features in the type system.
+ */
+ size_t getNumberOfFeatures() const {
+ return iv_vecFeatureBaseNames.size() - 1;
+ }
+
+ vector<icu::UnicodeString> const & getStringsForStringSubtype(TyFSType type) const;
+
+ /**
+ * get a list of all the types in the type system.
+ * @param rvecResult output parameter
+ */
+ void getAllTypes(vector<TyFSType>& rvecResult) const {
+ rvecResult.clear();
+ TyFSType i;
+ for (i=1; i<iv_vecTypeNames.size(); ++i) {
+ rvecResult.push_back(i);
+ }
+ }
+
+ /**
+ * get a list of all the features in the type system.
+ * @param rvecResult output parameter
+ */
+ void getAllFeatures(vector<TyFSFeature>& rvecResult) const {
+ rvecResult.clear();
+ TyFSFeature i;
+ for (i=1; i<iv_vecFeatureBaseNames.size(); ++i) {
+ rvecResult.push_back(i);
+ }
+ }
+
+ /**
+ * find the type by its name.
+ * Returns <code>INVALID_TYPE</code> if no type with the name exists.
+ */
+ TyFSType getTypeByName(icu::UnicodeString const & crusTypeName) const;
+
+ /**
+ * get the name of the type.
+ */
+ icu::UnicodeString const & getTypeName(TyFSType tyType) const {
+ assert( isValidType(tyType) );
+ return iv_vecTypeNames[ (size_t) tyType];
+ }
+
+ /**
+ * get the creator id of the type.
+ */
+ icu::UnicodeString const & getTypeCreatorID(TyFSType tyType) const {
+ assert( isValidType(tyType) );
+ return iv_vecTypeCreatorIDs[ (size_t) tyType];
+ }
+
+ /**
+ * get the feature by its fully qualified name.
+ * Returns <code>INVALID_FEATURE</code> if no feature with the name exists.
+ */
+ TyFSFeature getFeatureByFullName(icu::UnicodeString const & crusFeatureName) const;
+
+ /**
+ * get the feature by its base name w.r.t. to a type it is defined for.
+ */
+ TyFSFeature getFeatureByBaseName(TyFSType tyType, icu::UnicodeString const & crusFeatureName) const;
+
+ TyFSFeature getFeatureByBaseName(icu::UnicodeString const & crusTypeName, icu::UnicodeString const & crusFeatureName) const;
+
+ /**
+ * get the name of the feature.
+ */
+ icu::UnicodeString const & getFeatureBaseName(TyFSFeature tyFeature) const {
+ assert( isValidFeature(tyFeature) );
+ return iv_vecFeatureBaseNames[ tyFeature ];
+ }
+
+ /**
+ * returns the fully qualified name of the feature.
+ * The type name is its introduction type.
+ */
+ icu::UnicodeString getFeatureName(TyFSFeature tyFeature) const;
+
+ /**
+ * get the creator id of the feature.
+ */
+ icu::UnicodeString const & getFeatureCreatorID(TyFSFeature tyFeature) const {
+ assert( isValidFeature(tyFeature) );
+ return iv_vecFeatureCreatorIDs[ tyFeature ];
+ }
+
+
+ /**
+ * get a list of all features appropriate for <code>tyType</code>, i.e.,
+ * all features introduced by <code>tyType</code> or one of its ancestors.
+ * @param rResult output parameter
+ */
+ void getAppropriateFeatures(TyFSType tyType, vector<TyFSFeature>& rResult) const;
+
+ void getDirectSubTypes(TyFSType tyType, vector<TyFSType> & rResult) const;
+
+ /**
+ * get the range of the feature, i.e., the value type <code>tyFeature</code>
+ * must have.
+ */
+ TyFSType getRangeType(TyFSFeature tyFeature) const {
+ assert( isValidFeature(tyFeature) );
+ return iv_vecRangeTypes[tyFeature];
+ }
+
+
+ /**
+ * check if <code>tyFeature</code> is appropriate for <code>tyType</code>.
+ */
+ bool isAppropriateFeature(TyFSType tyType, TyFSFeature tyFeature) const {
+ assert( iv_bIsCommitted );
+ assert( isValidType(tyType) );
+ assert( isValidFeature(tyFeature) );
+ return iv_vecApprop[tyType][tyFeature];
+ }
+
+
+ /**
+ * get the top type.
+ */
+ TyFSType getTopType() const {
+ return iv_tyTop;
+ }
+
+ TyFSType getMostSpecificCommonSupertype(TyFSType t1, TyFSType t2) const;
+
+ /**
+ * get all subsumed types of <code>tyType</code>.
+ * @param rResult output parameter
+ */
+ void getSubsumedTypes(TyFSType tyType, vector<TyFSType>& rResult) const;
+
+ /**
+ * get the parent type of <code>tyType</code>.
+ */
+ TyFSType getParentType(TyFSType tyType) const;
+
+ /**
+ * check if <code>tyType1</code> subsumes <code>tyType2</code>.
+ */
+ bool subsumes(TyFSType tyType1, TyFSType tyType2) const;
+
+ bool hasPriorityOver(TyFSType tyType1, TyFSType tyType2) const {
+ assert( isValidType(tyType1) );
+ assert( isValidType(tyType2) );
+ assert( iv_mapTypePriority.find(tyType1) != iv_mapTypePriority.end() );
+ assert( iv_mapTypePriority.find(tyType2) != iv_mapTypePriority.end() );
+ size_t p1 = (*iv_mapTypePriority.find(tyType1)).second;
+ size_t p2 = (*iv_mapTypePriority.find(tyType2)).second;
+ return p1 < p2;
+ }
+
+ /**
+ * get the type where <code>tyFeature</code> was introduced.
+ */
+ TyFSType getIntroType(TyFSFeature tyFeature) const;
+
+ /**
+ * method for determining positional encodings of features
+ * for heap representation. Since we impose feature introduction,
+ * we don't need type information.
+ * Use this in combination with uima::lowlevel::FSHeap::getFeatureWithOffset for
+ * fast access of features.
+ */
+ TyFeatureOffset getFeatureOffset(TyFSFeature tyFeature) const {
+ assert( iv_bIsCommitted );
+ assert( isValidFeature(tyFeature) );
+ return iv_vecFeatureOffset[tyFeature];
+ }
+
+ TyFSFeature getFeatureFromOffset(TyFSType tyType, TyFeatureOffset tyOffset) const {
+ assert( isValidType(tyType) );
+ assert( tyType < iv_vecTypeFeatureOffsetMapping.size() );
+ assert( tyOffset < iv_vecTypeFeatureOffsetMapping[tyType].size() );
+ return iv_vecTypeFeatureOffsetMapping[tyType][tyOffset];
+ }
+
+ /**
+ * get the number of features of <code>tyType</code>.
+ */
+ TyFeatureOffset getFeatureNumber(TyFSType tyType) const {
+ assert( iv_bIsCommitted );
+ assert( isValidType(tyType) );
+ return iv_vecFeatureNumber[tyType];
+ }
+
+ static icu::UnicodeString const ustrCREATOR_ID_SYSTEM;
+ };
+
+ }
+}
+
+/* ----------------------------------------------------------------------- */
+/* Implementation */
+/* ----------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+
+
+#endif
+
Propchange: incubator/uima/uimacpp/trunk/src/cas/uima/lowlevel_typesystem.hpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/uima/uimacpp/trunk/src/cas/uima/sofaid.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/uima/sofaid.hpp?view=auto&rev=503249
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/uima/sofaid.hpp (added)
+++ incubator/uima/uimacpp/trunk/src/cas/uima/sofaid.hpp Sat Feb 3 08:54:50 2007
@@ -0,0 +1,111 @@
+/** \file sofaid.hpp .
+-----------------------------------------------------------------------------
+
+
+
+ * 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.
+
+-----------------------------------------------------------------------------
+
+ \brief Class to support sofaMapping
+
+ Description: A SofaID object contains the handle to a particular Sofa in
+ the CAS. An SofaId is obtained by calling
+ uima::AnnotatorContext::mapToSofaID().
+
+
+-----------------------------------------------------------------------------
+
+
+ 10/01/2004 Initial creation
+
+-------------------------------------------------------------------------- */
+#ifndef UIMA_SOFAID_HPP
+#define UIMA_SOFAID_HPP
+
+// ---------------------------------------------------------------------------
+// Includes
+// ---------------------------------------------------------------------------
+
+#include "uima/pragmas.hpp" //must be first to surpress warnings
+#include "uima/err_ids.h"
+
+#include "uima/taemetadata.hpp"
+#include <vector>
+
+namespace uima {
+
+ /** A SofaID object contains the handle to a particular Sofa in the CAS.
+ A SofaID is obtained by calling uima::AnnotatorContext::mapToSofaID().
+ */
+ class UIMA_LINK_IMPORTSPEC SofaID {
+ public:
+
+ //SofaID()
+ //iv_sofaId(), iv_componentSofaName()
+ //{
+ //
+ //}
+ //SofaID(icu:UnicodeString & sofaid, icu:UnicodeString & componentsofaname) {
+ // iv_sofaid = sofaid;
+ // iv_componentSofaName = componentsofaname;
+ //}
+
+ /**
+ * Set the Sofa ID string, the string representing the Sofa name in the CAS.
+ */
+ TyErrorId setSofaId(const icu::UnicodeString & sofaid) {
+ iv_sofaId=sofaid;
+ return UIMA_ERR_NONE;
+ }
+
+ /**
+ * Get the Sofa ID, the string representing the Sofa name in the CAS.
+ */
+ const icu::UnicodeString & getSofaId() const {
+ return iv_sofaId;
+ }
+
+ /**
+ * Set the component Sofa name, the Sofa name as known to the component.
+ */
+ TyErrorId setComponentSofaName(const icu::UnicodeString & componentSofaName) {
+ iv_componentSofaName=componentSofaName;
+ return UIMA_ERR_NONE;
+ }
+
+ /**
+ * Get the component Sofa name, the Sofa name as knnwn to the component.
+ */
+ const icu::UnicodeString & getComponentSofaName() const {
+ return iv_componentSofaName;
+ }
+
+
+
+ private:
+
+ SofaID & operator=(const SofaID & crOther);
+
+ icu::UnicodeString iv_sofaId;
+ icu::UnicodeString iv_componentSofaName;
+
+ };
+}
+
+#endif
Propchange: incubator/uima/uimacpp/trunk/src/cas/uima/sofaid.hpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/uima/uimacpp/trunk/src/cas/uima/sofastream.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/uima/sofastream.hpp?view=auto&rev=503249
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/uima/sofastream.hpp (added)
+++ incubator/uima/uimacpp/trunk/src/cas/uima/sofastream.hpp Sat Feb 3 08:54:50 2007
@@ -0,0 +1,254 @@
+/** \file sofastream.hpp .
+-----------------------------------------------------------------------------
+
+
+
+ * 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.
+
+-----------------------------------------------------------------------------
+
+ \brief Contains class uima::SofaDataStream
+
+ Description: The SofaDataStream class provides stream access
+ to Sofa data in a Sofa feature strucure in the CAS.
+ The Sofa data may be local in the CAS or remote from
+ the CAS and reference by a URI conformant string
+ set in the SofaURI feature.
+
+ Handlers for the various URI schemes both standard and user-defined
+ schemes may be registered by setting the environment variable
+ UIMACPP_STREAMHANDLERS as follows:
+
+ set UIMACPP_STREAMHANDLERS=file:sofastreamhandler_file;aURI:aDLLfilename
+
+ The APIs deliver data in native byte order and expect the
+ data read from the source to be in the network byte order.
+
+-----------------------------------------------------------------------------
+
+
+ 10/01/2004 Initial creation
+
+-------------------------------------------------------------------------- */
+#ifndef UIMA_SOFASTREAM_HPP
+#define UIMA_SOFASTREAM_HPP
+
+// ---------------------------------------------------------------------------
+// Includes
+// ---------------------------------------------------------------------------
+
+#include "uima/pragmas.hpp" //must be first to surpress warnings
+#include "uima/err_ids.h"
+#include "uima/taemetadata.hpp"
+#include "uima/cas.hpp"
+#include "uima/dllfile.hpp"
+#include <vector>
+
+/* ----------------------------------------------------------------------- */
+/* Forward declarations */
+/* ----------------------------------------------------------------------- */
+namespace uima {
+ class SofaFS;
+ class SofaStreamHandler;
+}
+
+
+/* ----------------------------------------------------------------------- */
+/* Types / Classes */
+/* ----------------------------------------------------------------------- */
+namespace uima {
+
+#define UIMA_SOFASTREAM_MAKE_HANDLER _TEXT("makeHandler")
+
+ typedef void * TySofaDataPointer;
+
+ /** The SofaDataStream class provides stream access
+ to Sofa data in a Sofa feature strucure in the CAS.
+ The Sofa data may be local in the CAS or remote from
+ the CAS and reference by a URI conformant string
+ set in the SofaURI feature.
+ <br><br>
+ Handlers for the various URI schemes both standard and user-defined
+ schemes may be registered by setting the environment variable
+ UIMACPP_STREAMHANDLERS as follows:
+ <br>
+ <br>
+ <code>
+ UIMACPP_STREAMHANDLERS=file:SofaStreamHandlerFile aScheme:aLibrary ...
+ </code>
+ <br>
+ The APIs deliver data in native byte order and expect the
+ data read from the source to be in the network byte order.
+ **/
+ class UIMA_LINK_IMPORTSPEC SofaDataStream {
+ public:
+ /**
+ * open the stream for reading
+ * @param minbufsize optional specifies the minimum
+ * size of the internal buffer the
+ * stream handler should use.
+ * defaults to the value of BUFSIZE
+ */
+ virtual int open(size_t minbufsize=0) =0;
+
+ /**
+ * Gets the total size of the stream in number of bytes if known.
+ *
+ * @return - size in bytes
+ * -1 if size cannot be determined as with an openended stream,
+ *
+ */
+ virtual INT64 getTotalStreamSizeInBytes()=0;
+
+ /**
+ * Gets the number of bytes available.
+ *
+ *
+ * @return - size in bytes
+ * -1 if size cannot be determined,
+ *
+ */
+ virtual INT64 howManyBytesAvailable()=0;
+
+
+ /**
+ * This call reads at most the number of elements into specified
+ * buffer. The call blocks until the number of required
+ * element are read or EOF. This will return elements in
+ * the native byte order for the current platform
+ *
+ * The buffer is allocated and owned by the caller and must be
+ * at least elementSize*numElements in size.
+ *
+ * @param pbuffer
+ * elementSize, e.g., 1, 2, 4, 8
+ * numElements
+ * @return number of elements read
+ * -1 indicates EOF and no elements read
+ * -2 indicates elementSize is not compatible with elementSize
+ * of the data source. This would be the case for a
+ * LocalSofA where the Sofa data is in a typed array FS.
+ */
+ virtual int read( void * pbuffer, int elementSize, size_t numElements)=0;
+
+
+ /*
+ * This call is used to reposition the current position in the stream to
+ * the specified offset from the specified origin.
+ * The origin is one of:
+ *
+ * @param - offset, in number of bytes
+ * origin as defined in stdio.h is one of
+ * SEEK_SET, from the start
+ * SEEK_CUR, from current location.
+ * SEEK_END, from end.
+ * @return 0 for success,
+ * -1 for EOF
+ * anything else indicates an error.
+ *
+ */
+ virtual int seek(INT64 offset, int origin)=0;
+
+
+ /*
+ * Close the stream.
+ *
+ */
+ virtual void close()=0;
+ /*
+ * Get the pointer to the data.
+ * This is valid only for a RemoteSofA
+ * where the entire SofA data is available in
+ * memory.
+ * @return a valid pointer or NULL.
+ */
+ virtual const TySofaDataPointer getDataPointer()=0;
+
+
+ /*
+ * Destructor
+ *
+ */
+ virtual ~SofaDataStream() { }
+ };
+
+
+ /**
+ * This class implements stream access to Sofa data for
+ * a Local Sofa.
+ */
+ class UIMA_LINK_IMPORTSPEC LocalSofaDataStream : public SofaDataStream {
+ public:
+ LocalSofaDataStream(SofaFS & sofaFS);
+ ~LocalSofaDataStream();
+ int open(size_t minbuf=0);
+ INT64 getTotalStreamSizeInBytes();
+ INT64 howManyBytesAvailable();
+ int read( void * pbuffer, int elementSize, size_t numElements);
+ int seek(INT64 offset, int origin);
+ void close();
+ const TySofaDataPointer getDataPointer();
+
+ private:
+ SofaFS * iv_psofafs; //the SofaFS
+ const char * iv_psofadata; //ptr to the sofa data
+ char * iv_pstringsofadata; //ptr to UTF 8 string
+ INT64 iv_curpos; //cursor position
+ INT32 iv_size; //total size of stream in bytes
+ bool iv_isstring; //is sofa data stored in a String Feature
+ bool iv_isintarray; //is sofa data stored in a FS array of ints
+ bool iv_isfloatarray; //is sofa data stored in a FS array of floats
+ bool iv_isbooleanarray; //is sofa data stored in a FS array of floats
+ bool iv_isbytearray; //is sofa data stored in a FS array of floats
+ bool iv_isshortarray; //is sofa data stored in a FS array of floats
+ bool iv_islongarray; //is sofa data stored in a FS array of floats
+ bool iv_isdoublearray; //is sofa data stored in a FS array of floats
+ };
+
+
+ /**
+ * This class implements stream access to Sofa data for
+ * a remote Sofa
+ */
+ class UIMA_LINK_IMPORTSPEC RemoteSofaDataStream : public SofaDataStream {
+ public:
+ RemoteSofaDataStream(SofaFS& sofaFS);
+ ~RemoteSofaDataStream();
+ int open(size_t minbuf=0);
+ INT64 getTotalStreamSizeInBytes();
+ INT64 howManyBytesAvailable();
+ int read( void * pbuffer, int elementSize, size_t numElements);
+ int seek(INT64 offset, int origin);
+ void close();
+ const TySofaDataPointer getDataPointer();
+
+ private:
+ SofaFS * iv_psofafs;
+ SofaStreamHandler * iv_pHandler;
+ util::DllProcLoaderFile * iv_pHandlerDll;
+ };
+
+//return codes
+
+#define SOFASTREAMHANDLER_SUCCESS 0
+#define SOFASTREAMHANDLER_EOF -1
+#define SOFASTREAMHANDLER_OPEN_ENDED -1
+
+}
+
+#endif
Propchange: incubator/uima/uimacpp/trunk/src/cas/uima/sofastream.hpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/uima/uimacpp/trunk/src/cas/uima/sofastreamhandler.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/uima/sofastreamhandler.hpp?view=auto&rev=503249
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/uima/sofastreamhandler.hpp (added)
+++ incubator/uima/uimacpp/trunk/src/cas/uima/sofastreamhandler.hpp Sat Feb 3 08:54:50 2007
@@ -0,0 +1,148 @@
+/** \file sofastreamhandler.hpp .
+-----------------------------------------------------------------------------
+
+ * 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.
+
+-----------------------------------------------------------------------------
+
+ \brief Functions that a stream handler must implement in order
+ to support remote Sofa access
+
+-----------------------------------------------------------------------------
+
+ Description:
+ This specifies the functions that a stream handler
+ must implement to support remote Sofa access in UIMACPP.
+*/
+
+#ifndef __UIMA_SOFASTREAMHANDLER_HPP__
+#define __UIMA_SOFASTREAMHANDLER_HPP__
+
+#include "uima/types.h"
+
+namespace uima {
+ /**
+ * The class <TT>SofaStreamHandler</TT> defines the API methods that must
+ * be implemented to support reading custom URI schemes for reading
+ */
+ class SofaStreamHandler {
+ public:
+ /** Constructor */
+ SofaStreamHandler(void);
+ /** Destructor */
+ virtual ~SofaStreamHandler() {
+ ;
+ }
+ /**
+ * Open a stream to this URL.
+ *
+ */
+ virtual void openStream(const char * uriString)=0;
+
+ /**
+ * Open a stream to this URL and specify the minimum size of
+ * the internal buffer.
+ *
+ */
+ virtual void openStream(const char * uriString, size_t minimumBufferSize)=0;
+
+ /**
+ * Gets the total size of the data in bytes.
+ */
+ virtual INT64 getTotalStreamSize()=0;
+
+ /**
+ * Gets the size of the internal buffer.
+ */
+ virtual size_t getBufferSize()=0;
+
+ /**
+ * Gets number of bytes available to read.
+ */
+ virtual INT64 howManyAvailable()=0;
+
+ /**
+ * Read the specified number of bytes from the current position.
+ * Advance the current position by the number of bytes read.
+ * This call blocks till read request is satisfied or EOF is
+ * reached.
+ * @param numBytes, the number of bytes to read
+ * @param pBuffer, buffer into which the bytes are to be copied.
+ * @returns number of bytes read of EOF (-1). This may be less than
+ * the number of bytes requested.
+ */
+ virtual INT64 getNext(size_t numBytes, void * pBuffer)=0;
+
+ /**
+ *
+ * Sets the position within the current stream.
+ *
+ * @param offset - number of bytes from origin
+ * @param origin is one of the following (taken from lseek spec):
+ * If SEEK_SET, the position is set to offset bytes.
+ * If SEEK_CUR, the position is set to its
+ * current location plus offset bytes.
+ * If SEEK_END, the position is set to the total length
+ * plus offset bytes.
+ * These constants are defined in stdio.h
+ *
+ * @return 0 indicates success
+ * -1 EOF
+ */
+ virtual int seek (INT64 offset,
+ int origin)=0;
+
+ /**
+ * closeStream
+ * close the stream. Delete the internal buffer.
+ */
+ virtual void closeStream()=0;
+
+ /**
+ * getDataPointer
+ * This returns a pointer to the data in memory.
+ * A valid pointer is returned only if the entire
+ * stream data is available in memory, that is getTotalLength()
+ * is equal to howManyAvailable(). Otherwise return NULL.
+ *
+ * @return pointer to data or NULL.
+ */
+ virtual void * getDataPointer();
+
+ }
+ ; /* SofaStreamHandler */
+
+
+ inline SofaStreamHandler::SofaStreamHandler(void) {
+ return;
+ }
+
+ inline void * SofaStreamHandler::getDataPointer() {
+ return NULL;
+ }
+
+
+ /** MAKE_HANDLER macro must be used by the custom handler writers
+ to export an entry point to the handler */
+#define MAKE_HANDLER(classHandler) extern "C" UIMA_ANNOTATOR_LINK_IMPORTSPEC SofaStreamHandler * makeHandler() { return new classHandler; }
+
+ extern "C" UIMA_ANNOTATOR_LINK_IMPORTSPEC SofaStreamHandler * makeHandler();
+
+ typedef SofaStreamHandler* (* TyMakeStreamHandler) (void);
+}
+#endif
Propchange: incubator/uima/uimacpp/trunk/src/cas/uima/sofastreamhandler.hpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/uima/uimacpp/trunk/src/cas/uima/type_or_feature.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/uima/type_or_feature.hpp?view=auto&rev=503249
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/uima/type_or_feature.hpp (added)
+++ incubator/uima/uimacpp/trunk/src/cas/uima/type_or_feature.hpp Sat Feb 3 08:54:50 2007
@@ -0,0 +1,197 @@
+/** \file type_or_feature.hpp .
+-----------------------------------------------------------------------------
+
+
+
+ * 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.
+
+-----------------------------------------------------------------------------
+
+ \brief Contains uima::ResultSpecification
+
+ Description:
+
+-----------------------------------------------------------------------------
+
+
+ 02/05/2003 Initial creation
+
+-------------------------------------------------------------------------- */
+
+#ifndef UIMA_TYPE_OR_FEATURE_HPP
+#define UIMA_TYPE_OR_FEATURE_HPP
+
+/* ----------------------------------------------------------------------- */
+/* Include dependencies */
+/* ----------------------------------------------------------------------- */
+
+#include "uima/pragmas.hpp" // must be first file to be included to get pragmas
+#include <set>
+#include "unicode/unistr.h"
+#include "uima/unistrref.hpp"
+
+#include "uima/typesystem.hpp"
+#include "uima/internal_fspromoter.hpp"
+
+/* ----------------------------------------------------------------------- */
+/* Constants */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/* Forward declarations */
+/* ----------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+/* Types / Classes */
+/* ----------------------------------------------------------------------- */
+
+namespace uima {
+
+ /**
+ * Wrapper class to encapsulate either a uima::Type <em>or</em> a
+ * uima::Feature object since both types and features can be used as
+ * parts of a result specification
+ *
+ * @see uima::ResultSpecification
+ */
+ class UIMA_LINK_IMPORTSPEC TypeOrFeature {
+ private:
+ Type iv_type;
+ Feature iv_feature;
+ public:
+ /// Default constructor
+ TypeOrFeature() {
+ assert( ! iv_type.isValid() );
+ assert( ! iv_feature.isValid() );
+ }
+ /// Constructor from a uima::Type object
+ TypeOrFeature(Type const & crType)
+ : iv_type( crType ),
+ iv_feature( ) {
+ assert( iv_type.isValid() );
+ assert( ! iv_feature.isValid() );
+ }
+
+ TypeOrFeature(TypeOrFeature const & crTOF) {
+ *this = crTOF;
+ }
+
+ TypeOrFeature & operator=(TypeOrFeature const & crTOF) {
+ iv_type = crTOF.iv_type;
+ iv_feature = crTOF.iv_feature;
+ assert( isValid() );
+ return *this;
+ }
+
+ /// Constructor from a uima::Feature object
+ TypeOrFeature(Feature const & crFeature)
+ : iv_type( ),
+ iv_feature( crFeature ) {
+ assert( ! iv_type.isValid() );
+ assert( iv_feature.isValid() );
+ }
+
+ bool isType() const {
+ return iv_type.isValid();
+ }
+
+ bool isValid() const {
+ if (isType()) {
+ return iv_type.isValid();
+ }
+ return iv_feature.isValid();
+ }
+
+ Type getType() const {
+ return iv_type;
+ }
+
+ Feature getFeature() const {
+ return iv_feature;
+ }
+
+ bool subsumes(TypeOrFeature const & crTypeOrFeature) const {
+ if (isType()) {
+ if (crTypeOrFeature.isType()) {
+ return iv_type.subsumes( crTypeOrFeature.iv_type );
+ }
+ return false;
+ }
+ if (crTypeOrFeature.isType()) {
+ return false;
+ }
+ return iv_feature == crTypeOrFeature.iv_feature;
+ }
+
+ UnicodeStringRef getName() const {
+ if (isType()) {
+ return iv_type.getName();
+ }
+ return iv_feature.getName();
+ }
+
+ bool operator==(TypeOrFeature const & crOther) const {
+ uima::lowlevel::TyFSFeature tyFeature = uima::internal::FSPromoter::demoteFeature(iv_feature);
+ uima::lowlevel::TyFSFeature tyOtherFeature = uima::internal::FSPromoter::demoteFeature(crOther.iv_feature);
+ if (tyFeature != tyOtherFeature) {
+ return false;
+ }
+
+ uima::lowlevel::TyFSType tyType = uima::internal::FSPromoter::demoteType(iv_type);
+ uima::lowlevel::TyFSType tyOtherType = uima::internal::FSPromoter::demoteType(crOther.iv_type);
+ if ( tyType != tyOtherType) {
+ return false;
+ }
+
+ return true;
+ }
+
+ bool operator<(TypeOrFeature const & crOther) const {
+ if ( (*this) == crOther ) {
+ return false;
+ }
+ uima::lowlevel::TyFSType tyType = uima::internal::FSPromoter::demoteType(iv_type);
+ uima::lowlevel::TyFSType tyOtherType = uima::internal::FSPromoter::demoteType(crOther.iv_type);
+ if (tyType == tyOtherType) {
+ uima::lowlevel::TyFSFeature tyFeature = uima::internal::FSPromoter::demoteFeature(iv_feature);
+ uima::lowlevel::TyFSFeature tyOtherFeature = uima::internal::FSPromoter::demoteFeature(crOther.iv_feature);
+ assert( tyFeature != tyOtherFeature );
+ return tyFeature < tyOtherFeature;
+ }
+
+ return tyType < tyOtherType;
+ }
+
+
+ }
+ ; /* class TypeOrFeature */
+
+
+
+} // namespace uima
+
+/* ----------------------------------------------------------------------- */
+/* Implementation */
+/* ----------------------------------------------------------------------- */
+
+
+#endif /* UIMA_TYPE_OR_FEATURE_HPP */
+
+/* <EOF> */
+
Propchange: incubator/uima/uimacpp/trunk/src/cas/uima/type_or_feature.hpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/uima/uimacpp/trunk/src/cas/uima/typenamespace.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/uima/typenamespace.hpp?view=auto&rev=503249
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/uima/typenamespace.hpp (added)
+++ incubator/uima/uimacpp/trunk/src/cas/uima/typenamespace.hpp Sat Feb 3 08:54:50 2007
@@ -0,0 +1,157 @@
+#ifndef UIMA_TYPENAMESPACE_HPP
+#define UIMA_TYPENAMESPACE_HPP
+/** \file typenamespace.hpp .
+-----------------------------------------------------------------------------
+
+
+
+
+ * 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.
+
+-----------------------------------------------------------------------------
+
+ \brief Contains class uima::TypeNameSpace and uima::TypeNameSpaceImport
+
+ Description:
+
+-----------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+/* Include dependencies */
+/* ----------------------------------------------------------------------- */
+#include "uima/pragmas.hpp" // must be first file to be included to get pragmas
+#include "uima/typesystem.hpp"
+#include "unicode/unistr.h"
+#include <vector>
+/* ----------------------------------------------------------------------- */
+/* Constants */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/* Forward declarations */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/* Types / Classes */
+/* ----------------------------------------------------------------------- */
+
+
+namespace uima {
+
+ /// The constant we use to seperate namespace parts: A period
+ const char TYPENAMESPACE_SEP = '.';
+
+ /**
+ * An accessor object that gives access to all types that share a common
+ * namespace.
+ * For example if a TypeNameSpace object is created for the
+ * namespace "uima.tt"
+ * (<code> TypeNameSpace ttNameSpace(ts, "uima.tt");</code>)
+ * you can then use this object to get type objects from types names
+ * by using only short names e.g.
+ * <code>Type t = ttNameSpace.getType("Lemma");</code>
+ * would be equivalent to
+ * <code>Type t = ts.getType("uima.tt.Lemma);</code>
+ */
+ class UIMA_LINK_IMPORTSPEC TypeNameSpace {
+ private:
+ icu::UnicodeString iv_usName;
+ uima::TypeSystem const * iv_cpTypeSystem;
+ public:
+ /**
+ * Construct a TypeNameSpace object by passing it a reference
+ * the type system it lives in and the name of the namespace
+ * it should represent.
+ */
+ TypeNameSpace(uima::TypeSystem const & crTypeSystem, icu::UnicodeString const & crName);
+
+ /**
+ * Find a type object by it's short name.
+ * Implicitly this just prepends the namespace name to crTypeBaseName
+ */
+ Type getType(icu::UnicodeString const & crTypeBaseName) const;
+
+ /// Return the name of this namespace object
+ icu::UnicodeString const & getName() const;
+
+ /// Return a container with type objects for all types in this namespace
+ void getAllTypes(vector<Type> & rResult) const;
+
+ /// Return the typesystem this namespace lives in
+ TypeSystem const & getTypeSystem() const;
+ };
+
+
+ /**
+ * This class is usefull to bundle several TypeNameSpace objects into
+ * a lookup sequence that can be used to lookup unqualified type names.
+ * The TypeNameSpaceImport object will try to find an unqualified type
+ * name in each TypeNameSpace objects that has been added to it.
+ * The lookup will be done in the sequence in which the TypeNameSpace
+ * objects have been added.
+ */
+ class UIMA_LINK_IMPORTSPEC TypeNameSpaceImport {
+ private:
+ vector<TypeNameSpace> iv_vecImports;
+ uima::TypeSystem const * iv_cpTypeSystem;
+ public:
+ /**
+ * Construct a TypeNameSpaceImport object from an type system
+ */
+ TypeNameSpaceImport( uima::TypeSystem const & );
+
+ /**
+ * Add a TypeNameSpace object to this TypeNameSpaceImport object.
+ * Note: The order of the addNameSpace() calls will be relevant
+ * for a later lookup using getType()
+ */
+ void addNameSpace(TypeNameSpace const & crNamespace);
+
+ /**
+ * try to get the type with the specified relative name.
+ * If there is a name conflict, false is returned, true otherwise.
+ * @param crRelativeTypeName input: not fully specified type name
+ * @param rResult output parameter
+ */
+ bool getType(icu::UnicodeString const & crRelativeTypeName, Type & rResult) const;
+
+ /**
+ * Return a container with type objects for all types of all namespace
+ * that have been added to this TypeNameSpaceImport object
+ */
+ void getAllTypes(vector<Type> & rResult) const;
+
+ /// Return the typesystem this TypeNameSpaceImport object lives in
+ TypeSystem const & getTypeSystem() const;
+ };
+}
+
+/* ----------------------------------------------------------------------- */
+/* Implementation */
+/* ----------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+
+
+#endif
+
Propchange: incubator/uima/uimacpp/trunk/src/cas/uima/typenamespace.hpp
------------------------------------------------------------------------------
svn:eol-style = native