Changed print methods to take a stream instead of hardcoded cout
[tpot/pegasus/.git] / src / Pegasus / Common / CIMClassRep.h
1 //BEGIN_LICENSE
2 //
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 //END_LICENSE
21 //BEGIN_HISTORY
22 //
23 // Author:
24 //
25 // $Log: CIMClassRep.h,v $
26 // Revision 1.4  2001/03/04 21:57:34  bob
27 // Changed print methods to take a stream instead of hardcoded cout
28 //
29 // Revision 1.3  2001/02/20 05:16:57  mike
30 // Implemented CIMInstance::getInstanceName()
31 //
32 // Revision 1.2  2001/02/19 01:47:16  mike
33 // Renamed names of the form CIMConst to ConstCIM.
34 //
35 // Revision 1.1  2001/02/18 18:39:05  mike
36 // new
37 //
38 // Revision 1.2  2001/02/18 03:56:00  mike
39 // Changed more class names (e.g., ConstClassDecl -> ConstCIMClass)
40 //
41 // Revision 1.1  2001/02/16 02:06:06  mike
42 // Renamed many classes and headers.
43 //
44 // Revision 1.2  2001/01/15 04:31:43  mike
45 // worked on resolve scheme
46 //
47 // Revision 1.1.1.1  2001/01/14 19:50:39  mike
48 // Pegasus import
49 //
50 //
51 //END_HISTORY
52
53 #ifndef Pegasus_ClassDeclRep_h
54 #define Pegasus_ClassDeclRep_h
55
56 #include <Pegasus/Common/Config.h>
57 #include <Pegasus/Common/Exception.h>
58 #include <Pegasus/Common/String.h>
59 #include <Pegasus/Common/CIMQualifier.h>
60 #include <Pegasus/Common/CIMQualifierList.h>
61 #include <Pegasus/Common/CIMProperty.h>
62 #include <Pegasus/Common/CIMMethod.h>
63
64 PEGASUS_NAMESPACE_BEGIN
65
66 class DeclContext;
67 class CIMClass;
68 class ConstCIMClass;
69 class CIMInstanceRep;
70
71 class PEGASUS_COMMON_LINKAGE CIMClassRep : public Sharable
72 {
73 public:
74     
75     CIMClassRep(
76         const String& className, 
77         const String& superClassName);
78
79     ~CIMClassRep();
80
81     Boolean isAssociation() const;
82
83     Boolean isAbstract() const;
84
85     const String& getClassName() const { return _className; }
86
87     const String& getSuperClassName() const { return _superClassName; }
88
89     void setSuperClassName(const String& superClassName);
90
91     void addQualifier(const CIMQualifier& qualifier)
92     {
93         _qualifiers.add(qualifier);
94     }
95
96     Uint32 findQualifier(const String& name) const
97     {
98         return _qualifiers.find(name);
99     }
100
101     CIMQualifier getQualifier(Uint32 pos)
102     {
103         return _qualifiers.getQualifier(pos);
104     }
105
106     CIMConstQualifier getQualifier(Uint32 pos) const
107     {
108         return _qualifiers.getQualifier(pos);
109     }
110
111     Uint32 getQualifierCount() const
112     {
113         return _qualifiers.getCount();
114     }
115
116     void addProperty(const CIMProperty& x);
117
118     void removeProperty(Uint32 pos);
119
120     Uint32 findProperty(const String& name);
121
122     Uint32 findProperty(const String& name) const
123     {
124         return ((CIMClassRep*)this)->findProperty(name);
125     }
126
127     CIMProperty getProperty(Uint32 pos);
128
129     ConstCIMProperty getProperty(Uint32 pos) const
130     {
131         return ((CIMClassRep*)this)->getProperty(pos);
132     }
133
134     Uint32 getPropertyCount() const;
135
136     void addMethod(const CIMMethod& x);
137
138     Uint32 findMethod(const String& name);
139
140     Uint32 findMethod(const String& name) const
141     {
142         return ((CIMClassRep*)this)->findMethod(name);
143     }
144
145     CIMMethod getMethod(Uint32 pos);
146
147     CIMConstMethod getMethod(Uint32 pos) const
148     {
149         return ((CIMClassRep*)this)->getMethod(pos);
150     }
151
152     Uint32 getMethodCount() const;
153
154     void resolve(
155         DeclContext* context,
156         const String& nameSpace);
157
158     void toXml(Array<Sint8>& out) const;
159
160     void print(std::ostream &o=std::cout) const;
161
162     Boolean identical(const CIMClassRep* x) const;
163
164     CIMClassRep* clone() const
165     {
166         return new CIMClassRep(*this);
167     }
168
169     /** Return the names of all properties which bear a true key qualifier. 
170         Sort the keys in ascending order.
171     */
172     void getKeyNames(Array<String>& keyNames) const;
173
174 private:
175
176     CIMClassRep();
177
178     CIMClassRep(const CIMClassRep& x);
179
180     CIMClassRep& operator=(const CIMClassRep& x);
181
182     String _className;
183     String _superClassName;
184     CIMQualifierList _qualifiers;
185     Array<CIMProperty> _properties;
186     Array<CIMMethod> _methods;
187     Boolean _resolved;
188
189     friend class CIMClass;
190     friend class CIMInstanceRep;
191 };
192
193 PEGASUS_NAMESPACE_END
194
195 #endif /* Pegasus_ClassDeclRep_h */