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 karl 1.20 //
|
21 kumpf 1.8 // 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 bob 1.5 //%////////////////////////////////////////////////////////////////////////////
|
33 mike 1.4
34
35 #include "compilerDeclContext.h"
36
|
37 kumpf 1.16 PEGASUS_NAMESPACE_BEGIN
38
|
39 bob 1.5 compilerDeclContext::compilerDeclContext(CIMRepository *repository,
|
40 karl 1.20 compilerCommonDefs::operationType ot) :
|
41 bob 1.5 RepositoryDeclContext(repository), _cimRepository(repository), _ot(ot)
|
42 mike 1.4 {
|
43 karl 1.20 if (!repository && ot != compilerCommonDefs::IGNORE_REPOSITORY)
44 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
45 "attempt to initialize repository with "
46 "invalid data");
|
47 mike 1.4 }
48
49 compilerDeclContext::~compilerDeclContext() {}
50
|
51 karl 1.20 CIMQualifierDecl compilerDeclContext::lookupQualifierDecl(
52 const CIMNamespaceName &nameSpace,
53 const CIMName &qualifierName) const
54 {
55 const CIMQualifierDecl *pTheQualifier = 0;
56 if (_ot != compilerCommonDefs::USE_REPOSITORY) {
57 if ( (pTheQualifier =
58 _findQualifierInMemory(qualifierName)) )
59 return *pTheQualifier;
60 }
61 if (_repository && (_ot != compilerCommonDefs::IGNORE_REPOSITORY)) {
62 return _repository->_getQualifier(nameSpace, qualifierName);
63 }
64 return CIMQualifierDecl();
65 }
66
67 CIMClass compilerDeclContext::lookupClass(const CIMNamespaceName &nameSpace,
68 const CIMName &className) const
69 {
70 const CIMClass *pTheClass;
71
72 karl 1.20 if (_ot != compilerCommonDefs::USE_REPOSITORY) {
73 if ( (pTheClass =_findClassInMemory(className)) )
74 return *pTheClass;
75 }
76 if (_repository && _ot != compilerCommonDefs::IGNORE_REPOSITORY) {
77 return _repository->_getClass(
78 nameSpace, className, false, true, true, CIMPropertyList());
79 }
80 return CIMClass();
|
81 mike 1.4 }
82
83 void
|
84 kumpf 1.9 compilerDeclContext::addQualifierDecl(const CIMNamespaceName &nameSpace,
|
85 karl 1.20 const CIMQualifierDecl &x)
|
86 mike 1.4 {
|
87 bob 1.5 if (_ot != compilerCommonDefs::USE_REPOSITORY)
|
88 mike 1.4 _qualifiers.append(x);
89 else
|
90 kumpf 1.15 _repository->_setQualifier(nameSpace, x);
|
91 mike 1.4 }
92
|
93 karl 1.20 void compilerDeclContext::addClass(const CIMNamespaceName &nameSpace,
94 CIMClass &x)
|
95 mike 1.4 {
|
96 karl 1.20 if (_ot != compilerCommonDefs::USE_REPOSITORY)
97 _classes.append(x);
98 else
99 _repository->_createClass(nameSpace, x);
|
100 bob 1.5 }
101
|
102 karl 1.20 void compilerDeclContext::addInstance(const CIMNamespaceName &nameSpace,
|
103 kumpf 1.9 CIMInstance &x)
|
104 bob 1.5 {
|
105 karl 1.20 if (_ot == compilerCommonDefs::USE_REPOSITORY)
106 _repository->_createInstance(nameSpace, x);
|
107 mike 1.4 }
108
|
109 karl 1.20 void compilerDeclContext::modifyClass(const CIMNamespaceName &nameSpace,
110 CIMClass &x)
|
111 mike 1.4 {
|
112 karl 1.20 if (_ot != compilerCommonDefs::USE_REPOSITORY)
113 {
114 _classes.append(x);
115 }
116 else
117 {
118 _repository->_modifyClass(nameSpace, x);
119 }
120 }
121
122 const CIMClass * compilerDeclContext::_findClassInMemory(
123 const CIMName &classname) const
124 {
125 for (unsigned int i = 0; i < _classes.size(); i++)
126 {
127 if (classname.equal (_classes[i].getClassName()))
128 return &(_classes[i]);
129 }
130 return 0;
131 }
132
133 karl 1.20 const CIMQualifierDecl * compilerDeclContext::_findQualifierInMemory(
134 const CIMName &classname) const
135 {
136 for (unsigned int i = 0; i < _qualifiers.size(); i++) {
137 if (classname.equal (_qualifiers[i].getName()))
138 return &(_qualifiers[i]);
139 }
140 return 0;
|
141 mike 1.4 }
|
142 kumpf 1.16
143 PEGASUS_NAMESPACE_END
|