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

  1 martin 1.7 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.8 //
  3 martin 1.7 // 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.8 //
 10 martin 1.7 // 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.8 //
 17 martin 1.7 // The above copyright notice and this permission notice shall be included
 18            // in all copies or substantial portions of the Software.
 19 martin 1.8 //
 20 martin 1.7 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.8 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.7 // 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.8 //
 28 martin 1.7 //////////////////////////////////////////////////////////////////////////
 29 chuck  1.1 //
 30            //%/////////////////////////////////////////////////////////////////////////////
 31            
 32            #include "RepositoryQueryContext.h"
 33            
 34            PEGASUS_NAMESPACE_BEGIN
 35 kumpf  1.4 
 36            RepositoryQueryContext::RepositoryQueryContext(
 37                const CIMNamespaceName& inNS,
 38                CIMRepository* inCIMRep)
 39                : QueryContext(inNS),
 40                  _CIMRep(inCIMRep)
 41 chuck  1.1 {
 42            }
 43            
 44 kumpf  1.4 RepositoryQueryContext::RepositoryQueryContext(
 45                const RepositoryQueryContext& ctx)
 46                : QueryContext(ctx),
 47                  _CIMRep(ctx._CIMRep)
 48 chuck  1.1 {
 49 kumpf  1.4 }
 50 chuck  1.1 
 51            RepositoryQueryContext::~RepositoryQueryContext()
 52            {
 53            }
 54            
 55 kumpf  1.4 RepositoryQueryContext& RepositoryQueryContext::operator=(
 56                const RepositoryQueryContext& rhs)
 57 chuck  1.1 {
 58 kumpf  1.4     if (this == &rhs)
 59                    return *this;
 60            
 61                QueryContext::operator=(rhs);
 62            
 63                _CIMRep = rhs._CIMRep;
 64            
 65 chuck  1.1     return *this;
 66 kumpf  1.4 }
 67 chuck  1.1 
 68 kumpf  1.4 CIMClass RepositoryQueryContext::getClass(const CIMName& inClassName) const
 69            {
 70                /* Hardcoded defaults */
 71                Boolean localOnly = false;
 72                Boolean includeQualifiers = true;
 73                Boolean includeClassOrigin = false;
 74                CIMPropertyList _emptyCIMPropertyList;
 75            
 76                CIMClass _class = _CIMRep->getClass(
 77                    getNamespace(),
 78                    inClassName,
 79                    localOnly,
 80                    includeQualifiers,
 81                    includeClassOrigin,
 82                    _emptyCIMPropertyList);
 83                return _class;
 84            }
 85            
 86            Array<CIMName> RepositoryQueryContext::enumerateClassNames(
 87                const CIMName& inClassName) const
 88            {
 89 kumpf  1.4     return _CIMRep->enumerateClassNames(
 90                    getNamespace(),
 91                    inClassName,
 92                    true);          // deepInheritance
 93            }
 94            
 95            Boolean RepositoryQueryContext::isSubClass(
 96                const CIMName& baseClass,
 97                const CIMName& derivedClass) const
 98            {
 99                if (baseClass == derivedClass)
100                {
101                    return false;
102                }
103            
104                Array<CIMName> subClasses = enumerateClassNames(baseClass);
105                for (Uint32 i = 0; i < subClasses.size(); i++)
106                {
107                    if (subClasses[i] == derivedClass)
108                    {
109                        return true;
110 kumpf  1.4         }
111                }
112            
113                return false;
114 chuck  1.1 }
115            
116 kumpf  1.4 QueryContext::ClassRelation RepositoryQueryContext::getClassRelation(
117                const CIMName& anchorClass,
118                const CIMName& relatedClass) const
119 chuck  1.1 {
120 kumpf  1.4     if (anchorClass == relatedClass)
121                {
122                    return SAMECLASS;
123                }
124            
125                if (isSubClass(anchorClass, relatedClass))
126                {
127                    return SUBCLASS;
128                }
129 chuck  1.1 
130 kumpf  1.4     if (isSubClass(relatedClass, anchorClass))
131 chuck  1.1     {
132 kumpf  1.4         return SUPERCLASS;
133                }
134 chuck  1.1 
135 kumpf  1.4     return NOTRELATED;
136 chuck  1.1 }
137            
138 kumpf  1.6 QueryContext* RepositoryQueryContext::clone() const
139 chuck  1.1 {
140 kumpf  1.4     return new RepositoryQueryContext(*this);
141 chuck  1.1 }
142            
143            PEGASUS_NAMESPACE_END
144            

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2