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

Diff for /pegasus/src/Pegasus/Common/OperationContext.cpp between version 1.2 and 1.3

version 1.2, 2001/12/13 14:54:01 version 1.3, 2002/05/09 16:01:08
Line 30 
Line 30 
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 void default_serialize(Sint8 *dst, Uint32 dst_sz) throw(BufferTooSmall, NotSupported)  OperationContext::OperationContext(void)
 { {
    throw NotSupported("no serialization routine present") ;  
 } }
  
 void default_delete(void * data)  OperationContext::~OperationContext(void)
 { {
    if( data != NULL)  
       ::operator delete(data);  
 } }
  
 void stringize_uid(void *uid, Sint8 **dest, size_t *size) throw (NullPointer, BufferTooSmall)  void OperationContext::clear(void)
 { {
    Sint8 *ptr;      _containers.clear();
   }
    if(uid == NULL || dest == NULL || *dest == NULL || size == NULL)  
       throw NullPointer();  
   
    if( *size < 37 )  
       throw BufferTooSmall(37);  
  
    ptr = (Sint8 *)uid;  const OperationContext::Container OperationContext::get(const Uint32 key) const
    sprintf(*dest,  {
            "%.2d%.2d%.2d%.2d-%.2d%.2d-%.2d%.2d-%.2d%.2d-%.2d%.2d%.2d%.2d%.2d%.2d",      for(Uint32 i = 0, n = _containers.size(); i < n; i++)
            *ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3),*(ptr + 4), *(ptr + 5),      {
            *(ptr + 6), *(ptr + 7), *(ptr + 8), *(ptr + 9), *(ptr + 10),          if(key == _containers[i].getKey())
            *(ptr + 11), *(ptr + 12),*(ptr + 13),*(ptr + 14),*(ptr + 15) );          {
    *dest += 37;              return(_containers[i]);
    *size -= 37;          }
    return;  
 } }
  
       throw Exception("object not found");
   }
  
 void binaryize_uid(Sint8 *uid, void *dest, size_t size) throw(NullPointer, BufferTooSmall)  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);
  
    if(uid == NULL || dest == NULL)              return;
       throw NullPointer();          }
    if(size < 16)      }
       throw(BufferTooSmall(16));  
    Sint8 *src = uid;  
    Sint8 *dst = (Sint8 *)dest;  
  
    int i = 0;      throw Exception("object not found");
    Sint8 temp;  }
  
    while( i < 16 )  void OperationContext::insert(const OperationContext::Container & container)
    {    {
       temp = *(src + 2);      for(Uint32 i = 0, n = _containers.size(); i < n; i++)
       *(src + 2) = 0x00;      {
       *(dst + i) = (Sint8)atoi(src);          if(container.getKey() == _containers[i].getKey())
       *(src + 2) = temp;          {
       i++;              throw Exception("object already exists.");
       src += 2;  
       if(*src == '-')  
          src++;  
    }    }
 } }
  
       _containers.append(container);
   }
  
 context::context(Uint32 data_size,  void OperationContext::remove(const Uint32 key)
                  void *data,  
                  void (*del)(void *),  
                  Uint32 uint_val ,  
                  Uint32 key ,  
                  Uint32 flag ,  
                  Uint8 *uid)  
    : _size(data_size), _uint_val(uint_val), _key(key), _flag(flag)  
   
 { {
    if(uid != 0)      for(Uint32 i = 0, n = _containers.size(); i < n; i++)
       memcpy(_uid, uid, 16);  
    else  
       memset(_uid, 0x00, 16);  
   
    if(flag & CONTEXT_POINTER)  
       _data = data;  
    else if (flag & CONTEXT_COPY_MEMORY)  
    {    {
       if(data != 0)          if(key == _containers[i].getKey())
       {       {
          _data = ::operator new(_size);              _containers.remove(i);
          memcpy(_data, data, _size);  
               return;
           }
       }       }
  
       throw Exception("object not found");
    }    }
  
    if(flag & CONTEXT_DELETE_MEMORY)  OperationContext::Container::Container(const Uint32 key) : _key(key)
    {    {
       if(del != 0)  
          _delete_func = del;  
       else  
          _delete_func =  default_delete;  
    }    }
   
   OperationContext::Container::~Container(void)
   {
 } }
  
 context::~context(void)  IdentityContainer::IdentityContainer(const String & userName)
       : OperationContext::Container(CONTEXT_IDENTITY), _userName(userName)
 { {
    if(_flag & CONTEXT_DELETE_MEMORY)  }
   
   IdentityContainer::~IdentityContainer(void)
    {    {
       if(_delete_func != 0)  
          _delete_func(_data);  
       else  
          default_delete(_data);  
    }    }
  
   LocaleContainer::LocaleContainer(const String & languageId)
       : OperationContext::Container(CONTEXT_LOCALE), _languageId(languageId)
   {
 } }
  
   LocaleContainer::~LocaleContainer(void)
   {
   }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2