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

   1 martin 1.4 //%LICENSE////////////////////////////////////////////////////////////////
   2 martin 1.5 //
   3 martin 1.4 // Licensed to The Open Group (TOG) under one or more contributor license
   4            // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
   5            // this work for additional information regarding copyright ownership.
   6            // Each contributor licenses this file to you under the OpenPegasus Open
   7            // Source License; you may not use this file except in compliance with the
   8            // License.
   9 martin 1.5 //
  10 martin 1.4 // Permission is hereby granted, free of charge, to any person obtaining a
  11            // copy of this software and associated documentation files (the "Software"),
  12            // to deal in the Software without restriction, including without limitation
  13            // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  14            // and/or sell copies of the Software, and to permit persons to whom the
  15            // Software is furnished to do so, subject to the following conditions:
  16 martin 1.5 //
  17 martin 1.4 // The above copyright notice and this permission notice shall be included
  18            // in all copies or substantial portions of the Software.
  19 martin 1.5 //
  20 martin 1.4 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  21 martin 1.5 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22 martin 1.4 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  23            // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  24            // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  25            // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  26            // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27 martin 1.5 //
  28 martin 1.4 //////////////////////////////////////////////////////////////////////////
  29 mike   1.1 //
  30            //%/////////////////////////////////////////////////////////////////////////////
  31            
  32 karl   1.7.6.2 /**
  33                 * This file redefines the CIMRepository.h interfaces to be a
  34                 * read-only memory-resident  class repository and an in-memory instance
  35                 * repository. It implements all functions of the
  36                 * CIMRepository.h interface. All  class functions that would
  37                 * modify the repository return exceptions since the repository is read-only.
  38                 * Functions that return data (ex. getClass, enumerateClasses, etc.) return
  39                 * the same form of data as the other repository implementations.
  40                 *
  41                 * NOTE: This repository does NOT implement a cache because it
  42                 * appeared that it would be of little gain since the movement
  43                 * of data from the in-memory repository is already fast.
  44                 * Therefore there are some parameters of the API (Ex clone)
  45                 * that are not implemented.
  46                 *
  47                 * The class repository is actually a .CPP/.h file that is
  48                 * produced by the MOF compiler from input mof files. This file
  49                 * includes the definition of all namespaces, qualifiers, and
  50                 * classes defined as part of the mof input.
  51                 *
  52                 * The instance repository is an in-memory repository that
  53 karl   1.7.6.2  * includes functions to load the instance repository on startup
  54                 * and checkpoint the instance repository each time a change is
  55                 * made
  56                 *
  57                 * See PEP 307 for more information on the implementation and
  58                 * usage of the memory-resident repository.
  59                 */
  60                
  61 mike   1.1     #include "MRR.h"
  62                #include <cstdarg>
  63                #include <Pegasus/Common/Resolver.h>
  64                #include <Pegasus/Common/Once.h>
  65                #include <Pegasus/Common/System.h>
  66                #include <Pegasus/Common/Tracer.h>
  67                #include <Pegasus/Common/Pair.h>
  68                #include "CIMRepository.h"
  69                #include "RepositoryDeclContext.h"
  70                #include "MRRSerialization.h"
  71                #include "MRRTypes.h"
  72                
  73                PEGASUS_NAMESPACE_BEGIN
  74                
  75                typedef Pair<CIMNamespaceName, CIMInstance> NamespaceInstancePair;
  76                
  77                #define PEGASUS_ARRAY_T NamespaceInstancePair
  78                # include <Pegasus/Common/ArrayInter.h>
  79                #undef PEGASUS_ARRAY_T
  80                
  81                class CIMRepositoryRep
  82 mike   1.1     {
  83                public:
  84                
  85                    Uint32 _findInstance(
  86                        const CIMNamespaceName& nameSpace,
  87                        const CIMObjectPath& instanceName);
  88                
  89                    void _processSaveCallback();
  90                
  91                    void _processLoadCallback();
  92                
  93                    Array<NamespaceInstancePair> _rep;
  94                };
  95                
  96                typedef const MRRClass* ConstMRRClassPtr;
  97                #define PEGASUS_ARRAY_T ConstMRRClassPtr
  98                # include <Pegasus/Common/ArrayInter.h>
  99                # include <Pegasus/Common/ArrayImpl.h>
 100                #undef PEGASUS_ARRAY_T
 101                
 102                #define PEGASUS_ARRAY_T NamespaceInstancePair
 103 mike   1.1     # include <Pegasus/Common/ArrayImpl.h>
 104                #undef PEGASUS_ARRAY_T
 105                
 106                //==============================================================================
 107                //
 108                // Local definitions:
 109                //
 110                //==============================================================================
 111                
 112                static size_t const _MAX_NAMESPACE_TABLE_SIZE = 64;
 113                static const MRRNameSpace* _nameSpaceTable[_MAX_NAMESPACE_TABLE_SIZE];
 114                static size_t _nameSpaceTableSize = 0;
 115                
 116                class ThrowContext
 117                {
 118                public:
 119                
 120                    PEGASUS_FORMAT(3, 4)
 121                    ThrowContext(CIMStatusCode code_, const char* format, ...) : code(code_)
 122                    {
 123                        char buffer[1024];
 124 mike   1.1             va_list ap;
 125                        va_start(ap, format);
 126                        vsprintf(buffer, format, ap);
 127                        va_end(ap);
 128                        msg = buffer;
 129                    }
 130                    CIMStatusCode code;
 131                    String msg;
 132                };
 133                
 134                #define Throw(ARGS) \
 135                    do \
 136                    { \
 137                        ThrowContext c ARGS; \
 138                        throw CIMException(c.code, c.msg); \
 139                    } \
 140                    while (0)
 141                
 142                class Str
 143                {
 144                public:
 145 mike   1.1         Str(const String& s) : _cstr(s.getCString()) { }
 146                    Str(const CIMName& n) : _cstr(n.getString().getCString()) { }
 147                    Str(const CIMNamespaceName& n) : _cstr(n.getString().getCString()) { }
 148                    Str(const Exception& e) : _cstr(e.getMessage().getCString()) { }
 149                    Str(const CIMDateTime& x) : _cstr(x.toString().getCString()) { }
 150                    Str(const CIMObjectPath& x) : _cstr(x.toString().getCString()) { }
 151                    const char* operator*() const { return (const char*)_cstr; }
 152                    operator const char*() const { return (const char*)_cstr; }
 153                private:
 154                    CString _cstr;
 155                };
 156                
 157                /** Check to see if the specified property is in the property list
 158                    @param property the specified property
 159                    @param propertyList the property list
 160                    @return true if the property is in the list otherwise false.
 161                */
 162                static Boolean _containsProperty(
 163 karl   1.7.6.2     const CIMProperty& property,
 164 mike   1.1         const CIMPropertyList& propertyList)
 165                {
 166                    //  For each property in the propertly list
 167                    for (Uint32 p=0; p<propertyList.size(); p++)
 168                    {
 169                        if (propertyList[p].equal(property.getName()))
 170 karl   1.7.6.2         {
 171 mike   1.1                 return true;
 172 karl   1.7.6.2         }
 173 mike   1.1         }
 174                    return false;
 175                }
 176                
 177                /* removes all Qualifiers from a CIMClass.  This function removes all
 178                   of the qualifiers from the class, from all of the properties,
 179                   from the methods, and from the parameters attached to the methods.
 180                   @param cimClass reference to the class from which qualifiers are to
 181                   be removed.
 182                   NOTE: This would be logical to be moved to CIMClass since it may be
 183                   more general than this usage.
 184                */
 185                static void _removeAllQualifiers(CIMClass& cimClass)
 186                {
 187                    // remove qualifiers of the class
 188                    Uint32 count = 0;
 189                    while ((count = cimClass.getQualifierCount()) > 0)
 190 karl   1.7.6.2     {
 191 mike   1.1             cimClass.removeQualifier(count - 1);
 192 karl   1.7.6.2     }
 193 mike   1.1     
 194                    // remove qualifiers from the properties
 195                    for (Uint32 i = 0; i < cimClass.getPropertyCount(); i++)
 196                    {
 197                        CIMProperty p = cimClass.getProperty(i);
 198                        count = 0;
 199                        while ((count = p.getQualifierCount()) > 0)
 200 karl   1.7.6.2         {
 201 mike   1.1                 p.removeQualifier(count - 1);
 202 karl   1.7.6.2         }
 203 mike   1.1         }
 204                
 205                    // remove qualifiers from the methods
 206                    for (Uint32 i = 0; i < cimClass.getMethodCount(); i++)
 207                    {
 208                        CIMMethod m = cimClass.getMethod(i);
 209                        for (Uint32 j = 0 ; j < m.getParameterCount(); j++)
 210                        {
 211                            CIMParameter p = m.getParameter(j);
 212                            count = 0;
 213                            while ((count = p.getQualifierCount()) > 0)
 214 karl   1.7.6.2             {
 215 mike   1.1                     p.removeQualifier(count - 1);
 216 karl   1.7.6.2             }
 217 mike   1.1             }
 218                        count = 0;
 219                        while ((count = m.getQualifierCount()) > 0)
 220 karl   1.7.6.2         {
 221 mike   1.1                 m.removeQualifier(count - 1);
 222 karl   1.7.6.2         }
 223 mike   1.1         }
 224                }
 225                
 226                /////////////////////////////////////////////////////////////////////////
 227                //
 228                // _removePropagatedQualifiers - Removes all qualifiers from the class
 229                // that are marked propagated
 230                //
 231                /////////////////////////////////////////////////////////////////////////
 232                
 233                /* removes propagatedQualifiers from the defined CIMClass.
 234                   This function removes the qualifiers from the class,
 235                   from each of the properties, from the methods and
 236                   the parameters if the qualifiers are marked propagated.
 237                   NOTE: This could be logical to be moved to CIMClass since it may be
 238                   more general than the usage here.
 239                */
 240                static void _removePropagatedQualifiers(CIMClass& cimClass)
 241                {
 242                    Uint32 count = cimClass.getQualifierCount();
 243                    // Remove nonlocal qualifiers from Class
 244 mike   1.1         for (Sint32 i = (count - 1); i >= 0; i--)
 245                    {
 246                        CIMQualifier q = cimClass.getQualifier(i);
 247                        if (q.getPropagated())
 248                        {
 249                            cimClass.removeQualifier(i);
 250                        }
 251                    }
 252                
 253 kumpf  1.7         // remove nonlocal qualifiers from the properties
 254 mike   1.1         for (Uint32 i = 0; i < cimClass.getPropertyCount(); i++)
 255                    {
 256                        CIMProperty p = cimClass.getProperty(i);
 257                        // loop to search qualifiers for nonlocal parameters
 258                        count = p.getQualifierCount();
 259                        for (Sint32 j = (count - 1); j >= 0; j--)
 260                        {
 261                            CIMQualifier q = p.getQualifier(j);
 262                            if (q.getPropagated())
 263                            {
 264                                p.removeQualifier(j);
 265                            }
 266                        }
 267                    }
 268                
 269 kumpf  1.7         // remove nonlocal qualifiers from the methods and parameters
 270 mike   1.1         for (Uint32 i = 0; i < cimClass.getMethodCount(); i++)
 271                    {
 272                        CIMMethod m = cimClass.getMethod(i);
 273                        // Remove  nonlocal qualifiers from all parameters
 274                        for (Uint32 j = 0 ; j < m.getParameterCount(); j++)
 275                        {
 276                            CIMParameter p = m.getParameter(j);
 277                            count = p.getQualifierCount();
 278                            for (Sint32 k = (count - 1); k >= 0; k--)
 279                            {
 280                                CIMQualifier q = p.getQualifier(k);
 281                                if (q.getPropagated())
 282                                {
 283                                    p.removeQualifier(k);
 284                                }
 285                            }
 286                        }
 287                
 288                        // remove nonlocal qualifiers from the method
 289                        count = m.getQualifierCount();
 290                        for (Sint32 j = (count - 1); j >= 0; j--)
 291 mike   1.1             {
 292                            CIMQualifier q = m.getQualifier(j);
 293                            if (q.getPropagated())
 294                            {
 295                                m.removeQualifier(j);
 296                            }
 297                        }
 298                    }
 299                }
 300                
 301                /* remove the properties from an instance based on attributes.
 302                    @param Instance from which properties will be removed.
 303                    @param propertyList PropertyList is used in the removal algorithm
 304                    NOTE: This could be logical to move to CIMInstance since the
 305                    usage is more general than just in the repository
 306                */
 307                static void _removeProperties(
 308                    CIMInstance& cimInstance,
 309 kumpf  1.7         const CIMPropertyList& propertyList)
 310 mike   1.1     {
 311 kumpf  1.7         if (!propertyList.isNull())
 312 mike   1.1         {
 313                        // Loop through properties to remove those that do not filter through
 314                        // local only attribute and are not in the property list.
 315                        // Work backwards because removal may be cheaper. Sint32 covers count=0
 316 kumpf  1.7             for (Sint32 i = (cimInstance.getPropertyCount() - 1); i >= 0; i--)
 317 mike   1.1             {
 318 kumpf  1.7                 // Since the propertyList is not NULL, only properties in the list
 319                            // should be included in the instance.
 320                            if (!_containsProperty(cimInstance.getProperty(i), propertyList))
 321 karl   1.7.6.2             {
 322 mike   1.1                     cimInstance.removeProperty(i);
 323 karl   1.7.6.2             }
 324 mike   1.1             }
 325                    }
 326                }
 327                
 328                /* remove all Qualifiers from a single CIMInstance. Removes
 329                    all of the qualifiers from the instance and from properties
 330                    within the instance.
 331                    @param instance from which parameters are removed.
 332                    NOTE: This could be logical to be moved to CIMInstance since
 333                    the usage may be more general than just in the repository.
 334                */
 335                static void _removeAllQualifiers(CIMInstance& cimInstance)
 336                {
 337                    // remove qualifiers from the instance
 338                    Uint32 count = 0;
 339                    while ((count = cimInstance.getQualifierCount()) > 0)
 340 karl   1.7.6.2     {
 341 mike   1.1             cimInstance.removeQualifier(count - 1);
 342 karl   1.7.6.2     }
 343 mike   1.1     
 344                    // remove qualifiers from the properties
 345                    for (Uint32 i = 0; i < cimInstance.getPropertyCount(); i++)
 346                    {
 347                        CIMProperty p = cimInstance.getProperty(i);
 348                        count = 0;
 349                        while ((count = p.getQualifierCount()) > 0)
 350 karl   1.7.6.2         {
 351 mike   1.1                 p.removeQualifier(count - 1);
 352 karl   1.7.6.2         }
 353 mike   1.1         }
 354                }
 355                
 356                /* removes all ClassOrigin attributes from a single CIMInstance. Removes
 357                    the classOrigin attribute from each property in the Instance.
 358                   @param Instance from which the ClassOrigin Properties will be removed.
 359                   NOTE: Logical to be moved to CIMInstance since it may be more general
 360                   than just the repositoryl
 361                */
 362                void _removeClassOrigins(CIMInstance& cimInstance)
 363                {
 364                    PEG_TRACE_CSTRING(TRC_REPOSITORY, Tracer::LEVEL4, "Remove Class Origins");
 365                
 366                    Uint32 propertyCount = cimInstance.getPropertyCount();
 367                    for (Uint32 i = 0; i < propertyCount ; i++)
 368 karl   1.7.6.2     {
 369 mike   1.1             cimInstance.getProperty(i).setClassOrigin(CIMName());
 370 karl   1.7.6.2     }
 371 mike   1.1     }
 372                
 373                /* Filters the properties, qualifiers, and classorigin out of a single instance.
 374 kumpf  1.7         Based on the parameters provided for propertyList, includeQualifiers,
 375 mike   1.1         and includeClassOrigin, this function simply filters the properties
 376                    qualifiers, and classOrigins out of a single instance.  This function
 377                    was created to have a single piece of code that processes getinstance
 378                    and enumerateInstances returns.
 379                    @param cimInstance reference to instance to be processed.
 380                    @param includeQualifiers Boolean defining if qualifiers to be returned.
 381                    @param includeClassOrigin Boolean defining if ClassOrigin attribute to
 382 kumpf  1.7             be removed from properties.
 383                    @param propertyList If not null, defines the properties to be included in
 384                        the instance.
 385 mike   1.1     */
 386                static void _filterInstance(
 387                    CIMInstance& cimInstance,
 388                    Boolean includeQualifiers,
 389                    Boolean includeClassOrigin,
 390                    const CIMPropertyList& propertyList)
 391                {
 392 kumpf  1.7         // Remove properties based on propertyList
 393                    _removeProperties(cimInstance, propertyList);
 394 mike   1.1     
 395                    // If includequalifiers false, remove all qualifiers from
 396                    // properties.
 397                
 398                    if (!includeQualifiers)
 399                    {
 400                        _removeAllQualifiers(cimInstance);
 401                    }
 402                
 403                    // if ClassOrigin Flag false, remove classOrigin info from Instance object
 404                    // by setting the classOrigin to Null.
 405                
 406                    if (!includeClassOrigin)
 407                    {
 408                        _removeClassOrigins(cimInstance);
 409                    }
 410                }
 411                
 412                static void _filterClass(
 413                    CIMClass& cimClass,
 414                    Boolean localOnly,
 415 mike   1.1         Boolean includeQualifiers,
 416                    Boolean includeClassOrigin,
 417                    const CIMPropertyList& propertyList)
 418                {
 419                    // Remove properties based on propertylist and localOnly flag (Bug 565)
 420                    Boolean propertyListNull = propertyList.isNull();
 421                
 422                    // if localOnly OR there is a property list, process properties
 423                    if ((!propertyListNull) || localOnly)
 424                    {
 425                        // Loop through properties to remove those that do not filter through
 426                        // local only attribute and are not in the property list.
 427                        Uint32 count = cimClass.getPropertyCount();
 428                        // Work backwards because removal may be cheaper. Sint32 covers count=0
 429                        for (Sint32 i = (count - 1); i >= 0; i--)
 430                        {
 431                            CIMProperty p = cimClass.getProperty(i);
 432                            // if localOnly==true, ignore properties defined in super class
 433                            if (localOnly && (p.getPropagated()))
 434                            {
 435                                cimClass.removeProperty(i);
 436 mike   1.1                     continue;
 437                            }
 438                
 439                            // propertyList NULL means all properties.  PropertyList
 440                            // empty, none.
 441                            // Test for removal if propertyList not NULL. The empty list option
 442                            // is covered by fact that property is not in the list.
 443                            if (!propertyListNull)
 444                                if (!_containsProperty(p, propertyList))
 445                                    cimClass.removeProperty(i);
 446                        }
 447                    }
 448                
 449                    // remove methods based on localOnly flag
 450                    if (localOnly)
 451                    {
 452                        Uint32 count = cimClass.getMethodCount();
 453                        // Work backwards because removal may be cheaper.
 454                        for (Sint32 i = (count - 1); i >= 0; i--)
 455                        {
 456                            CIMMethod m = cimClass.getMethod(i);
 457 mike   1.1     
 458                            // if localOnly==true, ignore properties defined in super class
 459                            if (localOnly && (m.getPropagated()))
 460                                cimClass.removeMethod(i);
 461                        }
 462                
 463                    }
 464                    // If includequalifiers false, remove all qualifiers from
 465                    // properties, methods and parameters.
 466                    if (!includeQualifiers)
 467                    {
 468                        _removeAllQualifiers(cimClass);
 469                    }
 470                    else
 471                    {
 472                        // if includequalifiers and localOnly, remove nonLocal qualifiers
 473                        if (localOnly)
 474                        {
 475                            _removePropagatedQualifiers(cimClass);
 476                        }
 477                
 478 mike   1.1         }
 479                
 480                
 481                    // if ClassOrigin Flag false, remove classOrigin info from class object
 482                    // by setting the property to Null.
 483                    if (!includeClassOrigin)
 484                    {
 485                        PEG_TRACE_CSTRING(TRC_REPOSITORY, Tracer::LEVEL4,
 486                            "Remove Class Origins");
 487                
 488                        Uint32 propertyCount = cimClass.getPropertyCount();
 489                        for (Uint32 i = 0; i < propertyCount ; i++)
 490 karl   1.7.6.2         {
 491 mike   1.1                 cimClass.getProperty(i).setClassOrigin(CIMName());
 492 karl   1.7.6.2         }
 493 mike   1.1     
 494                        Uint32 methodCount =  cimClass.getMethodCount();
 495                        for (Uint32 i=0; i < methodCount ; i++)
 496 karl   1.7.6.2         {
 497 mike   1.1                 cimClass.getMethod(i).setClassOrigin(CIMName());
 498 karl   1.7.6.2         }
 499 mike   1.1         }
 500                }
 501                
 502                
 503                static bool _contains(const CIMPropertyList& propertyList, const CIMName& name)
 504                {
 505                    for (Uint32 i = 0; i < propertyList.size(); i++)
 506                    {
 507                        if (propertyList[i] == name)
 508 karl   1.7.6.2         {
 509 mike   1.1                 return true;
 510 karl   1.7.6.2         }
 511 mike   1.1         }
 512                
 513                    return false;
 514                }
 515                
 516                static void _applyModifiedInstance(
 517                    const MRRClass* sc,
 518                    const CIMInstance& modifiedInstance_,
 519                    const CIMPropertyList& propertyList,
 520                    CIMInstance& resultInstance)
 521                {
 522                    CIMInstance& modifiedInstance = *((CIMInstance*)&modifiedInstance_);
 523                
 524                    for (Uint32 i = 0; i < modifiedInstance.getPropertyCount(); i++)
 525                    {
 526                        CIMProperty cp = modifiedInstance.getProperty(i);
 527                        Uint32 pos = resultInstance.findProperty(cp.getName());
 528                
 529                        if (propertyList.isNull() || _contains(propertyList, cp.getName()))
 530                        {
 531                            // Reject attempts to add properties not in class:
 532 mike   1.1     
 533 kumpf  1.6                 const MRRFeature* sf = FindFeature(sc,
 534 mike   1.1                     *Str(cp.getName()), MRR_FLAG_PROPERTY|MRR_FLAG_REFERENCE);
 535                
 536                            if (!sf)
 537                            {
 538 kumpf  1.6                     Throw((CIM_ERR_NOT_FOUND,
 539 mike   1.1                         "modifyInstance() failed: unknown property: %s",
 540                                    *Str(cp.getName())));
 541                            }
 542                
 543                            // Reject attempts to modify key properties:
 544                
 545                            if (sf->flags & MRR_FLAG_KEY)
 546                            {
 547                                Throw((CIM_ERR_FAILED,
 548                                    "modifyInstance() failed to modify key property: %s",
 549                                    *Str(cp.getName())));
 550                            }
 551                
 552                            // Add or replace property in result instance:
 553                
 554                            if (pos != PEG_NOT_FOUND)
 555 karl   1.7.6.2             {
 556 mike   1.1                     resultInstance.removeProperty(pos);
 557 karl   1.7.6.2             }
 558 mike   1.1     
 559                            resultInstance.addProperty(cp);
 560                        }
 561                    }
 562                }
 563                
 564                static void _print(const CIMInstance& ci)
 565                {
 566                    CIMObject co(ci);
 567                
 568                    std::cout << co.toString() << std::endl;
 569                }
 570                
 571                static Once _once = PEGASUS_ONCE_INITIALIZER;
 572                static const char* _hostName = 0;
 573                
 574                static void _initHostName()
 575                {
 576                    String hn = System::getHostName();
 577                    _hostName = strdup(*Str(hn));
 578                }
 579 mike   1.1     
 580                static inline const char* _getHostName()
 581                {
 582                    once(&_once, _initHostName);
 583                    return _hostName;
 584                }
 585                
 586                static bool _eqi(const char* s1, const char* s2)
 587                {
 588                    return System::strcasecmp(s1, s2) == 0;
 589                }
 590                
 591                static const MRRNameSpace* _findNameSpace(const char* name)
 592                {
 593                    for (size_t i = 0; i < _nameSpaceTableSize; i++)
 594                    {
 595                        const MRRNameSpace* ns = _nameSpaceTable[i];
 596                
 597                        if (_eqi(ns->name, name))
 598 karl   1.7.6.2         {
 599 mike   1.1                 return ns;
 600 karl   1.7.6.2         }
 601 mike   1.1         }
 602                
 603                    // Not found!
 604                    return 0;
 605                }
 606                
 607                static bool _isSubClass(const MRRClass* super, const MRRClass* sub)
 608                {
 609                    if (!super)
 610 karl   1.7.6.2     {
 611 mike   1.1             return true;
 612 karl   1.7.6.2     }
 613 mike   1.1     
 614                    for (MRRClass* p = sub->super; p; p = p->super)
 615                    {
 616                        if (p == super)
 617 karl   1.7.6.2         {
 618 mike   1.1                 return true;
 619 karl   1.7.6.2         }
 620 mike   1.1         }
 621                
 622                    return false;
 623                }
 624                
 625                static inline bool _isDirectSubClass(
 626 kumpf  1.6         const MRRClass* super,
 627 mike   1.1         const MRRClass* sub)
 628                {
 629                    return sub->super == super;
 630                }
 631                
 632                static char** _makePropertyList(const CIMPropertyList& propertyList)
 633                {
 634                    if (propertyList.isNull())
 635 karl   1.7.6.2     {
 636 mike   1.1             return 0;
 637 karl   1.7.6.2     }
 638 mike   1.1     
 639                    size_t size = propertyList.size();
 640                    char** pl = (char**)malloc(sizeof(char*) * (size + 1));
 641                
 642                    for (size_t i = 0; i < size; i++)
 643 karl   1.7.6.2     {
 644 mike   1.1             pl[i] = strdup(*Str(propertyList[i]));
 645 karl   1.7.6.2     }
 646 mike   1.1     
 647                    pl[size] = 0;
 648                
 649                    return pl;
 650                }
 651                
 652                static void _freePropertyList(char** pl)
 653                {
 654                    if (!pl)
 655 karl   1.7.6.2     {
 656 mike   1.1             return;
 657 karl   1.7.6.2     }
 658 mike   1.1     
 659                    for (size_t i = 0; pl[i]; i++)
 660                    {
 661                        free(pl[i]);
 662                    }
 663                
 664                    free(pl);
 665                }
 666                
 667                static void _printPropertyList(const char* const* pl)
 668                {
 669                    if (!pl)
 670 karl   1.7.6.2     {
 671 mike   1.1             return;
 672 karl   1.7.6.2     }
 673 mike   1.1     
 674                    for (size_t i = 0; pl[i]; i++)
 675 karl   1.7.6.2     {
 676 mike   1.1             printf("pl[%s]\n", pl[i]);
 677 karl   1.7.6.2     }
 678 mike   1.1     }
 679                
 680                static bool _contains(const Array<const MRRClass*>& x, const MRRClass* sc)
 681                {
 682                    Uint32 n = x.size();
 683                    const MRRClass* const* p = x.getData();
 684                
 685                    while (n--)
 686                    {
 687                        if (*p++ == sc)
 688 karl   1.7.6.2         {
 689 mike   1.1                 return true;
 690 karl   1.7.6.2         }
 691 mike   1.1         }
 692                
 693                    return false;
 694                }
 695                
 696                static void _associators(
 697                    const MRRNameSpace* ns,
 698                    const CIMName& className,
 699                    const CIMName& assocClass,
 700                    const CIMName& resultClass,
 701                    const String& role,
 702                    const String& resultRole,
 703                    Array<const MRRClass*>& result)
 704                {
 705                    // Lookup source class:
 706                
 707                    const MRRClass* sc = FindClass(ns, *Str(className));
 708 kumpf  1.6     
 709 mike   1.1         if (!sc)
 710 karl   1.7.6.2     {
 711 mike   1.1             Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className)));
 712 karl   1.7.6.2     }
 713 mike   1.1     
 714                
 715                    // Lookup result class (if any).
 716                
 717                    const MRRClass* rmc = 0;
 718                
 719                    if (!resultClass.isNull())
 720                    {
 721                        rmc = FindClass(ns, *Str(resultClass));
 722                
 723                        if (!rmc)
 724 karl   1.7.6.2         {
 725 mike   1.1                 Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(resultClass)));
 726 karl   1.7.6.2         }
 727 mike   1.1         }
 728                
 729                    // Convert these to UTF8 now to avoid doing so in loop below.
 730                
 731                    Str ac(assocClass);
 732                    Str r(role);
 733                    Str rr(resultRole);
 734                
 735                    // Process association classes:
 736                
 737                    for (size_t i = 0; ns->classes[i]; i++)
 738                    {
 739                        MRRClass* amc = ns->classes[i];
 740                
 741                        // Skip non-association classes:
 742                
 743                        if (!(amc->flags & MRR_FLAG_ASSOCIATION))
 744 karl   1.7.6.2         {
 745 mike   1.1                 continue;
 746 karl   1.7.6.2         }
 747 mike   1.1     
 748                        // Filter by assocClass parameter:
 749                
 750                        if (!assocClass.isNull() && !_eqi(ac, amc->name))
 751 karl   1.7.6.2         {
 752 mike   1.1                 continue;
 753 karl   1.7.6.2         }
 754 mike   1.1     
 755                        // Process reference properties:
 756                
 757                        MRRFeatureInfo features[MRR_MAX_FEATURES];
 758                        size_t size = 0;
 759                        MergeFeatures(amc, false, MRR_FLAG_REFERENCE, features, size);
 760                
 761                        for (size_t j = 0; j < size; j++)
 762                        {
 763                            const MRRFeature* sf = features[j].sf;
 764                
 765                            // Skip non references:
 766                
 767                            if (!(sf->flags & MRR_FLAG_REFERENCE))
 768 karl   1.7.6.2             {
 769 mike   1.1                     continue;
 770 karl   1.7.6.2             }
 771 mike   1.1     
 772                            const MRRReference* sr = (const MRRReference*)sf;
 773                
 774                            // Filter by role parameter.
 775                
 776                            if (role.size() && !_eqi(r, sf->name))
 777 karl   1.7.6.2             {
 778 mike   1.1                     continue;
 779 karl   1.7.6.2             }
 780 mike   1.1     
 781                            // Filter by source class:
 782                
 783                            if (!IsA(sr->ref, sc))
 784 karl   1.7.6.2             {
 785 mike   1.1                     continue;
 786 karl   1.7.6.2             }
 787 mike   1.1     
 788                            // Process result reference:
 789                
 790                            for (size_t k = 0; k < size; k++)
 791                            {
 792                                const MRRFeature* rmf = features[k].sf;
 793                
 794                                // Skip the feature under consideration:
 795                
 796                                if (rmf == sf)
 797 karl   1.7.6.2                 {
 798 mike   1.1                         continue;
 799 karl   1.7.6.2                 }
 800 mike   1.1     
 801                                // Skip non references:
 802                
 803                                if (!(rmf->flags & MRR_FLAG_REFERENCE))
 804 karl   1.7.6.2                 {
 805 mike   1.1                         continue;
 806 karl   1.7.6.2                 }
 807 mike   1.1     
 808                                const MRRReference* rmr = (const MRRReference*)rmf;
 809                
 810                                // Filter by resultRole parameter.
 811                
 812                                if (resultRole.size() && !_eqi(rr, rmf->name))
 813 karl   1.7.6.2                 {
 814 mike   1.1                         continue;
 815 karl   1.7.6.2                 }
 816 mike   1.1     
 817                                // Skip references not of the result class kind:
 818                
 819                                if (rmc && !IsA(rmr->ref, rmc))
 820 karl   1.7.6.2                 {
 821 mike   1.1                         continue;
 822 karl   1.7.6.2                 }
 823 mike   1.1     
 824                                // ATTN: should we include entire class hierarchy under
 825                                // result class?
 826                
 827                                // If reached, then save this one.
 828                
 829                                if (!_contains(result, rmr->ref))
 830 karl   1.7.6.2                 {
 831 mike   1.1                         result.append(rmr->ref);
 832 karl   1.7.6.2                 }
 833 mike   1.1                 }
 834                        }
 835                    }
 836                }
 837                
 838                static void _references(
 839                    const MRRNameSpace* ns,
 840                    const CIMName& className,
 841                    const CIMName& resultClass,
 842                    const String& role,
 843                    Array<const MRRClass*>& result)
 844                {
 845                    // Lookup source class:
 846                
 847                    const MRRClass* sc = FindClass(ns, *Str(className));
 848 kumpf  1.6     
 849 mike   1.1         if (!sc)
 850 karl   1.7.6.2     {
 851 mike   1.1             Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className)));
 852 karl   1.7.6.2     }
 853 mike   1.1     
 854                    // Lookup result class (if any).
 855                
 856                    const MRRClass* rmc = 0;
 857                
 858                    if (!resultClass.isNull())
 859                    {
 860                        rmc = FindClass(ns, *Str(resultClass));
 861                
 862                        if (!rmc)
 863 karl   1.7.6.2         {
 864 mike   1.1                 Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(resultClass)));
 865 karl   1.7.6.2         }
 866 mike   1.1         }
 867                
 868                    // Convert these to UTF8 now to avoid doing so in loop below.
 869                
 870                    Str r(role);
 871                
 872                    // Process association classes:
 873                
 874                    for (size_t i = 0; ns->classes[i]; i++)
 875                    {
 876                        MRRClass* amc = ns->classes[i];
 877                
 878                        // Skip non-association classes:
 879                
 880                        if (!(amc->flags & MRR_FLAG_ASSOCIATION))
 881 karl   1.7.6.2         {
 882 mike   1.1                 continue;
 883 karl   1.7.6.2         }
 884 mike   1.1     
 885                        // Filter by result class:
 886                
 887                        if (rmc && !IsA(rmc, amc))
 888 karl   1.7.6.2         {
 889 mike   1.1                 continue;
 890 karl   1.7.6.2         }
 891 mike   1.1     
 892                        // Process reference properties:
 893                
 894                        MRRFeatureInfo features[MRR_MAX_FEATURES];
 895                        size_t size = 0;
 896                        MergeFeatures(amc, false, MRR_FLAG_REFERENCE, features, size);
 897                
 898                        for (size_t j = 0; j < size; j++)
 899                        {
 900                            const MRRFeature* sf = features[j].sf;
 901                
 902                            // Skip non references:
 903                
 904                            if (!(sf->flags & MRR_FLAG_REFERENCE))
 905 karl   1.7.6.2             {
 906 mike   1.1                     continue;
 907 karl   1.7.6.2             }
 908 mike   1.1     
 909                            const MRRReference* sr = (const MRRReference*)sf;
 910                
 911                            // Filter by role parameter.
 912                
 913                            if (role.size() && !_eqi(r, sf->name))
 914 karl   1.7.6.2             {
 915 mike   1.1                     continue;
 916 karl   1.7.6.2             }
 917 mike   1.1     
 918                            // Filter by source class:
 919                
 920                            if (!IsA(sr->ref, sc))
 921 karl   1.7.6.2             {
 922 mike   1.1                     continue;
 923 karl   1.7.6.2             }
 924 mike   1.1     
 925                            // Add this one to the output:
 926                
 927                            if (!_contains(result, amc))
 928 karl   1.7.6.2             {
 929 mike   1.1                     result.append((MRRClass*)amc);
 930 karl   1.7.6.2             }
 931 mike   1.1             }
 932                    }
 933                }
 934                
 935                static const MRRClass* _findMRRClass(
 936                    const char* nameSpace,
 937                    const char* className)
 938                {
 939                    // Lookup namespace:
 940                
 941                    const MRRNameSpace* ns = _findNameSpace(nameSpace);
 942                
 943                    if (!ns)
 944 karl   1.7.6.2     {
 945 mike   1.1             return 0;
 946 karl   1.7.6.2     }
 947 mike   1.1     
 948                    return FindClass(ns, className);
 949                }
 950                
 951                static Array<CIMName> _enumerateClassNames(
 952                    const CIMNamespaceName& nameSpace,
 953                    const CIMName& className,
 954                    Boolean deepInheritance)
 955                {
 956                    // Lookup namespace:
 957                
 958                    const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace));
 959                
 960                    if (!ns)
 961 karl   1.7.6.2     {
 962 mike   1.1             Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));
 963 karl   1.7.6.2     }
 964 mike   1.1     
 965                    // Lookup class:
 966                
 967                    const MRRClass* super = 0;
 968 kumpf  1.6     
 969 mike   1.1         if (!className.isNull())
 970                    {
 971                        super = FindClass(ns, *Str(className));
 972                
 973                        if (!super)
 974 karl   1.7.6.2         {
 975 mike   1.1                 Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className)));
 976 karl   1.7.6.2         }
 977 mike   1.1         }
 978                
 979                    // Iterate all classes looking for matches:
 980                
 981                    Array<CIMName> result;
 982                
 983                    for (size_t i = 0; ns->classes[i]; i++)
 984                    {
 985                        MRRClass* sc = ns->classes[i];
 986                
 987                        if (deepInheritance)
 988                        {
 989                            if (_isSubClass(super, sc))
 990 karl   1.7.6.2             {
 991 mike   1.1                     result.append(sc->name);
 992 karl   1.7.6.2             }
 993 mike   1.1             }
 994                        else
 995                        {
 996                            if (_isDirectSubClass(super, sc))
 997 karl   1.7.6.2             {
 998 mike   1.1                     result.append(sc->name);
 999 karl   1.7.6.2             }
1000 mike   1.1             }
1001                    }
1002                
1003                    return result;
1004                }
1005                
1006                static void _getSubClassNames(
1007                    const CIMNamespaceName& nameSpace,
1008                    const CIMName& className,
1009                    Boolean deepInheritance,
1010                    Array<CIMName>& subClassNames)
1011                {
1012                    subClassNames = _enumerateClassNames(
1013                        nameSpace, className, deepInheritance);
1014                }
1015                
1016                static Array<CIMObject> _associatorClasses(
1017                    const CIMNamespaceName& nameSpace,
1018                    const CIMName& className,
1019                    const CIMName& assocClass,
1020                    const CIMName& resultClass,
1021 mike   1.1         const String& role,
1022                    const String& resultRole,
1023                    Boolean includeQualifiers,
1024                    Boolean includeClassOrigin,
1025                    const CIMPropertyList& propertyList)
1026                {
1027                    // Lookup namespace:
1028                
1029                    const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace));
1030                
1031                    if (!ns)
1032 karl   1.7.6.2     {
1033 mike   1.1             Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));
1034 karl   1.7.6.2     }
1035 mike   1.1     
1036                    // Get associator schema-classes:
1037                
1038                    Array<const MRRClass*> mcs;
1039                    _associators(ns, className, assocClass, resultClass, role, resultRole, mcs);
1040                
1041                    // Convert schema-classes to classes.
1042                
1043                    Array<CIMObject> result;
1044                
1045                    char** pl = _makePropertyList(propertyList);
1046                
1047                    for (Uint32 i = 0; i < mcs.size(); i++)
1048                    {
1049                        const MRRClass* sc = mcs[i];
1050                        CIMClass cc;
1051                
1052 kumpf  1.6             if (MakeClass(_getHostName(), ns, sc, false, includeQualifiers,
1053 mike   1.1                 includeClassOrigin, pl, cc) != 0)
1054                        {
1055                            _freePropertyList(pl);
1056                            Throw((CIM_ERR_FAILED, "conversion failed: %s", sc->name));
1057                        }
1058                
1059                        result.append(cc);
1060                    }
1061                
1062                    _freePropertyList(pl);
1063                    return result;
1064                }
1065                
1066                static Array<CIMObjectPath> _associatorClassPaths(
1067                    const CIMNamespaceName& nameSpace,
1068                    const CIMName& className,
1069                    const CIMName& assocClass,
1070                    const CIMName& resultClass,
1071                    const String& role,
1072                    const String& resultRole)
1073                {
1074 mike   1.1         // Lookup namespace:
1075                
1076                    const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace));
1077                
1078                    if (!ns)
1079 karl   1.7.6.2     {
1080 mike   1.1             Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));
1081 karl   1.7.6.2     }
1082 mike   1.1     
1083                    // Get associator schema-classes:
1084                
1085                    Array<const MRRClass*> mcs;
1086                    _associators(ns, className, assocClass, resultClass, role, resultRole, mcs);
1087                
1088                    // Convert schema-classes to object names:
1089                
1090                    Array<CIMObjectPath> result;
1091                
1092                    for (Uint32 i = 0; i < mcs.size(); i++)
1093 karl   1.7.6.2     {
1094 mike   1.1             result.append(CIMObjectPath(_getHostName(), nameSpace, mcs[i]->name));
1095 karl   1.7.6.2     }
1096 mike   1.1     
1097                    return result;
1098                }
1099                
1100                static Array<CIMObject> _referenceClasses(
1101                    const CIMNamespaceName& nameSpace,
1102                    const CIMName& className,
1103                    const CIMName& resultClass,
1104                    const String& role,
1105                    Boolean includeQualifiers,
1106                    Boolean includeClassOrigin,
1107                    const CIMPropertyList& propertyList)
1108                {
1109                    // Lookup namespace:
1110                
1111                    const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace));
1112                
1113                    if (!ns)
1114 karl   1.7.6.2     {
1115 mike   1.1             Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));
1116 karl   1.7.6.2     }
1117 mike   1.1     
1118                    // Get reference schema-classes:
1119                
1120                    Array<const MRRClass*> mcs;
1121                    _references(ns, className, resultClass, role, mcs);
1122                
1123                    // Convert schema-classes to classes.
1124                
1125                    Array<CIMObject> result;
1126                
1127                    char** pl = _makePropertyList(propertyList);
1128                
1129                    for (Uint32 i = 0; i < mcs.size(); i++)
1130                    {
1131                        const MRRClass* sc = mcs[i];
1132                        CIMClass cc;
1133                
1134 kumpf  1.6             if (MakeClass(_getHostName(), ns, sc, false, includeQualifiers,
1135 mike   1.1                 includeClassOrigin, pl, cc) != 0)
1136                        {
1137                            _freePropertyList(pl);
1138                            Throw((CIM_ERR_FAILED, "conversion failed: %s", sc->name));
1139                        }
1140                
1141                        result.append(cc);
1142                    }
1143                
1144                    _freePropertyList(pl);
1145                    return result;
1146                }
1147                
1148                static Array<CIMObjectPath> _referenceClassPaths(
1149                    const CIMNamespaceName& nameSpace,
1150                    const CIMName& className,
1151                    const CIMName& resultClass,
1152                    const String& role)
1153                {
1154                    // Lookup namespace:
1155                
1156 mike   1.1         const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace));
1157                
1158                    if (!ns)
1159 karl   1.7.6.2     {
1160 mike   1.1             Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));
1161 karl   1.7.6.2     }
1162 mike   1.1     
1163                    // Get reference schema-classes:
1164                
1165                    Array<const MRRClass*> mcs;
1166                    _references(ns, className, resultClass, role, mcs);
1167                
1168                    // Convert schema-classes to object paths.
1169                
1170                    Array<CIMObjectPath> result;
1171                
1172                    for (Uint32 i = 0; i < mcs.size(); i++)
1173 karl   1.7.6.2     {
1174 mike   1.1             result.append(CIMObjectPath(_getHostName(), nameSpace, mcs[i]->name));
1175 karl   1.7.6.2     }
1176 mike   1.1     
1177                    return result;
1178                }
1179                
1180                static CIMQualifierDecl _getQualifier(
1181                    const CIMNamespaceName& nameSpace,
1182                    const CIMName& qualifierName)
1183                {
1184                    // Lookup namespace:
1185                
1186                    const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace));
1187                
1188                    if (!ns)
1189 karl   1.7.6.2     {
1190 mike   1.1             Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));
1191 karl   1.7.6.2     }
1192 mike   1.1     
1193                    // Lookup qualifier:
1194                
1195                    const MRRQualifierDecl* mqd = FindQualifierDecl(ns, *Str(qualifierName));
1196 kumpf  1.6     
1197 mike   1.1         if (!mqd)
1198 karl   1.7.6.2     {
1199 kumpf  1.6             Throw((CIM_ERR_NOT_FOUND,
1200 mike   1.1                 "unknown qualifier: %s", *Str(qualifierName)));
1201 karl   1.7.6.2     }
1202 mike   1.1     
1203                    // Make the qualifier declaration:
1204                
1205                    CIMQualifierDecl cqd;
1206                
1207                    if (MakeQualifierDecl(ns, mqd, cqd) != 0)
1208                    {
1209                        Throw((CIM_ERR_FAILED, "conversion failed: %s", mqd->name));
1210                    }
1211                
1212                    return cqd;
1213                }
1214                
1215                static Array<CIMQualifierDecl> _enumerateQualifiers(
1216                    const CIMNamespaceName& nameSpace)
1217                {
1218                    // Lookup namespace:
1219                
1220                    const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace));
1221                
1222                    if (!ns)
1223 karl   1.7.6.2     {
1224 mike   1.1             Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));
1225 karl   1.7.6.2     }
1226 mike   1.1     
1227                    // Build the array of qualifier declarations:
1228                
1229                    Array<CIMQualifierDecl> result;
1230                
1231                    for (size_t i = 0; ns->qualifiers[i]; i++)
1232                    {
1233                        const MRRQualifierDecl* mqd = ns->qualifiers[i];
1234                        CIMQualifierDecl cqd;
1235                
1236                        if (MakeQualifierDecl(ns, mqd, cqd) != 0)
1237                        {
1238                            Throw((CIM_ERR_FAILED, "conversion failed: %s", mqd->name));
1239                        }
1240                
1241                        result.append(cqd);
1242                    }
1243                
1244                    return result;
1245                
1246                }
1247 mike   1.1     
1248                static Array<CIMNamespaceName> _enumerateNameSpaces()
1249                {
1250                    Array<CIMNamespaceName> result;
1251                
1252                    for (size_t i = 0; i < _nameSpaceTableSize; i++)
1253                    {
1254                        const MRRNameSpace* ns = _nameSpaceTable[i];
1255                        result.append(ns->name);
1256                    }
1257                
1258                    return result;
1259                }
1260                
1261                static void _getSuperClassNames(
1262                    const CIMNamespaceName& nameSpace,
1263                    const CIMName& className,
1264                    Array<CIMName>& superClassNames)
1265                {
1266                    superClassNames.clear();
1267                
1268 mike   1.1         // Lookup namespace:
1269                
1270                    const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace));
1271                
1272                    if (!ns)
1273 karl   1.7.6.2     {
1274 mike   1.1             Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));
1275 karl   1.7.6.2     }
1276 mike   1.1     
1277                    // Lookup class:
1278                
1279                    const MRRClass* sc = FindClass(ns, *Str(className));
1280 kumpf  1.6     
1281 mike   1.1         if (!sc)
1282                        Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className)));
1283                
1284                    // Append superclass names:
1285                
1286                    for (const MRRClass* p = sc->super; p; p = p->super)
1287 karl   1.7.6.2     {
1288 mike   1.1             superClassNames.append(p->name);
1289 karl   1.7.6.2     }
1290 mike   1.1     }
1291                
1292                //==============================================================================
1293                //
1294                // class CIMRepository:
1295                //
1296                //==============================================================================
1297                
1298                static void (*_saveCallback)(const Buffer& buffer, void* data);
1299                static void* _saveData;
1300                
1301                static void (*_loadCallback)(Buffer& buffer, void* data);
1302                static void* _loadData;
1303                
1304                static void (*_initializeCallback)(CIMRepository* rep, void* data);
1305                static void* _initializeData;
1306                
1307                CIMRepository::CIMRepository(
1308                    const String& repositoryRoot,
1309                    Uint32 mode,
1310                    RepositoryDeclContext* declContext)
1311 mike   1.1     {
1312                    /* ATTN: declContext is not used here! */
1313                
1314                    _rep = new CIMRepositoryRep;
1315                
1316                    // Load users data if any:
1317                    _rep->_processLoadCallback();
1318                
1319                    // Call initialize callback if any.
1320                
1321                    if (_initializeCallback)
1322                        (*_initializeCallback)(this, _initializeData);
1323                }
1324                
1325                CIMRepository::~CIMRepository()
1326                {
1327                    delete _rep;
1328                }
1329                
1330                CIMClass CIMRepository::getClass(
1331                    const CIMNamespaceName& nameSpace,
1332 mike   1.1         const CIMName& className,
1333                    Boolean localOnly,
1334                    Boolean includeQualifiers,
1335                    Boolean includeClassOrigin,
1336                    const CIMPropertyList& propertyList)
1337                {
1338                    // Lookup namespace:
1339                
1340                    const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace));
1341                
1342                    if (!ns)
1343 karl   1.7.6.2     {
1344 mike   1.1             Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));
1345 karl   1.7.6.2     }
1346 mike   1.1     
1347                    // Lookup class:
1348                
1349                    const MRRClass* sc = FindClass(ns, *Str(className));
1350                
1351                    if (!sc)
1352                    {
1353                        Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className)));
1354                    }
1355                
1356                    // Build property list:
1357                
1358                    char** pl = _makePropertyList(propertyList);
1359                
1360                    // Make class:
1361                
1362                    CIMClass cc;
1363                
1364 kumpf  1.6         if (MakeClass(_getHostName(), ns, sc, localOnly, includeQualifiers,
1365 mike   1.1             includeClassOrigin, pl, cc) != 0)
1366                    {
1367                        _freePropertyList(pl);
1368                        Throw((CIM_ERR_FAILED, "conversion failed: %s", sc->name));
1369                    }
1370                
1371                    _freePropertyList(pl);
1372                    return cc;
1373                }
1374                
1375                CIMInstance CIMRepository::getInstance(
1376                    const CIMNamespaceName& nameSpace,
1377                    const CIMObjectPath& instanceName,
1378                    Boolean includeQualifiers,
1379                    Boolean includeClassOrigin,
1380                    const CIMPropertyList& propertyList)
1381                {
1382                    Uint32 pos = _rep->_findInstance(nameSpace, instanceName);
1383                
1384                    if (pos == PEG_NOT_FOUND)
1385 karl   1.7.6.2     {
1386 mike   1.1             Throw((CIM_ERR_NOT_FOUND, "%s", *Str(instanceName)));
1387 karl   1.7.6.2     }
1388 mike   1.1     
1389                    CIMInstance cimInstance = _rep->_rep[pos].second.clone();
1390                
1391                    _filterInstance(
1392                        cimInstance,
1393                        includeQualifiers,
1394                        includeClassOrigin,
1395                        propertyList);
1396                
1397                    return cimInstance;
1398                }
1399                
1400                void CIMRepository::deleteClass(
1401                    const CIMNamespaceName& nameSpace,
1402                    const CIMName& className)
1403                {
1404                    Throw((CIM_ERR_NOT_SUPPORTED, "deleteClass()"));
1405                }
1406                
1407                void CIMRepository::deleteInstance(
1408                    const CIMNamespaceName& nameSpace,
1409 mike   1.1         const CIMObjectPath& instanceName)
1410                {
1411                    Uint32 pos = _rep->_findInstance(nameSpace, instanceName);
1412                
1413                    if (pos == PEG_NOT_FOUND)
1414 karl   1.7.6.2     {
1415 mike   1.1             Throw((CIM_ERR_NOT_FOUND, "%s", *Str(instanceName)));
1416 karl   1.7.6.2     }
1417 mike   1.1     
1418                    _rep->_rep.remove(pos);
1419                    _rep->_processSaveCallback();
1420                }
1421                
1422                void CIMRepository::createClass(
1423                    const CIMNamespaceName& nameSpace,
1424 kumpf  1.3         const CIMClass& newClass)
1425 mike   1.1     {
1426                    Throw((CIM_ERR_NOT_SUPPORTED, "createClass()"));
1427                }
1428                
1429                CIMObjectPath CIMRepository::createInstance(
1430                    const CIMNamespaceName& nameSpace,
1431 kumpf  1.3         const CIMInstance& newInstance)
1432 mike   1.1     {
1433                    // Resolve the instance first:
1434                
1435                    CIMInstance ci(newInstance.clone());
1436                    CIMConstClass cc;
1437                    RepositoryDeclContext context;
1438                    context.setRepository(this);
1439                    Resolver::resolveInstance(ci, &context, nameSpace, cc, false);
1440                    CIMObjectPath cop = ci.buildPath(cc);
1441                
1442                    ci.setPath(cop);
1443                
1444                    // Reject if an instance with this name already exists:
1445                
1446                    if (_rep->_findInstance(nameSpace, cop) != PEG_NOT_FOUND)
1447 karl   1.7.6.2     {
1448 mike   1.1             Throw((CIM_ERR_ALREADY_EXISTS, "%s", *Str(cop)));
1449 karl   1.7.6.2     }
1450 mike   1.1     
1451                    // Add instance to array:
1452                
1453                    _rep->_rep.append(NamespaceInstancePair(nameSpace, ci));
1454                    _rep->_processSaveCallback();
1455                
1456                    return cop;
1457                }
1458                
1459                void CIMRepository::modifyClass(
1460                    const CIMNamespaceName& nameSpace,
1461 kumpf  1.3         const CIMClass& modifiedClass)
1462 mike   1.1     {
1463                    Throw((CIM_ERR_NOT_SUPPORTED, "modifyClass()"));
1464                }
1465                
1466                void CIMRepository::modifyInstance(
1467                    const CIMNamespaceName& nameSpace,
1468                    const CIMInstance& modifiedInstance,
1469                    Boolean includeQualifiers,
1470 kumpf  1.3         const CIMPropertyList& propertyList)
1471 mike   1.1     {
1472                    const CIMObjectPath& cop = modifiedInstance.getPath();
1473                    CIMName className = cop.getClassName();
1474                
1475                    // Get the schema-class for this instance.
1476                
1477                    const MRRClass* sc = _findMRRClass(*Str(nameSpace), *Str(className));
1478                
1479                    if (!sc)
1480                    {
1481 kumpf  1.6             Throw((CIM_ERR_FAILED,
1482 mike   1.1                 "modifyInstance() failed: unknown class: %s:%s",
1483                            *Str(nameSpace), *Str(className)));
1484                    }
1485                
1486                    // Get original instance to be modified:
1487                
1488                    Uint32 pos = _rep->_findInstance(nameSpace, cop);
1489                
1490                    if (pos == PEG_NOT_FOUND)
1491                    {
1492 kumpf  1.6             Throw((CIM_ERR_NOT_FOUND,
1493 mike   1.1                 "modifyInstance() failed: unknown instance: %s",
1494                            *Str(cop.toString())));
1495                    }
1496                
1497                    CIMInstance resultInstance = _rep->_rep[pos].second.clone();
1498                
1499                    // Apply features of modifiedInstance to result instance.
1500                
1501                    _applyModifiedInstance(sc, modifiedInstance, propertyList, resultInstance);
1502                
1503                    // Resolve the instance.
1504                
1505                    CIMConstClass cc;
1506                    RepositoryDeclContext context;
1507                    context.setRepository(this);
1508                    Resolver::resolveInstance(resultInstance, &context, nameSpace, cc, false);
1509                
1510                    // Replace original instance.
1511                
1512                    _rep->_rep[pos].second = resultInstance;
1513                    _rep->_processSaveCallback();
1514 mike   1.1     }
1515                
1516                Array<CIMClass> CIMRepository::enumerateClasses(
1517                    const CIMNamespaceName& nameSpace,
1518                    const CIMName& className,
1519                    Boolean deepInheritance,
1520                    Boolean localOnly,
1521                    Boolean includeQualifiers,
1522                    Boolean includeClassOrigin)
1523                {
1524                    // Lookup namespace:
1525                
1526                    const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace));
1527                
1528                    if (!ns)
1529 karl   1.7.6.2     {
1530 mike   1.1             Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));
1531 karl   1.7.6.2     }
1532 mike   1.1     
1533                    // Lookup class:
1534                
1535                    const MRRClass* super = 0;
1536 kumpf  1.6     
1537 mike   1.1         if (!className.isNull())
1538                    {
1539                        super = FindClass(ns, *Str(className));
1540                
1541                        if (!super)
1542 karl   1.7.6.2         {
1543 mike   1.1                 Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className)));
1544 karl   1.7.6.2         }
1545 mike   1.1         }
1546                
1547                    // Iterate all classes looking for matches:
1548                
1549                    Array<CIMClass> result;
1550                
1551                    for (size_t i = 0; ns->classes[i]; i++)
1552                    {
1553                        MRRClass* sc = ns->classes[i];
1554                
1555                        bool flag = false;
1556                
1557                        if (deepInheritance)
1558                        {
1559                            if (_isSubClass(super, sc))
1560                                flag = true;
1561                        }
1562                        else
1563                        {
1564                            if (_isDirectSubClass(super, sc))
1565                                flag = true;
1566 mike   1.1             }
1567                
1568                        if (flag)
1569                        {
1570                            CIMClass cc;
1571                
1572 kumpf  1.6                 if (MakeClass(_getHostName(), ns, sc, localOnly, includeQualifiers,
1573 mike   1.1                     includeClassOrigin, 0, cc) != 0)
1574                            {
1575                                Throw((CIM_ERR_FAILED, "conversion failed: %s", sc->name));
1576                            }
1577                
1578                            result.append(cc);
1579                        }
1580                    }
1581                
1582                    return result;
1583                }
1584                
1585                Array<CIMName> CIMRepository::enumerateClassNames(
1586                    const CIMNamespaceName& nameSpace,
1587                    const CIMName& className,
1588                    Boolean deepInheritance)
1589                {
1590                    return _enumerateClassNames(nameSpace, className, deepInheritance);
1591                }
1592                
1593                Array<CIMInstance> CIMRepository::enumerateInstancesForSubtree(
1594 mike   1.1         const CIMNamespaceName& nameSpace,
1595                    const CIMName& className,
1596                    Boolean includeQualifiers,
1597                    Boolean includeClassOrigin,
1598                    const CIMPropertyList& propertyList)
1599                {
1600                    // Form array of classnames for this class and descendent classes:
1601                
1602                    Array<CIMName> classNames;
1603                    classNames.append(className);
1604                    _getSubClassNames(nameSpace, className, true, classNames);
1605                
1606                    // Get all instances for this class and all descendent classes
1607                
1608                    Array<CIMInstance> result;
1609                
1610                    for (Uint32 i = 0; i < classNames.size(); i++)
1611                    {
1612                        Array<CIMInstance> instances = enumerateInstancesForClass(
1613 karl   1.7.6.2             nameSpace, classNames[i], includeQualifiers,
1614 mike   1.1                 includeClassOrigin, propertyList);
1615                
1616                        for (Uint32 i = 0 ; i < instances.size(); i++)
1617                        {
1618                            _filterInstance(
1619                                instances[i],
1620                                includeQualifiers,
1621                                includeClassOrigin,
1622                                propertyList);
1623                        }
1624                
1625                        result.appendArray(instances);
1626                    }
1627                
1628                    return result;
1629                }
1630                
1631                Array<CIMInstance> CIMRepository::enumerateInstancesForClass(
1632                    const CIMNamespaceName& nameSpace,
1633                    const CIMName& className,
1634                    Boolean includeQualifiers,
1635 mike   1.1         Boolean includeClassOrigin,
1636                    const CIMPropertyList& propertyList)
1637                {
1638                    Array<CIMInstance> result;
1639                
1640                    for (Uint32 i = 0; i < _rep->_rep.size(); i++)
1641                    {
1642                        if (_rep->_rep[i].first != nameSpace)
1643                            continue;
1644                
1645                        CIMInstance& ci = _rep->_rep[i].second;
1646                
1647                        if (ci.getPath().getClassName() == className)
1648                        {
1649                            CIMInstance tmp = ci.clone();
1650                
1651                            _filterInstance(
1652                                tmp,
1653                                includeQualifiers,
1654                                includeClassOrigin,
1655                                propertyList);
1656 mike   1.1     
1657                            result.append(tmp);
1658                        }
1659                    }
1660                
1661                    return result;
1662                }
1663                
1664                Array<CIMObjectPath> CIMRepository::enumerateInstanceNamesForSubtree(
1665                    const CIMNamespaceName& nameSpace,
1666                    const CIMName& className)
1667                {
1668                    // Form array of classnames for this class and descendent classes:
1669                
1670                    Array<CIMName> classNames;
1671                    classNames.append(className);
1672                    _getSubClassNames(nameSpace, className, true, classNames);
1673                
1674                    // Get all instances for this class and all descendent classes
1675                
1676                    Array<CIMObjectPath> result;
1677 mike   1.1     
1678                    for (Uint32 i = 0; i < classNames.size(); i++)
1679                    {
1680                        Array<CIMObjectPath> paths = enumerateInstanceNamesForClass(
1681                            nameSpace, classNames[i]);
1682                
1683                        result.appendArray(paths);
1684                    }
1685                
1686                    return result;
1687                }
1688                
1689                Array<CIMObjectPath> CIMRepository::enumerateInstanceNamesForClass(
1690                    const CIMNamespaceName& nameSpace,
1691                    const CIMName& className)
1692                {
1693                    Array<CIMObjectPath> result;
1694                
1695                    for (Uint32 i = 0; i < _rep->_rep.size(); i++)
1696                    {
1697                        if (_rep->_rep[i].first != nameSpace)
1698 karl   1.7.6.2         {
1699 mike   1.1                 continue;
1700 karl   1.7.6.2         }
1701 mike   1.1     
1702                        CIMInstance& ci = _rep->_rep[i].second;
1703                
1704                        if (ci.getPath().getClassName() == className)
1705 karl   1.7.6.2         {
1706 mike   1.1                 result.append(ci.getPath());
1707 karl   1.7.6.2         }
1708 mike   1.1         }
1709                
1710                    return result;
1711                }
1712                
1713                Array<CIMObject> CIMRepository::associators(
1714                    const CIMNamespaceName& nameSpace,
1715                    const CIMObjectPath& objectName,
1716                    const CIMName& assocClass,
1717                    const CIMName& resultClass,
1718                    const String& role,
1719                    const String& resultRole,
1720                    Boolean includeQualifiers,
1721                    Boolean includeClassOrigin,
1722                    const CIMPropertyList& propertyList)
1723                {
1724                    if (objectName.getKeyBindings().size() == 0)
1725                    {
1726                        return _associatorClasses(
1727                            nameSpace,
1728                            objectName.getClassName(),
1729 mike   1.1                 assocClass,
1730                            resultClass,
1731                            role,
1732                            resultRole,
1733                            includeQualifiers,
1734                            includeClassOrigin,
1735                            propertyList);
1736                    }
1737                    else
1738                    {
1739                        Throw((CIM_ERR_NOT_SUPPORTED, "associators()"));
1740                        return Array<CIMObject>();
1741                    }
1742                }
1743                
1744                Array<CIMObjectPath> CIMRepository::associatorNames(
1745                    const CIMNamespaceName& nameSpace,
1746                    const CIMObjectPath& objectName,
1747                    const CIMName& assocClass,
1748                    const CIMName& resultClass,
1749                    const String& role,
1750 mike   1.1         const String& resultRole)
1751                {
1752                    if (objectName.getKeyBindings().size() == 0)
1753                    {
1754                        return _associatorClassPaths(
1755                            nameSpace,
1756                            objectName.getClassName(),
1757                            assocClass,
1758                            resultClass,
1759                            role,
1760                            resultRole);
1761                    }
1762                    else
1763                    {
1764                        Throw((CIM_ERR_NOT_SUPPORTED, "associatorNames()"));
1765                        return Array<CIMObjectPath>();
1766                    }
1767                }
1768                
1769                Array<CIMObject> CIMRepository::references(
1770                    const CIMNamespaceName& nameSpace,
1771 mike   1.1         const CIMObjectPath& objectName,
1772                    const CIMName& resultClass,
1773                    const String& role,
1774                    Boolean includeQualifiers,
1775                    Boolean includeClassOrigin,
1776                    const CIMPropertyList& propertyList)
1777                {
1778                    if (objectName.getKeyBindings().size() == 0)
1779                    {
1780                        return _referenceClasses(
1781                            nameSpace,
1782                            objectName.getClassName(),
1783                            resultClass,
1784                            role,
1785                            includeQualifiers,
1786                            includeClassOrigin,
1787                            propertyList);
1788                    }
1789                    else
1790                    {
1791                        Throw((CIM_ERR_NOT_SUPPORTED, "references()"));
1792 mike   1.1             return Array<CIMObject>();
1793                    }
1794                }
1795                
1796                Array<CIMObjectPath> CIMRepository::referenceNames(
1797                    const CIMNamespaceName& nameSpace,
1798                    const CIMObjectPath& objectName,
1799                    const CIMName& resultClass,
1800                    const String& role)
1801                {
1802                    if (objectName.getKeyBindings().size() == 0)
1803                    {
1804                        return _referenceClassPaths(
1805                            nameSpace,
1806                            objectName.getClassName(),
1807                            resultClass,
1808                            role);
1809                    }
1810                    else
1811                    {
1812                        Throw((CIM_ERR_NOT_SUPPORTED, "referenceNames()"));
1813 mike   1.1             return Array<CIMObjectPath>();
1814                    }
1815                }
1816                
1817                CIMValue CIMRepository::getProperty(
1818                    const CIMNamespaceName& nameSpace,
1819                    const CIMObjectPath& instanceName,
1820                    const CIMName& propertyName)
1821                {
1822                    CIMInstance ci = getInstance(
1823 kumpf  1.7             nameSpace, instanceName, true, true, CIMPropertyList());
1824 mike   1.1     
1825                    Uint32 pos = ci.findProperty(propertyName);
1826                
1827                    if (pos == PEG_NOT_FOUND)
1828                    {
1829                        Throw((CIM_ERR_NO_SUCH_PROPERTY, "%s", *Str(propertyName)));
1830                    }
1831                
1832                    return ci.getProperty(pos).getValue();
1833                }
1834                
1835                void CIMRepository::setProperty(
1836                    const CIMNamespaceName& nameSpace,
1837                    const CIMObjectPath& instanceName,
1838                    const CIMName& propertyName,
1839 kumpf  1.3         const CIMValue& newValue)
1840 mike   1.1     {
1841                    CIMInstance ci(instanceName.getClassName());
1842                    ci.addProperty(CIMProperty(propertyName, newValue));
1843                    ci.setPath(instanceName);
1844                
1845                    Array<CIMName> tmp;
1846                    tmp.append(propertyName);
1847                    CIMPropertyList properties(tmp);
1848                
1849 kumpf  1.3         modifyInstance(nameSpace, ci, false, properties);
1850 mike   1.1     }
1851                
1852                CIMQualifierDecl CIMRepository::getQualifier(
1853                    const CIMNamespaceName& nameSpace,
1854                    const CIMName& qualifierName)
1855                {
1856                    return _getQualifier(nameSpace, qualifierName);
1857                }
1858                
1859                void CIMRepository::setQualifier(
1860                    const CIMNamespaceName& nameSpace,
1861 kumpf  1.3         const CIMQualifierDecl& qualifierDecl)
1862 mike   1.1     {
1863                    Throw((CIM_ERR_NOT_SUPPORTED, "setQualifier()"));
1864                }
1865                
1866                void CIMRepository::deleteQualifier(
1867                    const CIMNamespaceName& nameSpace,
1868                    const CIMName& qualifierName)
1869                {
1870                    Throw((CIM_ERR_NOT_SUPPORTED, "deleteQualifier()"));
1871                }
1872                
1873                Array<CIMQualifierDecl> CIMRepository::enumerateQualifiers(
1874                    const CIMNamespaceName& nameSpace)
1875                {
1876                    return _enumerateQualifiers(nameSpace);
1877                }
1878                
1879                void CIMRepository::createNameSpace(
1880                    const CIMNamespaceName& nameSpace,
1881                    const NameSpaceAttributes& attributes)
1882                {
1883 mike   1.1         Throw((CIM_ERR_NOT_SUPPORTED, "createNameSpace()"));
1884                }
1885                
1886                void CIMRepository::modifyNameSpace(
1887                    const CIMNamespaceName& nameSpace,
1888                    const NameSpaceAttributes& attributes)
1889                {
1890                    Throw((CIM_ERR_NOT_SUPPORTED, "modifyNameSpace()"));
1891                }
1892                
1893                Array<CIMNamespaceName> CIMRepository::enumerateNameSpaces() const
1894                {
1895                    return _enumerateNameSpaces();
1896                }
1897                
1898                void CIMRepository::deleteNameSpace(
1899                    const CIMNamespaceName& nameSpace)
1900                {
1901                    Throw((CIM_ERR_NOT_SUPPORTED, "deleteNameSpace()"));
1902                }
1903                
1904 mike   1.1     Boolean CIMRepository::getNameSpaceAttributes(
1905                    const CIMNamespaceName& nameSpace,
1906                    NameSpaceAttributes& attributes)
1907                {
1908                    attributes.clear();
1909                    return false;
1910                }
1911                
1912                Boolean CIMRepository::isDefaultInstanceProvider()
1913                {
1914                    return true;
1915                }
1916                
1917                void CIMRepository::getSubClassNames(
1918                    const CIMNamespaceName& nameSpace,
1919                    const CIMName& className,
1920                    Boolean deepInheritance,
1921                    Array<CIMName>& subClassNames) const
1922                {
1923                    _getSubClassNames(nameSpace, className, deepInheritance, subClassNames);
1924                }
1925 mike   1.1     
1926                void CIMRepository::getSuperClassNames(
1927                    const CIMNamespaceName& nameSpace,
1928                    const CIMName& className,
1929                    Array<CIMName>& superClassNames) const
1930                {
1931                    _getSuperClassNames(nameSpace, className, superClassNames);
1932                }
1933                
1934                Boolean CIMRepository::isRemoteNameSpace(
1935                    const CIMNamespaceName& nameSpace,
1936                    String& remoteInfo)
1937                {
1938                    return false;
1939                }
1940                
1941                #ifdef PEGASUS_DEBUG
1942                void CIMRepository::DisplayCacheStatistics()
1943                {
1944                }
1945                #endif
1946 mike   1.1     
1947                Uint32 CIMRepositoryRep::_findInstance(
1948                    const CIMNamespaceName& nameSpace,
1949                    const CIMObjectPath& instanceName)
1950                {
1951                    for (Uint32 i = 0; i < _rep.size(); i++)
1952                    {
1953                        if (_rep[i].first == nameSpace &&
1954                            _rep[i].second.getPath() == instanceName)
1955                        {
1956                            return i;
1957                        }
1958                    }
1959                
1960                    return PEG_NOT_FOUND;
1961                }
1962                
1963                void MRRInstallSaveCallback(
1964                    void (*callback)(const Buffer& buffer, void* data),
1965                    void * data)
1966                {
1967 mike   1.1         _saveCallback = callback;
1968                    _saveData = data;
1969                }
1970                
1971                void MRRInstallLoadCallback(
1972                    void (*callback)(Buffer& buffer, void* data),
1973                    void * data)
1974                {
1975                    _loadCallback = callback;
1976                    _loadData = data;
1977                }
1978                
1979                void CIMRepositoryRep::_processSaveCallback()
1980                {
1981                    if (!_saveCallback)
1982                        return;
1983                
1984                    Buffer out;
1985                
1986                    for (Uint32 i = 0; i < _rep.size(); i++)
1987                    {
1988 mike   1.1             MRRSerializeNameSpace(out, _rep[i].first);
1989                        MRRSerializeInstance(out, _rep[i].second);
1990                    }
1991                
1992                    (*_saveCallback)(out, _saveData);
1993                }
1994                
1995                void CIMRepositoryRep::_processLoadCallback()
1996                {
1997                    if (!_loadCallback)
1998                        return;
1999                
2000                    Buffer in;
2001                    (*_loadCallback)(in, _loadData);
2002                    size_t pos = 0;
2003                
2004                    while (pos != in.size())
2005                    {
2006                        CIMNamespaceName nameSpace;
2007                
2008                        if (MRRDeserializeNameSpace(in, pos, nameSpace) != 0)
2009 karl   1.7.6.2         {
2010 mike   1.1                 return;
2011 karl   1.7.6.2         }
2012 mike   1.1     
2013                        CIMInstance cimInstance;
2014                
2015                        if (MRRDeserializeInstance(in, pos, cimInstance) != 0)
2016 karl   1.7.6.2         {
2017 mike   1.1                 return;
2018 karl   1.7.6.2         }
2019 mike   1.1     
2020                        _rep.append(NamespaceInstancePair(nameSpace, cimInstance));
2021                    }
2022                }
2023                
2024                Boolean MRRAddNameSpace(const MRRNameSpace* nameSpace)
2025                {
2026                    if (!nameSpace)
2027 karl   1.7.6.2     {
2028 mike   1.1             return false;
2029 karl   1.7.6.2     }
2030 mike   1.1     
2031                    if (_nameSpaceTableSize == _MAX_NAMESPACE_TABLE_SIZE)
2032 karl   1.7.6.2     {
2033 mike   1.1             return false;
2034 karl   1.7.6.2     }
2035 mike   1.1     
2036                    if (_findNameSpace(nameSpace->name))
2037 karl   1.7.6.2     {
2038 mike   1.1             return false;
2039 karl   1.7.6.2     }
2040 mike   1.1     
2041                    _nameSpaceTable[_nameSpaceTableSize++] = nameSpace;
2042                
2043                    return true;
2044                }
2045                
2046                void MRRInstallInitializeCallback(
2047                    void (*callback)(CIMRepository* repository, void * data),
2048                    void *data)
2049                {
2050                    _initializeCallback = callback;
2051                    _initializeData = data;
2052                }
2053                
2054                //==============================================================================
2055                //
2056                // Non-locking forms of repository methods.
2057                //
2058                //==============================================================================
2059                
2060                CIMClass CIMRepository::_getClass(
2061 mike   1.1         const CIMNamespaceName& nameSpace,
2062                    const CIMName& className,
2063                    Boolean localOnly,
2064                    Boolean includeQualifiers,
2065                    Boolean includeClassOrigin,
2066 karl   1.7.6.2     const CIMPropertyList& propertyList,
2067                    Boolean clone)                 // Not used by MRR.
2068 mike   1.1     {
2069                    return getClass(nameSpace, className, localOnly, includeQualifiers,
2070                        includeClassOrigin, propertyList);
2071                }
2072                
2073                CIMInstance CIMRepository::_getInstance(
2074                    const CIMNamespaceName& nameSpace,
2075                    const CIMObjectPath& instanceName,
2076                    Boolean includeQualifiers,
2077                    Boolean includeClassOrigin,
2078 kumpf  1.2         const CIMPropertyList& propertyList,
2079                    Boolean resolveInstance)
2080 mike   1.1     {
2081 kumpf  1.7         return getInstance(nameSpace, instanceName, includeQualifiers,
2082 mike   1.1             includeClassOrigin, propertyList);
2083                }
2084                
2085                void CIMRepository::_createClass(
2086                    const CIMNamespaceName& nameSpace,
2087                    const CIMClass& newClass)
2088                {
2089                    createClass(nameSpace, newClass);
2090                }
2091                
2092                CIMObjectPath CIMRepository::_createInstance(
2093                    const CIMNamespaceName& nameSpace,
2094                    const CIMInstance& newInstance)
2095                {
2096                    return createInstance(nameSpace, newInstance);
2097                }
2098                
2099                void CIMRepository::_modifyClass(
2100                    const CIMNamespaceName& nameSpace,
2101                    const CIMClass& modifiedClass)
2102                {
2103 mike   1.1         modifyClass(nameSpace, modifiedClass);
2104                }
2105                
2106                Array<CIMObjectPath> CIMRepository::_associatorNames(
2107                    const CIMNamespaceName& nameSpace,
2108                    const CIMObjectPath& objectName,
2109                    const CIMName& assocClass,
2110                    const CIMName& resultClass,
2111                    const String& role,
2112                    const String& resultRole)
2113                {
2114                    return associatorNames(nameSpace, objectName, assocClass, resultClass,
2115                        role, resultRole);
2116                }
2117                
2118                Array<CIMObjectPath> CIMRepository::_referenceNames(
2119                    const CIMNamespaceName& nameSpace,
2120                    const CIMObjectPath& objectName,
2121                    const CIMName& resultClass,
2122                    const String& role)
2123                {
2124 mike   1.1         return referenceNames(nameSpace, objectName, resultClass, role);
2125                }
2126                
2127                CIMQualifierDecl CIMRepository::_getQualifier(
2128                    const CIMNamespaceName& nameSpace,
2129                    const CIMName& qualifierName)
2130                {
2131                    return getQualifier(nameSpace, qualifierName);
2132                }
2133                
2134                void CIMRepository::_setQualifier(
2135                    const CIMNamespaceName& nameSpace,
2136                    const CIMQualifierDecl& qualifierDecl)
2137                {
2138                    return setQualifier(nameSpace, qualifierDecl);
2139                }
2140                
2141                PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2