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