(file) Return to CIMRepository.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Repository

  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 karl  1.42         Boolean includeInheritance = false,
162 karl  1.35         const CIMPropertyList& propertyList = CIMPropertyList());
163            
164            
165 karl  1.42     /** enumerateInstanceNames returns names of instances that
166                    meet the critera.  This is an extension of the CIM
167                    enumerate instances client call
168                    @nameSpace - target namespace
169                    @param className - Name of the target class
170                    @param Boolean that defines whether to search inheritance or not
171                    @return CIMObjectPath defining the names of the found instances.
172                    @exception - Yes
173                */
174 kumpf 1.34     virtual Array<CIMObjectPath> enumerateInstanceNames(
175 kumpf 1.41         const CIMNamespaceName& nameSpace,
176                    const CIMName& className);
177 karl  1.35 
178                /** enumerateInstanceNames for a single Class. This is a temporary
179                	hack and should eventually be merged with enumerateInstanceNames
180            	This function allows you to either include the inheritance tree
181            	or not with teh boolean includeInheritance.
182                */
183                virtual Array<CIMObjectPath> enumerateInstanceNamesForClass(
184 kumpf 1.41         const CIMNamespaceName& nameSpace,
185                    const CIMName& className,
186 karl  1.42         const Boolean includeInheritance = true);
187 karl  1.35 
188 mike  1.25 
189                /// execQuery
190                virtual Array<CIMInstance> execQuery(
191 mike  1.27         const String& queryLanguage,
192                    const String& query) ;
193 mike  1.25 
194                /// associators
195 kumpf 1.37     virtual Array<CIMObject> associators(
196 kumpf 1.41         const CIMNamespaceName& nameSpace,
197 kumpf 1.34         const CIMObjectPath& objectName,
198 kumpf 1.41         const CIMName& assocClass = CIMName(),
199                    const CIMName& resultClass = CIMName(),
200 mike  1.27         const String& role = String::EMPTY,
201                    const String& resultRole = String::EMPTY,
202                    Boolean includeQualifiers = false,
203                    Boolean includeClassOrigin = false,
204                    const CIMPropertyList& propertyList = CIMPropertyList());
205 mike  1.25 
206                /// associateNames
207 kumpf 1.34     virtual Array<CIMObjectPath> associatorNames(
208 kumpf 1.41         const CIMNamespaceName& nameSpace,
209 kumpf 1.34         const CIMObjectPath& objectName,
210 kumpf 1.41         const CIMName& assocClass = CIMName(),
211                    const CIMName& resultClass = CIMName(),
212 mike  1.27         const String& role = String::EMPTY,
213                    const String& resultRole = String::EMPTY);
214 mike  1.25 
215                /// references
216 kumpf 1.37     virtual Array<CIMObject> references(
217 kumpf 1.41         const CIMNamespaceName& nameSpace,
218 kumpf 1.34         const CIMObjectPath& objectName,
219 kumpf 1.41         const CIMName& resultClass = CIMName(),
220 mike  1.27         const String& role = String::EMPTY,
221                    Boolean includeQualifiers = false,
222                    Boolean includeClassOrigin = false,
223                    const CIMPropertyList& propertyList = CIMPropertyList());
224 mike  1.25 
225                /// referenceNames
226 kumpf 1.34     virtual Array<CIMObjectPath> referenceNames(
227 kumpf 1.41         const CIMNamespaceName& nameSpace,
228 kumpf 1.34         const CIMObjectPath& objectName,
229 karl  1.42         const CIMName& resultClass = CIMName(),
230                    const String& role = String::EMPTY);
231            
232                /** Get the names of the Referenced Classes for the Target
233                    Class.  Note that this is really a subfunction of the
234                    ReferenceNames function except that it operates on class
235                 * input and returns only class names. It is a toolto get
236                 * information for the distribution of CIM associator operations
237                 * to providers.
238 david.eger 1.42.2.1      * This function returns the list of referenced class names, not
239 karl       1.42          * the references.
240                         */
241                         virtual Array<CIMName> referencedClassNames(
242                             const CIMNamespaceName& nameSpace,
243                             const CIMName& className,
244 kumpf      1.41             const CIMName& resultClass = CIMName(),
245 mike       1.27             const String& role = String::EMPTY);
246 mike       1.25     
247                         /// getProperty
248                         virtual CIMValue getProperty(
249 kumpf      1.41             const CIMNamespaceName& nameSpace,
250 kumpf      1.34             const CIMObjectPath& instanceName,
251 kumpf      1.41             const CIMName& propertyName);
252 mike       1.25     
253                         /// setProperty
254                         virtual void setProperty(
255 kumpf      1.41             const CIMNamespaceName& nameSpace,
256 kumpf      1.34             const CIMObjectPath& instanceName,
257 kumpf      1.41             const CIMName& propertyName,
258 mike       1.27             const CIMValue& newValue = CIMValue());
259 mike       1.25     
260                         /// getQualifier
261                         virtual CIMQualifierDecl getQualifier(
262 kumpf      1.41             const CIMNamespaceName& nameSpace,
263                             const CIMName& qualifierName);
264 mike       1.25     
265                         /// setQualifier
266                         virtual void setQualifier(
267 kumpf      1.41             const CIMNamespaceName& nameSpace,
268 mike       1.27             const CIMQualifierDecl& qualifierDecl);
269 mike       1.25     
270                         /// virtual deleteQualifier
271                         virtual void deleteQualifier(
272 kumpf      1.41             const CIMNamespaceName& nameSpace,
273                             const CIMName& qualifierName);
274 mike       1.25     
275                         /// enumerateQualifiers
276                         virtual Array<CIMQualifierDecl> enumerateQualifiers(
277 kumpf      1.41             const CIMNamespaceName& nameSpace);
278 mike       1.25     
279                         /** CIMMethod createNameSpace - Creates a new namespace in the repository
280 mike       1.27             @param String with the name of the namespace
281                             @exception - Throws "Already_Exists if the Namespace exits.
282                             Throws "CannotCreateDirectory" if there are problems in the
283                             creation.
284 mike       1.25         */
285 kumpf      1.41         virtual void createNameSpace(const CIMNamespaceName& nameSpace);
286 mike       1.25     
287                         /** CIMMethod enumerateNameSpaces - Get all of the namespaces in the
288 mike       1.27             repository. \Ref{NAMESPACE}
289                             @return Array of strings with the namespaces
290 mike       1.25         */
291 kumpf      1.41         virtual Array<CIMNamespaceName> enumerateNameSpaces() const;
292 mike       1.25     
293                         /** CIMMethod deleteNameSpace - Deletes a namespace in the repository.
294 mike       1.27             The deleteNameSpace method will only delete a namespace if there are
295                             no classed defined in the namespace.  Today this is a Pegasus
296                             characteristics and not defined as part of the DMTF standards.
297                             @param String with the name of the namespace
298                             @exception - Throws NoSuchDirectory if the Namespace does not exist.
299 mike       1.25         */
300 kumpf      1.41         virtual void deleteNameSpace(const CIMNamespaceName& nameSpace);
301 mike       1.31     
302                         ////////////////////////////////////////////////////////////////////////////
303 mike       1.25     
304 bob        1.26         /** CIMMethod setDeclContext - allows the Declaration Context set
305                             by default in the CIMRepository constructor to be overridden.
306                             This is useful, for example, when a compiler wants to check syntax
307                             without actually adding to the repository.
308                         */
309                         void setDeclContext(RepositoryDeclContext *context);
310                     
311 mike       1.27         /** Indicates whether instance operations that do not have a provider
312                             registered should be served by this repository.
313                         */
314                         Boolean isDefaultInstanceProvider()
315                         {
316                             return _isDefaultInstanceProvider;
317                         }
318                     
319 mike       1.31         /** Get subclass names of the given class in the given namespace.
320 sage       1.28             @param nameSpaceName
321                             @param className - class whose subclass names will be gotten. If
322                                 className is empty, all classnames are returned.
323                             @param deepInheritance - if true all descendent classes of class
324 karl       1.33                 are returned. If className is empty, only root classes are returned.
325                             @param subClassNames - output argument to hold subclass names.
326 sage       1.28             @exception CIMException(CIM_ERR_INVALID_CLASS)
327                         */
328 mike       1.31         virtual void getSubClassNames(
329 kumpf      1.41             const CIMNamespaceName& nameSpaceName,
330                             const CIMName& className,
331 sage       1.28             Boolean deepInheritance,
332 kumpf      1.41             Array<CIMName>& subClassNames) const
333 sage       1.28         {
334                             _nameSpaceManager.getSubClassNames(nameSpaceName,
335                                                                className,
336                                                                deepInheritance,
337                                                                subClassNames);
338                         }
339                     
340                         /** Get the names of all superclasses (direct and indirect) of this
341                             class.
342                         */
343 mike       1.31         virtual void getSuperClassNames(
344 kumpf      1.41             const CIMNamespaceName& nameSpaceName,
345                             const CIMName& className,
346                             Array<CIMName>& subClassNames) const
347 sage       1.28         {
348                             _nameSpaceManager.getSuperClassNames(nameSpaceName,
349                                                                  className,
350                                                                  subClassNames);
351                         }
352                     
353 mike       1.25     private:
354                     
355 mike       1.27         void _createAssocInstEntries(
356 kumpf      1.41             const CIMNamespaceName& nameSpace,
357 mike       1.27             const CIMConstClass& cimClass,
358                             const CIMInstance& cimInstance,
359 kumpf      1.34             const CIMObjectPath& instanceName);
360 mike       1.27     
361                         void _createAssocClassEntries(
362 kumpf      1.41             const CIMNamespaceName& nameSpace,
363 mike       1.27             const CIMConstClass& assocClass);
364                     
365                         /** Returns the index (or byte location) and size of the instance
366                             record in the instance file for a given instance.  Returns true
367                             if successful.  Returns false if the instance cannot be found.
368                     
369                             @param   nameSpace      the namespace of the instance
370                             @param   instanceName   the name of the instance
371                             @param   className      the name of the class
372                             @param   size           the size of the instance record found
373                             @param   index          the byte positon of the instance record found
374                             @param   searchSuper    if true, search all superclasses 
375                          
376                             @return  true           if the instance is found
377                                      false          if the instance cannot be found
378                          */
379 mike       1.25         Boolean _getInstanceIndex(
380 kumpf      1.41             const CIMNamespaceName& nameSpace,
381 kumpf      1.34             const CIMObjectPath& instanceName,
382 kumpf      1.41             CIMName& className,
383 mike       1.27             Uint32& size,
384                             Uint32& index,
385                             Boolean searchSuperClasses = false) const;
386                     
387                         /** Returns the file path of the instance index file.
388 mike       1.25     
389 mike       1.27             @param   nameSpace      the namespace of the instance
390                             @param   className      the name of the class
391                     
392                             @return  a string containing the index file path
393                          */
394 mike       1.29         String _getInstanceIndexFilePath(
395 kumpf      1.41             const CIMNamespaceName& nameSpace,
396                             const CIMName& className) const;
397 mike       1.27     
398                         /** Returns the file path of the instance file.
399                     
400                             @param   nameSpace      the namespace of the instance
401                             @param   className      the name of the class
402 mike       1.25     
403 mike       1.27             @return  a string containing the instance file path
404                          */
405 mike       1.29         String _getInstanceDataFilePath(
406 kumpf      1.41             const CIMNamespaceName& nameSpace,
407                             const CIMName& className) const;
408 mike       1.25     
409 mike       1.27         /** Saves an instance object from memory to disk file.  The byte
410                             position and the size of the newly inserted instance record are
411                             returned.  Returns true on success.
412                     
413                             @param   path      the file path of the instance file
414                             @param   object    the CIMInstance object to be saved
415                             @param   index     the byte positon of the saved instance record
416                             @param   size      the size of the saved instance record
417                     
418                             @return  true      if successful
419                                      false     if an error occurs in saving the instance to file
420                          */
421                         Boolean _saveInstance(
422                             const String& path,
423                             const CIMInstance& object,
424                             Uint32& index,
425                             Uint32& size);
426                     
427                         /** loads an instance object from disk to memory.  The caller passes 
428                             the byte position and the size of the instance record to be loaded.
429                             Returns true on success.
430 mike       1.27     
431                             @param   path      the file path of the instance file
432                             @param   object    the CIMInstance object to be returned
433                             @param   index     the byte positon of the instance record
434                             @param   size      the size of the instance record
435                             @param   data      the buffer to hold the instance data
436                     
437                             @return  true      if successful
438                                      false     if an error occurs in loading the instance from file
439                          */
440                         Boolean _loadInstance(
441                             const String& path,
442                             CIMInstance& object,
443                             Uint32 index,
444                             Uint32 size);
445                     
446                         /** loads all the instance objects from disk to memeory.  Returns true
447                             on success.
448                     
449                             @param   nameSpace      the namespace of the instances to be loaded 
450                             @param   className      the class of the instances to be loaded
451 kumpf      1.36             @param   namedInstances an array of CIMInstance objects to which
452 mike       1.27                                     the loaded instances are appended
453                     
454                             @return  true      if successful
455                                      false     if an error occurs in loading the instances
456                          */
457                         Boolean _loadAllInstances(
458 kumpf      1.41             const CIMNamespaceName& nameSpace,
459                             const CIMName& className,
460 kumpf      1.36             Array<CIMInstance>& namedInstances);
461 mike       1.27     
462                         /** Modifies an instance object saved in the disk file.  The byte position
463                             and the size of the newly added instance record are returned.  Returns
464                             true on success.
465                     
466                             @param   path      the file path of the instance file
467                             @param   object    the modified CIMInstance object
468                             @param   oldIndex  the byte positon of the old instance record
469                             @param   oldSize   the size of the old instance record
470                             @param   newIndex  the byte positon of the new instance record
471                             @param   newSize   the size of the new instance record
472                     
473                             @return  true      if successful
474                                      false     if an error occurs in modifying the instance
475                          */
476                         Boolean _modifyInstance(
477                             const String& path,
478                             const CIMInstance& object,
479                             Uint32 oldIndex,
480                             Uint32 oldSize,
481                             Uint32& newIndex,
482 mike       1.27             Uint32& newSize);
483                     
484                         /** Renames the temporary instance and instance index files back to the
485                             original files.  The temporary files were created for an insert,
486                             remove, or modify operation (to avoid data inconsistency between
487                             the two files in case of unexpected system termination or failure).
488                             This method is called after a successful insert, remove, or modify
489                             operation on BOTH the index file and the instance file.  Returns
490                             true on success.
491                     
492                             @param   indexFilePath   the file path of the instance index file
493                             @param   instancePath    the file path of the instance file
494                     
495                             @return  true      if successful
496                                      false     if an error occurs in removing the original files
497                                                or renaming the temporary files.
498                          */
499                         Boolean _renameTempInstanceAndIndexFiles(
500                             const String& indexFilePath,
501                             const String& instanceFilePath);
502 mike       1.25     
503                         String _repositoryRoot;
504                         NameSpaceManager _nameSpaceManager;
505                     
506 kumpf      1.32         // This must be initialized in the constructor using values from the
507 mike       1.27         // ConfigManager.
508                         Boolean _isDefaultInstanceProvider;
509                     
510 mike       1.25     protected:
511 mike       1.31     
512                         // Used by getInstance(); indicates whether instance should be resolved
513                         // after it is retrieved from the file.
514                     
515 mike       1.27         ReadWriteSem _lock;
516 mike       1.25         RepositoryDeclContext* _context;
517 mike       1.31         Boolean _resolveInstance;
518 mike       1.25     };
519                     
520 kumpf      1.41     String PEGASUS_REPOSITORY_LINKAGE namespaceNameToDirName(const CIMNamespaceName& namespaceName);
521 kumpf      1.39     String PEGASUS_REPOSITORY_LINKAGE dirNameToNamespaceName(const String& dirName);
522                     
523 mike       1.25     PEGASUS_NAMESPACE_END
524                     
525                     #endif /* PegasusRepository_Repository_h */
526                     

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2