(file) Return to cimmofRepositoryInterface.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Compiler

  1 karl  1.13 //%2006////////////////////////////////////////////////////////////////////////
  2 bob   1.1  //
  3 karl  1.10 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4            // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5            // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6 karl  1.8  // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.10 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8            // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 karl  1.11 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.13 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 bob   1.1  //
 14            // Permission is hereby granted, free of charge, to any person obtaining a copy
 15 kumpf 1.4  // of this software and associated documentation files (the "Software"), to
 16            // deal in the Software without restriction, including without limitation the
 17            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18 bob   1.1  // sell copies of the Software, and to permit persons to whom the Software is
 19            // furnished to do so, subject to the following conditions:
 20            // 
 21 kumpf 1.4  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22 bob   1.1  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24 kumpf 1.4  // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27 bob   1.1  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29            //
 30            //==============================================================================
 31            //
 32            // Author: Bob Blair (bblair@bmc.com)
 33            //
 34 kumpf 1.6  // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
 35            //                (carolann_graves@hp.com)
 36 gerarda 1.7  //              Gerarda Marquez (gmarquez@us.ibm.com)
 37              //              -- PEP 43 changes
 38 kumpf   1.9  //              Terry Martin, Hewlett-Packard Company (terry.martin@hp.com)
 39 bob     1.1  //
 40              //%/////////////////////////////////////////////////////////////////////////////
 41              
 42 kumpf   1.9  #include <Pegasus/Common/Config.h>
 43              #include <Pegasus/Common/CIMQualifierDecl.h>
 44              #include <Pegasus/Common/CIMClass.h>
 45              #include <Pegasus/Common/CIMInstance.h>
 46 bob     1.1  #include "cimmofRepository.h"
 47              #include "cimmofClient.h"
 48              #include "cimmofParser.h"
 49              #include "cimmofMessages.h"
 50 kumpf   1.9  #include "cimmofRepositoryInterface.h"
 51 bob     1.1  
 52              PEGASUS_USING_PEGASUS;
 53              
 54              cimmofRepositoryInterface::cimmofRepositoryInterface() :
 55                _repository(0),
 56                _client(0),
 57                _ot(compilerCommonDefs::USE_REPOSITORY)
 58              {
 59              }
 60              
 61              cimmofRepositoryInterface::~cimmofRepositoryInterface() {
 62                if (_repository)
 63                  delete _repository;
 64                if (_client)
 65                  delete _client;
 66              }
 67              
 68              void
 69              cimmofRepositoryInterface::init(_repositoryType type, String location,
 70 jim.wunderlich 1.12 				const CIMRepository_Mode Mode,
 71 bob            1.1  				compilerCommonDefs::operationType ot)
 72                     {
 73                       String message;
 74                       cimmofMessages::arglist arglist;
 75                       _ot = ot;
 76                       if (type == REPOSITORY_INTERFACE_LOCAL) {
 77                         // create a cimmofRepository object and put it in _repository
 78                         cimmofParser *p = cimmofParser::Instance();
 79                         const String NameSpace = p->getDefaultNamespacePath();
 80                         if (location != "") {
 81 jim.wunderlich 1.12       try { 
 82                     	_repository = new cimmofRepository(location, Mode,  _ot);
 83 bob            1.1        } catch(Exception &e) {
 84                             arglist.append(location);
 85                             arglist.append(e.getMessage());
 86                             cimmofMessages::getMessage(message,
 87                                                       cimmofMessages::REPOSITORY_CREATE_ERROR,
 88                                                       arglist);
 89                             p->elog(message);
 90                             delete _repository;
 91                             _repository = 0;
 92                           }
 93                         }
 94                       } else if (type == REPOSITORY_INTERFACE_CLIENT) {
 95                         // create a CIMClient object and put it in _client
 96                         _client = new cimmofClient();
 97                         try {
 98                           _client->init(location, ot);
 99 kumpf          1.5      } catch(Exception &e) {
100 bob            1.1        arglist.append(location);
101                           arglist.append(e.getMessage());
102                           cimmofMessages::getMessage(message,
103                     				 cimmofMessages::REPOSITORY_CREATE_ERROR,
104                     				 arglist);
105                           cimmofParser *p = cimmofParser::Instance();
106                           p->elog(message);
107                           delete _client;
108                           _client = 0;
109                         }
110                       } else {
111                         // throw an exception
112                       }
113                     }
114                     
115                     void
116 kumpf          1.6  cimmofRepositoryInterface::addClass(const CIMNamespaceName &nameSpace, 
117                         CIMClass &Class)
118 bob            1.1    const {
119                       if (_repository)
120                         _repository->addClass(nameSpace, &Class);
121                       if (_client)
122 kumpf          1.2        _client->addClass(nameSpace, Class);
123 bob            1.1  }
124                     
125                     void
126 kumpf          1.6  cimmofRepositoryInterface::addQualifier(const CIMNamespaceName &nameSpace,
127 bob            1.1  					CIMQualifierDecl &qualifier) const
128                     {
129                       if (_repository)
130                         _repository->addQualifier(nameSpace, &qualifier);
131                       if (_client)
132 kumpf          1.5      _client->addQualifier(nameSpace, qualifier);
133 bob            1.1  }
134                     
135                     void
136 kumpf          1.6  cimmofRepositoryInterface::addInstance(const CIMNamespaceName &nameSpace,
137 bob            1.1  				       CIMInstance &instance) const
138                     {
139                       if (_repository)
140                         _repository->addInstance(nameSpace, &instance);
141                       if (_client)
142 kumpf          1.5      _client->addInstance(nameSpace, instance);
143 bob            1.1  }
144                     
145                     CIMQualifierDecl
146 kumpf          1.6  cimmofRepositoryInterface::getQualifierDecl(const CIMNamespaceName &nameSpace,
147                     					    const CIMName &qualifierName) const
148 bob            1.1  {
149                       if (_repository)
150                         return (_repository->getQualifierDecl(nameSpace, qualifierName));
151                       else if (_client)
152 kumpf          1.5      return (_client->getQualifierDecl(nameSpace, qualifierName));
153 bob            1.1    else
154                         return CIMQualifierDecl();
155                     }
156                     
157                     CIMClass
158 kumpf          1.6  cimmofRepositoryInterface::getClass(const CIMNamespaceName &nameSpace,
159                     				    const CIMName &className) const
160 bob            1.1  {
161                       if (_repository)
162                         return (_repository->getClass(nameSpace, className));
163                       else if (_client)
164 kumpf          1.5      return (_client->getClass(nameSpace, className));
165 bob            1.1    else
166                         return CIMClass();
167 gerarda        1.7  }
168                     
169                     void
170                     cimmofRepositoryInterface::modifyClass(const CIMNamespaceName &nameSpace, 
171                         CIMClass &Class)
172                       const {
173                       if (_repository)
174                       {
175                         _repository->modifyClass(nameSpace, &Class);
176                       }
177                       if (_client)
178                       {
179                         _client->modifyClass(nameSpace, Class);
180                       }
181 bob            1.1  }
182                     
183                     void
184 kumpf          1.6  cimmofRepositoryInterface::createNameSpace(
185                         const CIMNamespaceName &nameSpace) const
186 bob            1.1  {
187                       if (_repository)
188                         _repository->createNameSpace(nameSpace);
189                       else if (_client)
190 kumpf          1.3    {
191 kumpf          1.2        _client->createNameSpace(nameSpace);
192 kumpf          1.3    }
193 bob            1.1  }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2