ApiUtilities.h

Go to the documentation of this file.
00001 /*
00002 * The information in this file is
00003 * Copyright(c) 2007 Ball Aerospace & Technologies Corporation
00004 * and is subject to the terms and conditions of the
00005 * GNU Lesser General Public License Version 2.1
00006 * The license text is available from   
00007 * http://www.gnu.org/licenses/lgpl.html
00008 */
00009 
00010 #ifndef APIUTILITIES_H__
00011 #define APIUTILITIES_H__
00012 
00013 #include "AppConfig.h"
00014 
00015 class DataElement;
00016 class Layer;
00017 class View;
00018 
00019 #ifdef __cplusplus
00020 extern "C"
00021 {
00022 #endif
00023    /** \addtogroup simple_api
00024     *  This group of functions represents a datacentric API which is compatible
00025     *  with C calling conventions and can be used from a variety of programming language
00026     *  interpreters. Some C++ classes are passed around and may be treated as opaque pointers
00027     *  but their partial declarations may cause compilation errors. In most cases you
00028     *  can create a preprocessor definition for the \c class keyword which resolves to
00029     *  \c typedef \c void* to resolve these compilation problems.
00030     */
00031    /*@{*/
00032 
00033    /**
00034     * @file ApiUtilities.h
00035     * This file contains general API utilities which don't fit well into another category.
00036     */
00037 
00038    /**
00039     * Initialize the services pointer.
00040     *
00041     * @param pExternal
00042     *        Opaque handle obtained from ModuleManager::instance()->getServices() called from
00043     *        the main Opticks module. This generally needs to be called when loading the
00044     *        simple API from a DSO. If a static library is used, this may not be needed.
00045     *
00046     * @see handle()
00047     */
00048    EXPORT_SYMBOL void setHandle(void* pExternal);
00049 
00050    /**
00051     * Get the services pointer for future initialization.
00052     *
00053     * @return An opaque handle which can be passed to setHandle() in another module.
00054     *         This function should be called from the main Opticks module. The corresponding
00055     *         setHandle() function is then called from other modules. This generally needs to be
00056     *         used when loading the simple API from a DSO. If a static library is used, this may not be needed.
00057     * @see setHandle()
00058     */
00059    EXPORT_SYMBOL void* handle();
00060 
00061    /**
00062     * Get the application version number as a string.
00063     *
00064     * @param pVersion
00065     *        Buffer to store the version string. This will be \c NULL terminated.
00066     * @param versionSize
00067     *        The size of the buffer. If the version string is too long an error will be set.
00068     *        If this is 0, the minimum size of the buffer including the trailing \c NULL will be returned.
00069     * @return the actual length of the version string.
00070     */
00071    EXPORT_SYMBOL uint32_t getOpticksVersion(char* pVersion, uint32_t versionSize);
00072 
00073    /**
00074     * Get the test data path.
00075     *
00076     * @param pPath
00077     *        Buffer to store the path. This will be \c NULL terminated.
00078     * @param pathSize
00079     *        The size of the Buffer. If the name is too long, an error
00080     *        will be set.
00081     *        If this is 0, the minimum size of the buffer including the trailing \c NULL will be returned.
00082     * @return the actual length of the path.
00083     */
00084    EXPORT_SYMBOL uint32_t getTestDataPath(char* pPath, uint32_t pathSize);
00085 
00086    /**
00087     * Load a file using the autoimporter.
00088     *
00089     * @param pFilename
00090     *        The filename to load.
00091     * @param batch
00092     *        If zero, load in interactive mode, otherwise load in batch mode.
00093     * @return The number of datasets which were loaded. A 0 return value may indicate an error.
00094     */
00095    EXPORT_SYMBOL uint32_t loadFile(const char* pFilename, int batch);
00096 
00097    /**
00098     * Get a DataElement pointer given an identifying name.
00099     *
00100     * @param pName
00101     *        First, an attempt will be made to use this as a session ID.
00102     *        Next, this will be split into an item name path with a | delimiter.
00103     *        The DataElement tree is traversed until the requested item is found or an error occurs. Each item in the
00104     *        name path will be treated as a DataElement name. If an item is not found, each child of the current parent
00105     *        is checked against a display name.
00106     *
00107     * @param pType
00108     *        If not \c NULL or empty, an element of this type will be returned. See TypeConverter for valid type names.
00109     *
00110     * @param create
00111     *        If the element does not exists, should it be created? If zero, an element will not be created. If
00112     *        non-zero, an attempt will be made to create the element. pType must not be \c NULL if an element is to be
00113     *        created. Certain elements can't be created this way, most notably RasterElement.
00114     *
00115     * @return A pointer to the requested DataElement or \c NULL if the element is not found.
00116     *         If the element is not found, getLastError() may be queried for information on the error.
00117     *
00118     * @see createRasterElement()
00119     */
00120    EXPORT_SYMBOL DataElement* getDataElement(const char* pName, const char* pType, int create);
00121 
00122    /**
00123     * Permanently destroy a DataElement.
00124     *
00125     * Suitable for use as a cleanup callback.
00126     *
00127     * @param pElement
00128     *        The DataElement to destroy.
00129     *        No error checking is performed on this value and a \c NULL will cause a NOOP.
00130     * @see ModelServices::destroyElement()
00131     */
00132    EXPORT_SYMBOL void destroyDataElement(DataElement* pElement);
00133 
00134    /**
00135     * Get the name of the given DataElement.
00136     *
00137     * @param pElement
00138     *        The DataElement to query.
00139     * @param pName
00140     *        Buffer to store the name. This will be \c NULL terminated.
00141     * @param nameSize
00142     *        The size of the buffer. If the name is too long, an error will be set.
00143     *        If this is 0, the minimum size of the buffer including the trailing \c NULL will be returned.
00144     * @return the actual length of the name.
00145     */
00146    EXPORT_SYMBOL uint32_t getDataElementName(DataElement* pElement, char* pName, uint32_t nameSize);
00147 
00148    /**
00149     * Get the type name of the given DataElement.
00150     *
00151     * @param pElement
00152     *        The DataElement to query.
00153     * @param pType
00154     *        Buffer to store the type name. This will be \c NULL terminated.
00155     * @param typeSize
00156     *        The size of the buffer. If the type name is too long, an error will be set.
00157     *        If this is 0, the minimum size of the buffer including the trailing \c NULL will be returned.
00158     * @return the actual length of the type name.
00159     */
00160    EXPORT_SYMBOL uint32_t getDataElementType(DataElement* pElement, char* pType, uint32_t typeSize);
00161 
00162    /**
00163     * Get the name of the file corresponding to the given DataElement.
00164     *
00165     * @param pElement
00166     *        The DataElement to query.
00167     * @param pFilename
00168     *        Buffer to store the filename. This will be \c NULL terminated.
00169     * @param filenameSize
00170     *        The size of the Buffer. If the filename is too long, an error
00171     *        will be set.
00172     *        If this is 0, the minimum size of the buffer including the trailing \c NULL will be returned.
00173     * @return the actual length of the filename.
00174     *
00175     * @see getDataElement()
00176     */
00177    EXPORT_SYMBOL uint32_t getDataElementFilename(DataElement* pElement, char* pFilename, uint32_t filenameSize);
00178 
00179    /**
00180     * Get the number of child DataElements of a given DataElement.
00181     *
00182     * @param pElement
00183     *        The DataElement to query.
00184     * @return the number of children.
00185     */
00186    EXPORT_SYMBOL uint32_t getDataElementChildCount(DataElement* pElement);
00187 
00188    /**
00189     * Get a child of a DataElement.
00190     *
00191     * @param pElement
00192     *        The parent DataElement.
00193     * @param index
00194     *        The index of the child. This may change as children are added and removed.
00195     * @return the child DataElement.
00196     */
00197    EXPORT_SYMBOL DataElement* getDataElementChild(DataElement* pElement, uint32_t index);
00198 
00199    /**
00200     * Cast a DataElement to a sub-type.
00201     *
00202     * @param pElement
00203     *        The DataElement to cast.
00204     * @param pType
00205     *        The name of the sub-type.
00206     * @return A void* to the cast element or \c NULL if the cast is invalid.
00207     */
00208    EXPORT_SYMBOL void* castDataElement(DataElement* pElement, const char* pType);
00209 
00210    /**
00211     * Cast a DataElement sub-type to a DataElement.
00212     *
00213     * @param pElement
00214     *        The sub-type to cast as a void*.
00215     * @param pType
00216     *        The name of the sub-type.
00217     * @return A DataElement* or \c NULL if the cast is invalid.
00218     */
00219    EXPORT_SYMBOL DataElement* castToDataElement(void* pElement, const char* pType);
00220 
00221    /**
00222     * Cast a Layer to a sub-type.
00223     *
00224     * @param pLayer
00225     *        The Layer to cast.
00226     * @param pType
00227     *        The name of the sub-type.
00228     * @return A void* to the cast layer or \c NULL if the cast is invalid.
00229     */
00230    EXPORT_SYMBOL void* castLayer(Layer* pLayer, const char* pType);
00231 
00232    /**
00233     * Copy the classification from a data element to another data element.
00234     *
00235     * @param pCopyFrom
00236     *        The DataElement from which the classification is to be copied.
00237     * @param pCopyTo
00238     *        The DataElement to which the classification is to be copied.
00239     */
00240    EXPORT_SYMBOL void copyClassification(DataElement* pCopyFrom, DataElement* pCopyTo);
00241 
00242    /*@}*/
00243 #ifdef __cplusplus
00244 }
00245 #endif
00246 
00247 #endif

Software Development Kit - Opticks 4.9.0 Build 16218