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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2