1 mike 1.3 //%/////////////////////////////////////////////////////////////////////////////
|
2 mike 1.1 //
3 // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
11 //
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 // DEALINGS IN THE SOFTWARE.
19 //
|
20 mike 1.3 //==============================================================================
|
21 mike 1.1 //
|
22 mike 1.3 // Author: Mike Brasher (mbrasher@bmc.com)
|
23 mike 1.1 //
|
24 mike 1.3 // Modified By:
|
25 mike 1.2 //
|
26 mike 1.3 //%/////////////////////////////////////////////////////////////////////////////
|
27 mike 1.1
28 #include "DeclContext.h"
|
29 mike 1.2 #include "CIMName.h"
|
30 mike 1.1
31 PEGASUS_NAMESPACE_BEGIN
32
|
33 mike 1.5 #define PEGASUS_ARRAY_T QPair
34 # include "ArrayImpl.h"
35 #undef PEGASUS_ARRAY_T
36
37 #define PEGASUS_ARRAY_T CPair
38 # include "ArrayImpl.h"
39 #undef PEGASUS_ARRAY_T
40
|
41 mike 1.1 DeclContext::~DeclContext()
42 {
43
44 }
45
46 SimpleDeclContext::~SimpleDeclContext()
47 {
48
49 }
50
51 void SimpleDeclContext::addQualifierDecl(
52 const String& nameSpace,
|
53 mike 1.2 const CIMQualifierDecl& x)
|
54 mike 1.1 {
55 if (lookupQualifierDecl(nameSpace, x.getName()))
56 throw AlreadyExists();
57
58 _qualifierDeclarations.append(QPair(nameSpace, x));
59 }
60
|
61 mike 1.3 void SimpleDeclContext::addClass(
|
62 mike 1.1 const String& nameSpace,
|
63 mike 1.2 const CIMClass& x)
|
64 mike 1.1 {
|
65 mike 1.3 if (lookupClass(nameSpace, x.getClassName()))
|
66 mike 1.1 throw AlreadyExists();
67
68 _classDeclarations.append(CPair(nameSpace, x));
69 }
70
|
71 mike 1.2 CIMQualifierDecl SimpleDeclContext::lookupQualifierDecl(
|
72 mike 1.1 const String& nameSpace,
73 const String& name) const
74 {
|
75 mike 1.4 for (Uint32 i = 0, n = _qualifierDeclarations.size(); i < n; i++)
|
76 mike 1.1 {
77 const String& first = _qualifierDeclarations[i].first;
|
78 mike 1.2 const CIMQualifierDecl& second = _qualifierDeclarations[i].second;
|
79 mike 1.1
|
80 mike 1.2 if (CIMName::equal(first, nameSpace) &&
81 CIMName::equal(second.getName(), name))
|
82 mike 1.1 {
83 return second;
84 }
85 }
86
87 // Not found:
|
88 mike 1.2 return CIMQualifierDecl();
|
89 mike 1.1 }
90
|
91 mike 1.3 CIMClass SimpleDeclContext::lookupClass(
|
92 mike 1.1 const String& nameSpace,
93 const String& name) const
94 {
|
95 mike 1.4 for (Uint32 i = 0, n = _classDeclarations.size(); i < n; i++)
|
96 mike 1.1 {
97 const String& first = _classDeclarations[i].first;
|
98 mike 1.2 const CIMClass& second = _classDeclarations[i].second;
|
99 mike 1.1
|
100 mike 1.2 if (CIMName::equal(first, nameSpace) &&
101 CIMName::equal(second.getClassName(), name))
|
102 mike 1.1 {
103 return second;
104 }
105 }
106
107 // Not found:
|
108 mike 1.2 return CIMClass();
|
109 mike 1.1 }
110
111 PEGASUS_NAMESPACE_END
|