1 kumpf 1.1 //%2006////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
7 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
11 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
13 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
20 //
21 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 kumpf 1.1 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
34 #ifndef Pegasus_FileBasedStore_h
35 #define Pegasus_FileBasedStore_h
36
37 #include <Pegasus/Common/Config.h>
38 #include <Pegasus/Common/String.h>
39 #include <Pegasus/Common/CIMClass.h>
40 #include <Pegasus/Common/CIMQualifierDecl.h>
41 #include <Pegasus/Common/CIMObjectPath.h>
42 #include <Pegasus/Common/CIMInstance.h>
43 kumpf 1.1 #include <Pegasus/Common/AutoStreamer.h>
44 #include <Pegasus/Common/Pair.h>
45 #include <Pegasus/Common/HashTable.h>
46
47 PEGASUS_NAMESPACE_BEGIN
48
49 class ClassAssociation
50 {
51 public:
52
53 ClassAssociation(
54 const CIMName& assocClassName_,
55 const CIMName& fromClassName_,
56 const CIMName& fromPropertyName_,
57 const CIMName& toClassName_,
58 const CIMName& toPropertyName_)
59 : assocClassName(assocClassName_),
60 fromClassName(fromClassName_),
61 fromPropertyName(fromPropertyName_),
62 toClassName(toClassName_),
63 toPropertyName(toPropertyName_)
64 kumpf 1.1 {
65 }
66
67 CIMName assocClassName;
68 CIMName fromClassName;
69 CIMName fromPropertyName;
70 CIMName toClassName;
71 CIMName toPropertyName;
72 };
73
74 class InstanceAssociation
75 {
76 public:
77
78 InstanceAssociation(
79 const String& assocInstanceName_,
80 const CIMName& assocClassName_,
81 const String& fromInstanceName_,
82 const CIMName& fromClassName_,
83 const CIMName& fromPropertyName_,
84 const String& toInstanceName_,
85 kumpf 1.1 const CIMName& toClassName_,
86 const CIMName& toPropertyName_)
87 : assocInstanceName(assocInstanceName_),
88 assocClassName(assocClassName_),
89 fromInstanceName(fromInstanceName_),
90 fromClassName(fromClassName_),
91 fromPropertyName(fromPropertyName_),
92 toInstanceName(toInstanceName_),
93 toClassName(toClassName_),
94 toPropertyName(toPropertyName_)
95 {
96 }
97
98 String assocInstanceName;
99 CIMName assocClassName;
100 String fromInstanceName;
101 CIMName fromClassName;
102 CIMName fromPropertyName;
103 String toInstanceName;
104 CIMName toClassName;
105 CIMName toPropertyName;
106 kumpf 1.1 };
107
108 class NamespaceDefinition
109 {
110 public:
111
112 NamespaceDefinition(const CIMNamespaceName& name_)
113 : name(name_),
114 shareable(false),
115 updatesAllowed(true),
116 parentNameSpace()
117 #ifdef PEGASUS_ENABLE_REMOTE_CMPI
118 ,shared(false),
119 remote(false),
120 remoteId(),
121 remoteHost(),
122 remotePort(),
123 remoteInfo()
124 #endif
125 {
126 }
127 kumpf 1.1
128 CIMNamespaceName name;
129 Boolean shareable;
130 Boolean updatesAllowed;
131 CIMNamespaceName parentNameSpace;
132
133 #ifdef PEGASUS_ENABLE_REMOTE_CMPI
134 Boolean shared;
135 Boolean remote;
136 String remoteId;
137 String remoteHost;
138 String remotePort;
139 String remoteInfo;
140 #endif
141 };
142
143 class PEGASUS_REPOSITORY_LINKAGE FileBasedStore
144 {
145 public:
146 FileBasedStore(
147 const String& repositoryPath,
148 kumpf 1.1 ObjectStreamer* streamer,
149 Boolean compressMode);
150
151 ~FileBasedStore();
152
153 Array<NamespaceDefinition> enumerateNameSpaces();
154 void createNameSpace(
155 const CIMNamespaceName& nameSpace,
156 Boolean shareable,
157 Boolean updatesAllowed,
158 const String& parent);
159 void modifyNameSpace(
160 const CIMNamespaceName& nameSpace,
161 Boolean shareable,
162 Boolean updatesAllowed);
163 void deleteNameSpace(const CIMNamespaceName& nameSpace);
164 Boolean isNameSpaceEmpty(const CIMNamespaceName& nameSpace);
165
166 Array<CIMQualifierDecl> enumerateQualifiers(
167 const CIMNamespaceName& nameSpace);
168 /**
169 kumpf 1.1 Gets a qualifier declaration for a specified qualifier name in a
170 specified namespace. Returns an uninitialized object if the qualifier
171 is not found.
172 */
173 CIMQualifierDecl getQualifier(
174 const CIMNamespaceName& nameSpace,
175 const CIMName& qualifierName);
176 void setQualifier(
177 const CIMNamespaceName& nameSpace,
178 const CIMQualifierDecl& qualifierDecl);
179 void deleteQualifier(
180 const CIMNamespaceName& nameSpace,
181 const CIMName& qualifierName);
182
183 Array<Pair<String, String> > enumerateClassNames(
184 const CIMNamespaceName& nameSpace);
185 CIMClass getClass(
186 const CIMNamespaceName& nameSpace,
187 const CIMName& className,
188 const CIMName& superClassName);
189 void createClass(
190 kumpf 1.1 const CIMNamespaceName& nameSpace,
191 const CIMClass& newClass);
192 void modifyClass(
193 const CIMNamespaceName& nameSpace,
194 const CIMClass& modifiedClass);
195 void deleteClass(
196 const CIMNamespaceName& nameSpace,
197 const CIMName& className,
198 const CIMName& superClassName);
199
200 Array<CIMObjectPath> enumerateInstanceNamesForClass(
201 const CIMNamespaceName& nameSpace,
202 const CIMName& className);
203 Array<CIMInstance> enumerateInstancesForClass(
204 const CIMNamespaceName& nameSpace,
205 const CIMName& className);
206 CIMInstance getInstance(
207 const CIMNamespaceName& nameSpace,
208 const CIMObjectPath& instanceName);
209 void createInstance(
210 const CIMNamespaceName& nameSpace,
211 kumpf 1.1 const CIMObjectPath& instanceName,
212 const CIMInstance& cimInstance);
213 void modifyInstance(
214 const CIMNamespaceName& nameSpace,
215 const CIMObjectPath& instanceName,
216 const CIMInstance& cimInstance);
217 void deleteInstance(
218 const CIMNamespaceName& nameSpace,
219 const CIMObjectPath& instanceName);
220 void deleteAllInstances(
221 const CIMNamespaceName& nameSpace,
222 const CIMName& className);
223 Boolean instanceExists(
224 const CIMNamespaceName& nameSpace,
225 const CIMObjectPath& instanceName);
226
227 void addClassAssociations(
228 const CIMNamespaceName& nameSpace,
229 const Array<ClassAssociation>& classAssocEntries);
230 Boolean removeClassAssociation(
231 const CIMNamespaceName& nameSpace,
232 kumpf 1.1 const CIMName& assocClassName);
233 void getClassAssociatorNames(
234 const CIMNamespaceName& nameSpace,
235 const Array<CIMName>& classList,
236 const Array<CIMName>& assocClassList,
237 const Array<CIMName>& resultClassList,
238 const String& role,
239 const String& resultRole,
240 Array<String>& associatorNames);
241 void getClassReferenceNames(
242 const CIMNamespaceName& nameSpace,
243 const Array<CIMName>& classList,
244 const Array<CIMName>& resultClassList,
245 const String& role,
246 Array<String>& referenceNames);
247
248 void addInstanceAssociations(
249 const CIMNamespaceName& nameSpace,
250 const Array<InstanceAssociation>& instanceAssocEntries);
251 void removeInstanceAssociation(
252 const CIMNamespaceName& nameSpace,
253 kumpf 1.1 const CIMObjectPath& assocInstanceName);
254 void getInstanceAssociatorNames(
255 const CIMNamespaceName& nameSpace,
256 const CIMObjectPath& instanceName,
257 const Array<CIMName>& assocClassList,
258 const Array<CIMName>& resultClassList,
259 const String& role,
260 const String& resultRole,
261 Array<String>& associatorNames);
262 void getInstanceReferenceNames(
263 const CIMNamespaceName& nameSpace,
264 const CIMObjectPath& instanceName,
265 const Array<CIMName>& resultClassList,
266 const String& role,
267 Array<String>& referenceNames);
268
269 private:
270
271 void _rollbackIncompleteTransactions();
272
273 /**
274 kumpf 1.1 Converts a namespace name into a directory path. The specified
275 namespace name is not required to match the case of the namespace
276 name that was originally created.
277
278 @param nameSpace The namespace for which to determine the directory
279 path.
280 @return A string containing the directory path for the namespace.
281 */
282 String _getNameSpaceDirPath(const CIMNamespaceName& nameSpace) const;
283
284 /** Returns the path of the qualifier file.
285
286 @param nameSpace the namespace of the qualifier
287 @param qualifierName the name of the qualifier
288
289 @return a string containing the qualifier file path
290 */
291 String _getQualifierFilePath(
292 const CIMNamespaceName& nameSpace,
293 const CIMName& qualifierName) const;
294
295 kumpf 1.1 /** Returns the path of the class file.
296
297 @param nameSpace the namespace of the class
298 @param className the name of the class
299
300 @return a string containing the class file path
301 */
302 String _getClassFilePath(
303 const CIMNamespaceName& nameSpace,
304 const CIMName& className,
305 const CIMName& superClassName) const;
306
307 /** Returns the path of the instance index file.
308
309 @param nameSpace the namespace of the instance
310 @param className the name of the class
311
312 @return a string containing the index file path
313 */
314 String _getInstanceIndexFilePath(
315 const CIMNamespaceName& nameSpace,
316 kumpf 1.1 const CIMName& className) const;
317
318 /** Returns the path of the instance file.
319
320 @param nameSpace the namespace of the instance
321 @param className the name of the class
322
323 @return a string containing the instance file path
324 */
325 String _getInstanceDataFilePath(
326 const CIMNamespaceName& nameSpace,
327 const CIMName& className) const;
328
329 /** Returns the path of the class association file.
330
331 @param nameSpace the namespace of the associations
332
333 @return a string containing the class association file path
334 */
335 String _getAssocClassPath(const CIMNamespaceName& nameSpace) const;
336
337 kumpf 1.1 /** Returns the path of the instance association file.
338
339 @param nameSpace the namespace of the associations
340
341 @return a string containing the instance association file path
342 */
343 String _getAssocInstPath(const CIMNamespaceName& nameSpace) const;
344
345 Boolean _loadInstance(
346 const String& path,
347 CIMInstance& object,
348 Uint32 index,
349 Uint32 size);
350
351 /** loads all the instance objects from disk to memeory. Returns true
352 on success.
353
354 @param nameSpace the namespace of the instances to be loaded
355 @param className the class of the instances to be loaded
356 @param namedInstances an array of CIMInstance objects to which
357 the loaded instances are appended
358 kumpf 1.1
359 @return true if successful
360 false if an error occurs in loading the instances
361 */
362 Boolean _loadAllInstances(
363 const CIMNamespaceName& nameSpace,
364 const CIMName& className,
365 Array<CIMInstance>& namedInstances);
366
367 String _repositoryPath;
368 ObjectStreamer* _streamer;
369 Boolean _compressMode;
370
371 /**
372 Maps namespace names to directory paths
373 */
374 HashTable<String, String, EqualNoCaseFunc, HashLowerCaseFunc>
375 _nameSpacePathTable;
376 };
377
378 PEGASUS_NAMESPACE_END
379 kumpf 1.1
380 #endif /* Pegasus_FileBasedStore_h */
|