1 kumpf 1.8 //%/////////////////////////////////////////////////////////////////////////////
|
2 mike 1.4 //
|
3 kumpf 1.8 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
4 // The Open Group, Tivoli Systems
|
5 mike 1.4 //
|
6 kumpf 1.8 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to
8 // deal in the Software without restriction, including without limitation the
9 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 // sell copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
14 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
15 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
16 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21 mike 1.4 //
|
22 kumpf 1.8 //==============================================================================
|
23 mike 1.4 //
24 // Author: Mike Brasher (mbrasher@bmc.com)
25 //
26 // Modified By: Bob Blair (bblair@bmc.com)
|
27 kumpf 1.9 // Carol Ann Krug Graves, Hewlett-Packard Company
28 // (carolann_graves@hp.com)
|
29 mike 1.4 //
|
30 bob 1.5 //%////////////////////////////////////////////////////////////////////////////
|
31 mike 1.4
32
33 #include "compilerDeclContext.h"
34
|
35 bob 1.5 compilerDeclContext::compilerDeclContext(CIMRepository *repository,
36 compilerCommonDefs::operationType ot) :
37 RepositoryDeclContext(repository), _cimRepository(repository), _ot(ot)
|
38 mike 1.4 {
|
39 bob 1.5 if (!repository && ot != compilerCommonDefs::IGNORE_REPOSITORY)
40 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
41 "attempt to initialize repository with "
42 "invalid data");
|
43 mike 1.4 }
44
45 compilerDeclContext::~compilerDeclContext() {}
46
47 CIMQualifierDecl
|
48 kumpf 1.9 compilerDeclContext::lookupQualifierDecl(const CIMNamespaceName &nameSpace,
49 const CIMName &qualifierName) const
|
50 mike 1.4 {
51 const CIMQualifierDecl *pTheQualifier = 0;
|
52 bob 1.5 if (_ot != compilerCommonDefs::USE_REPOSITORY) {
|
53 mike 1.4 if ( (pTheQualifier =
54 _findQualifierInMemory(qualifierName)) )
55 return *pTheQualifier;
56 }
|
57 bob 1.5 if (_repository && (_ot != compilerCommonDefs::IGNORE_REPOSITORY)) {
|
58 mike 1.4 return _repository->getQualifier(nameSpace, qualifierName);
59 }
60 return CIMQualifierDecl();
61 }
62
63 CIMClass
|
64 kumpf 1.9 compilerDeclContext::lookupClass(const CIMNamespaceName &nameSpace,
65 const CIMName &className) const
|
66 mike 1.4 {
67 const CIMClass *pTheClass;
|
68 karl 1.6
|
69 bob 1.5 if (_ot != compilerCommonDefs::USE_REPOSITORY) {
|
70 mike 1.4 if ( (pTheClass =_findClassInMemory(className)) )
71 return *pTheClass;
72 }
|
73 bob 1.5 if (_repository && _ot != compilerCommonDefs::IGNORE_REPOSITORY) {
|
74 mike 1.4 return _repository->getClass(nameSpace, className);
75 }
76 return CIMClass();
77 }
78
79 void
|
80 kumpf 1.9 compilerDeclContext::addQualifierDecl(const CIMNamespaceName &nameSpace,
|
81 mike 1.4 const CIMQualifierDecl &x)
82 {
|
83 bob 1.5 if (_ot != compilerCommonDefs::USE_REPOSITORY)
|
84 mike 1.4 _qualifiers.append(x);
85 else
86 _repository->setQualifier(nameSpace, x);
87 }
88
89 void
|
90 kumpf 1.9 compilerDeclContext::addClass(const CIMNamespaceName &nameSpace, CIMClass &x)
|
91 mike 1.4 {
|
92 bob 1.5 if (_ot != compilerCommonDefs::USE_REPOSITORY)
|
93 mike 1.4 _classes.append(x);
94 else
95 _repository->createClass(nameSpace, x);
|
96 bob 1.5 }
97
98 void
|
99 kumpf 1.9 compilerDeclContext::addInstance(const CIMNamespaceName &nameSpace,
100 CIMInstance &x)
|
101 bob 1.5 {
102 if (_ot == compilerCommonDefs::USE_REPOSITORY)
103 _repository->createInstance(nameSpace, x);
|
104 mike 1.4 }
105
106 const CIMClass *
|
107 kumpf 1.9 compilerDeclContext::_findClassInMemory(const CIMName &classname) const
|
108 mike 1.4 {
109 for (unsigned int i = 0; i < _classes.size(); i++) {
110 if (String::equal(classname, (_classes[i]).getClassName()))
111 return &(_classes[i]);
112 }
113 return 0;
114 }
115
116 const CIMQualifierDecl *
|
117 kumpf 1.9 compilerDeclContext::_findQualifierInMemory(const CIMName &classname) const
|
118 mike 1.4 {
119 for (unsigned int i = 0; i < _qualifiers.size(); i++) {
120 if (String::equal(classname, (_qualifiers[i]).getName()))
121 return &(_qualifiers[i]);
122 }
123 return 0;
124 }
|