1 karl 1.19 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.4 //
|
3 karl 1.17 // 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.14 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.17 // 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.18 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.19 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.4 //
|
14 kumpf 1.8 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // 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 // 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 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // 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 // 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 // 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 mike 1.4 //
|
30 kumpf 1.8 //==============================================================================
|
31 mike 1.4 //
32 // Author: Mike Brasher (mbrasher@bmc.com)
33 //
34 // Modified By: Bob Blair (bblair@bmc.com)
|
35 kumpf 1.9 // Carol Ann Krug Graves, Hewlett-Packard Company
36 // (carolann_graves@hp.com)
|
37 gerarda 1.11 // Gerarda Marquez (gmarquez@us.ibm.com)
38 // -- PEP 43 changes
|
39 mike 1.4 //
|
40 bob 1.5 //%////////////////////////////////////////////////////////////////////////////
|
41 mike 1.4
42
43 #include "compilerDeclContext.h"
44
|
45 kumpf 1.16 PEGASUS_NAMESPACE_BEGIN
46
|
47 bob 1.5 compilerDeclContext::compilerDeclContext(CIMRepository *repository,
48 compilerCommonDefs::operationType ot) :
49 RepositoryDeclContext(repository), _cimRepository(repository), _ot(ot)
|
50 mike 1.4 {
|
51 bob 1.5 if (!repository && ot != compilerCommonDefs::IGNORE_REPOSITORY)
52 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
53 "attempt to initialize repository with "
54 "invalid data");
|
55 mike 1.4 }
56
57 compilerDeclContext::~compilerDeclContext() {}
58
59 CIMQualifierDecl
|
60 kumpf 1.9 compilerDeclContext::lookupQualifierDecl(const CIMNamespaceName &nameSpace,
61 const CIMName &qualifierName) const
|
62 mike 1.4 {
63 const CIMQualifierDecl *pTheQualifier = 0;
|
64 bob 1.5 if (_ot != compilerCommonDefs::USE_REPOSITORY) {
|
65 mike 1.4 if ( (pTheQualifier =
66 _findQualifierInMemory(qualifierName)) )
67 return *pTheQualifier;
68 }
|
69 bob 1.5 if (_repository && (_ot != compilerCommonDefs::IGNORE_REPOSITORY)) {
|
70 kumpf 1.15 return _repository->_getQualifier(nameSpace, qualifierName);
|
71 mike 1.4 }
72 return CIMQualifierDecl();
73 }
74
75 CIMClass
|
76 kumpf 1.9 compilerDeclContext::lookupClass(const CIMNamespaceName &nameSpace,
77 const CIMName &className) const
|
78 mike 1.4 {
79 const CIMClass *pTheClass;
|
80 karl 1.6
|
81 bob 1.5 if (_ot != compilerCommonDefs::USE_REPOSITORY) {
|
82 mike 1.4 if ( (pTheClass =_findClassInMemory(className)) )
83 return *pTheClass;
84 }
|
85 bob 1.5 if (_repository && _ot != compilerCommonDefs::IGNORE_REPOSITORY) {
|
86 kumpf 1.15 return _repository->_getClass(
87 nameSpace, className, false, true, true, CIMPropertyList());
|
88 mike 1.4 }
89 return CIMClass();
90 }
91
92 void
|
93 kumpf 1.9 compilerDeclContext::addQualifierDecl(const CIMNamespaceName &nameSpace,
|
94 mike 1.4 const CIMQualifierDecl &x)
95 {
|
96 bob 1.5 if (_ot != compilerCommonDefs::USE_REPOSITORY)
|
97 mike 1.4 _qualifiers.append(x);
98 else
|
99 kumpf 1.15 _repository->_setQualifier(nameSpace, x);
|
100 mike 1.4 }
101
102 void
|
103 kumpf 1.9 compilerDeclContext::addClass(const CIMNamespaceName &nameSpace, CIMClass &x)
|
104 mike 1.4 {
|
105 bob 1.5 if (_ot != compilerCommonDefs::USE_REPOSITORY)
|
106 mike 1.4 _classes.append(x);
107 else
|
108 kumpf 1.15 _repository->_createClass(nameSpace, x);
|
109 bob 1.5 }
110
111 void
|
112 kumpf 1.9 compilerDeclContext::addInstance(const CIMNamespaceName &nameSpace,
113 CIMInstance &x)
|
114 bob 1.5 {
115 if (_ot == compilerCommonDefs::USE_REPOSITORY)
|
116 kumpf 1.15 _repository->_createInstance(nameSpace, x);
|
117 gerarda 1.11 }
118
119 void
120 compilerDeclContext::modifyClass(const CIMNamespaceName &nameSpace, CIMClass &x)
121 {
122 if (_ot != compilerCommonDefs::USE_REPOSITORY)
123 {
124 _classes.append(x);
125 }
126 else
127 {
|
128 kumpf 1.15 _repository->_modifyClass(nameSpace, x);
|
129 gerarda 1.11 }
|
130 mike 1.4 }
131
132 const CIMClass *
|
133 kumpf 1.9 compilerDeclContext::_findClassInMemory(const CIMName &classname) const
|
134 mike 1.4 {
135 for (unsigned int i = 0; i < _classes.size(); i++) {
|
136 kumpf 1.10 if (classname.equal (_classes[i].getClassName()))
|
137 mike 1.4 return &(_classes[i]);
138 }
139 return 0;
140 }
141
142 const CIMQualifierDecl *
|
143 kumpf 1.9 compilerDeclContext::_findQualifierInMemory(const CIMName &classname) const
|
144 mike 1.4 {
145 for (unsigned int i = 0; i < _qualifiers.size(); i++) {
|
146 kumpf 1.10 if (classname.equal (_qualifiers[i].getName()))
|
147 mike 1.4 return &(_qualifiers[i]);
148 }
149 return 0;
150 }
|
151 kumpf 1.16
152 PEGASUS_NAMESPACE_END
|