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

  1 martin 1.18 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.19 //
  3 martin 1.18 // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9 martin 1.19 //
 10 martin 1.18 // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16 martin 1.19 //
 17 martin 1.18 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.19 //
 20 martin 1.18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.19 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.18 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.19 //
 28 martin 1.18 //////////////////////////////////////////////////////////////////////////
 29 bob    1.1  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32 kumpf  1.9  #include <Pegasus/Common/Config.h>
 33             #include <Pegasus/Common/CIMQualifierDecl.h>
 34             #include <Pegasus/Common/CIMClass.h>
 35             #include <Pegasus/Common/CIMInstance.h>
 36 bob    1.1  #include "cimmofRepository.h"
 37             #include "cimmofClient.h"
 38             #include "cimmofParser.h"
 39             #include "cimmofMessages.h"
 40 kumpf  1.9  #include "cimmofRepositoryInterface.h"
 41 bob    1.1  
 42 mike   1.17 #ifdef PEGASUS_ENABLE_MRR_GENERATION
 43             # include "cimmofMRR.h"
 44             #endif
 45             
 46 bob    1.1  PEGASUS_USING_PEGASUS;
 47             
 48             cimmofRepositoryInterface::cimmofRepositoryInterface() :
 49               _repository(0),
 50               _client(0),
 51 mike   1.17   _mrr(0),
 52 bob    1.1    _ot(compilerCommonDefs::USE_REPOSITORY)
 53             {
 54             }
 55             
 56 karl   1.16 cimmofRepositoryInterface::~cimmofRepositoryInterface()
 57             {
 58 bob    1.1      delete _repository;
 59                 delete _client;
 60 mike   1.17 #ifdef PEGASUS_ENABLE_MRR_GENERATION
 61                 delete _mrr;
 62             #endif
 63 bob    1.1  }
 64             
 65 karl   1.16 void cimmofRepositoryInterface::init(_repositoryType type, String location,
 66                             Uint32 mode,
 67 mike   1.17                 compilerCommonDefs::operationType ot,
 68                             bool descriptions)
 69 karl   1.16 {
 70                 String message;
 71                 cimmofMessages::arglist arglist;
 72                 _ot = ot;
 73                 if (type == REPOSITORY_INTERFACE_LOCAL)
 74                 {
 75                     // create a cimmofRepository object and put it in _repository
 76                     cimmofParser *p = cimmofParser::Instance();
 77                     const String NameSpace = p->getDefaultNamespacePath();
 78                     if (location != "")
 79                     {
 80                         try
 81                         {
 82                             _repository = new cimmofRepository(location, mode, _ot);
 83                         }
 84                         catch(Exception &e)
 85                         {
 86                             arglist.append(location);
 87                             arglist.append(e.getMessage());
 88                             cimmofMessages::getMessage(message,
 89                                     cimmofMessages::REPOSITORY_CREATE_ERROR,
 90 karl   1.16                         arglist);
 91                             p->elog(message);
 92                             delete _repository;
 93                             _repository = 0;
 94                         }
 95                     }
 96                 }
 97                 else if (type == REPOSITORY_INTERFACE_CLIENT)
 98                 {
 99                     // create a CIMClient object and put it in _client
100                     _client = new cimmofClient();
101                     try
102                     {
103                         _client->init(location, ot);
104                     }
105 denise.eckstein 1.20         catch (const CannotConnectException &)
106                              {
107                                  delete _client;
108                                  _client = 0;
109                                  throw;
110                              }
111 karl            1.16         catch(Exception &e)
112                              {
113                                  arglist.append(location);
114                                  arglist.append(e.getMessage());
115                                  cimmofMessages::getMessage(message,
116                                          cimmofMessages::REPOSITORY_CREATE_ERROR,
117                                          arglist);
118                                  cimmofParser *p = cimmofParser::Instance();
119                                  p->elog(message);
120                                  delete _client;
121                                  _client = 0;
122                              }
123                          }
124 mike            1.17 #ifdef PEGASUS_ENABLE_MRR_GENERATION
125                          else if (type == REPOSITORY_INTERFACE_MRR)
126                          {
127                              // create memory-resident repository handler.
128                              _mrr = new cimmofMRR(descriptions);
129                          }
130                      #endif
131 karl            1.16     else
132                          {
133                              // throw an exception
134                          }
135                      }
136                      
137                      void cimmofRepositoryInterface::addClass(const CIMNamespaceName &nameSpace,
138                          CIMClass &Class)  const
139                      {
140                          if (_repository)
141                              _repository->addClass(nameSpace, &Class);
142                          if (_client)
143                              _client->addClass(nameSpace, Class);
144 mike            1.17 #ifdef PEGASUS_ENABLE_MRR_GENERATION
145                          if (_mrr)
146                              _mrr->addClass(nameSpace, Class);
147                      #endif
148 karl            1.16 }
149                      
150                      void cimmofRepositoryInterface::addQualifier(const CIMNamespaceName &nameSpace,
151                                          CIMQualifierDecl &qualifier) const
152                      {
153                          if (_repository)
154                              _repository->addQualifier(nameSpace, &qualifier);
155                          if (_client)
156                              _client->addQualifier(nameSpace, qualifier);
157 mike            1.17 #ifdef PEGASUS_ENABLE_MRR_GENERATION
158                          if (_mrr)
159                              _mrr->addQualifier(nameSpace, qualifier);
160                      #endif
161 karl            1.16 }
162                      
163                      void cimmofRepositoryInterface::addInstance(const CIMNamespaceName &nameSpace,
164                                             CIMInstance &instance) const
165                      {
166                          if (_repository)
167                              _repository->addInstance(nameSpace, &instance);
168                          if (_client)
169                              _client->addInstance(nameSpace, instance);
170 mike            1.17 #ifdef PEGASUS_ENABLE_MRR_GENERATION
171                          if (_mrr)
172                              _mrr->addInstance(nameSpace, instance);
173                      #endif
174 karl            1.16 }
175                      
176                      CIMQualifierDecl cimmofRepositoryInterface::getQualifierDecl(
177                              const CIMNamespaceName &nameSpace,
178                              const CIMName &qualifierName) const
179                      {
180                          if (_repository)
181                              return (_repository->getQualifierDecl(nameSpace, qualifierName));
182                          else if (_client)
183                              return (_client->getQualifierDecl(nameSpace, qualifierName));
184 mike            1.17 #ifdef PEGASUS_ENABLE_MRR_GENERATION
185                          else if (_mrr)
186                              return (_mrr->getQualifierDecl(nameSpace, qualifierName));
187                      #endif
188 karl            1.16     else
189                              return CIMQualifierDecl();
190                      }
191                      
192                      CIMClass cimmofRepositoryInterface::getClass(const CIMNamespaceName &nameSpace,
193                                          const CIMName &className) const
194                      {
195                          if (_repository)
196                              return (_repository->getClass(nameSpace, className));
197                          else if (_client)
198                              return (_client->getClass(nameSpace, className));
199 mike            1.17 #ifdef PEGASUS_ENABLE_MRR_GENERATION
200                          else if (_mrr)
201                              return (_mrr->getClass(nameSpace, className));
202                      #endif
203 karl            1.16     else
204                              return CIMClass();
205 bob             1.1  }
206                      
207 karl            1.16 void cimmofRepositoryInterface::modifyClass(const CIMNamespaceName &nameSpace,
208                          CIMClass &Class) const
209                      {
210                          if (_repository)
211                          {
212                              _repository->modifyClass(nameSpace, &Class);
213                          }
214                          if (_client)
215                          {
216                              _client->modifyClass(nameSpace, Class);
217                          }
218 mike            1.17 #ifdef PEGASUS_ENABLE_MRR_GENERATION
219                          if (_mrr)
220                          {
221                              _mrr->modifyClass(nameSpace, Class);
222                          }
223                      #endif
224 karl            1.16 }
225                      
226                      void cimmofRepositoryInterface::createNameSpace(
227 kumpf           1.6      const CIMNamespaceName &nameSpace) const
228 bob             1.1  {
229 karl            1.16     if (_repository)
230                              _repository->createNameSpace(nameSpace);
231                          else if (_client)
232                          {
233                              _client->createNameSpace(nameSpace);
234                          }
235 mike            1.17 #ifdef PEGASUS_ENABLE_MRR_GENERATION
236                          else if (_mrr)
237                          {
238                              _mrr->createNameSpace(nameSpace);
239                          }
240                      #endif
241                      }
242                      
243                      void cimmofRepositoryInterface::start()
244                      {
245                      #ifdef PEGASUS_ENABLE_MRR_GENERATION
246                          if (_mrr)
247                              _mrr->start();
248                      #endif
249                      }
250                      
251                      void cimmofRepositoryInterface::finish()
252                      {
253                      #ifdef PEGASUS_ENABLE_MRR_GENERATION
254                          if (_mrr)
255                              _mrr->finish();
256 mike            1.17 #endif
257 bob             1.1  }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2