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:58:56 UTC
svn commit: r503251 [11/13] -
/incubator/uima/uimacpp/trunk/src/framework/uima/
Added: incubator/uima/uimacpp/trunk/src/framework/uima/trace.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/framework/uima/trace.hpp?view=auto&rev=503251
==============================================================================
--- incubator/uima/uimacpp/trunk/src/framework/uima/trace.hpp (added)
+++ incubator/uima/uimacpp/trunk/src/framework/uima/trace.hpp Sat Feb 3 08:58:54 2007
@@ -0,0 +1,261 @@
+/** \file trace.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 A Trace class
+
+-------------------------------------------------------------------------- */
+
+#ifndef __UIMA_TRACE_HPP
+#define __UIMA_TRACE_HPP
+
+/* ----------------------------------------------------------------------- */
+/* Interface dependencies */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/* Implementation dependencies */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/* Constants */
+/* ----------------------------------------------------------------------- */
+
+#include "uima/types.h"
+#include "uima/text.h"
+#include "uima/comp_ids.h"
+
+// Copy enough from cos .h files to keep compiler happy.
+
+#ifndef UIMA_TRACE_ORIGIN
+#define UIMA_TRACE_ORIGIN ""
+#endif
+
+/* ----------------------------------------------------------------------- */
+/* Types */
+/* ----------------------------------------------------------------------- */
+
+namespace uima {
+ namespace util {
+
+ /** the following trace levels of details can be distinguished */
+ typedef enum EnTraceDetail {
+ enTraceDetailOff = 0,
+ enTraceDetailLow = 1,
+ enTraceDetailMedium = 2,
+ enTraceDetailHigh = 3
+ /* NOTE: all EnTraceDetail values must be < 4 (0x4) !!! */
+ } EnTraceDetail;
+
+ /* ----------------------------------------------------------------------- */
+ /* Classes */
+ /* ----------------------------------------------------------------------- */
+
+ /**
+ * The class <tt> util::Trace</tt> is used to send information about function
+ * execution and data (trace events) to a trace buffer.
+ * Information will be sent only if the trace is enabled.
+ *
+ * \note An object of class util::Trace must be instantiated with
+ * UIMA_TRACE_ORIGIN as an argument!
+ * \code
+ foo(unsigned int uiAValue, const char * cpszBValue)
+ {
+ util::Trace clTrace(util::EnTraceDetailLow, UIMA_TRACE_ORIGIN, COMPONENT_FOO);
+
+ // your code here ...
+
+ clTrace.dump(EnTraceDetailHigh, "AValue [before]", uiAValue);
+ clTrace.dump(EnTraceDetailHigh, "BValue [before]", cpszBValue);
+
+ // your code here ...
+
+ clTrace.dump("AValue", uiAValue);
+ clTrace.dump("BValue", cpszBValue);
+
+ // your code here ...
+
+ }
+ \endcode
+ */
+ class Trace {
+ public:
+ /** @name Constructors */
+ /*@{*/
+ /** create a trace with the specified level of details and an optional
+ component id.
+ \note Do not provide arguments for <tt> cpszFile</tt> directly, use the
+ macro <tt> UIMA_TRACE_ORIGIN</tt> instead. */
+
+ Trace(EnTraceDetail enDetail,
+ const char * cpszOrigin,
+ uima::TyComponentId utCompId = UIMA_TRACE_COMPONENT_ID_UNDEFINED);
+ /*@}*/
+ /** @name Properties */
+ /*@{*/
+ /** return TRUE if the trace is enabled */
+ bool isEnabled(void) const;
+ /*@}*/
+ /** @name Dump Methods */
+ /*@{*/
+ /** dump data into the trace using the detail level set as a default by constructor.
+ Several different data types are available: */
+ void dump(const TCHAR * cpszMessage);
+ void dump(const TCHAR * cpszMessage, const TCHAR * cpszValue);
+#ifdef UNICODE
+ void dump(const TCHAR * cpszMessage, const char * cpszValue);
+#endif
+ void dump(const TCHAR * cpszMessage, const void * cpvValue, size_t uiSize);
+ void dump(const TCHAR * cpszMessage, bool bValue);
+ void dump(const TCHAR * cpszMessage, char cValue);
+ void dump(const TCHAR * cpszMessage, unsigned char ucValue);
+ void dump(const TCHAR * cpszMessage, short sValue);
+ void dump(const TCHAR * cpszMessage, unsigned short usValue);
+ void dump(const TCHAR * cpszMessage, int iValue);
+ void dump(const TCHAR * cpszMessage, unsigned int uiValue);
+ void dump(const TCHAR * cpszMessage, long lValue);
+ void dump(const TCHAR * cpszMessage, unsigned long ulValue);
+// void dump(const TCHAR * cpszMessage, INT64 lValue);
+// void dump(const TCHAR * cpszMessage, WORD64 ulValue);
+ void dump(const TCHAR * cpszMessage, float fValue);
+ void dump(const TCHAR * cpszMessage, double dValue);
+ void dump(const TCHAR * cpszMessage, long double ldValue);
+ /** dump the address into the trace using the detail level set as a default
+ by constructor. */
+ void dumpAdrs(const TCHAR * cpszMessage, const void * cpvValue);
+ /** dump the specified data as UNICODE data into the trace using the detail
+ level set as a default by constructor. */
+ void dumpUnicode(const char * cpszMessage, const void * cpvValue, size_t uiLength);
+ /** dump boolean data into the trace using a specific detail level. */
+ void dumpBool(const TCHAR * cpszMessage, bool bValue);
+ /** dump data into the trace using a specific detail level.
+ Several different data types are available: */
+ void dump(EnTraceDetail enDetail, const TCHAR * cpszMessage);
+ void dump(EnTraceDetail enDetail, const TCHAR * cpszMessage, const TCHAR * cpszValue);
+#ifdef UNICODE
+ void dump(EnTraceDetail enDetail, const TCHAR * cpszMessage, const char * cpszValue);
+#endif
+ void dump(EnTraceDetail enDetail, const TCHAR * cpszMessage, const void * cpvValue, size_t uiSize);
+ void dump(EnTraceDetail enDetail, const TCHAR * cpszMessage, bool bValue);
+ void dump(EnTraceDetail enDetail, const TCHAR * cpszMessage, char cValue);
+ void dump(EnTraceDetail enDetail, const TCHAR * cpszMessage, unsigned char ucValue);
+ void dump(EnTraceDetail enDetail, const TCHAR * cpszMessage, short sValue);
+ void dump(EnTraceDetail enDetail, const TCHAR * cpszMessage, unsigned short usValue);
+ void dump(EnTraceDetail enDetail, const TCHAR * cpszMessage, int iValue);
+ void dump(EnTraceDetail enDetail, const TCHAR * cpszMessage, unsigned int uiValue);
+ void dump(EnTraceDetail enDetail, const TCHAR * cpszMessage, long lValue);
+ void dump(EnTraceDetail enDetail, const TCHAR * cpszMessage, unsigned long ulValue);
+// void dump(EnTraceDetail enDetail, const TCHAR * cpszMessage, INT64 lValue);
+// void dump(EnTraceDetail enDetail, const TCHAR * cpszMessage, WORD64 ulValue);
+ void dump(EnTraceDetail enDetail, const TCHAR * cpszMessage, float fValue);
+ void dump(EnTraceDetail enDetail, const TCHAR * cpszMessage, double dValue);
+ void dump(EnTraceDetail enDetail, const TCHAR * cpszMessage, long double ldValue);
+ /** dump the address into the trace using the specified detail level */
+ void dumpAdrs(EnTraceDetail enDetail, const TCHAR * cpszMessage, const void * cpvValue);
+ /** dump the specified data as UNICODE data into the trace using the
+ specified detail level */
+ void dumpUnicode(EnTraceDetail enDetail, const char * cpszMessage, const void * cpvValue, size_t uiLength);
+ /*@}*/
+ /** @name Miscelleanous */
+ /*@{*/
+ /** flush the trace entries so that they are written to the trace file */
+ void flush(void);
+ /*@}*/
+ protected:
+ /* --- functions --- */
+ private:
+ /* --- functions --- */
+ /* BASE CONSTRUCTOR NOT SUPPORTED */
+ Trace(void); //lint !e1704
+ /* COPY CONSTRUCTOR NOT SUPPORTED */
+ Trace(const Trace & ); //lint !e1704
+ /* ASSIGNMENT OPERATOR NOT SUPPORTED */
+ Trace & operator=(const Trace & crclObject);
+ }
+ ; /* Trace */
+
+ /* ----------------------------------------------------------------------- */
+ /* Globals */
+ /* ----------------------------------------------------------------------- */
+
+ /* ----------------------------------------------------------------------- */
+ /* Function declarations */
+ /* ----------------------------------------------------------------------- */
+
+ /* ----------------------------------------------------------------------- */
+ /* Macro definitions */
+ /* ----------------------------------------------------------------------- */
+
+ /* ----------------------------------------------------------------------- */
+ /* Public implementation */
+ /* ----------------------------------------------------------------------- */
+
+ inline Trace::Trace(EnTraceDetail, const char *, uima::TyComponentId) {
+ ;
+ }
+
+ inline bool Trace::isEnabled(void) const {
+ return(false);
+ }
+
+ inline void Trace::dump(const TCHAR *) {}
+
+ inline void Trace::dump(const TCHAR *, const TCHAR *) {
+ return;
+ }
+
+ inline void Trace::dump(const TCHAR *, long) {
+ return;
+ }
+
+ inline void Trace::dump(const TCHAR *, unsigned long) {
+ return;
+ }
+
+ inline void Trace::dump(const TCHAR *, int) {
+ return;
+ }
+
+ inline void Trace::dump(const TCHAR *, unsigned int) {
+ return;
+ }
+
+ inline void Trace::dumpAdrs(const TCHAR *, const void *) {
+ return;
+ }
+
+ inline void Trace::dump(EnTraceDetail, const TCHAR *) {
+ return;
+ }
+ inline void Trace::dump(EnTraceDetail, const TCHAR *, unsigned short) {
+ return;
+ }
+ inline void Trace::dumpAdrs(EnTraceDetail, const TCHAR *, const void *) {
+ return;
+ }
+
+ } // namespace util
+} // namespace uima
+
+#endif /* __UIMA_TRACE_HPP */
+
+/* <EOF> */
Propchange: incubator/uima/uimacpp/trunk/src/framework/uima/trace.hpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/uima/uimacpp/trunk/src/framework/uima/types.h
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/framework/uima/types.h?view=auto&rev=503251
==============================================================================
--- incubator/uima/uimacpp/trunk/src/framework/uima/types.h (added)
+++ incubator/uima/uimacpp/trunk/src/framework/uima/types.h Sat Feb 3 08:58:54 2007
@@ -0,0 +1,117 @@
+/** \file types.h .
+-----------------------------------------------------------------------------
+
+
+
+ * 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 types definitions used throughout UIMACPP
+
+ Description:
+
+-----------------------------------------------------------------------------
+
+
+ 5/11/1999 Initial creation
+
+-------------------------------------------------------------------------- */
+
+#ifndef UIMA_TYPES_H
+#define UIMA_TYPES_H
+
+/* ----------------------------------------------------------------------- */
+/* Include dependencies */
+/* ----------------------------------------------------------------------- */
+
+#include "uima/configure.h"
+#include "uima/pragmas.hpp"
+
+#include <stdlib.h>
+
+#include "apr.h"
+
+/* ----------------------------------------------------------------------- */
+/* Constants */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/* Forward declarations */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/* Types / Classes */
+/* ----------------------------------------------------------------------- */
+
+/** Importing and Exporting global objects, such as variables and functions. */
+#if defined(__GNUC__)
+# define UIMA_LINK_IMPORTSPEC
+# define UIMA_ANNOTATOR_LINK_SPEC
+# define UIMA_ANNOTATOR_LINK_IMPORTSPEC
+#elif defined(_MSC_VER)
+# define UIMA_ANNOTATOR_LINK_SPEC __cdecl
+# if defined(_UIMA_LIBRARY_)
+# define UIMA_LINK_IMPORTSPEC __declspec(dllexport)
+# define UIMA_ANNOTATOR_LINK_IMPORTSPEC __declspec(dllimport)
+# else
+# define UIMA_LINK_IMPORTSPEC __declspec(dllimport)
+# define UIMA_ANNOTATOR_LINK_IMPORTSPEC __declspec(dllexport)
+# endif
+#else
+# error Code requires port to host Compiler!
+#endif
+
+/** the type uima::TyHandle is used as a handle to a resource */
+/** the type uima::ComponentId is used in trace msgs */
+
+namespace uima {
+
+ typedef long TyDocTextDistance;
+
+ typedef unsigned long TyMessageId;
+
+ typedef size_t TyDocIndex;
+
+ typedef void * TyHandle;
+
+ typedef unsigned short TyComponentId;
+
+} // namespace uima
+
+// Types formerly defined in obsolete headers
+
+typedef apr_byte_t WORD8;
+typedef apr_uint16_t WORD16;
+typedef apr_uint32_t WORD32;
+typedef apr_uint64_t WORD64;
+typedef apr_int32_t INT32;
+typedef apr_int64_t INT64;
+
+// "bool" is already defined on Windows (MS IDE 7.1.3088)
+
+/* ----------------------------------------------------------------------- */
+/* Implementation */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+
+#endif /* UIMA_TYPES_H */
+
+/* <EOF> */
+
Propchange: incubator/uima/uimacpp/trunk/src/framework/uima/types.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/uima/uimacpp/trunk/src/framework/uima/typesystemdescription.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/framework/uima/typesystemdescription.hpp?view=auto&rev=503251
==============================================================================
--- incubator/uima/uimacpp/trunk/src/framework/uima/typesystemdescription.hpp (added)
+++ incubator/uima/uimacpp/trunk/src/framework/uima/typesystemdescription.hpp Sat Feb 3 08:58:54 2007
@@ -0,0 +1,421 @@
+/** \file typesystemdescription.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 classes uima::TypeDescription uima::FeatureDescription and uima::TypeSystemDescription
+
+ Description: Defines the type system used in a Text Analysis Engine
+
+-----------------------------------------------------------------------------
+
+ 01/30/2003 Initial creation
+
+-------------------------------------------------------------------------- */
+#ifndef UIMA_TYPESYSTEMDESCRIPTION_HPP
+#define UIMA_TYPESYSTEMDESCRIPTION_HPP
+
+// ---------------------------------------------------------------------------
+// Includes
+// ---------------------------------------------------------------------------
+
+#include "uima/pragmas.hpp" //must be first to surpress warnings
+#include "uima/err_ids.h"
+#include "uima/taemetadata.hpp"
+#include "uima/importdescription.hpp"
+
+#include <vector>
+#include <map>
+
+namespace uima {
+
+ /**
+ * If a type can only contain an enumeration of values, there is an <code>AllowedValue</code> object
+ * for each value. The value itself is returned by <code>getName</code>, <code>getDescription</code>
+ * returns a description of the value.
+ **/
+ class UIMA_LINK_IMPORTSPEC AllowedValue :public MetaDataObject {
+ public:
+ AllowedValue()
+ :MetaDataObject(), iv_name(), iv_description() {}
+
+ AllowedValue(const AllowedValue & crOther) {
+ iv_name = crOther.getName();
+ iv_description = crOther.getDescription();
+ }
+
+
+
+ TyErrorId setName(const icu::UnicodeString & name) {
+ if (! isModifiable()) {
+ return UIMA_ERR_CONFIG_OBJECT_COMITTED;
+ }
+ iv_name = name;
+ return UIMA_ERR_NONE;
+ }
+
+ TyErrorId setDescription(const icu::UnicodeString & description) {
+ if (! isModifiable()) {
+ return UIMA_ERR_CONFIG_OBJECT_COMITTED;
+ }
+ iv_description = description;
+ return UIMA_ERR_NONE;
+ }
+
+ const icu::UnicodeString & getName() const {
+ return iv_name;
+ }
+
+ const icu::UnicodeString & getDescription() const {
+ return iv_description;
+ }
+
+ private:
+ icu::UnicodeString iv_name;
+ icu::UnicodeString iv_description;
+ };
+
+ /**
+ * Defines a feature by its name and the range type that its values can assume.
+ * <code>getDescription</code> returns a textual description of the feature.
+ **/
+ class UIMA_LINK_IMPORTSPEC FeatureDescription:public MetaDataObject {
+
+ public:
+
+ FeatureDescription()
+ :MetaDataObject(), iv_name(), iv_description(), iv_rangeType() {}
+
+ FeatureDescription(const FeatureDescription & crOther) {
+ iv_name = crOther.getName();
+ iv_description = crOther.getDescription();
+ iv_rangeType = crOther.getRangeTypeName();
+ }
+
+ TyErrorId setName(const icu::UnicodeString & featName) {
+ if (! isModifiable()) {
+ return UIMA_ERR_CONFIG_OBJECT_COMITTED;
+ }
+ iv_name = featName;
+ return UIMA_ERR_NONE;
+ }
+
+ const icu::UnicodeString & getName() const {
+ return iv_name;
+ }
+
+ TyErrorId setRangeTypeName(const icu::UnicodeString & rangeName) {
+ if (! isModifiable()) {
+ return UIMA_ERR_CONFIG_OBJECT_COMITTED;
+ }
+ iv_rangeType = rangeName;
+ return UIMA_ERR_NONE;
+ }
+
+ const icu::UnicodeString & getRangeTypeName() const {
+ return iv_rangeType;
+ }
+
+ TyErrorId setDescription(const icu::UnicodeString & desc) {
+ if (! isModifiable()) {
+ return UIMA_ERR_CONFIG_OBJECT_COMITTED;
+ }
+ iv_description = desc;
+ return UIMA_ERR_NONE;
+ }
+
+ const icu::UnicodeString & getDescription() const {
+ return iv_description;
+ }
+
+ private:
+ icu::UnicodeString iv_name;
+ icu::UnicodeString iv_description;
+ icu::UnicodeString iv_rangeType;
+ };
+
+ /**
+ * Defines a type by its name and the name of its super type.
+ * If a type defines features or can only assume values from a
+ * predefined set, the information is accessible via
+ * <code>getFeatureDescriptions</code> and <code>getAllowedValues</code>, resp.
+ * <code>getDescription</code> returns a textual description of the type.
+ **/
+ class UIMA_LINK_IMPORTSPEC TypeDescription :public MetaDataObject {
+
+ public:
+ typedef vector<FeatureDescription *> TyVecpFeatureDescriptions;
+ typedef vector<AllowedValue *> TyVecpAllowedValues;
+
+ TypeDescription()
+ :MetaDataObject(), iv_typeName(), iv_superTypeName(), iv_description(),
+ iv_vecpFeatureDescriptions(), iv_vecpAllowedValues() {};
+
+ TypeDescription(const TypeDescription & crOther);
+
+ ~TypeDescription() {
+ size_t i;
+ for (i=0; i < iv_vecpFeatureDescriptions.size(); i++) {
+ delete iv_vecpFeatureDescriptions[i];
+ }
+ for (i=0; i < iv_vecpAllowedValues.size(); i++) {
+ delete iv_vecpAllowedValues[i];
+ }
+ }
+
+ void commit() {
+ size_t i;
+ for (i=0; i < iv_vecpFeatureDescriptions.size(); i++) {
+ iv_vecpFeatureDescriptions[i]->commit();
+ }
+ for (i=0; i < iv_vecpAllowedValues.size(); i++) {
+ iv_vecpAllowedValues[i]->commit();
+ }
+ iv_bIsModifiable = false;
+ }
+
+ TyErrorId setName(const icu::UnicodeString & name) {
+ if (! isModifiable()) {
+ return UIMA_ERR_CONFIG_OBJECT_COMITTED;
+ }
+ iv_typeName = name;
+ return UIMA_ERR_NONE;
+ }
+
+ const icu::UnicodeString & getName() const {
+ return iv_typeName;
+ }
+
+ TyErrorId setSuperTypeName(const icu::UnicodeString & name) {
+ if (! isModifiable()) {
+ return UIMA_ERR_CONFIG_OBJECT_COMITTED;
+ }
+ iv_superTypeName = name;
+ return UIMA_ERR_NONE;
+ }
+
+ const icu::UnicodeString & getSuperTypeName() const {
+ return iv_superTypeName;
+ }
+
+ TyErrorId setDescription(const icu::UnicodeString & desc) {
+ if (! isModifiable()) {
+ return UIMA_ERR_CONFIG_OBJECT_COMITTED;
+ }
+ iv_description = desc;
+ return UIMA_ERR_NONE;
+ }
+
+ const icu::UnicodeString & getDescription() const {
+ return iv_description;
+ }
+
+ /**
+ * NOTE: This object will assume memory ownership of <code>feature</code>,
+ * i.e. it will delete it when destroyed.
+ **/
+ TyErrorId addFeatureDescription(FeatureDescription * feature, bool & takesMemoryOwnership);
+
+ /**
+ * Adds an AllowedValue object to the list of AllowedValues
+ * NOTE: This object will assume memory ownership of <code>AllowedValue</code>,
+ * i.e. it will delete it when destroyed.
+ */
+ TyErrorId addAllowedValue(AllowedValue * allowed, bool & takesMemoryOwnership);
+
+ /**
+ * Adds all feature descriptions in descs to this TypeDescription.
+ * If there are two features with the same name and rangetype, only
+ * one will be in this TypeDescription.
+ * However, if two features have the same name, but different rangetypes,
+ * the TypeDescription will contain both.
+ * The error will be identified when validating the TextAnalysisEngineSpecifier.
+ * <code>FeatureDescription</code> objects contained in <code>descs</code> will
+ * be copied, hence, the memory ownership of the objects in <code>descs</code>
+ * will remain with the caller of this method.
+ *
+ **/
+ void mergeFeatureDescriptions(const TyVecpFeatureDescriptions & descs);
+
+ void mergeAllowedValues(const TyVecpAllowedValues & descs);
+
+ const TyVecpFeatureDescriptions & getFeatureDescriptions() const {
+ return iv_vecpFeatureDescriptions;
+ }
+
+ const TyVecpAllowedValues & getAllowedValues() const {
+ return iv_vecpAllowedValues;
+ }
+
+ /**
+ * returns a <code>FeatureDescription</code> with name <code>featureName</code>
+ * or NULL, if no such feature can be found.
+ **/
+ FeatureDescription * getFeatureDescription(const icu::UnicodeString & featureName) const;
+
+ AllowedValue * getAllowedValue(const icu::UnicodeString & name) const;
+
+ void validate();
+ private:
+
+ TypeDescription & operator=(const TypeDescription & crOther);
+
+ icu::UnicodeString iv_typeName;
+ icu::UnicodeString iv_superTypeName;
+ icu::UnicodeString iv_description;
+ TyVecpFeatureDescriptions iv_vecpFeatureDescriptions;
+ TyVecpAllowedValues iv_vecpAllowedValues;
+ };
+
+ /**
+ * Contains an ordered list of type names. The ordering implies priority,
+ * that is, if entry b comes after entry a in the list, then a as a higher
+ * priority than b.
+ **/
+ class UIMA_LINK_IMPORTSPEC TypePriority :public MetaDataObject {
+ public:
+ TypePriority() :iv_vecTypeOrder() {}
+
+ TyErrorId addType(const icu::UnicodeString & type) {
+ if (! isModifiable()) {
+ return UIMA_ERR_CONFIG_OBJECT_COMITTED;
+ }
+ iv_vecTypeOrder.push_back(type);
+ return UIMA_ERR_NONE;
+ }
+
+ const vector <icu::UnicodeString> & getTypeOrder() const {
+ return iv_vecTypeOrder;
+ }
+
+ private:
+ vector <icu::UnicodeString> iv_vecTypeOrder;
+ };
+
+ /**
+ * Contains all <code>TypeDescription</code> and <code>TypePriority</code> objects
+ * for a <code>TextAnalysisEngine</code>.
+ **/
+ class UIMA_LINK_IMPORTSPEC TypeSystemDescription :public MetaDataObject {
+ public:
+ typedef vector<TypeDescription *> TyVecpTypeDescriptions;
+ typedef vector<ImportDescription *> TyVecpImportDescriptions;
+
+
+ TypeSystemDescription()
+ :MetaDataObject(), iv_vecpTypeDescriptions() {};
+
+ ~TypeSystemDescription() {
+ size_t i;
+ for (i=0; i < iv_vecpTypeDescriptions.size(); i++) {
+ delete iv_vecpTypeDescriptions[i];
+ }
+ for (i=0; i < iv_vecpImportDescriptions.size(); i++) {
+ delete iv_vecpImportDescriptions[i];
+ }
+ }
+
+ void commit() {
+ iv_bIsModifiable = false;
+
+ vector<icu::UnicodeString> alreadyImportedLocations;
+ resolveImports(alreadyImportedLocations);
+ size_t i;
+ for (i=0; i < iv_vecpTypeDescriptions.size(); i++) {
+ iv_vecpTypeDescriptions[i]->commit();
+ }
+ }
+
+ /**
+ * Adds all type descriptions in descs to this type system description.
+ * If there are two type descriptions with the same name and same supertype,
+ * their features are merged into one TypeDescription.
+ * If two descriptions have the same name, but different supertype names
+ * (which is not allowed), the TypeSystemDescription will contain both entries.
+ * The error will be identified when validating the TextAnalysisEngineSpecifier
+ * <code>TypeDescription</code> objects contained in <code>descs</code> will
+ * be copied, hence, the memory ownership of the objects in <code>descs</code>
+ * will remain with the caller of this method.
+ * @see validate()
+ **/
+ void mergeTypeDescriptions(const TyVecpTypeDescriptions & descs);
+
+ /**
+ * NOTE: This object will assume memory ownership of <code>desc</code>,
+ * i.e. it will delete it when destroyed !
+ **/
+ TyErrorId addTypeDescription(TypeDescription * desc, bool & takesMemoryOwnerShip);
+
+ const TyVecpTypeDescriptions & getTypeDescriptions() const {
+ return iv_vecpTypeDescriptions;
+ }
+
+ TypeDescription * getTypeDescription(const icu::UnicodeString & typeName) const;
+
+ const TypeDescription * getTypeDescriptionConst(const icu::UnicodeString & typeName) const {
+ return getTypeDescription(typeName);
+ }
+
+ bool hasTypeDescription(const icu::UnicodeString & typeName) const {
+ return(EXISTS(getTypeDescriptionConst(typeName)));
+ }
+
+ //Import
+ void setXmlFileLocation(const icu::UnicodeString xmlLoc) {
+ iv_xmlFileLoc = xmlLoc;
+ }
+
+ /**
+ * @return The full path name of the XML file used to build up this Specifier.
+ * If it was built from a memory buffer,
+ * returns some buffer ID generated by Xerces
+ */
+ const icu::UnicodeString & getXmlFileLocation() const {
+ return iv_xmlFileLoc;
+ }
+
+ TyErrorId addImportDescription(ImportDescription * pDesc, bool & takesMemoryOwnerShip );
+
+ const TyVecpImportDescriptions & getImportDescriptions() const {
+ return iv_vecpImportDescriptions;
+ }
+
+ TyErrorId resolveImports(std::vector<icu::UnicodeString> & alreadyImportedTypeSystemLocations);
+
+ TyErrorId resolveImport(const icu::UnicodeString & fileLocation,
+ std::vector<icu::UnicodeString> & alreadyImportedTypeSystemLocations,
+ TyVecpTypeDescriptions & result);
+ void validate();
+ private:
+ TypeSystemDescription(const TypeSystemDescription & crOther);
+ TypeSystemDescription operator=(const TypeSystemDescription & crOther);
+
+ TyVecpTypeDescriptions iv_vecpTypeDescriptions;
+ TyVecpImportDescriptions iv_vecpImportDescriptions;
+ icu::UnicodeString iv_xmlFileLoc;
+ };
+
+
+
+}
+#endif
+
Propchange: incubator/uima/uimacpp/trunk/src/framework/uima/typesystemdescription.hpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/uima/uimacpp/trunk/src/framework/uima/u2cpcnvrt.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/framework/uima/u2cpcnvrt.hpp?view=auto&rev=503251
==============================================================================
--- incubator/uima/uimacpp/trunk/src/framework/uima/u2cpcnvrt.hpp (added)
+++ incubator/uima/uimacpp/trunk/src/framework/uima/u2cpcnvrt.hpp Sat Feb 3 08:58:54 2007
@@ -0,0 +1,116 @@
+/** \file u2cpcnvrt.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 Unicode2CodePageConverter a class to convert from UNICODE to several other codepages
+
+ Description:
+
+-----------------------------------------------------------------------------
+
+
+ 5/21/1999 Initial creation
+
+-------------------------------------------------------------------------- */
+
+#ifndef UIMA_U2CPCNVRT_HPP
+#define UIMA_U2CPCNVRT_HPP
+
+/* ----------------------------------------------------------------------- */
+/* Include dependencies */
+/* ----------------------------------------------------------------------- */
+
+#include "uima/pragmas.hpp" // must be first file to be included to get pragmas
+#include "uima/exceptions.hpp"
+#include "unicode/ucnv.h"
+/* ----------------------------------------------------------------------- */
+/* Constants */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/* Forward declarations */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/* Types / Classes */
+/* ----------------------------------------------------------------------- */
+
+namespace uima {
+
+ /**
+ * The class <TT>Unicode2CodePageConverter</TT> is used to convert all
+ * characters in a specified buffer from UNICODE (CCSID: CCSID::EnCCSID_UCS2),
+ * to another buffer with specified CCSID.
+ * \code
+ \endcode
+ * @see CodePage2UnicodeConverter
+ */
+ class UIMA_LINK_IMPORTSPEC Unicode2CodePageConverter {
+ public:
+ /** @name Constructors */
+ /*@{*/
+ Unicode2CodePageConverter(const char * converterName);
+ /*@}*/
+ /** @name Miscellaneous */
+ /*@{*/
+
+ /** the maximum size in bytes required when converted from Unicode to
+ using this code page converter */
+ size_t getMaximumSize(const UChar * cpclSource,
+ size_t uiSourceLength);
+
+ /** Convert the specified source buffer <TT>cpacSource</TT>, with size
+ <TT>uiSourceSize</TT> in bytes to target buffer <TT>pclTarget</TT>,
+ with size <TT>uiTargetMaxSize</TT> in bytes from the UNICODE using
+ this codepage converter. Return the number of bytes converted. */
+ size_t convertFromUnicode(char * pacTarget,
+ size_t uiTargetMaxLength,
+ const UChar * cpclSource,
+ size_t uiSourceLength);
+ /*@}*/
+
+ protected:
+ /* --- functions --- */
+ private:
+ /* --- functions --- */
+ /* BASE CONSTRUCTOR NOT SUPPORTED */
+ Unicode2CodePageConverter(void); //lint !e1704
+ /* COPY CONSTRUCTOR NOT SUPPORTED */
+ Unicode2CodePageConverter(const Unicode2CodePageConverter & ); //lint !e1704
+ /* ASSIGNMENT OPERATOR NOT SUPPORTED */
+ Unicode2CodePageConverter & operator=(const Unicode2CodePageConverter & crclObject);
+ /* --- variables --- */
+ UConverter * iv_uconverter;
+ }
+ ; /* Unicode2CodePageConverter */
+}
+
+/* ----------------------------------------------------------------------- */
+/* Implementation */
+/* ----------------------------------------------------------------------- */
+
+#endif /* UIMA_U2CPCNVRT_HPP */
+
+/* <EOF> */
+
Propchange: incubator/uima/uimacpp/trunk/src/framework/uima/u2cpcnvrt.hpp
------------------------------------------------------------------------------
svn:eol-style = native