/* * $Id: tm.h,v 1.1.1.1 2004/08/25 19:21:21 jan Exp $ * * Copyright (c) 2002,2003 Jan Algermissen * See the file "COPYING" for copying permission. * */ #ifndef TM_H #define TM_H #ifdef __cplusplus extern "C" { #endif #include "tmtk.h" #include "tmerror.h" #include "tmmodel.h" /* #include "tmdisclosureframework.h" */ /** \defgroup TMLibHandle * \ingroup LibraryCore * * Global library handle. * * @{ */ /** The TmTk handle. * Per process/thread library handle. * If using several threads, use one handle per thread. */ typedef struct TM *TM; #include "tmvaluetype.h" #include "tmstorage.h" /* #include "tmdisclosureframework.h" */ /** Log levels. * These log levels are available: */ typedef enum { TM_LOG_NOTHING = 0, /**< log nothing */ TM_LOG_CRITICAL, /**< log critical errors only */ TM_LOG_ERROR, /**< log errors and critical */ TM_LOG_WARNING, /**< log warnings, errors and critical */ TM_LOG_INFO, /**< log info, warnings, errors and critical */ TM_LOG_DEBUG /**< log everything */ } TMLogLevel; #ifndef TM_DISABLE_LOGS # undef _ # define _ , # define TM_LOG(TM,LEVEL,ARGS) do { tm_log((TM),(LEVEL),ARGS); } while (0) #else # define TM_LOG(TM,LEVEL,ARGS) /* empty */ #endif /* TM_DISABLE_LOGS */ /** Initialize a library handle. * TMTK uses a global handle for certain initialization, * error message management and the like. This function creates * and initializes a new library handle. * * @return the library handle; */ TM_API(TM) tm_init(void); /** Set the disclosure framework to be used. * * @param tm the library handle * @param df_name the name of the disclosure framework (there * is currently only 'www-df', but TMTK might be used with any * kind of technology (not just HTTP/XML) in the future. * @param df_arg this is a generic argument, currently unused, but * maybe later, we want to pas something in. Simply set this to * NULL for now. * * @return TM_OK on success, error code otherwise. */ TM_API(TMError) tm_set_df(TM tm,const char *df_name,void *df_arg); /** Cleanup a library handle. * @param ptm pointer to library handle. */ TM_API(void) tm_cleanup(TM *ptm); /** Set log level. * Set the maximum level of messages to be logged. */ TM_API(int) tm_set_loglevel(TM tm,int level); /** Log something. * Print a log message to stdout. * @todo allow user defined log function. * @param tm library handle * @param level log level * @param fmt printf style format string, followed by arguments * */ TM_API(void) tm_log(TM tm,int level,const char *fmt,...); /** Set lib handle's error message. * */ TM_API(const char*) tm_set_error(TM self, const char *fmt,...); /** Get libhandle's error message. * */ TM_API(const char*) tm_get_error(TM self); /** Lookup a value type implementation by its name. * */ TM_API(TMValueType) tm_lookup_valuetype(TM self,const char *name); /** Lookup a storage implementation by its name. * */ TM_API(TMTopicMapStorageDescriptor) tm_lookup_storage_descriptor(TM self,const char *name); /** Get the disclosure framework of the TM handle. * (currently only ;www-df' is available) */ /* TM_API(TMDisclosureFramework) tm_get_disclosureframework(TM self); */ /** Lookup a model by its name. * Model objects (regardless of how they came into being) are * are cached in the library's internal model cache, thus * subsequent calls to this function do not impose significant * overhead. * */ TM_API(TMError) tm_lookup_model(TM tm,const char *name,TMModel *mp); /** * * */ TM_API(TMProperty) tm_get_property(TM tm,const char *fullname); /** Get the resource pool of the handle. * This is the top resource pool, the root of the pool tree. * Allocations made with this pool will only be cleaned up when the * elibrary handle is destructed. * @param tm the library handle * @return the pool. */ TM_API(TMPool) tm_get_pool(TM tm); TM_API(void) tm_model_dict_put(TM self, const char *name,void *data); TM_API(void*) tm_model_dict_lookup(TM self, const char *name); /** @} */ #ifdef __cplusplus } // extern "C" #endif #endif /* ifndef TM_H */