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 kumpf 1.3 parentNameSpace(),
|
117 kumpf 1.1 remoteInfo()
118 {
119 }
120
121 CIMNamespaceName name;
122 Boolean shareable;
123 Boolean updatesAllowed;
124 CIMNamespaceName parentNameSpace;
|
125 kumpf 1.3 String remoteInfo; // Only used with Remote CMPI
|
126 kumpf 1.1 };
127
128 class PEGASUS_REPOSITORY_LINKAGE FileBasedStore
129 {
130 public:
131 FileBasedStore(
132 const String& repositoryPath,
133 ObjectStreamer* streamer,
134 Boolean compressMode);
135
136 ~FileBasedStore();
137
|
138 kumpf 1.4 Boolean storeCompleteClassDefinitions()
139 {
140 return _storeCompleteClasses;
141 }
142
|
143 kumpf 1.1 Array<NamespaceDefinition> enumerateNameSpaces();
144 void createNameSpace(
145 const CIMNamespaceName& nameSpace,
146 Boolean shareable,
147 Boolean updatesAllowed,
148 const String& parent);
149 void modifyNameSpace(
150 const CIMNamespaceName& nameSpace,
151 Boolean shareable,
152 Boolean updatesAllowed);
153 void deleteNameSpace(const CIMNamespaceName& nameSpace);
154 Boolean isNameSpaceEmpty(const CIMNamespaceName& nameSpace);
155
156 Array<CIMQualifierDecl> enumerateQualifiers(
157 const CIMNamespaceName& nameSpace);
158 /**
159 Gets a qualifier declaration for a specified qualifier name in a
160 specified namespace. Returns an uninitialized object if the qualifier
161 is not found.
162 */
163 CIMQualifierDecl getQualifier(
164 kumpf 1.1 const CIMNamespaceName& nameSpace,
165 const CIMName& qualifierName);
166 void setQualifier(
167 const CIMNamespaceName& nameSpace,
168 const CIMQualifierDecl& qualifierDecl);
169 void deleteQualifier(
170 const CIMNamespaceName& nameSpace,
171 const CIMName& qualifierName);
172
173 Array<Pair<String, String> > enumerateClassNames(
174 const CIMNamespaceName& nameSpace);
175 CIMClass getClass(
176 const CIMNamespaceName& nameSpace,
177 const CIMName& className,
178 const CIMName& superClassName);
|
179 kumpf 1.2 /**
180 Creates a class definition. If the class is an association class,
181 the class association entries are also added.
182 */
|
183 kumpf 1.1 void createClass(
184 const CIMNamespaceName& nameSpace,
|
185 kumpf 1.2 const CIMClass& newClass,
186 const Array<ClassAssociation>& classAssocEntries);
187 /**
188 Modifies a class definition. If the class is an association class,
189 the class association entries are also updated to the specified set.
190 */
|
191 kumpf 1.1 void modifyClass(
192 const CIMNamespaceName& nameSpace,
|
193 kumpf 1.2 const CIMClass& modifiedClass,
|
194 kumpf 1.4 const CIMName& oldSuperClassName,
|
195 kumpf 1.2 Boolean isAssociation,
196 const Array<ClassAssociation>& classAssocEntries);
197 /**
198 Deletes a class definition. If the class is an association class,
199 the class association entries are also deleted. It is expected to
200 have already been verified that no instances of this class exist. A
201 list of dependent namespace names is provided to allow appropriate
202 clean-up of instance files, if necessary.
203 */
|
204 kumpf 1.1 void deleteClass(
205 const CIMNamespaceName& nameSpace,
206 const CIMName& className,
|
207 kumpf 1.2 const CIMName& superClassName,
208 Boolean isAssociation,
209 const Array<CIMNamespaceName>& dependentNameSpaceNames);
|
210 kumpf 1.1
211 Array<CIMObjectPath> enumerateInstanceNamesForClass(
212 const CIMNamespaceName& nameSpace,
213 const CIMName& className);
214 Array<CIMInstance> enumerateInstancesForClass(
215 const CIMNamespaceName& nameSpace,
216 const CIMName& className);
217 CIMInstance getInstance(
218 const CIMNamespaceName& nameSpace,
219 const CIMObjectPath& instanceName);
|
220 kumpf 1.2 /**
221 Creates an instance definition. If it is an association instance,
222 the instance association entries are also added.
223 */
|
224 kumpf 1.1 void createInstance(
225 const CIMNamespaceName& nameSpace,
226 const CIMObjectPath& instanceName,
|
227 kumpf 1.2 const CIMInstance& cimInstance,
228 const Array<InstanceAssociation>& instAssocEntries);
|
229 kumpf 1.1 void modifyInstance(
230 const CIMNamespaceName& nameSpace,
231 const CIMObjectPath& instanceName,
232 const CIMInstance& cimInstance);
|
233 kumpf 1.2 /**
234 Deletes an instance definition. If it is an association instance,
235 the instance association entries are also deleted.
236 */
|
237 kumpf 1.1 void deleteInstance(
238 const CIMNamespaceName& nameSpace,
239 const CIMObjectPath& instanceName);
240 Boolean instanceExists(
241 const CIMNamespaceName& nameSpace,
242 const CIMObjectPath& instanceName);
243
244 void getClassAssociatorNames(
245 const CIMNamespaceName& nameSpace,
246 const Array<CIMName>& classList,
247 const Array<CIMName>& assocClassList,
248 const Array<CIMName>& resultClassList,
249 const String& role,
250 const String& resultRole,
251 Array<String>& associatorNames);
252 void getClassReferenceNames(
253 const CIMNamespaceName& nameSpace,
254 const Array<CIMName>& classList,
255 const Array<CIMName>& resultClassList,
256 const String& role,
257 Array<String>& referenceNames);
258 kumpf 1.1
259 void getInstanceAssociatorNames(
260 const CIMNamespaceName& nameSpace,
261 const CIMObjectPath& instanceName,
262 const Array<CIMName>& assocClassList,
263 const Array<CIMName>& resultClassList,
264 const String& role,
265 const String& resultRole,
266 Array<String>& associatorNames);
267 void getInstanceReferenceNames(
268 const CIMNamespaceName& nameSpace,
269 const CIMObjectPath& instanceName,
270 const Array<CIMName>& resultClassList,
271 const String& role,
272 Array<String>& referenceNames);
273
274 private:
275
276 void _rollbackIncompleteTransactions();
277
278 /**
279 kumpf 1.1 Converts a namespace name into a directory path. The specified
280 namespace name is not required to match the case of the namespace
281 name that was originally created.
282
283 @param nameSpace The namespace for which to determine the directory
284 path.
285 @return A string containing the directory path for the namespace.
286 */
287 String _getNameSpaceDirPath(const CIMNamespaceName& nameSpace) const;
288
289 /** Returns the path of the qualifier file.
290
291 @param nameSpace the namespace of the qualifier
292 @param qualifierName the name of the qualifier
293
294 @return a string containing the qualifier file path
295 */
296 String _getQualifierFilePath(
297 const CIMNamespaceName& nameSpace,
298 const CIMName& qualifierName) const;
299
300 kumpf 1.1 /** Returns the path of the class file.
301
302 @param nameSpace the namespace of the class
303 @param className the name of the class
304
305 @return a string containing the class file path
306 */
307 String _getClassFilePath(
308 const CIMNamespaceName& nameSpace,
309 const CIMName& className,
310 const CIMName& superClassName) const;
311
312 /** Returns the path of the instance index file.
313
314 @param nameSpace the namespace of the instance
315 @param className the name of the class
316
317 @return a string containing the index file path
318 */
319 String _getInstanceIndexFilePath(
320 const CIMNamespaceName& nameSpace,
321 kumpf 1.1 const CIMName& className) const;
322
323 /** Returns the path of the instance file.
324
325 @param nameSpace the namespace of the instance
326 @param className the name of the class
327
328 @return a string containing the instance file path
329 */
330 String _getInstanceDataFilePath(
331 const CIMNamespaceName& nameSpace,
332 const CIMName& className) const;
333
334 /** Returns the path of the class association file.
335
336 @param nameSpace the namespace of the associations
337
338 @return a string containing the class association file path
339 */
340 String _getAssocClassPath(const CIMNamespaceName& nameSpace) const;
341
342 kumpf 1.1 /** Returns the path of the instance association file.
343
344 @param nameSpace the namespace of the associations
345
346 @return a string containing the instance association file path
347 */
348 String _getAssocInstPath(const CIMNamespaceName& nameSpace) const;
349
350 Boolean _loadInstance(
351 const String& path,
352 CIMInstance& object,
353 Uint32 index,
354 Uint32 size);
355
356 /** loads all the instance objects from disk to memeory. Returns true
357 on success.
358
359 @param nameSpace the namespace of the instances to be loaded
360 @param className the class of the instances to be loaded
361 @param namedInstances an array of CIMInstance objects to which
362 the loaded instances are appended
363 kumpf 1.1
364 @return true if successful
365 false if an error occurs in loading the instances
366 */
367 Boolean _loadAllInstances(
368 const CIMNamespaceName& nameSpace,
369 const CIMName& className,
370 Array<CIMInstance>& namedInstances);
371
|
372 kumpf 1.2 void _addClassAssociationEntries(
373 const CIMNamespaceName& nameSpace,
374 const Array<ClassAssociation>& classAssocEntries);
375 void _removeClassAssociationEntries(
376 const CIMNamespaceName& nameSpace,
377 const CIMName& assocClassName);
378
379 void _addInstanceAssociationEntries(
380 const CIMNamespaceName& nameSpace,
381 const Array<InstanceAssociation>& instanceAssocEntries);
382 void _removeInstanceAssociationEntries(
383 const CIMNamespaceName& nameSpace,
384 const CIMObjectPath& assocInstanceName);
385
|
386 kumpf 1.1 String _repositoryPath;
387 ObjectStreamer* _streamer;
388 Boolean _compressMode;
|
389 kumpf 1.4 Boolean _storeCompleteClasses;
|
390 kumpf 1.1
391 /**
392 Maps namespace names to directory paths
393 */
394 HashTable<String, String, EqualNoCaseFunc, HashLowerCaseFunc>
395 _nameSpacePathTable;
396 };
397
398 PEGASUS_NAMESPACE_END
399
400 #endif /* Pegasus_FileBasedStore_h */
|