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

  1 mike  1.1.2.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 mike  1.1.2.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               #include <cstdarg>
 35               #include <cassert>
 36               #include "MetaRepository.h"
 37               #include <Pegasus/Common/System.h>
 38 mike  1.1.2.8 #include <Pegasus/Common/Once.h>
 39 mike  1.1.2.7 #include "MetaTypes.h"
 40 mike  1.1.2.1 
 41               PEGASUS_NAMESPACE_BEGIN
 42               
 43 mike  1.1.2.8 typedef const MetaClass* ConstMetaClassPtr;
 44               #define PEGASUS_ARRAY_T ConstMetaClassPtr
 45               # include <Pegasus/Common/ArrayInter.h>
 46               # include <Pegasus/Common/ArrayImpl.h>
 47               #undef PEGASUS_ARRAY_T
 48               
 49 mike  1.1.2.10 //
 50                // Callback function and client data used to obtain namespaces from client.
 51                //
 52                static const MetaNameSpace* const* _nameSpaces;
 53 mike  1.1.2.1  
 54                static const size_t _MAX_FEATURES = 1024;
 55                static const size_t _MAX_QUALIFIERS = 1024;
 56                
 57 mike  1.1.2.5  PEGASUS_FORMAT(2, 3)
 58                static void _throw(CIMStatusCode code, const char* format, ...)
 59                {
 60                    char buffer[4096];
 61                
 62                    va_list ap;
 63                    va_start(ap, format);
 64                    vsprintf(buffer, format, ap);
 65                    va_end(ap);
 66                    throw CIMException(code, buffer);
 67                }
 68                
 69                static bool _eqi(const char* s1, const char* s2)
 70                {
 71                    return System::strcasecmp(s1, s2) == 0;
 72                }
 73                
 74 mike  1.1.2.1  class Str
 75                {
 76                public:
 77                    Str(const String& s) : _cstr(s.getCString()) { }
 78                    Str(const CIMName& n) : _cstr(n.getString().getCString()) { }
 79                    Str(const CIMNamespaceName& n) : _cstr(n.getString().getCString()) { }
 80                    Str(const Exception& e) : _cstr(e.getMessage().getCString()) { }
 81                    Str(const CIMDateTime& x) : _cstr(x.toString().getCString()) { }
 82                    Str(const CIMObjectPath& x) : _cstr(x.toString().getCString()) { }
 83                    const char* operator*() const { return (const char*)_cstr; }
 84                    operator const char*() const { return (const char*)_cstr; }
 85                private:
 86                    CString _cstr;
 87                };
 88                
 89                static const MetaNameSpace* _findNameSpace(const char* name)
 90                {
 91 mike  1.1.2.10     if (!_nameSpaces)
 92                        return 0;
 93                
 94                    for (const MetaNameSpace* const* p = _nameSpaces; *p; p++)
 95 mike  1.1.2.1      {
 96 mike  1.1.2.10         const MetaNameSpace* ns = *p;
 97                
 98                        if (_eqi(ns->name, name))
 99                            return ns;
100 mike  1.1.2.1      }
101                
102                    // Not found!
103                    return 0;
104                }
105                
106                static bool _isSubClass(const MetaClass* super, const MetaClass* sub)
107                {
108                    if (!super)
109                        return true;
110                
111                    for (MetaClass* p = sub->super; p; p = p->super)
112                    {
113                        if (p == super)
114                            return true;
115                    }
116                
117                    return false;
118                }
119                
120                static inline bool _isDirectSubClass(
121 mike  1.1.2.1      const MetaClass* super, 
122                    const MetaClass* sub)
123                {
124                    return sub->super == super;
125                }
126                
127 mike  1.1.2.3  static char** _makePropertyList(const CIMPropertyList& propertyList)
128                {
129                    if (propertyList.isNull())
130                        return 0;
131                
132                    size_t size = propertyList.size();
133                    char** pl = (char**)malloc(sizeof(char*) * (size + 1));
134                
135                    for (size_t i = 0; i < size; i++)
136                        pl[i] = strdup(*Str(propertyList[i]));
137                
138                    pl[size] = 0;
139                
140                    return pl;
141                }
142                
143                static void _freePropertyList(char** pl)
144                {
145                    if (!pl)
146                        return;
147                
148 mike  1.1.2.3      for (size_t i = 0; pl[i]; i++)
149                    {
150                        free(pl[i]);
151                    }
152                
153                    free(pl);
154                }
155                
156                static void _printPropertyList(const char* const* pl)
157                {
158                    if (!pl)
159                        return;
160                
161                    for (size_t i = 0; pl[i]; i++)
162                        printf("pl[%s]\n", pl[i]);
163                }
164                
165 mike  1.1.2.8  static bool _contains(const Array<const MetaClass*>& x, const MetaClass* mc)
166                {
167                    Uint32 n = x.size();
168                    const MetaClass* const* p = x.getData();
169                
170                    while (n--)
171                    {
172                        if (*p++ == mc)
173                            return true;
174                    }
175                
176                    return false;
177                }
178                
179                static void _associators(
180                    const MetaNameSpace* ns,
181                    const CIMName& className,
182                    const CIMName& assocClass,
183                    const CIMName& resultClass,
184                    const String& role,
185                    const String& resultRole,
186 mike  1.1.2.8      Array<const MetaClass*>& result)
187                {
188                    // Lookup source class:
189                
190                    const MetaClass* mc = FindClass(ns, *Str(className));
191                    
192                    if (!mc)
193                        _throw(CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className));
194                
195                
196                    // Lookup result class (if any).
197                
198                    const MetaClass* rmc = 0;
199                
200                    if (!resultClass.isNull())
201                    {
202                        rmc = FindClass(ns, *Str(resultClass));
203                
204                        if (!rmc)
205                            _throw(CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(resultClass));
206                    }
207 mike  1.1.2.8  
208                    // Convert these to UTF8 now to avoid doing so in loop below.
209                
210                    Str ac(assocClass);
211                    Str r(role);
212                    Str rr(resultRole);
213                
214                    // Process association classes:
215                
216                    for (size_t i = 0; ns->classes[i]; i++)
217                    {
218                        MetaClass* amc = ns->classes[i];
219                
220                        // Skip non-association classes:
221                
222                        if (!(amc->flags & META_FLAG_ASSOCIATION))
223                            continue;
224                
225                        // Filter by assocClass parameter:
226                
227                        if (!assocClass.isNull() && !_eqi(ac, amc->name))
228 mike  1.1.2.8              continue;
229                
230                        // Process reference properties:
231                
232                        MetaFeatureInfo features[META_MAX_FEATURES];
233                        size_t size = 0;
234                        MergeFeatures(amc, false, META_FLAG_REFERENCE, features, size);
235                
236                        for (size_t j = 0; j < size; j++)
237                        {
238                            const MetaFeature* mf = features[j].mf;
239                
240                            // Skip non references:
241                
242                            if (!(mf->flags & META_FLAG_REFERENCE))
243                                continue;
244                
245                            const MetaReference* mr = (const MetaReference*)mf;
246                
247                            // Filter by role parameter.
248                
249 mike  1.1.2.8              if (role.size() && !_eqi(r, mf->name))
250                                continue;
251                
252                            // Filter by source class:
253                
254                            if (!IsA(mr->ref, mc))
255                                continue;
256                
257                            // Process result reference:
258                
259                            for (size_t k = 0; k < size; k++)
260                            {
261                                const MetaFeature* rmf = features[k].mf;
262                
263                                // Skip the feature under consideration:
264                
265                                if (rmf == mf)
266                                    continue;
267                
268                                // Skip non references:
269                
270 mike  1.1.2.8                  if (!(rmf->flags & META_FLAG_REFERENCE))
271                                    continue;
272                
273                                const MetaReference* rmr = (const MetaReference*)rmf;
274                
275                                // Filter by resultRole parameter.
276                
277                                if (resultRole.size() && !_eqi(rr, rmf->name))
278                                    continue;
279                
280                                // Skip references not of the result class kind:
281                
282                                if (rmc && !IsA(rmr->ref, rmc))
283                                    continue;
284                
285                                // ATTN: should we include entire class hierarchy under
286                                // result class?
287                
288                                // If reached, then save this one.
289                
290                                if (!_contains(result, rmr->ref))
291 mike  1.1.2.8                      result.append(rmr->ref);
292                            }
293                        }
294                    }
295                }
296                
297                static void _references(
298                    const MetaNameSpace* ns,
299                    const CIMName& className,
300                    const CIMName& resultClass,
301                    const String& role,
302                    Array<const MetaClass*>& result)
303                {
304                    // Lookup source class:
305                
306                    const MetaClass* mc = FindClass(ns, *Str(className));
307                    
308                    if (!mc)
309                        _throw(CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className));
310                
311                    // Lookup result class (if any).
312 mike  1.1.2.8  
313                    const MetaClass* rmc = 0;
314                
315                    if (!resultClass.isNull())
316                    {
317                        rmc = FindClass(ns, *Str(resultClass));
318                
319                        if (!rmc)
320                            _throw(CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(resultClass));
321                    }
322                
323                    // Convert these to UTF8 now to avoid doing so in loop below.
324                
325                    Str r(role);
326                
327                    // Process association classes:
328                
329                    for (size_t i = 0; ns->classes[i]; i++)
330                    {
331                        MetaClass* amc = ns->classes[i];
332                
333 mike  1.1.2.8          // Skip non-association classes:
334                
335                        if (!(amc->flags & META_FLAG_ASSOCIATION))
336                            continue;
337                
338                        // Filter by result class:
339                
340                        if (rmc && !IsA(rmc, amc))
341                            continue;
342                
343                        // Process reference properties:
344                
345                        MetaFeatureInfo features[META_MAX_FEATURES];
346                        size_t size = 0;
347                        MergeFeatures(amc, false, META_FLAG_REFERENCE, features, size);
348                
349                        for (size_t j = 0; j < size; j++)
350                        {
351                            const MetaFeature* mf = features[j].mf;
352                
353                            // Skip non references:
354 mike  1.1.2.8  
355                            if (!(mf->flags & META_FLAG_REFERENCE))
356                                continue;
357                
358                            const MetaReference* mr = (const MetaReference*)mf;
359                
360                            // Filter by role parameter.
361                
362                            if (role.size() && !_eqi(r, mf->name))
363                                continue;
364                
365                            // Filter by source class:
366                
367                            if (!IsA(mr->ref, mc))
368                                continue;
369                
370                            // Add this one to the output:
371                
372                            if (!_contains(result, amc))
373                                result.append((MetaClass*)amc);
374                        }
375 mike  1.1.2.8      }
376                }
377                
378                //==============================================================================
379                //
380                // _getHostName()
381                //
382                //==============================================================================
383                
384                static Once _once = PEGASUS_ONCE_INITIALIZER;
385                static const char* _hostName = 0;
386                
387                static void _initHostName()
388                {
389                    String hn = System::getHostName();
390                    _hostName = strdup(*Str(hn));
391                }
392                
393                static inline const char* _getHostName()
394                {
395                    once(&_once, _initHostName);
396 mike  1.1.2.8      return _hostName;
397                }
398                
399 mike  1.1.2.1  //==============================================================================
400                //
401                // class MetaRepository
402                //
403                //==============================================================================
404                
405                MetaRepository::MetaRepository()
406                {
407                }
408                
409                MetaRepository::~MetaRepository()
410                {
411                }
412                
413                CIMClass MetaRepository::getClass(
414                    const CIMNamespaceName& nameSpace,
415                    const CIMName& className,
416                    Boolean localOnly,
417                    Boolean includeQualifiers,
418                    Boolean includeClassOrigin,
419                    const CIMPropertyList& propertyList)
420 mike  1.1.2.1  {
421 mike  1.1.2.3      // Lookup namespace:
422                
423                    const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));
424                
425                    if (!ns)
426                        _throw(CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace));
427                
428                    // Lookup class:
429                
430 mike  1.1.2.8      const MetaClass* mc = FindClass(ns, *Str(className));
431 mike  1.1.2.3  
432                    if (!mc)
433                        _throw(CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className));
434                
435                    // Build property list:
436                
437                    char** pl = _makePropertyList(propertyList);
438                
439                    // Make class:
440                
441                    CIMClass cc;
442                
443 mike  1.1.2.8      if (MakeClass(_getHostName(), ns, mc, localOnly, includeQualifiers, 
444                        includeClassOrigin, pl, cc) != 0)
445 mike  1.1.2.3      {
446                        _freePropertyList(pl);
447                        _throw(CIM_ERR_FAILED, "conversion failed: %s", mc->name);
448                    }
449                
450                    _freePropertyList(pl);
451                    return cc;
452 mike  1.1.2.1  }
453                
454                Array<CIMClass> MetaRepository::enumerateClasses(
455                    const CIMNamespaceName& nameSpace,
456                    const CIMName& className,
457                    Boolean deepInheritance,
458                    Boolean localOnly,
459                    Boolean includeQualifiers,
460                    Boolean includeClassOrigin)
461                {
462                    // Lookup namespace:
463                
464                    const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));
465                
466                    if (!ns)
467                        _throw(CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace));
468                
469                    // Lookup class:
470                
471                    const MetaClass* super = 0;
472                    
473 mike  1.1.2.1      if (!className.isNull())
474                    {
475 mike  1.1.2.8          super = FindClass(ns, *Str(className));
476 mike  1.1.2.1  
477                        if (!super)
478                            _throw(CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className));
479                    }
480                
481                    // Iterate all classes looking for matches:
482                
483                    Array<CIMClass> result;
484                
485                    for (size_t i = 0; ns->classes[i]; i++)
486                    {
487 mike  1.1.2.3          MetaClass* mc = ns->classes[i];
488 mike  1.1.2.1  
489 mike  1.1.2.3          bool flag = false;
490 mike  1.1.2.1  
491                        if (deepInheritance)
492                        {
493 mike  1.1.2.3              if (_isSubClass(super, mc))
494                                flag = true;
495 mike  1.1.2.1          }
496                        else
497                        {
498 mike  1.1.2.3              if (_isDirectSubClass(super, mc))
499                                flag = true;
500                        }
501                
502                        if (flag)
503                        {
504                            CIMClass cc;
505 mike  1.1.2.1  
506 mike  1.1.2.8              if (MakeClass(_getHostName(), ns, mc, localOnly, includeQualifiers, 
507                                includeClassOrigin, 0, cc) != 0)
508 mike  1.1.2.3              {
509                                _throw(CIM_ERR_FAILED, "conversion failed: %s", mc->name);
510 mike  1.1.2.1              }
511 mike  1.1.2.8  
512                            result.append(cc);
513 mike  1.1.2.1          }
514                    }
515                
516                    return result;
517                }
518                
519                Array<CIMName> MetaRepository::enumerateClassNames(
520                    const CIMNamespaceName& nameSpace,
521                    const CIMName& className,
522                    Boolean deepInheritance)
523                {
524                    // Lookup namespace:
525                
526                    const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));
527                
528                    if (!ns)
529                        _throw(CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace));
530                
531                    // Lookup class:
532                
533                    const MetaClass* super = 0;
534 mike  1.1.2.1      
535                    if (!className.isNull())
536                    {
537 mike  1.1.2.8          super = FindClass(ns, *Str(className));
538 mike  1.1.2.1  
539                        if (!super)
540                            _throw(CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className));
541                    }
542                
543                    // Iterate all classes looking for matches:
544                
545                    Array<CIMName> result;
546                
547                    for (size_t i = 0; ns->classes[i]; i++)
548                    {
549 mike  1.1.2.3          MetaClass* mc = ns->classes[i];
550 mike  1.1.2.1  
551                        if (deepInheritance)
552                        {
553 mike  1.1.2.3              if (_isSubClass(super, mc))
554                                result.append(mc->name);
555 mike  1.1.2.1          }
556                        else
557                        {
558 mike  1.1.2.3              if (_isDirectSubClass(super, mc))
559                                result.append(mc->name);
560 mike  1.1.2.1          }
561                    }
562                
563                    return result;
564                }
565                
566                void MetaRepository::deleteClass(
567                    const CIMNamespaceName& nameSpace,
568                    const CIMName& className)
569                {
570                    _throw(CIM_ERR_NOT_SUPPORTED, "deleteClass()");
571                }
572                
573                void MetaRepository::createClass(
574                    const CIMNamespaceName& nameSpace,
575                    const CIMClass& newClass)
576                {
577                    _throw(CIM_ERR_NOT_SUPPORTED, "createClass()");
578                }
579                
580                void MetaRepository::modifyClass(
581 mike  1.1.2.1      const CIMNamespaceName& nameSpace,
582                    const CIMClass& newClass)
583                {
584                    _throw(CIM_ERR_NOT_SUPPORTED, "modifyClass()");
585                }
586                
587 mike  1.1.2.4  void MetaRepository::getSubClassNames(
588                    const CIMNamespaceName& nameSpace,
589                    const CIMName& className,
590                    Boolean deepInheritance,
591                    Array<CIMName>& subClassNames)
592                {
593                    subClassNames = MetaRepository::enumerateClassNames(
594                        nameSpace, className, deepInheritance);
595                }
596                
597                void MetaRepository::getSuperClassNames(
598                    const CIMNamespaceName& nameSpace,
599                    const CIMName& className,
600                    Array<CIMName>& superClassNames)
601                {
602                    superClassNames.clear();
603                
604                    // Lookup namespace:
605                
606                    const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));
607                
608 mike  1.1.2.4      if (!ns)
609                        _throw(CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace));
610                
611                    // Lookup class:
612                
613 mike  1.1.2.8      const MetaClass* mc = FindClass(ns, *Str(className));
614 mike  1.1.2.4      
615                    if (!mc)
616                        _throw(CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className));
617                
618                    // Append superclass names:
619                
620                    for (const MetaClass* p = mc->super; p; p = p->super)
621                        superClassNames.append(p->name);
622                }
623                
624                void MetaRepository::createNameSpace(
625                    const CIMNamespaceName& nameSpace,
626                    const NameSpaceAttributes& attributes)
627                {
628                    _throw(CIM_ERR_NOT_SUPPORTED, "createNameSpace()");
629                }
630                
631                void MetaRepository::modifyNameSpace(
632                    const CIMNamespaceName& nameSpace,
633                    const NameSpaceAttributes& attributes)
634                {
635 mike  1.1.2.4      _throw(CIM_ERR_NOT_SUPPORTED, "modifyNameSpace()");
636                }
637                
638                Array<CIMNamespaceName> MetaRepository::enumerateNameSpaces()
639                {
640 mike  1.1.2.10     Array<CIMNamespaceName> result;
641                
642                    if (!_nameSpaces)
643                        return Array<CIMNamespaceName>();
644 mike  1.1.2.4  
645 mike  1.1.2.10     for (const MetaNameSpace* const* p = _nameSpaces; *p; p++)
646                    {
647                        const MetaNameSpace* ns = *p;
648                        result.append(ns->name);
649                    }
650 mike  1.1.2.4  
651 mike  1.1.2.10     return result;
652 mike  1.1.2.4  }
653                
654                void MetaRepository::deleteNameSpace(
655                    const CIMNamespaceName& nameSpace)
656                {
657                    _throw(CIM_ERR_NOT_SUPPORTED, "deleteNameSpace()");
658                }
659                
660                Boolean MetaRepository::getNameSpaceAttributes(
661                    const CIMNamespaceName& nameSpace,
662                    NameSpaceAttributes& attributes)
663                {
664                    _throw(CIM_ERR_NOT_SUPPORTED, "getNameSpaceAttributes()");
665                
666                    return false;
667                }
668                
669                Boolean MetaRepository::isRemoteNameSpace(
670                    const CIMNamespaceName& nameSpace,
671                    String& remoteInfo)
672                {
673 mike  1.1.2.4      return false;
674                }
675                
676                CIMQualifierDecl MetaRepository::getQualifier(
677                    const CIMNamespaceName& nameSpace,
678                    const CIMName& qualifierName)
679                {
680                    // Lookup namespace:
681                
682                    const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));
683                
684                    if (!ns)
685                        _throw(CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace));
686                
687                    // Lookup qualifier:
688                
689 mike  1.1.2.8      const MetaQualifierDecl* mqd = FindQualifierDecl(ns, *Str(qualifierName));
690 mike  1.1.2.4      
691                    if (!mqd)
692                        _throw(CIM_ERR_NOT_FOUND, "unknown qualifier: %s", *Str(qualifierName));
693                
694                    // Make the qualifier declaration:
695                
696                    CIMQualifierDecl cqd;
697                
698 mike  1.1.2.5      if (MakeQualifierDecl(ns, mqd, cqd) != 0)
699 mike  1.1.2.4      {
700                        _throw(CIM_ERR_FAILED, "conversion failed: %s", mqd->name);
701                    }
702                
703                    return cqd;
704                }
705                
706                void MetaRepository::setQualifier(
707                    const CIMNamespaceName& nameSpace,
708                    const CIMQualifierDecl& qualifierDecl)
709                {
710                    _throw(CIM_ERR_NOT_SUPPORTED, "setQualifier()");
711                
712                }
713                
714                void MetaRepository::deleteQualifier(
715                    const CIMNamespaceName& nameSpace,
716                    const CIMName& qualifierName)
717                {
718                    _throw(CIM_ERR_NOT_SUPPORTED, "deleteQualifier()");
719                }
720 mike  1.1.2.4  
721                Array<CIMQualifierDecl> MetaRepository::enumerateQualifiers(
722                    const CIMNamespaceName& nameSpace)
723                {
724                    // Lookup namespace:
725                
726                    const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));
727                
728                    if (!ns)
729                        _throw(CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace));
730                
731                    // Build the array of qualifier declarations:
732                
733                    Array<CIMQualifierDecl> result;
734                
735                    for (size_t i = 0; ns->qualifiers[i]; i++)
736                    {
737                        const MetaQualifierDecl* mqd = ns->qualifiers[i];
738                        CIMQualifierDecl cqd;
739                
740 mike  1.1.2.5          if (MakeQualifierDecl(ns, mqd, cqd) != 0)
741 mike  1.1.2.4          {
742                            _throw(CIM_ERR_FAILED, "conversion failed: %s", mqd->name);
743                        }
744                
745                        result.append(cqd);
746                    }
747                
748                    return result;
749                }
750                
751 mike  1.1.2.8  Array<CIMObjectPath> MetaRepository::associatorClassPaths(
752                    const CIMNamespaceName& nameSpace,
753                    const CIMName& className,
754                    const CIMName& assocClass,
755                    const CIMName& resultClass,
756                    const String& role,
757                    const String& resultRole)
758                {
759                    // Lookup namespace:
760                
761                    const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));
762                
763                    if (!ns)
764                        _throw(CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace));
765                
766                    // Get associator meta-classes:
767                
768                    Array<const MetaClass*> mcs;
769                    _associators(ns, className, assocClass, resultClass, role, resultRole, mcs);
770                
771                    // Convert meta-classes to object names:
772 mike  1.1.2.8  
773                    Array<CIMObjectPath> result;
774                
775                    for (Uint32 i = 0; i < mcs.size(); i++)
776                        result.append(CIMObjectPath(_getHostName(), nameSpace, mcs[i]->name));
777                
778                    return result;
779                }
780                
781                Array<CIMObject> MetaRepository::associatorClasses(
782                    const CIMNamespaceName& nameSpace,
783                    const CIMName& className,
784                    const CIMName& assocClass,
785                    const CIMName& resultClass,
786                    const String& role,
787                    const String& resultRole,
788                    Boolean includeQualifiers,
789                    Boolean includeClassOrigin,
790                    const CIMPropertyList& propertyList)
791                {
792                    // Lookup namespace:
793 mike  1.1.2.8  
794                    const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));
795                
796                    if (!ns)
797                        _throw(CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace));
798                
799                    // Get associator meta-classes:
800                
801                    Array<const MetaClass*> mcs;
802                    _associators(ns, className, assocClass, resultClass, role, resultRole, mcs);
803                
804                    // Convert meta-classes to classes.
805                
806                    Array<CIMObject> result;
807                
808                    char** pl = _makePropertyList(propertyList);
809                
810                    for (Uint32 i = 0; i < mcs.size(); i++)
811                    {
812                        const MetaClass* mc = mcs[i];
813                        CIMClass cc;
814 mike  1.1.2.8  
815                        if (MakeClass(_getHostName(), ns, mc, false, includeQualifiers, 
816                            includeClassOrigin, pl, cc) != 0)
817                        {
818                            _freePropertyList(pl);
819                            _throw(CIM_ERR_FAILED, "conversion failed: %s", mc->name);
820                        }
821                
822                        result.append(cc);
823                    }
824                
825                    _freePropertyList(pl);
826                    return result;
827                }
828                
829                Array<CIMObject> MetaRepository::referenceClasses(
830                    const CIMNamespaceName& nameSpace,
831                    const CIMName& className,
832                    const CIMName& resultClass,
833                    const String& role,
834                    Boolean includeQualifiers,
835 mike  1.1.2.8      Boolean includeClassOrigin,
836                    const CIMPropertyList& propertyList)
837                {
838                    // Lookup namespace:
839                
840                    const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));
841                
842                    if (!ns)
843                        _throw(CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace));
844                
845                    // Get reference meta-classes:
846                
847                    Array<const MetaClass*> mcs;
848                    _references(ns, className, resultClass, role, mcs);
849                
850                    // Convert meta-classes to classes.
851                
852                    Array<CIMObject> result;
853                
854                    char** pl = _makePropertyList(propertyList);
855                
856 mike  1.1.2.8      for (Uint32 i = 0; i < mcs.size(); i++)
857                    {
858                        const MetaClass* mc = mcs[i];
859                        CIMClass cc;
860                
861                        if (MakeClass(_getHostName(), ns, mc, false, includeQualifiers, 
862                            includeClassOrigin, pl, cc) != 0)
863                        {
864                            _freePropertyList(pl);
865                            _throw(CIM_ERR_FAILED, "conversion failed: %s", mc->name);
866                        }
867                
868                        result.append(cc);
869                    }
870                
871                    _freePropertyList(pl);
872                    return result;
873                }
874                
875                Array<CIMObjectPath> MetaRepository::referenceClassPaths(
876                    const CIMNamespaceName& nameSpace,
877 mike  1.1.2.8      const CIMName& className,
878                    const CIMName& resultClass,
879                    const String& role)
880                {
881                    // Lookup namespace:
882                
883                    const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));
884                
885                    if (!ns)
886                        _throw(CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace));
887                
888                    // Get reference meta-classes:
889                
890                    Array<const MetaClass*> mcs;
891                    _references(ns, className, resultClass, role, mcs);
892                
893                    // Convert meta-classes to object paths.
894                
895                    Array<CIMObjectPath> result;
896                
897                    for (Uint32 i = 0; i < mcs.size(); i++)
898 mike  1.1.2.8          result.append(CIMObjectPath(_getHostName(), nameSpace, mcs[i]->name));
899                
900                    return result;
901                }
902                
903 mike  1.1.2.9  const MetaClass* MetaRepository::findMetaClass(
904                    const char* nameSpace,
905                    const char* className)
906                {
907                    // Lookup namespace:
908                
909                    const MetaNameSpace* ns = _findNameSpace(nameSpace);
910                
911                    if (!ns)
912                        return 0;
913                
914                    return FindClass(ns, className);
915                }
916                
917 mike  1.1.2.10 void MetaRepository::installNameSpaces(const MetaNameSpace* const* nameSpaces)
918                {
919                    _nameSpaces = nameSpaces;
920                }
921                
922 mike  1.1.2.1  PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2