jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
Public Member Functions | Private Attributes | List of all members
jubatus::core::common::byte_buffer Class Reference

#include <byte_buffer.hpp>

Collaboration diagram for jubatus::core::common::byte_buffer:
Collaboration graph

Public Member Functions

void assign (const void *ptr, size_t size)
 
 byte_buffer ()
 
 byte_buffer (size_t size)
 
 byte_buffer (const void *ptr, size_t size)
 
const char * ptr () const
 
char * ptr ()
 
size_t size () const
 
void swap (byte_buffer &other)
 

Private Attributes

jubatus::util::lang::shared_ptr< std::vector< char > > buf_
 

Detailed Description

Definition at line 30 of file byte_buffer.hpp.

Constructor & Destructor Documentation

jubatus::core::common::byte_buffer::byte_buffer ( )
inline

Definition at line 32 of file byte_buffer.hpp.

Referenced by assign().

32  {
33  }

Here is the caller graph for this function:

jubatus::core::common::byte_buffer::byte_buffer ( size_t  size)
inlineexplicit

Definition at line 35 of file byte_buffer.hpp.

36  : buf_(new std::vector<char>(size)) {
37  }
jubatus::util::lang::shared_ptr< std::vector< char > > buf_
Definition: byte_buffer.hpp:92
jubatus::core::common::byte_buffer::byte_buffer ( const void *  ptr,
size_t  size 
)
inline

Definition at line 39 of file byte_buffer.hpp.

References buf_, and ptr().

39  {
40  const char* const first = static_cast<const char*>(ptr);
41  buf_.reset(new std::vector<char>(first, first+size));
42  }
jubatus::util::lang::shared_ptr< std::vector< char > > buf_
Definition: byte_buffer.hpp:92

Here is the call graph for this function:

Member Function Documentation

void jubatus::core::common::byte_buffer::assign ( const void *  ptr,
size_t  size 
)
inline

Definition at line 60 of file byte_buffer.hpp.

References buf_, byte_buffer(), and ptr().

Referenced by msgpack::operator>>().

60  {
61  if (buf_.unique()) {
62  const char* const first = static_cast<const char*>(ptr);
63  buf_->assign(first, first + size);
64  } else {
65  byte_buffer(ptr, size).swap(*this);
66  }
67  }
jubatus::util::lang::shared_ptr< std::vector< char > > buf_
Definition: byte_buffer.hpp:92

Here is the call graph for this function:

Here is the caller graph for this function:

const char* jubatus::core::common::byte_buffer::ptr ( ) const
inline

Definition at line 69 of file byte_buffer.hpp.

References buf_.

Referenced by assign(), byte_buffer(), msgpack::operator<<(), and ptr().

69  {
70  if (buf_ && !buf_->empty()) {
71  return &(*buf_)[0];
72  // `buf_->data()' is much better (C++11 feature)
73  } else {
74  return NULL;
75  }
76  }
jubatus::util::lang::shared_ptr< std::vector< char > > buf_
Definition: byte_buffer.hpp:92

Here is the caller graph for this function:

char* jubatus::core::common::byte_buffer::ptr ( )
inline

Definition at line 78 of file byte_buffer.hpp.

References ptr().

78  {
79  return const_cast<char*>(
80  const_cast<const byte_buffer*>(this)->ptr());
81  }

Here is the call graph for this function:

size_t jubatus::core::common::byte_buffer::size ( ) const
inline

Definition at line 83 of file byte_buffer.hpp.

References buf_.

Referenced by msgpack::operator<<().

83  {
84  if (buf_) {
85  return buf_->size();
86  } else {
87  return 0;
88  }
89  }
jubatus::util::lang::shared_ptr< std::vector< char > > buf_
Definition: byte_buffer.hpp:92

Here is the caller graph for this function:

void jubatus::core::common::byte_buffer::swap ( byte_buffer other)
inline

Definition at line 49 of file byte_buffer.hpp.

References buf_.

Referenced by jubatus::core::common::swap().

49  {
50  this->buf_.swap(other.buf_);
51  // jubatus::util::lang::shared_ptr provides no non-member swap;
52  // `swap(this->buf_, other.buf_);' may be inefficient.
53  // when jubatus::util::lang::shared_ptr provide non-member swap,
54  // this function should be rewritten with it
55  // because if new data members are added to
56  // jubatus::util::lang::shared_ptr, member function swap
57  // (currently derived from base) may cause object slicing.
58  }
jubatus::util::lang::shared_ptr< std::vector< char > > buf_
Definition: byte_buffer.hpp:92

Here is the caller graph for this function:

Member Data Documentation

jubatus::util::lang::shared_ptr<std::vector<char> > jubatus::core::common::byte_buffer::buf_
private

Definition at line 92 of file byte_buffer.hpp.

Referenced by assign(), byte_buffer(), ptr(), size(), and swap().


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