1 mike 1.25 //%/////////////////////////////////////////////////////////////////////////////
2 //
|
3 kumpf 1.38 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
4 // The Open Group, Tivoli Systems
|
5 mike 1.25 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // 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 // 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 kumpf 1.38 //
|
13 mike 1.25 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
14 // 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 // 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 // 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 mike 1.27 // Modified By: Jenny Yu, Hewlett-Packard Company (jenny_yu@hp.com)
27 // Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
28 // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
|
29 kumpf 1.36 // Carol Ann Krug Graves, Hewlett-Packard Company
30 // (carolann_graves@hp.com)
|
31 mike 1.25 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
34 #ifndef PegasusRepository_Repository_h
35 #define PegasusRepository_Repository_h
36
37 #include <Pegasus/Common/Config.h>
|
38 mike 1.27 #include <Pegasus/Common/IPC.h>
|
39 mike 1.25 #include <Pegasus/Common/CIMClass.h>
|
40 mike 1.27 #include <Pegasus/Common/CIMObject.h>
|
41 mike 1.25 #include <Pegasus/Common/CIMInstance.h>
|
42 mike 1.27 #include <Pegasus/Common/CIMPropertyList.h>
|
43 mike 1.25 #include <Pegasus/Common/CIMQualifierDecl.h>
|
44 mike 1.31 #include <Pegasus/Common/CIMRepositoryBase.h>
|
45 mike 1.27 #include <Pegasus/Config/ConfigManager.h>
|
46 mike 1.25 #include <Pegasus/Repository/NameSpaceManager.h>
|
47 kumpf 1.40 #include <Pegasus/Repository/Linkage.h>
|
48 mike 1.25
49 PEGASUS_NAMESPACE_BEGIN
50
51 class RepositoryDeclContext;
52
|
53 mike 1.27 /** This class provides a simple implementation of a CIM repository.
|
54 mike 1.25 */
|
55 mike 1.31 class PEGASUS_REPOSITORY_LINKAGE CIMRepository : public CIMRepositoryBase
|
56 mike 1.25 {
57 public:
58
59 /// Constructor
60 CIMRepository(const String& repositoryRoot);
61
62 /// Descructor
63 virtual ~CIMRepository();
64
|
65 mike 1.27 // Repositories MUST Have a read/write lock
66
67 virtual void read_lock(void) throw(IPCException);
68 virtual void read_unlock(void);
69
70 virtual void write_lock(void) throw(IPCException);
71 virtual void write_unlock(void);
72
|
73 mike 1.25 /// virtual class CIMClass. From the operations class
74 virtual CIMClass getClass(
|
75 kumpf 1.41 const CIMNamespaceName& nameSpace,
76 const CIMName& className,
|
77 mike 1.27 Boolean localOnly = true,
78 Boolean includeQualifiers = true,
79 Boolean includeClassOrigin = false,
80 const CIMPropertyList& propertyList = CIMPropertyList());
|
81 mike 1.25
82 /// getInstance
83 virtual CIMInstance getInstance(
|
84 kumpf 1.41 const CIMNamespaceName& nameSpace,
|
85 kumpf 1.34 const CIMObjectPath& instanceName,
|
86 mike 1.27 Boolean localOnly = true,
87 Boolean includeQualifiers = false,
88 Boolean includeClassOrigin = false,
|
89 mike 1.31 const CIMPropertyList& propertyList = CIMPropertyList());
|
90 mike 1.25
91 /// deleteClass
92 virtual void deleteClass(
|
93 kumpf 1.41 const CIMNamespaceName& nameSpace,
94 const CIMName& className);
|
95 mike 1.25
96 /// deleteInstance
97 virtual void deleteInstance(
|
98 kumpf 1.41 const CIMNamespaceName& nameSpace,
|
99 kumpf 1.34 const CIMObjectPath& instanceName);
|
100 mike 1.25
101 /// createClass
102 virtual void createClass(
|
103 kumpf 1.41 const CIMNamespaceName& nameSpace,
|
104 mike 1.27 const CIMClass& newClass);
|
105 mike 1.25
106 /// createInstance
|
107 kumpf 1.34 virtual CIMObjectPath createInstance(
|
108 kumpf 1.41 const CIMNamespaceName& nameSpace,
|
109 mike 1.27 const CIMInstance& newInstance);
|
110 mike 1.25
111 /// modifyClass
112 virtual void modifyClass(
|
113 kumpf 1.41 const CIMNamespaceName& nameSpace,
|
114 mike 1.27 const CIMClass& modifiedClass);
|
115 mike 1.25
116 /// modifyInstance
117 virtual void modifyInstance(
|
118 kumpf 1.41 const CIMNamespaceName& nameSpace,
|
119 kumpf 1.36 const CIMInstance& modifiedInstance,
|
120 mike 1.27 Boolean includeQualifiers = true,
121 const CIMPropertyList& propertyList = CIMPropertyList());
|
122 mike 1.25
123 /// enumerateClasses
124 virtual Array<CIMClass> enumerateClasses(
|
125 kumpf 1.41 const CIMNamespaceName& nameSpace,
126 const CIMName& className = CIMName(),
|
127 mike 1.27 Boolean deepInheritance = false,
128 Boolean localOnly = true,
129 Boolean includeQualifiers = true,
130 Boolean includeClassOrigin = false);
|
131 mike 1.25
132 /// enumerateClassNames
|
133 kumpf 1.41 virtual Array<CIMName> enumerateClassNames(
134 const CIMNamespaceName& nameSpace,
135 const CIMName& className = CIMName(),
|
136 mike 1.27 Boolean deepInheritance = false);
|
137 mike 1.25
|
138 karl 1.35
|
139 kumpf 1.36 virtual Array<CIMInstance> enumerateInstances(
|
140 kumpf 1.41 const CIMNamespaceName& nameSpace,
141 const CIMName& className,
|
142 mike 1.27 Boolean deepInheritance = true,
143 Boolean localOnly = true,
144 Boolean includeQualifiers = false,
145 Boolean includeClassOrigin = false,
146 const CIMPropertyList& propertyList = CIMPropertyList());
|
147 mike 1.25
|
148 karl 1.35 /** enumerateInstances for a single Class. This and the forClass
149 // in enumerate instancenames are a temp hack to get a version
150 // that only gets for a single class until we can go through all
151 // code and put them back together again.
152 // This simply adds the includeInheritance property
153 */
|
154 kumpf 1.36 virtual Array<CIMInstance> enumerateInstancesForClass(
|
155 kumpf 1.41 const CIMNamespaceName& nameSpace,
156 const CIMName& className,
|
157 karl 1.35 Boolean deepInheritance = true,
158 Boolean localOnly = true,
159 Boolean includeQualifiers = false,
160 Boolean includeClassOrigin = false,
161 Boolean includeInheritance = false,
162 const CIMPropertyList& propertyList = CIMPropertyList());
163
164
|
165 mike 1.25 /// enumerateInstanceNames
|
166 kumpf 1.34 virtual Array<CIMObjectPath> enumerateInstanceNames(
|
167 kumpf 1.41 const CIMNamespaceName& nameSpace,
168 const CIMName& className);
|
169 karl 1.35
170 /** enumerateInstanceNames for a single Class. This is a temporary
171 hack and should eventually be merged with enumerateInstanceNames
172 This function allows you to either include the inheritance tree
173 or not with teh boolean includeInheritance.
174 */
175 virtual Array<CIMObjectPath> enumerateInstanceNamesForClass(
|
176 kumpf 1.41 const CIMNamespaceName& nameSpace,
177 const CIMName& className,
|
178 karl 1.35 Boolean includeInheritance);
179
|
180 mike 1.25
181 /// execQuery
182 virtual Array<CIMInstance> execQuery(
|
183 mike 1.27 const String& queryLanguage,
184 const String& query) ;
|
185 mike 1.25
186 /// associators
|
187 kumpf 1.37 virtual Array<CIMObject> associators(
|
188 kumpf 1.41 const CIMNamespaceName& nameSpace,
|
189 kumpf 1.34 const CIMObjectPath& objectName,
|
190 kumpf 1.41 const CIMName& assocClass = CIMName(),
191 const CIMName& resultClass = CIMName(),
|
192 mike 1.27 const String& role = String::EMPTY,
193 const String& resultRole = String::EMPTY,
194 Boolean includeQualifiers = false,
195 Boolean includeClassOrigin = false,
196 const CIMPropertyList& propertyList = CIMPropertyList());
|
197 mike 1.25
198 /// associateNames
|
199 kumpf 1.34 virtual Array<CIMObjectPath> associatorNames(
|
200 kumpf 1.41 const CIMNamespaceName& nameSpace,
|
201 kumpf 1.34 const CIMObjectPath& objectName,
|
202 kumpf 1.41 const CIMName& assocClass = CIMName(),
203 const CIMName& resultClass = CIMName(),
|
204 mike 1.27 const String& role = String::EMPTY,
205 const String& resultRole = String::EMPTY);
|
206 mike 1.25
207 /// references
|
208 kumpf 1.37 virtual Array<CIMObject> references(
|
209 kumpf 1.41 const CIMNamespaceName& nameSpace,
|
210 kumpf 1.34 const CIMObjectPath& objectName,
|
211 kumpf 1.41 const CIMName& resultClass = CIMName(),
|
212 mike 1.27 const String& role = String::EMPTY,
213 Boolean includeQualifiers = false,
214 Boolean includeClassOrigin = false,
215 const CIMPropertyList& propertyList = CIMPropertyList());
|
216 mike 1.25
217 /// referenceNames
|
218 kumpf 1.34 virtual Array<CIMObjectPath> referenceNames(
|
219 kumpf 1.41 const CIMNamespaceName& nameSpace,
|
220 kumpf 1.34 const CIMObjectPath& objectName,
|
221 kumpf 1.41 const CIMName& resultClass = CIMName(),
|
222 mike 1.27 const String& role = String::EMPTY);
|
223 mike 1.25
224 /// getProperty
225 virtual CIMValue getProperty(
|
226 kumpf 1.41 const CIMNamespaceName& nameSpace,
|
227 kumpf 1.34 const CIMObjectPath& instanceName,
|
228 kumpf 1.41 const CIMName& propertyName);
|
229 mike 1.25
230 /// setProperty
231 virtual void setProperty(
|
232 kumpf 1.41 const CIMNamespaceName& nameSpace,
|
233 kumpf 1.34 const CIMObjectPath& instanceName,
|
234 kumpf 1.41 const CIMName& propertyName,
|
235 mike 1.27 const CIMValue& newValue = CIMValue());
|
236 mike 1.25
237 /// getQualifier
238 virtual CIMQualifierDecl getQualifier(
|
239 kumpf 1.41 const CIMNamespaceName& nameSpace,
240 const CIMName& qualifierName);
|
241 mike 1.25
242 /// setQualifier
243 virtual void setQualifier(
|
244 kumpf 1.41 const CIMNamespaceName& nameSpace,
|
245 mike 1.27 const CIMQualifierDecl& qualifierDecl);
|
246 mike 1.25
247 /// virtual deleteQualifier
248 virtual void deleteQualifier(
|
249 kumpf 1.41 const CIMNamespaceName& nameSpace,
250 const CIMName& qualifierName);
|
251 mike 1.25
252 /// enumerateQualifiers
253 virtual Array<CIMQualifierDecl> enumerateQualifiers(
|
254 kumpf 1.41 const CIMNamespaceName& nameSpace);
|
255 mike 1.25
256 /** CIMMethod createNameSpace - Creates a new namespace in the repository
|
257 mike 1.27 @param String with the name of the namespace
258 @exception - Throws "Already_Exists if the Namespace exits.
259 Throws "CannotCreateDirectory" if there are problems in the
260 creation.
|
261 mike 1.25 */
|
262 kumpf 1.41 virtual void createNameSpace(const CIMNamespaceName& nameSpace);
|
263 mike 1.25
264 /** CIMMethod enumerateNameSpaces - Get all of the namespaces in the
|
265 mike 1.27 repository. \Ref{NAMESPACE}
266 @return Array of strings with the namespaces
|
267 mike 1.25 */
|
268 kumpf 1.41 virtual Array<CIMNamespaceName> enumerateNameSpaces() const;
|
269 mike 1.25
270 /** CIMMethod deleteNameSpace - Deletes a namespace in the repository.
|
271 mike 1.27 The deleteNameSpace method will only delete a namespace if there are
272 no classed defined in the namespace. Today this is a Pegasus
273 characteristics and not defined as part of the DMTF standards.
274 @param String with the name of the namespace
275 @exception - Throws NoSuchDirectory if the Namespace does not exist.
|
276 mike 1.25 */
|
277 kumpf 1.41 virtual void deleteNameSpace(const CIMNamespaceName& nameSpace);
|
278 mike 1.31
279 ////////////////////////////////////////////////////////////////////////////
|
280 mike 1.25
|
281 bob 1.26 /** CIMMethod setDeclContext - allows the Declaration Context set
282 by default in the CIMRepository constructor to be overridden.
283 This is useful, for example, when a compiler wants to check syntax
284 without actually adding to the repository.
285 */
286 void setDeclContext(RepositoryDeclContext *context);
287
|
288 mike 1.27 /** Indicates whether instance operations that do not have a provider
289 registered should be served by this repository.
290 */
291 Boolean isDefaultInstanceProvider()
292 {
293 return _isDefaultInstanceProvider;
294 }
295
|
296 mike 1.31 /** Get subclass names of the given class in the given namespace.
|
297 sage 1.28 @param nameSpaceName
298 @param className - class whose subclass names will be gotten. If
299 className is empty, all classnames are returned.
300 @param deepInheritance - if true all descendent classes of class
|
301 karl 1.33 are returned. If className is empty, only root classes are returned.
302 @param subClassNames - output argument to hold subclass names.
|
303 sage 1.28 @exception CIMException(CIM_ERR_INVALID_CLASS)
304 */
|
305 mike 1.31 virtual void getSubClassNames(
|
306 kumpf 1.41 const CIMNamespaceName& nameSpaceName,
307 const CIMName& className,
|
308 sage 1.28 Boolean deepInheritance,
|
309 kumpf 1.41 Array<CIMName>& subClassNames) const
|
310 sage 1.28 {
311 _nameSpaceManager.getSubClassNames(nameSpaceName,
312 className,
313 deepInheritance,
314 subClassNames);
315 }
316
317 /** Get the names of all superclasses (direct and indirect) of this
318 class.
319 */
|
320 mike 1.31 virtual void getSuperClassNames(
|
321 kumpf 1.41 const CIMNamespaceName& nameSpaceName,
322 const CIMName& className,
323 Array<CIMName>& subClassNames) const
|
324 sage 1.28 {
325 _nameSpaceManager.getSuperClassNames(nameSpaceName,
326 className,
327 subClassNames);
328 }
329
|
330 mike 1.25 private:
331
|
332 mike 1.27 void _createAssocInstEntries(
|
333 kumpf 1.41 const CIMNamespaceName& nameSpace,
|
334 mike 1.27 const CIMConstClass& cimClass,
335 const CIMInstance& cimInstance,
|
336 kumpf 1.34 const CIMObjectPath& instanceName);
|
337 mike 1.27
338 void _createAssocClassEntries(
|
339 kumpf 1.41 const CIMNamespaceName& nameSpace,
|
340 mike 1.27 const CIMConstClass& assocClass);
341
342 /** Returns the index (or byte location) and size of the instance
343 record in the instance file for a given instance. Returns true
344 if successful. Returns false if the instance cannot be found.
345
346 @param nameSpace the namespace of the instance
347 @param instanceName the name of the instance
348 @param className the name of the class
349 @param size the size of the instance record found
350 @param index the byte positon of the instance record found
351 @param searchSuper if true, search all superclasses
352
353 @return true if the instance is found
354 false if the instance cannot be found
355 */
|
356 mike 1.25 Boolean _getInstanceIndex(
|
357 kumpf 1.41 const CIMNamespaceName& nameSpace,
|
358 kumpf 1.34 const CIMObjectPath& instanceName,
|
359 kumpf 1.41 CIMName& className,
|
360 mike 1.27 Uint32& size,
361 Uint32& index,
362 Boolean searchSuperClasses = false) const;
363
364 /** Returns the file path of the instance index file.
|
365 mike 1.25
|
366 mike 1.27 @param nameSpace the namespace of the instance
367 @param className the name of the class
368
369 @return a string containing the index file path
370 */
|
371 mike 1.29 String _getInstanceIndexFilePath(
|
372 kumpf 1.41 const CIMNamespaceName& nameSpace,
373 const CIMName& className) const;
|
374 mike 1.27
375 /** Returns the file path of the instance file.
376
377 @param nameSpace the namespace of the instance
378 @param className the name of the class
|
379 mike 1.25
|
380 mike 1.27 @return a string containing the instance file path
381 */
|
382 mike 1.29 String _getInstanceDataFilePath(
|
383 kumpf 1.41 const CIMNamespaceName& nameSpace,
384 const CIMName& className) const;
|
385 mike 1.25
|
386 mike 1.27 /** Saves an instance object from memory to disk file. The byte
387 position and the size of the newly inserted instance record are
388 returned. Returns true on success.
389
390 @param path the file path of the instance file
391 @param object the CIMInstance object to be saved
392 @param index the byte positon of the saved instance record
393 @param size the size of the saved instance record
394
395 @return true if successful
396 false if an error occurs in saving the instance to file
397 */
398 Boolean _saveInstance(
399 const String& path,
400 const CIMInstance& object,
401 Uint32& index,
402 Uint32& size);
403
404 /** loads an instance object from disk to memory. The caller passes
405 the byte position and the size of the instance record to be loaded.
406 Returns true on success.
407 mike 1.27
408 @param path the file path of the instance file
409 @param object the CIMInstance object to be returned
410 @param index the byte positon of the instance record
411 @param size the size of the instance record
412 @param data the buffer to hold the instance data
413
414 @return true if successful
415 false if an error occurs in loading the instance from file
416 */
417 Boolean _loadInstance(
418 const String& path,
419 CIMInstance& object,
420 Uint32 index,
421 Uint32 size);
422
423 /** loads all the instance objects from disk to memeory. Returns true
424 on success.
425
426 @param nameSpace the namespace of the instances to be loaded
427 @param className the class of the instances to be loaded
|
428 kumpf 1.36 @param namedInstances an array of CIMInstance objects to which
|
429 mike 1.27 the loaded instances are appended
430
431 @return true if successful
432 false if an error occurs in loading the instances
433 */
434 Boolean _loadAllInstances(
|
435 kumpf 1.41 const CIMNamespaceName& nameSpace,
436 const CIMName& className,
|
437 kumpf 1.36 Array<CIMInstance>& namedInstances);
|
438 mike 1.27
439 /** Modifies an instance object saved in the disk file. The byte position
440 and the size of the newly added instance record are returned. Returns
441 true on success.
442
443 @param path the file path of the instance file
444 @param object the modified CIMInstance object
445 @param oldIndex the byte positon of the old instance record
446 @param oldSize the size of the old instance record
447 @param newIndex the byte positon of the new instance record
448 @param newSize the size of the new instance record
449
450 @return true if successful
451 false if an error occurs in modifying the instance
452 */
453 Boolean _modifyInstance(
454 const String& path,
455 const CIMInstance& object,
456 Uint32 oldIndex,
457 Uint32 oldSize,
458 Uint32& newIndex,
459 mike 1.27 Uint32& newSize);
460
461 /** Renames the temporary instance and instance index files back to the
462 original files. The temporary files were created for an insert,
463 remove, or modify operation (to avoid data inconsistency between
464 the two files in case of unexpected system termination or failure).
465 This method is called after a successful insert, remove, or modify
466 operation on BOTH the index file and the instance file. Returns
467 true on success.
468
469 @param indexFilePath the file path of the instance index file
470 @param instancePath the file path of the instance file
471
472 @return true if successful
473 false if an error occurs in removing the original files
474 or renaming the temporary files.
475 */
476 Boolean _renameTempInstanceAndIndexFiles(
477 const String& indexFilePath,
478 const String& instanceFilePath);
|
479 mike 1.25
480 String _repositoryRoot;
481 NameSpaceManager _nameSpaceManager;
482
|
483 kumpf 1.32 // This must be initialized in the constructor using values from the
|
484 mike 1.27 // ConfigManager.
485 Boolean _isDefaultInstanceProvider;
486
|
487 mike 1.25 protected:
|
488 mike 1.31
489 // Used by getInstance(); indicates whether instance should be resolved
490 // after it is retrieved from the file.
491
|
492 mike 1.27 ReadWriteSem _lock;
|
493 mike 1.25 RepositoryDeclContext* _context;
|
494 mike 1.31 Boolean _resolveInstance;
|
495 mike 1.25 };
496
|
497 kumpf 1.41 String PEGASUS_REPOSITORY_LINKAGE namespaceNameToDirName(const CIMNamespaceName& namespaceName);
|
498 kumpf 1.39 String PEGASUS_REPOSITORY_LINKAGE dirNameToNamespaceName(const String& dirName);
499
|
500 mike 1.25 PEGASUS_NAMESPACE_END
501
502 #endif /* PegasusRepository_Repository_h */
503
|