1 martin 1.26 //%LICENSE////////////////////////////////////////////////////////////////
2 //
3 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 martin 1.26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 mike 1.9 //
|
28 martin 1.26 //////////////////////////////////////////////////////////////////////////
|
29 mike 1.9 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #include "DeclContext.h"
33 #include "CIMName.h"
|
34 kumpf 1.25 #include <Pegasus/Common/MessageLoader.h>
|
35 mike 1.9
36 PEGASUS_NAMESPACE_BEGIN
37
38 DeclContext::~DeclContext()
39 {
40
41 }
42
43 SimpleDeclContext::~SimpleDeclContext()
44 {
45
46 }
47
48 void SimpleDeclContext::addQualifierDecl(
|
49 kumpf 1.14 const CIMNamespaceName& nameSpace,
|
50 mike 1.9 const CIMQualifierDecl& x)
51 {
|
52 kumpf 1.24 if (!lookupQualifierDecl(nameSpace, x.getName()).isUninitialized())
53 {
54 MessageLoaderParms parms(
55 "Common.DeclContext.DECLARATION_OF_QUALIFIER",
56 "declaration of qualifier \"$0\"",
57 x.getName().getString());
58 throw AlreadyExistsException(parms);
|
59 humberto 1.19 }
|
60 mike 1.9
61 _qualifierDeclarations.append(QPair(nameSpace, x));
62 }
63
64 void SimpleDeclContext::addClass(
|
65 kumpf 1.14 const CIMNamespaceName& nameSpace,
|
66 mike 1.9 const CIMClass& x)
67 {
|
68 kumpf 1.24 if (!lookupClass(nameSpace, x.getClassName()).isUninitialized())
69 {
70 MessageLoaderParms parms(
71 "Common.DeclContext.CLASS",
72 "class \"$0\"",
73 x.getClassName().getString());
|
74 humberto 1.19 throw AlreadyExistsException(parms);
75 }
|
76 mike 1.9
77 _classDeclarations.append(CPair(nameSpace, x));
78 }
79
80 CIMQualifierDecl SimpleDeclContext::lookupQualifierDecl(
|
81 kumpf 1.14 const CIMNamespaceName& nameSpace,
82 const CIMName& name) const
|
83 mike 1.9 {
84 for (Uint32 i = 0, n = _qualifierDeclarations.size(); i < n; i++)
85 {
|
86 kumpf 1.24 const CIMNamespaceName& first = _qualifierDeclarations[i].first;
87 const CIMQualifierDecl& second = _qualifierDeclarations[i].second;
|
88 mike 1.9
|
89 kumpf 1.24 if (first.equal(nameSpace) &&
90 second.getName().equal(name))
91 {
92 return second;
93 }
|
94 mike 1.9 }
95
96 // Not found:
97 return CIMQualifierDecl();
98 }
99
100 CIMClass SimpleDeclContext::lookupClass(
|
101 kumpf 1.14 const CIMNamespaceName& nameSpace,
102 const CIMName& name) const
|
103 mike 1.9 {
104 for (Uint32 i = 0, n = _classDeclarations.size(); i < n; i++)
105 {
|
106 kumpf 1.24 const CIMNamespaceName& first = _classDeclarations[i].first;
107 const CIMClass& second = _classDeclarations[i].second;
|
108 mike 1.9
|
109 kumpf 1.24 if (first.equal(nameSpace) &&
110 second.getClassName().equal(name))
111 {
112 return second;
113 }
|
114 mike 1.9 }
115
116 // Not found:
117 return CIMClass();
118 }
119
120 PEGASUS_NAMESPACE_END
|