Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

gdalmajorobject.cpp

00001 /******************************************************************************
00002  * $Id: gdalmajorobject_cpp-source.html,v 1.10 2002/04/16 13:11:48 warmerda Exp $
00003  *
00004  * Project:  GDAL Core
00005  * Purpose:  Base class for objects with metadata, etc.
00006  * Author:   Frank Warmerdam, warmerda@home.com
00007  *
00008  ******************************************************************************
00009  * Copyright (c) 2000, Frank Warmerdam
00010  *
00011  * Permission is hereby granted, free of charge, to any person obtaining a
00012  * copy of this software and associated documentation files (the "Software"),
00013  * to deal in the Software without restriction, including without limitation
00014  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00015  * and/or sell copies of the Software, and to permit persons to whom the
00016  * Software is furnished to do so, subject to the following conditions:
00017  *
00018  * The above copyright notice and this permission notice shall be included
00019  * in all copies or substantial portions of the Software.
00020  *
00021  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00022  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00023  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00024  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00025  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00026  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00027  * DEALINGS IN THE SOFTWARE.
00028  ******************************************************************************
00029  *
00030  * $Log: gdalmajorobject_cpp-source.html,v $
00030  * Revision 1.10  2002/04/16 13:11:48  warmerda
00030  * updated
00030  *
00031  * Revision 1.4  2001/09/25 15:56:37  warmerda
00032  * implemented rest of C entry points for metadata, document C++ methods
00033  *
00034  * Revision 1.3  2001/07/18 04:04:30  warmerda
00035  * added CPL_CVSID
00036  *
00037  * Revision 1.2  2000/06/26 15:26:21  warmerda
00038  * added GDALGetDescription
00039  *
00040  * Revision 1.1  2000/04/20 20:52:03  warmerda
00041  * New
00042  *
00043  */
00044 
00045 #include "gdal_priv.h"
00046 #include "cpl_string.h"
00047 
00048 CPL_CVSID("$Id: gdalmajorobject_cpp-source.html,v 1.10 2002/04/16 13:11:48 warmerda Exp $");
00049 
00050 /************************************************************************/
00051 /*                          GDALMajorObject()                           */
00052 /************************************************************************/
00053 
00054 GDALMajorObject::GDALMajorObject()
00055 
00056 {
00057     pszDescription = NULL;
00058     papszMetadata = NULL;
00059 }
00060 
00061 /************************************************************************/
00062 /*                          ~GDALMajorObject()                          */
00063 /************************************************************************/
00064 
00065 GDALMajorObject::~GDALMajorObject()
00066 
00067 {
00068     CPLFree( pszDescription );
00069     CSLDestroy( papszMetadata );
00070 }
00071 
00072 /************************************************************************/
00073 /*                           GetDescription()                           */
00074 /************************************************************************/
00075 
00086 const char *GDALMajorObject::GetDescription() const
00087 
00088 {
00089     if( pszDescription == NULL )
00090         return "";
00091     else
00092         return pszDescription;
00093 }
00094 
00095 /************************************************************************/
00096 /*                         GDALGetDescription()                         */
00097 /************************************************************************/
00098 
00099 const char *GDALGetDescription( GDALMajorObjectH hObject )
00100 
00101 {
00102     return ((GDALMajorObject *) hObject)->GetDescription();
00103 }
00104 
00105 /************************************************************************/
00106 /*                           SetDescription()                           */
00107 /************************************************************************/
00108 
00109 void GDALMajorObject::SetDescription( const char * pszNewDesc ) 
00110 
00111 {
00112     CPLFree( pszDescription );
00113     pszDescription = CPLStrdup( pszNewDesc );
00114 }
00115 
00116 /************************************************************************/
00117 /*                            GetMetadata()                             */
00118 /************************************************************************/
00119 
00138 char **GDALMajorObject::GetMetadata( const char * pszDomain )
00139 
00140 {
00141     if( pszDomain == NULL || EQUAL(pszDomain,"") )
00142         return papszMetadata;
00143     else
00144         return NULL;
00145 }
00146 
00147 /************************************************************************/
00148 /*                          GDALGetMetadata()                           */
00149 /************************************************************************/
00150 
00151 char **GDALGetMetadata( GDALMajorObjectH hObject, const char * pszDomain )
00152 
00153 {
00154     return ((GDALMajorObject *) hObject)->GetMetadata(pszDomain);
00155 }
00156 
00157 /************************************************************************/
00158 /*                            SetMetadata()                             */
00159 /************************************************************************/
00160 
00175 CPLErr GDALMajorObject::SetMetadata( char ** papszMetadataIn, 
00176                                      const char * pszDomain )
00177 
00178 {
00179     if( pszDomain != NULL && !EQUAL(pszDomain,"") )
00180     {
00181         CPLError( CE_Failure, CPLE_NotSupported, 
00182                   "Non-default domain not supported for this object." );
00183         return CE_Failure;
00184     }
00185 
00186     CSLDestroy( papszMetadata );
00187     papszMetadata = CSLDuplicate( papszMetadataIn );
00188     
00189     return CE_None;
00190 }
00191 
00192 /************************************************************************/
00193 /*                          GDALSetMetadata()                           */
00194 /************************************************************************/
00195 
00196 CPLErr GDALSetMetadata( GDALMajorObjectH hObject, char **papszMD, 
00197                         const char *pszDomain )
00198 
00199 {
00200     return ((GDALMajorObject *) hObject)->SetMetadata( papszMD, pszDomain );
00201 }
00202 
00203 
00204 /************************************************************************/
00205 /*                          GetMetadataItem()                           */
00206 /************************************************************************/
00207 
00220 const char *GDALMajorObject::GetMetadataItem( const char * pszName, 
00221                                               const char * pszDomain )
00222 
00223 {
00224     char  **papszMD = GetMetadata( pszDomain );
00225     
00226     return CSLFetchNameValue( papszMD, pszName );
00227 }
00228 
00229 /************************************************************************/
00230 /*                        GDALGetMetadataItem()                         */
00231 /************************************************************************/
00232 
00233 const char *GDALGetMetadataItem( GDALMajorObjectH hObject, 
00234                                  const char *pszName, 
00235                                  const char *pszDomain )
00236 
00237 {
00238     return ((GDALMajorObject *) hObject)->GetMetadataItem( pszName, pszDomain);
00239 }
00240 
00241 /************************************************************************/
00242 /*                          SetMetadataItem()                           */
00243 /************************************************************************/
00244 
00257 CPLErr GDALMajorObject::SetMetadataItem( const char * pszName, 
00258                                          const char * pszValue, 
00259                                          const char * pszDomain )
00260 
00261 {
00262     if( pszDomain != NULL && !EQUAL(pszDomain,"") )
00263     {
00264         CPLError( CE_Failure, CPLE_NotSupported, 
00265                   "Non-default domain not supported for this object." );
00266         return CE_Failure;
00267     }
00268 
00269     papszMetadata = CSLSetNameValue( papszMetadata, pszName, pszValue );
00270 
00271     return CE_None;
00272 }
00273 
00274 /************************************************************************/
00275 /*                        GDALSetMetadataItem()                         */
00276 /************************************************************************/
00277 
00278 CPLErr GDALSetMetadataItem( GDALMajorObjectH hObject, 
00279                             const char *pszName, const char *pszValue, 
00280                             const char *pszDomain )
00281 
00282 {
00283     return ((GDALMajorObject *) hObject)->SetMetadataItem( pszName, pszValue,
00284                                                            pszDomain );
00285 }

Generated at Thu Mar 28 09:47:30 2002 for GDAL by doxygen1.2.3-20001105 written by Dimitri van Heesch, © 1997-2000