(file) Return to clientRepositoryInterface.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Clients / tomof

  1 karl  1.1 //%/////////////////////////////////////////////////////////////////////////////
  2           //
  3 kumpf 1.6 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
  4           // The Open Group, Tivoli Systems
  5 karl  1.1 //
  6           // Permission is hereby granted, free of charge, to any person obtaining a copy
  7 kumpf 1.6 // of this software and associated documentation files (the "Software"), to
  8           // deal in the Software without restriction, including without limitation the
  9           // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 10 karl  1.1 // sell copies of the Software, and to permit persons to whom the Software is
 11           // furnished to do so, subject to the following conditions:
 12           // 
 13 kumpf 1.6 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 14 karl  1.1 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 15           // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 16 kumpf 1.6 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 17           // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 18           // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 19 karl  1.1 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 20           // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 21           //
 22           //==============================================================================
 23           //
 24           // Author: Karl Schopmeyer (k.schopmeyer@opengroup.org)
 25           //
 26 kumpf 1.5 // Modified By:  Carol Ann Krug Graves, Hewlett-Packard Company
 27           //               (carolann_graves@hp.com)
 28 karl  1.1 //
 29           //%/////////////////////////////////////////////////////////////////////////////
 30           
 31           #include "clientRepositoryInterface.h"
 32           #include <Pegasus/Repository/CIMRepository.h>
 33           #include <Pegasus/Common/CIMClass.h>
 34           #include <Pegasus/Common/CIMInstance.h>
 35           #include <Pegasus/Client/CIMClient.h>
 36 karl  1.2 #include <Pegasus/Common/Exception.h>
 37 karl  1.1 
 38           PEGASUS_USING_STD;
 39           PEGASUS_NAMESPACE_BEGIN
 40           
 41           clientRepositoryInterface::clientRepositoryInterface() :
 42             _repository(0),
 43             _client(0)
 44           {
 45           }
 46           
 47           clientRepositoryInterface::~clientRepositoryInterface() 
 48           {
 49             if (_repository)
 50               delete _repository;
 51             if (_client)
 52               delete _client;
 53           }
 54           
 55           void
 56           clientRepositoryInterface::init(_repositoryType type, 
 57                                           String location)
 58 karl  1.1 {
 59             String message;
 60             // _ot = ot;
 61             if (type == REPOSITORY_INTERFACE_LOCAL)
 62             {
 63                 _repository = new CIMRepository(location);
 64                 // test to find if repository exists.
 65             }
 66             else if (type == REPOSITORY_INTERFACE_CLIENT) 
 67             {
 68               // create a CIMClient object and put it in _client
 69               try
 70               {
 71 kumpf 1.11         Uint32 index = location.find (':');
 72                    String host = location.subString (0, index);
 73                    Uint32 portNumber = 0;
 74                    if (index != PEG_NOT_FOUND)
 75                    {
 76                        String portStr = location.subString (index + 1, location.size ());
 77                        sscanf (portStr.getCString (), "%u", &portNumber);
 78                    }
 79                    _client = new CIMClient();
 80                    _client->connect (host, portNumber, String::EMPTY, String::EMPTY);
 81 karl  1.1      } 
 82                
 83                catch(Exception &e) 
 84                {
 85 karl  1.2  	  cerr << "Internal Error:" << e.getMessage() << endl;
 86 karl  1.1        delete _client;
 87                  _client = 0;
 88                }
 89              }
 90              else 
 91              {
 92 kumpf 1.8  	  throw IndexOutOfBoundsException();
 93 karl  1.1    }
 94            }
 95            
 96            
 97            Array<CIMQualifierDecl> clientRepositoryInterface::enumerateQualifiers(
 98 kumpf 1.10     const CIMNamespaceName& nameSpace) const 
 99 karl  1.1  {
100              if (_repository)
101                return _repository->enumerateQualifiers(nameSpace);
102              if (_client)
103                  return _client->enumerateQualifiers(nameSpace);
104 kumpf 1.8  	throw IndexOutOfBoundsException();
105 karl  1.1  }
106            
107            CIMClass clientRepositoryInterface::getClass(
108 kumpf 1.10     const CIMNamespaceName& nameSpace,
109                const CIMName& className,
110 karl  1.1      const Boolean localOnly,
111                const Boolean includeQualifiers,
112                const Boolean includeClassOrigin) const
113            {
114                if (_repository)
115                    return _repository->getClass(nameSpace, className,
116                                    localOnly, includeQualifiers, includeClassOrigin);
117                if (_client)
118                    return _client->getClass(nameSpace, className,
119                                    localOnly, includeQualifiers, includeClassOrigin);
120 kumpf 1.8  	throw IndexOutOfBoundsException();
121 karl  1.1  };
122            
123            
124            Array<CIMClass> clientRepositoryInterface::enumerateClasses(
125 kumpf 1.10     const CIMNamespaceName& nameSpace,
126                const CIMName& className,
127 karl  1.1      const Boolean deepInheritance,
128                const Boolean localOnly,
129                const Boolean includeQualifiers,
130                const Boolean includeClassOrigin) const
131            {
132                if (_repository)
133                    return _repository->enumerateClasses(
134                                                nameSpace,
135                                                className,
136                                                deepInheritance,
137                                                localOnly,
138                                                includeQualifiers,
139                                                includeClassOrigin);
140            
141                 if (_client)
142            
143                   return _client->enumerateClasses(
144                                                nameSpace,
145                                                className,
146                                                deepInheritance,
147                                                localOnly,
148 karl  1.1                                      includeQualifiers,
149                                                includeClassOrigin);
150 kumpf 1.8  	 throw IndexOutOfBoundsException();
151 karl  1.1  };
152 kumpf 1.7  Array<CIMName> clientRepositoryInterface::enumerateClassNames(
153 kumpf 1.10     const CIMNamespaceName& nameSpace,
154                const CIMName& className,
155 karl  1.1      const Boolean deepInheritance)
156            
157            {
158                if (_repository)
159 kumpf 1.7      {
160 kumpf 1.10        Array<CIMName> classNameArray = _repository->enumerateClassNames
161                       (nameSpace, className, deepInheritance);
162 kumpf 1.7         // ATTN: Temporary code until the repository uses CIMName
163                   Array<CIMName> cimNameArray;
164                   for (Uint32 i = 0; i < classNameArray.size(); i++)
165                   {
166                       cimNameArray.append(classNameArray[i]);
167                   }
168                   return cimNameArray;
169                }
170 karl  1.1  
171                if (_client)
172                   return _client->enumerateClassNames(nameSpace, className, deepInheritance);
173 kumpf 1.8  	throw IndexOutOfBoundsException();
174 karl  1.1  };
175            
176 kumpf 1.4  Array<CIMObjectPath> clientRepositoryInterface::enumerateInstanceNames(
177 kumpf 1.10 	const CIMNamespaceName& nameSpace,
178            	const CIMName& className)
179 karl  1.3  {
180                if (_repository)
181                   return _repository->enumerateInstanceNames(nameSpace, className);
182            
183                if (_client)
184                   return _client->enumerateInstanceNames(nameSpace, className);
185 kumpf 1.8  	throw IndexOutOfBoundsException();
186 karl  1.3  };
187            
188 kumpf 1.5  Array<CIMInstance> clientRepositoryInterface::enumerateInstances(
189 kumpf 1.10 	const CIMNamespaceName& nameSpace,
190            	const CIMName& className,
191 karl  1.3  	Boolean deepInheritance,
192            	Boolean localOnly,
193            	Boolean includeQualifiers,
194            	Boolean includeClassOrigin,
195            	const CIMPropertyList& propertyList)
196            	
197            {
198                if (_repository)
199                   return _repository->enumerateInstances(nameSpace, className,
200            			deepInheritance, localOnly,includeQualifiers,includeClassOrigin);
201            
202                if (_client)
203                   return _client->enumerateInstances(nameSpace, className,
204            		   deepInheritance, localOnly,includeQualifiers,includeClassOrigin);
205 kumpf 1.8  	throw IndexOutOfBoundsException();
206 karl  1.3  };
207            
208            
209 karl  1.1  PEGASUS_NAMESPACE_END
210            

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2