1 martin 1.27 //%LICENSE////////////////////////////////////////////////////////////////
2 //
3 // 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 //
10 // 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 //
17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 martin 1.27 // 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 //
28 //////////////////////////////////////////////////////////////////////////
|
29 mike 1.9 //
30 //%/////////////////////////////////////////////////////////////////////////////
31 //
|
32 bob 1.10 // implementation of cimmofRepository
33 //
|
34 mike 1.9 //
35 //
|
36 bob 1.11 // This class acts as a buffer between the compiler and the repository
|
37 david.eger 1.16 // interface. The main thing it does is registers a non-standard
|
38 bob 1.11 // DeclContext so we can do local checking of context for new objects
|
39 mike 1.9 //
40
41 #include "cimmofRepository.h"
42
|
43 bob 1.11 PEGASUS_USING_PEGASUS;
44
|
45 karl 1.23 cimmofRepository::cimmofRepository(const String& path,
|
46 kumpf 1.22 Uint32 mode,
47 compilerCommonDefs::operationType ot)
48 : _cimrepository(0), _context(0), _ot(ot)
|
49 bob 1.10 {
|
50 dmitry.mikulin 1.26 // Decl context is allocated here but will be owned and deleted by
51 // the CIMRepository class
52 _context = new compilerDeclContext(_ot);
53
|
54 karl 1.23 // don't catch the exceptions that might be thrown. They should go up.
55 if (_ot != compilerCommonDefs::IGNORE_REPOSITORY) {
|
56 dmitry.mikulin 1.26 _cimrepository = new CIMRepository(path, mode, _context);
|
57 karl 1.23 }
|
58 dmitry.mikulin 1.26
|
59 karl 1.23 if (_cimrepository)
|
60 dmitry.mikulin 1.26 {
61 _context->setRepository(_cimrepository);
62 }
63 else if (ot != compilerCommonDefs::IGNORE_REPOSITORY)
64 {
65 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
66 "attempt to initialize repository with invalid data");
67 }
|
68 bob 1.10 }
|
69 mike 1.9
|
70 karl 1.23 cimmofRepository::~cimmofRepository()
71 {
|
72 dmitry.mikulin 1.26 delete _cimrepository;
|
73 bob 1.10 }
|
74 mike 1.9
|
75 karl 1.23 int cimmofRepository::addClass(const CIMNamespaceName &nameSpace,
76 CIMClass *classdecl)
|
77 mike 1.9 {
|
78 karl 1.23 // Don't catch errors: pass them up to the requester
79 _context->addClass( nameSpace, *classdecl);
80 return 0;
|
81 mike 1.9 }
82
83
|
84 karl 1.23 int cimmofRepository::addInstance(const CIMNamespaceName &nameSpace,
85 CIMInstance *instance)
86 {
87 // Don't catch errors: pass them up to the requester
88 _context->addInstance(nameSpace, *instance);
89 return 0;
|
90 mike 1.9 }
91
|
92 karl 1.23 int cimmofRepository::addQualifier(const CIMNamespaceName &nameSpace,
93 CIMQualifierDecl *qualifier)
94 {
95 // Don't catch errors: pass them up to the requester
96 _context->addQualifierDecl(nameSpace, *qualifier);
97 return 0;
|
98 mike 1.9 }
99
|
100 karl 1.23 CIMQualifierDecl cimmofRepository::getQualifierDecl(
101 const CIMNamespaceName &nameSpace,
102 const CIMName &name)
|
103 mike 1.9 {
|
104 karl 1.23 // Don't catch errors: pass them up to the requester
105 return _context->lookupQualifierDecl(nameSpace, name);
|
106 mike 1.9 }
107
|
108 karl 1.23 CIMClass cimmofRepository::getClass(const CIMNamespaceName &nameSpace,
109 const CIMName &classname)
|
110 bob 1.10 {
|
111 karl 1.23 // Don't catch errors: pass them up to the requester
112 return _context->lookupClass(nameSpace, classname);
|
113 gerarda 1.15 }
114
|
115 karl 1.23 int cimmofRepository::modifyClass(const CIMNamespaceName &nameSpace,
116 CIMClass *classdecl)
|
117 gerarda 1.15 {
|
118 karl 1.23 // Don't catch errors: pass them up to the requester
119 _context->modifyClass( nameSpace, *classdecl);
120 return 0;
|
121 bob 1.10 }
|
122 mike 1.9
|
123 karl 1.23 void cimmofRepository::createNameSpace(const CIMNamespaceName &nameSpaceName)
|
124 bob 1.10 {
|
125 karl 1.23 if (_cimrepository && _ot != compilerCommonDefs::IGNORE_REPOSITORY)
126 _cimrepository->createNameSpace(nameSpaceName);
|
127 bob 1.10 }
|