version 1.1.2.1, 2001/10/09 18:50:24
|
version 1.6, 2002/05/22 21:35:47
|
|
|
// | // |
// Author: Chip Vincent (cvincent@us.ibm.com) | // Author: Chip Vincent (cvincent@us.ibm.com) |
// | // |
// Modified By: Mike Day (mdday@us.ibm.com) |
// Modified By: |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
void default_serialize(Sint8 *dst, Uint32 dst_sz) throw(BufferTooSmall, NotImplemented) |
// |
|
// OperationContext |
|
// |
|
OperationContext::OperationContext(void) |
|
{ |
|
} |
|
|
|
OperationContext::OperationContext(const OperationContext & context) |
{ | { |
throw NotImplemented("no serialization routine present") ; |
*this = context; |
} | } |
| |
void default_delete(void * data) |
OperationContext::~OperationContext(void) |
{ | { |
if( data != NULL) |
clear(); |
::operator delete(data); |
|
} | } |
| |
void stringize_uid(void *uid, Sint8 **dest, size_t *size) throw (NullPointer, BufferTooSmall) |
OperationContext & OperationContext::operator=(const OperationContext & context) |
|
{ |
|
if(this == &context) |
{ | { |
Sint8 *ptr; |
return(*this); |
|
} |
| |
if(uid == NULL || dest == NULL || *dest == NULL || size == NULL) |
clear(); |
throw NullPointer(); |
|
| |
if( *size < 37 ) |
for(Uint32 i = 0, n = context._containers.size(); i < n; i++) |
throw BufferTooSmall(37); |
{ |
|
_containers.append(context._containers[i]->clone()); |
|
} |
|
|
|
return(*this); |
|
} |
|
|
|
void OperationContext::clear(void) |
|
{ |
|
for(Uint32 i = 0, n = _containers.size(); i < n; i++) |
|
{ |
|
delete _containers[i]; |
|
} |
|
|
|
_containers.clear(); |
|
} |
|
|
|
const OperationContext::Container & OperationContext::get(const Uint32 key) const |
|
{ |
|
for(Uint32 i = 0, n = _containers.size(); i < n; i++) |
|
{ |
|
if(key == _containers[i]->getKey()) |
|
{ |
|
Container * p = _containers[i]; |
|
|
|
return(*p); |
|
} |
|
} |
|
|
|
throw Exception("object not found"); |
|
} |
|
|
|
void OperationContext::set(const OperationContext::Container & container) |
|
{ |
|
for(Uint32 i = 0, n = _containers.size(); i < n; i++) |
|
{ |
|
if(container.getKey() == _containers[i]->getKey()) |
|
{ |
|
// delete previous container |
|
_containers.remove(i); |
|
|
|
// append current container |
|
_containers.append(container.clone()); |
|
|
|
return; |
|
} |
|
} |
|
|
|
throw Exception("object not found"); |
|
} |
|
|
|
void OperationContext::insert(const OperationContext::Container & container) |
|
{ |
|
for(Uint32 i = 0, n = _containers.size(); i < n; i++) |
|
{ |
|
if(container.getKey() == _containers[i]->getKey()) |
|
{ |
|
throw Exception("object already exists."); |
|
} |
|
} |
|
|
|
_containers.append(container.clone()); |
|
} |
|
|
|
void OperationContext::remove(const Uint32 key) |
|
{ |
|
for(Uint32 i = 0, n = _containers.size(); i < n; i++) |
|
{ |
|
if(key == _containers[i]->getKey()) |
|
{ |
|
_containers.remove(i); |
| |
ptr = (Sint8 *)uid; |
|
sprintf(*dest, |
|
"%.2d%.2d%.2d%.2d-%.2d%.2d-%.2d%.2d-%.2d%.2d-%.2d%.2d%.2d%.2d%.2d%.2d", |
|
*ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3),*(ptr + 4), *(ptr + 5), |
|
*(ptr + 6), *(ptr + 7), *(ptr + 8), *(ptr + 9), *(ptr + 10), |
|
*(ptr + 11), *(ptr + 12),*(ptr + 13),*(ptr + 14),*(ptr + 15) ); |
|
*dest += 37; |
|
*size -= 37; |
|
return; | return; |
} | } |
|
} |
|
|
|
throw Exception("object not found"); |
|
} |
|
|
|
// |
|
// OperationContext::Container |
|
// |
|
OperationContext::Container::Container(const Uint32 key) : _key(key) |
|
{ |
|
} |
| |
|
OperationContext::Container::~Container(void) |
|
{ |
|
} |
|
|
|
OperationContext::Container * OperationContext::Container::clone(void) const |
|
{ |
|
return(new Container(*this)); |
|
} |
| |
void binaryize_uid(Sint8 *uid, void *dest, size_t size) throw(NullPointer, BufferTooSmall) |
// |
|
// IdentitiyContainer |
|
// |
|
IdentityContainer::IdentityContainer(const OperationContext::Container & container) |
{ | { |
|
const IdentityContainer * p = dynamic_cast<const IdentityContainer *>(&container); |
| |
if(uid == NULL || dest == NULL) |
if(p == 0) |
throw NullPointer(); |
{ |
if(size < 16) |
throw DynamicCastFailed(); |
throw(BufferTooSmall(16)); |
|
Sint8 *src = uid; |
|
Sint8 *dst = (Sint8 *)dest; |
|
|
|
int i = 0; |
|
Sint8 temp; |
|
|
|
while( i < 16 ) |
|
{ |
|
temp = *(src + 2); |
|
*(src + 2) = 0x00; |
|
*(dst + i) = (Sint8)atoi(src); |
|
*(src + 2) = temp; |
|
i++; |
|
src += 2; |
|
if(*src == '-') |
|
src++; |
|
} | } |
|
|
|
*this = *p; |
|
} |
|
|
|
IdentityContainer::IdentityContainer(const String & userName) |
|
: OperationContext::Container(CONTEXT_IDENTITY), _userName(userName) |
|
{ |
|
} |
|
|
|
OperationContext::Container * IdentityContainer::clone(void) const |
|
{ |
|
return(new IdentityContainer(*this)); |
|
} |
|
|
|
String IdentityContainer::getUserName(void) const |
|
{ |
|
return(_userName); |
|
} |
|
|
|
// |
|
// LocaleContainer |
|
// |
|
LocaleContainer::LocaleContainer(const OperationContext::Container & container) |
|
{ |
|
const LocaleContainer * p = dynamic_cast<const LocaleContainer *>(&container); |
|
|
|
if(p == 0) |
|
{ |
|
throw DynamicCastFailed(); |
|
} |
|
|
|
*this = *p; |
|
} |
|
|
|
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 |
|
{ |
|
return(_languageId); |
|
} |
|
|
|
// |
|
// ProviderIdContainer |
|
// |
|
ProviderIdContainer::ProviderIdContainer(const OperationContext::Container & container) |
|
{ |
|
const ProviderIdContainer * p = dynamic_cast<const ProviderIdContainer *>(&container); |
|
|
|
if(p == 0) |
|
{ |
|
throw DynamicCastFailed(); |
|
} |
|
|
|
*this = *p; |
|
} |
|
|
|
ProviderIdContainer::ProviderIdContainer(const CIMInstance & module, const CIMInstance & provider) |
|
: OperationContext::Container(CONTEXT_PROVIDERID), _module(module), _provider(provider) |
|
{ |
|
} |
|
|
|
OperationContext::Container * ProviderIdContainer::clone(void) const |
|
{ |
|
return(new ProviderIdContainer(*this)); |
|
} |
|
|
|
CIMInstance ProviderIdContainer::getModule(void) const |
|
{ |
|
return(_module); |
|
} |
|
|
|
CIMInstance ProviderIdContainer::getProvider(void) const |
|
{ |
|
return(_provider); |
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |