version 1.10, 2002/08/21 22:45:50
|
version 1.11, 2002/09/19 16:17:36
|
|
|
// | // |
// Author: Chip Vincent (cvincent@us.ibm.com) | // Author: Chip Vincent (cvincent@us.ibm.com) |
// | // |
// Modified By: |
// Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
// | // |
// OperationContext | // OperationContext |
// | // |
|
|
class OperationContextRep | class OperationContextRep |
{ | { |
public: | public: |
|
|
{ | { |
for(Uint32 i = 0, n = _rep->containers.size(); i < n; i++) | for(Uint32 i = 0, n = _rep->containers.size(); i < n; i++) |
{ | { |
delete _rep->containers[i]; |
_rep->containers[i]->destroy(); |
} | } |
| |
_rep->containers.clear(); | _rep->containers.clear(); |
} | } |
| |
|
const OperationContext::Container & OperationContext::get( |
|
const String& containerName) const |
|
{ |
|
for(Uint32 i = 0, n = _rep->containers.size(); i < n; i++) |
|
{ |
|
if(containerName == _rep->containers[i]->getName()) |
|
{ |
|
Container * p = _rep->containers[i]; |
|
|
|
return(*p); |
|
} |
|
} |
|
|
|
throw Exception("object not found"); |
|
} |
|
|
|
#ifndef PEGASUS_REMOVE_DEPRECATED |
const OperationContext::Container & OperationContext::get(const Uint32 key) const | const OperationContext::Container & OperationContext::get(const Uint32 key) const |
{ | { |
for(Uint32 i = 0, n = _rep->containers.size(); i < n; i++) | for(Uint32 i = 0, n = _rep->containers.size(); i < n; i++) |
|
|
| |
throw Exception("object not found"); | throw Exception("object not found"); |
} | } |
|
#endif |
| |
void OperationContext::set(const OperationContext::Container & container) | void OperationContext::set(const OperationContext::Container & container) |
{ | { |
for(Uint32 i = 0, n = _rep->containers.size(); i < n; i++) | for(Uint32 i = 0, n = _rep->containers.size(); i < n; i++) |
{ | { |
if(container.getKey() == _rep->containers[i]->getKey()) |
if(container.getName() == _rep->containers[i]->getName()) |
{ | { |
// delete previous container | // delete previous container |
delete _rep->containers[i]; |
_rep->containers[i]->destroy(); |
_rep->containers.remove(i); | _rep->containers.remove(i); |
| |
// append current container | // append current container |
|
|
{ | { |
for(Uint32 i = 0, n = _rep->containers.size(); i < n; i++) | for(Uint32 i = 0, n = _rep->containers.size(); i < n; i++) |
{ | { |
if(container.getKey() == _rep->containers[i]->getKey()) |
if(container.getName() == _rep->containers[i]->getName()) |
{ | { |
throw Exception("object already exists."); | throw Exception("object already exists."); |
} | } |
|
|
_rep->containers.append(container.clone()); | _rep->containers.append(container.clone()); |
} | } |
| |
|
void OperationContext::remove(const String& containerName) |
|
{ |
|
for(Uint32 i = 0, n = _rep->containers.size(); i < n; i++) |
|
{ |
|
if(containerName == _rep->containers[i]->getName()) |
|
{ |
|
_rep->containers[i]->destroy(); |
|
_rep->containers.remove(i); |
|
|
|
return; |
|
} |
|
} |
|
|
|
throw Exception("object not found"); |
|
} |
|
|
|
#ifndef PEGASUS_REMOVE_DEPRECATED |
void OperationContext::remove(const Uint32 key) | void OperationContext::remove(const Uint32 key) |
{ | { |
for(Uint32 i = 0, n = _rep->containers.size(); i < n; i++) | for(Uint32 i = 0, n = _rep->containers.size(); i < n; i++) |
|
|
| |
throw Exception("object not found"); | throw Exception("object not found"); |
} | } |
|
#endif |
| |
// | // |
// OperationContext::Container | // OperationContext::Container |
// | // |
|
|
|
#ifndef PEGASUS_REMOVE_DEPRECATED |
OperationContext::Container::Container(const Uint32 key) : _key(key) | OperationContext::Container::Container(const Uint32 key) : _key(key) |
{ | { |
} | } |
|
#endif |
| |
OperationContext::Container::~Container(void) | OperationContext::Container::~Container(void) |
{ | { |
} | } |
| |
|
#ifndef PEGASUS_REMOVE_DEPRECATED |
const Uint32 & OperationContext::Container::getKey(void) const | const Uint32 & OperationContext::Container::getKey(void) const |
{ | { |
return(_key); | return(_key); |
} | } |
|
#endif |
OperationContext::Container * OperationContext::Container::clone(void) const |
|
{ |
|
return(new Container(*this)); |
|
} |
|
| |
// | // |
// IdentityContainer | // IdentityContainer |
// | // |
IdentityContainer::IdentityContainer(const OperationContext::Container & container) |
|
{ |
|
const IdentityContainer * p = dynamic_cast<const IdentityContainer *>(&container); |
|
|
|
if(p == 0) |
|
{ |
|
throw DynamicCastFailedException(); |
|
} |
|
|
|
*this = *p; |
|
} |
|
| |
IdentityContainer::IdentityContainer(const String & userName) |
class IdentityContainerRep |
: OperationContext::Container(CONTEXT_IDENTITY), _userName(userName) |
|
{ |
|
} |
|
|
|
OperationContext::Container * IdentityContainer::clone(void) const |
|
{ | { |
return(new IdentityContainer(*this)); |
public: |
} |
String userName; |
|
}; |
| |
String IdentityContainer::getUserName(void) const |
const String IdentityContainer::NAME = "IdentityContainer"; |
{ |
|
return(_userName); |
|
} |
|
| |
// |
IdentityContainer::IdentityContainer(const OperationContext::Container & container) |
// LocaleContainer |
|
// |
|
LocaleContainer::LocaleContainer(const OperationContext::Container & container) |
|
{ | { |
const LocaleContainer * p = dynamic_cast<const LocaleContainer *>(&container); |
const IdentityContainer * p = dynamic_cast<const IdentityContainer *>(&container); |
| |
if(p == 0) | if(p == 0) |
{ | { |
throw DynamicCastFailedException(); | throw DynamicCastFailedException(); |
} | } |
| |
*this = *p; |
_rep = new IdentityContainerRep(); |
} |
_rep->userName = p->_rep->userName; |
|
|
LocaleContainer::LocaleContainer(const String & languageId) |
|
: OperationContext::Container(CONTEXT_LOCALE), _languageId(languageId) |
|
{ |
|
} |
|
|
|
OperationContext::Container * LocaleContainer::clone(void) const |
|
{ |
|
return(new LocaleContainer(*this)); |
|
} | } |
| |
String LocaleContainer::getLanguageId(void) const |
IdentityContainer::IdentityContainer(const String & userName) |
|
#ifndef PEGASUS_REMOVE_DEPRECATED |
|
: OperationContext::Container(CONTEXT_IDENTITY) |
|
#endif |
{ | { |
return(_languageId); |
_rep = new IdentityContainerRep(); |
|
_rep->userName = userName; |
} | } |
| |
// |
IdentityContainer::~IdentityContainer(void) |
// ProviderIdContainer |
|
// |
|
ProviderIdContainer::ProviderIdContainer(const OperationContext::Container & container) |
|
{ | { |
const ProviderIdContainer * p = dynamic_cast<const ProviderIdContainer *>(&container); |
delete _rep; |
|
|
if(p == 0) |
|
{ |
|
throw DynamicCastFailedException(); |
|
} |
|
|
|
*this = *p; |
|
} | } |
| |
ProviderIdContainer::ProviderIdContainer(const CIMInstance & module, const CIMInstance & provider) |
String IdentityContainer::getName(void) const |
: OperationContext::Container(CONTEXT_PROVIDERID), _module(module), _provider(provider) |
|
{ | { |
|
return(NAME); |
} | } |
| |
OperationContext::Container * ProviderIdContainer::clone(void) const |
OperationContext::Container * IdentityContainer::clone(void) const |
{ | { |
return(new ProviderIdContainer(*this)); |
return(new IdentityContainer(_rep->userName)); |
} | } |
| |
CIMInstance ProviderIdContainer::getModule(void) const |
void IdentityContainer::destroy(void) |
{ | { |
return(_module); |
delete this; |
} | } |
| |
CIMInstance ProviderIdContainer::getProvider(void) const |
String IdentityContainer::getUserName(void) const |
{ | { |
return(_provider); |
return(_rep->userName); |
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |