version 1.6, 2002/05/22 21:35:47
|
version 1.7, 2002/05/28 21:20:36
|
|
|
// | // |
// OperationContext | // OperationContext |
// | // |
|
class OperationContextRep |
|
{ |
|
public: |
|
Array<OperationContext::Container *> containers; |
|
}; |
|
|
OperationContext::OperationContext(void) | OperationContext::OperationContext(void) |
{ | { |
|
_rep = new OperationContextRep; |
} | } |
| |
OperationContext::OperationContext(const OperationContext & context) | OperationContext::OperationContext(const OperationContext & context) |
{ | { |
|
_rep = new OperationContextRep; |
*this = context; | *this = context; |
} | } |
| |
OperationContext::~OperationContext(void) | OperationContext::~OperationContext(void) |
{ | { |
clear(); | clear(); |
|
delete _rep; |
} | } |
| |
OperationContext & OperationContext::operator=(const OperationContext & context) | OperationContext & OperationContext::operator=(const OperationContext & context) |
|
|
| |
clear(); | clear(); |
| |
for(Uint32 i = 0, n = context._containers.size(); i < n; i++) |
for(Uint32 i = 0, n = context._rep->containers.size(); i < n; i++) |
{ | { |
_containers.append(context._containers[i]->clone()); |
_rep->containers.append(context._rep->containers[i]->clone()); |
} | } |
| |
return(*this); | return(*this); |
|
|
| |
void OperationContext::clear(void) | void OperationContext::clear(void) |
{ | { |
for(Uint32 i = 0, n = _containers.size(); i < n; i++) |
for(Uint32 i = 0, n = _rep->containers.size(); i < n; i++) |
{ | { |
delete _containers[i]; |
delete _rep->containers[i]; |
} | } |
| |
_containers.clear(); |
_rep->containers.clear(); |
} | } |
| |
const OperationContext::Container & OperationContext::get(const Uint32 key) const | const OperationContext::Container & OperationContext::get(const Uint32 key) const |
{ | { |
for(Uint32 i = 0, n = _containers.size(); i < n; i++) |
for(Uint32 i = 0, n = _rep->containers.size(); i < n; i++) |
{ | { |
if(key == _containers[i]->getKey()) |
if(key == _rep->containers[i]->getKey()) |
{ | { |
Container * p = _containers[i]; |
Container * p = _rep->containers[i]; |
| |
return(*p); | return(*p); |
} | } |
|
|
| |
void OperationContext::set(const OperationContext::Container & container) | void OperationContext::set(const OperationContext::Container & container) |
{ | { |
for(Uint32 i = 0, n = _containers.size(); i < n; i++) |
for(Uint32 i = 0, n = _rep->containers.size(); i < n; i++) |
{ | { |
if(container.getKey() == _containers[i]->getKey()) |
if(container.getKey() == _rep->containers[i]->getKey()) |
{ | { |
// delete previous container | // delete previous container |
_containers.remove(i); |
delete _rep->containers[i]; |
|
_rep->containers.remove(i); |
| |
// append current container | // append current container |
_containers.append(container.clone()); |
_rep->containers.append(container.clone()); |
| |
return; | return; |
} | } |
|
|
| |
void OperationContext::insert(const OperationContext::Container & container) | void OperationContext::insert(const OperationContext::Container & container) |
{ | { |
for(Uint32 i = 0, n = _containers.size(); i < n; i++) |
for(Uint32 i = 0, n = _rep->containers.size(); i < n; i++) |
{ | { |
if(container.getKey() == _containers[i]->getKey()) |
if(container.getKey() == _rep->containers[i]->getKey()) |
{ | { |
throw Exception("object already exists."); | throw Exception("object already exists."); |
} | } |
} | } |
| |
_containers.append(container.clone()); |
_rep->containers.append(container.clone()); |
} | } |
| |
void OperationContext::remove(const Uint32 key) | void OperationContext::remove(const Uint32 key) |
{ | { |
for(Uint32 i = 0, n = _containers.size(); i < n; i++) |
for(Uint32 i = 0, n = _rep->containers.size(); i < n; i++) |
{ | { |
if(key == _containers[i]->getKey()) |
if(key == _rep->containers[i]->getKey()) |
{ | { |
_containers.remove(i); |
delete _rep->containers[i]; |
|
_rep->containers.remove(i); |
| |
return; | return; |
} | } |
|
|
{ | { |
} | } |
| |
|
const Uint32 & OperationContext::Container::getKey(void) const |
|
{ |
|
return(_key); |
|
} |
|
|
OperationContext::Container * OperationContext::Container::clone(void) const | OperationContext::Container * OperationContext::Container::clone(void) const |
{ | { |
return(new Container(*this)); | return(new Container(*this)); |
} | } |
| |
// | // |
// IdentitiyContainer |
// IdentityContainer |
// | // |
IdentityContainer::IdentityContainer(const OperationContext::Container & container) | IdentityContainer::IdentityContainer(const OperationContext::Container & container) |
{ | { |