Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Types | Public Member Functions | Private Attributes
ARex::PrefixedFilePayload Class Reference
Inheritance diagram for ARex::PrefixedFilePayload:
Inheritance graph
[legend]
Collaboration diagram for ARex::PrefixedFilePayload:
Collaboration graph
[legend]

List of all members.

Public Types

typedef signed long long int Size_t

Public Member Functions

 PrefixedFilePayload (const std::string &prefix, const std::string &postfix, int handle)
 ~PrefixedFilePayload (void)
virtual char operator[] (Size_t pos) const
 Returns content of byte at specified position.
virtual char * Content (Size_t pos)
 Get pointer to buffer content at global position 'pos'.
virtual Size_t Size (void) const
 Returns logical size of whole structure.
virtual char * Insert (Size_t pos=0, Size_t size=0)
 Create new buffer at global position 'pos' of size 'size'.
virtual char * Insert (const char *s, Size_t pos=0, Size_t size=-1)
 Create new buffer at global position 'pos' of size 'size'.
virtual char * Buffer (unsigned int num=0)
 Returns pointer to num'th buffer.
virtual Size_t BufferSize (unsigned int num=0) const
 Returns length of num'th buffer.
virtual Size_t BufferPos (unsigned int num=0) const
 Returns position of num'th buffer.
virtual bool Truncate (Size_t size)
 Change size of stored information.

Private Attributes

std::string prefix_
std::string postfix_
int handle_
void * addr_
size_t length_

Detailed Description

Definition at line 146 of file information_collector.cpp.


Member Typedef Documentation

typedef signed long long int Arc::PayloadRawInterface::Size_t [inherited]

Definition at line 19 of file PayloadRaw.h.


Constructor & Destructor Documentation

ARex::PrefixedFilePayload::PrefixedFilePayload ( const std::string &  prefix,
const std::string &  postfix,
int  handle 
) [inline]

Definition at line 154 of file information_collector.cpp.

                                                                                   {
    prefix_ = prefix;
    postfix_ = postfix;
    handle_ = handle;
    addr_ = NULL;
    length_ = 0;
    if(handle != -1) {
      struct stat st;
      if(::fstat(handle,&st) == 0) {
        if(st.st_size > 0) {
          length_ = st.st_size;
          addr_ = ::mmap(NULL,st.st_size,PROT_READ,MAP_PRIVATE,handle,0);
          if(!addr_) length_=0;
        };
      };
    };
  };

Definition at line 171 of file information_collector.cpp.

                             {
    if(addr_) ::munmap(addr_,length_);
    ::close(handle_);
  };

Member Function Documentation

virtual char* ARex::PrefixedFilePayload::Buffer ( unsigned int  num = 0) [inline, virtual]

Returns pointer to num'th buffer.

Implements Arc::PayloadRawInterface.

Definition at line 197 of file information_collector.cpp.

                                             {
    if(num == 0) return (char*)(prefix_.c_str());
    if(addr_) {
      if(num == 1) return (char*)addr_;
    } else {
      ++num;
    };
    if(num == 2) return (char*)(postfix_.c_str());
    return NULL;
  };
virtual Size_t ARex::PrefixedFilePayload::BufferPos ( unsigned int  num = 0) const [inline, virtual]

Returns position of num'th buffer.

Implements Arc::PayloadRawInterface.

Definition at line 217 of file information_collector.cpp.

                                                       {
    if(num == 0) return 0;
    if(addr_) {
      if(num == 1) return prefix_.length();
    } else {
      ++num;
    };
    if(num == 2) return (prefix_.length() + length_);
    return (prefix_.length() + length_ + postfix_.length());
  };
virtual Size_t ARex::PrefixedFilePayload::BufferSize ( unsigned int  num = 0) const [inline, virtual]

Returns length of num'th buffer.

Implements Arc::PayloadRawInterface.

Definition at line 207 of file information_collector.cpp.

                                                        {
    if(num == 0) return prefix_.length();
    if(addr_) {
      if(num == 1) return length_;
    } else {
      ++num;
    };
    if(num == 2) return postfix_.length();
    return 0;
  };
virtual char* ARex::PrefixedFilePayload::Content ( Size_t  pos) [inline, virtual]

Get pointer to buffer content at global position 'pos'.

By default to beginning of main buffer whatever that means.

Implements Arc::PayloadRawInterface.

Definition at line 180 of file information_collector.cpp.

                                    {
    if(pos < prefix_.length()) return (char*)(prefix_.c_str() + pos);
    pos -= prefix_.length();
    if(pos < length_) return ((char*)(addr_) + pos);
    pos -= length_; 
    if(pos < postfix_.length()) return (char*)(postfix_.c_str() + pos);
    return NULL;
  };
virtual char* ARex::PrefixedFilePayload::Insert ( Size_t  pos = 0,
Size_t  size = 0 
) [inline, virtual]

Create new buffer at global position 'pos' of size 'size'.

Implements Arc::PayloadRawInterface.

Definition at line 191 of file information_collector.cpp.

                                                       {
    return NULL;
  };
virtual char* ARex::PrefixedFilePayload::Insert ( const char *  s,
Size_t  pos = 0,
Size_t  size = -1 
) [inline, virtual]

Create new buffer at global position 'pos' of size 'size'.

Created buffer is filled with content of memory at 's'. If 'size' is negative content at 's' is expected to be null-terminated.

Implements Arc::PayloadRawInterface.

Definition at line 194 of file information_collector.cpp.

                                                                      {
    return NULL;
  };
virtual char ARex::PrefixedFilePayload::operator[] ( Size_t  pos) const [inline, virtual]

Returns content of byte at specified position.

Specified position 'pos' is treated as global one and goes through all buffers placed one after another.

Implements Arc::PayloadRawInterface.

Definition at line 175 of file information_collector.cpp.

                                            {
    char* p = ((PrefixedFilePayload*)this)->Content(pos);
    if(!p) return 0;
    return *p;
  };
virtual Size_t ARex::PrefixedFilePayload::Size ( void  ) const [inline, virtual]

Returns logical size of whole structure.

Implements Arc::PayloadRawInterface.

Definition at line 188 of file information_collector.cpp.

                                  {
    return (prefix_.length() + length_ + postfix_.length());
  };
virtual bool ARex::PrefixedFilePayload::Truncate ( Size_t  size) [inline, virtual]

Change size of stored information.

If size exceeds end of allocated buffer, buffers are not re-allocated, only logical size is extended. Buffers with location behind new size are deallocated.

Implements Arc::PayloadRawInterface.

Definition at line 227 of file information_collector.cpp.

{ return false; };

Member Data Documentation

Definition at line 151 of file information_collector.cpp.

Definition at line 150 of file information_collector.cpp.

Definition at line 152 of file information_collector.cpp.

std::string ARex::PrefixedFilePayload::postfix_ [private]

Definition at line 149 of file information_collector.cpp.

std::string ARex::PrefixedFilePayload::prefix_ [private]

Definition at line 148 of file information_collector.cpp.


The documentation for this class was generated from the following file: