1 mike 1.9 //%/////////////////////////////////////////////////////////////////////////////
2 //
|
3 kumpf 1.12 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
4 // The Open Group, Tivoli Systems
|
5 mike 1.9 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 kumpf 1.12 // 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 mike 1.9 // 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 kumpf 1.12 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
14 mike 1.9 // 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 kumpf 1.12 // 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 mike 1.9 // 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 //
22 //==============================================================================
23 //
24 // Author: Mike Brasher (mbrasher@bmc.com)
25 //
26 // Modified By:
27 //
28 //%/////////////////////////////////////////////////////////////////////////////
29
30 #include "DeclContext.h"
31 #include "CIMName.h"
32
33 PEGASUS_NAMESPACE_BEGIN
34
35 DeclContext::~DeclContext()
36 {
37
38 }
39
40 mike 1.9 SimpleDeclContext::~SimpleDeclContext()
41 {
42
43 }
44
45 void SimpleDeclContext::addQualifierDecl(
46 const String& nameSpace,
47 const CIMQualifierDecl& x)
48 {
|
49 kumpf 1.10 if (!lookupQualifierDecl(nameSpace, x.getName()).isNull())
|
50 mike 1.9 throw AlreadyExists();
51
52 _qualifierDeclarations.append(QPair(nameSpace, x));
53 }
54
55 void SimpleDeclContext::addClass(
56 const String& nameSpace,
57 const CIMClass& x)
58 {
|
59 kumpf 1.10 if (!lookupClass(nameSpace, x.getClassName()).isNull())
|
60 mike 1.9 throw AlreadyExists();
61
62 _classDeclarations.append(CPair(nameSpace, x));
63 }
64
65 CIMQualifierDecl SimpleDeclContext::lookupQualifierDecl(
66 const String& nameSpace,
67 const String& name) const
68 {
69 for (Uint32 i = 0, n = _qualifierDeclarations.size(); i < n; i++)
70 {
71 const String& first = _qualifierDeclarations[i].first;
72 const CIMQualifierDecl& second = _qualifierDeclarations[i].second;
73
74 if (CIMName::equal(first, nameSpace) &&
75 CIMName::equal(second.getName(), name))
76 {
77 return second;
78 }
79 }
80
81 mike 1.9 // Not found:
82 return CIMQualifierDecl();
83 }
84
85 CIMClass SimpleDeclContext::lookupClass(
86 const String& nameSpace,
87 const String& name) const
88 {
89 for (Uint32 i = 0, n = _classDeclarations.size(); i < n; i++)
90 {
91 const String& first = _classDeclarations[i].first;
92 const CIMClass& second = _classDeclarations[i].second;
93
94 if (CIMName::equal(first, nameSpace) &&
95 CIMName::equal(second.getClassName(), name))
96 {
97 return second;
98 }
99 }
100
101 // Not found:
102 mike 1.9 return CIMClass();
103 }
104
105 PEGASUS_NAMESPACE_END
|