当前位置: 首页>>代码示例>>C++>>正文


C++ shared_array::reset方法代码示例

本文整理汇总了C++中boost::shared_array::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ shared_array::reset方法的具体用法?C++ shared_array::reset怎么用?C++ shared_array::reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost::shared_array的用法示例。


在下文中一共展示了shared_array::reset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SortedAggExecStreamGenerator

    SortedAggExecStreamGenerator(
        uint nRows, uint nKeys, std::vector<int> repeatSeqValues)
    {
        this->nRows = nRows;
        this->nKeys = nKeys;
        for (uint i = 0; i < nKeys; i++) {
            keyRepeats.push_back(repeatSeqValues[i]);
        }
        interval = LbmExecStreamTestBase::getTupleInterval(keyRepeats);

        sortedToUnsortedMap.reset(new uint[interval]);
        for (uint i = 0; i < interval; i++) {
            uint value = 0;
            uint scale = 1;
            // calculate sorted position (backwards)
            // value = key0 * scale_1_to_n + key1 * scale_2_to_n + ...
            for (int j = nKeys - 1; j >= 0; j--) {
                uint key = i % keyRepeats[j];
                value += key * scale;
                scale *= keyRepeats[j];
            }
            sortedToUnsortedMap[value] = i;
        }
        current = -1;
        currentRow.reset(new uint[nKeys + 1]);
    }
开发者ID:LucidDB,项目名称:luciddb_perforce_swimlanes_DONOTFORK,代码行数:26,代码来源:LbmSortedAggExecStreamTest.cpp

示例2: GetMsgParam

inline bool GetMsgParam(const std::string& netmsgbus_msgcontent, boost::shared_array<char>& msgparam, uint32_t& param_len)
{
    std::string msgparamstr;
    if (netmsgbus_msgcontent.length() < SENDER_LEN_BYTES)
      return false;
    uint8_t msgsender_len = (uint8_t)netmsgbus_msgcontent[0];
    if (netmsgbus_msgcontent.length() < SENDER_LEN_BYTES + (std::size_t)msgsender_len + MSGKEY_LEN_BYTES)
      return false;
    uint8_t msgkey_len = (uint8_t)(netmsgbus_msgcontent[SENDER_LEN_BYTES + msgsender_len]);
    uint32_t msgparam_offset = SENDER_LEN_BYTES + msgsender_len + MSGKEY_LEN_BYTES + msgkey_len;
    if (netmsgbus_msgcontent.length() <  msgparam_offset + MSGVALUE_LEN_BYTES)
      return false;

    uint32_t netparam_len = *((uint32_t *)&netmsgbus_msgcontent[msgparam_offset]);
    param_len = ntohl(netparam_len);
    if (netmsgbus_msgcontent.length() < msgparam_offset + MSGVALUE_LEN_BYTES + param_len)
      return false;

    msgparam.reset(new char[param_len]);
    memcpy(msgparam.get(), &netmsgbus_msgcontent[msgparam_offset + MSGVALUE_LEN_BYTES], param_len);
    return true;

    //if(GetMsgKey(netmsgbus_msgcontent, msgparam_str, msgparamstr))
    //{
    //    assert(msgparamstr.size());
    //    msgparam.reset(new char[msgparamstr.size()]);
    //    memcpy(msgparam.get(), msgparamstr.data(), msgparamstr.size());
    //    param_len = msgparamstr.size();
    //    return true;
    //}
    //printf("netmsgbus_msgcontent error, no msgparam found.\n");
    //return false;
}
开发者ID:absolute8511,项目名称:Message-Bus-All-In-One-For-In-Process--Inter-Process-and-Internet,代码行数:33,代码来源:NetMsgBusUtility.hpp

示例3: recv_msg_async

// 0 for received nothing
int recv_msg_async(zmq::socket_t &sock, boost::shared_array<uint8_t> &data)
{
    zmq::message_t msgt;
    int nbytes;
    try{
      nbytes = sock.recv(&msgt, ZMQ_DONTWAIT);
    }catch(zmq::error_t e){
      return -1;
    }

    if(nbytes == 0){
      if(zmq_errno() == EAGAIN)
	return 0;
      else
	return -1;
    }

    size_t len = msgt.size();    
    uint8_t *dataptr;
    try{
      dataptr = new uint8_t[len];
    }catch(std::bad_alloc e){
      return -1;
    }
    
    memcpy(dataptr, msgt.data(), len);
    data.reset(dataptr);
    return len;
}
开发者ID:jinliangwei,项目名称:CommTest,代码行数:30,代码来源:zmq_util.cpp

示例4: recv_msg

/*
 * return number of bytes received, negative if error, 0 for received nothing, which should be treated as error
 */
int recv_msg(zmq::socket_t &sock, boost::shared_array<uint8_t> &data)
{
    zmq::message_t msgt;
    int nbytes;
    try{
      nbytes = sock.recv(&msgt);
    }catch(zmq::error_t e){
      //LOG(NOR, stderr, "recv failed: %s\n", e.what());
      return -1;
    }

    if(nbytes == 0) return 0;

    size_t len = msgt.size();    
    uint8_t *dataptr;
    try{
      dataptr = new uint8_t[len];
    }catch(std::bad_alloc e){
      //LOG(DBG, stderr, "can not allocate memory!\n");
      return -1;
    }
    
    memcpy(dataptr, msgt.data(), len);
    data.reset(dataptr);
    return len;
}
开发者ID:jinliangwei,项目名称:CommTest,代码行数:29,代码来源:zmq_util.cpp

示例5: RecvMsg

  /*
   * return number of bytes received, negative if error, 0 for received nothing,
   *  which should be treated as error
   */
  int32_t RecvMsg(zmq::socket_t &sock, boost::shared_array<uint8_t> &data,
      bool *_more){
    zmq::message_t msgt;
    int nbytes;
    try{
      nbytes = sock.recv(&msgt);
    }catch(zmq::error_t &e){
      LOG(ERROR) << "RecvMsg error = " << e.what();
      return -1;
    }

    if(nbytes == 0) return 0;

    size_t len = msgt.size();    
    uint8_t *dataptr;
    try{
      dataptr = new uint8_t[len];
    }catch(std::bad_alloc &e){
      return -1;
    }
    
    memcpy(dataptr, msgt.data(), len);
    data.reset(dataptr);

    if(_more != NULL){
      int more_recv;
      size_t s = sizeof(int);
      sock.getsockopt(ZMQ_RCVMORE, &more_recv, &s);
      *_more = (more_recv == 1) ? true : false;
    }
    return len;
  }
开发者ID:chonglinsun,项目名称:quiltdb,代码行数:36,代码来源:zmq_util.cpp

示例6: createBuffers

void AsynchIO::createBuffers(uint32_t size) {
    // Allocate all the buffer memory at once
    bufferMemory.reset(new char[size*BufferCount]);

    // Create the Buffer structs in a vector
    // And push into the buffer queue
    buffers.reserve(BufferCount);
    for (uint32_t i = 0; i < BufferCount; i++) {
        buffers.push_back(BufferBase(&bufferMemory[i*size], size));
        queueReadBuffer(&buffers[i]);
    }
}
开发者ID:gregerts,项目名称:debian-qpid-cpp,代码行数:12,代码来源:AsynchIO.cpp

示例7: NormalizerExecStreamGenerator

 NormalizerExecStreamGenerator(
     uint nRows, uint nKeys, std::vector<int> repeatSeqValues)
 {
     this->nKeys = nKeys;
     this->repeatSeqValues = repeatSeqValues;
     interval = LbmExecStreamTestBase::getTupleInterval(repeatSeqValues);
     changeIndexes.reset(new uint[interval]);
     changeIndexes[0] = getValueCount(nRows, interval, 0);
     for (uint i = 1; i < interval; i++) {
         changeIndexes[i] =
             changeIndexes[i - 1] + getValueCount(nRows, interval, i);
     }
     current = 0;
     lastRow = 0;
 }
开发者ID:LucidDB,项目名称:luciddb_perforce_swimlanes_DONOTFORK,代码行数:15,代码来源:LbmNormalizerExecStreamTest.cpp

示例8: read_header

void region::read_header()
{
    header.reset(new char[HEADER_SIZE]);

    std::ifstream fp(path.string().c_str(), std::ios::binary);

    if (fp.fail()) {
      throw std::runtime_error(std::string("file not found (") + path.string() + ")");
    }

    fp.read(header.get(), HEADER_SIZE);

    if (fp.fail()) {
        throw std::runtime_error(std::string("cannot read header (") + path.string() + ")");
    }
}
开发者ID:Cosmotronic,项目名称:hexahedra,代码行数:16,代码来源:robinton_generator.cpp

示例9: write

void Header::write(const M_string& key_vals, boost::shared_array<uint8_t>& buffer, uint32_t& size)
{
    // Calculate the necessary size
    size = 0;
    {
        M_string::const_iterator it = key_vals.begin();
        M_string::const_iterator end = key_vals.end();
        for (; it != end; ++it)
        {
            const std::string& key = it->first;
            const std::string& value = it->second;

            size += key.length();
            size += value.length();
            size += 1; // = sign
            size += 4; // 4-byte length
        }
    }

    if (size == 0)
    {
        return;
    }

    buffer.reset(new uint8_t[size]);
    char* ptr = (char*)buffer.get();

    // Write the data
    {
        M_string::const_iterator it = key_vals.begin();
        M_string::const_iterator end = key_vals.end();
        for (; it != end; ++it)
        {
            const std::string& key = it->first;
            const std::string& value = it->second;

            uint32_t len = key.length() + value.length() + 1;
            SROS_SERIALIZE_PRIMITIVE(ptr, len);
            SROS_SERIALIZE_BUFFER(ptr, key.data(), key.length());
            static const char equals = '=';
            SROS_SERIALIZE_PRIMITIVE(ptr, equals);
            SROS_SERIALIZE_BUFFER(ptr, value.data(), value.length());
        }
    }

    ROS_ASSERT(ptr == (char*)buffer.get() + size);
}
开发者ID:robotambassador,项目名称:robot-ambassadors,代码行数:47,代码来源:header.cpp

示例10: cleanupOpenSSL

void TSSLSocketFactory::cleanupOpenSSL() {
  if (!initialized) {
    return;
  }
  initialized = false;
#if (OPENSSL_VERSION_NUMBER < OPENSSL_VERSION_NO_THREAD_ID)
  CRYPTO_set_id_callback(NULL);
#endif
  CRYPTO_set_locking_callback(NULL);
  CRYPTO_set_dynlock_create_callback(NULL);
  CRYPTO_set_dynlock_lock_callback(NULL);
  CRYPTO_set_dynlock_destroy_callback(NULL);
  CRYPTO_cleanup_all_ex_data();
  ERR_free_strings();
  EVP_cleanup();
  ERR_remove_state(0);
  mutexes.reset();
}
开发者ID:ACher,项目名称:thrift,代码行数:18,代码来源:TSSLSocket.cpp

示例11: image_callback

void kpoBaseApp::image_callback (const boost::shared_ptr<openni_wrapper::Image> &image)
{
    unsigned image_width_ = image->getWidth();
    unsigned image_height_ = image->getHeight();

    static unsigned rgb_array_size = 0;
    static boost::shared_array<unsigned char> rgb_array ((unsigned char*)(NULL));

    static unsigned char* rgb_buffer = 0;

    // here we need exact the size of the point cloud for a one-one correspondence!
    if (rgb_array_size < image_width_ * image_height_ * 3)
    {
      rgb_array_size = image_width_ * image_height_ * 3;
      rgb_array.reset (new unsigned char [rgb_array_size]);
      rgb_buffer = rgb_array.get ();
    }
    image->fillRGB (image_width_, image_height_, rgb_buffer, image_width_ * 3);

    {
        QMutexLocker locker (&mtx_);

        openniImage2opencvMat((XnRGB24Pixel*)rgb_buffer, scene_image_, image_height_, image_width_);

        if (need_image_cap) {
            std::cout << "need_image_cap " << need_image_cap << std::endl;
            cv::Mat rgb_image_;
            cv::cvtColor(scene_image_, rgb_image_, CV_BGR2RGB);

            qint64 timestamp = QDateTime::currentMSecsSinceEpoch();
            if (timestamp - last_snapshot_time > 30000) {
                last_snapshot_time = timestamp;
                QString filename = QString::fromUtf8("/myshare/autonomous_snapshots/");
                filename += QString::number(timestamp);
                filename += QString::fromUtf8(".png");

                cv::imwrite(filename.toStdString().c_str(), rgb_image_);
                need_image_cap = 0;
            }
        }
    }

}
开发者ID:jbeuckm,项目名称:kinect_pcl_osc_qt,代码行数:43,代码来源:kpoBaseApp.cpp

示例12: initialise

void initialise()
{
	open_console_wnd();
	
	// Initialise the memory pool 
	c_cuda_mem_pool& mem_pool = c_cuda_mem_pool::get_instance(); 
	mem_pool.initialise(256*1024*1024, 256*1024);

	// Device memory 
	g_rands = new c_randoms_chunk(g_size); 
	g_rands->alloc_device_memory(); 

	// Host memory
	h_rands.reset(new float[g_size]);

	// Init CUDA MT
	srand(1337); 
	c_cuda_rng& rng = c_cuda_rng::get_instance();
	bool ret = rng.init(mt_dat_file); 
	assert(ret); 
	ret = rng.seed(1337);
	assert(ret); 
}
开发者ID:stevegocoding,项目名称:yart_gpu,代码行数:23,代码来源:test_mt.cpp

示例13: RecvMsgAsync

  // 0 for received nothing
  int32_t RecvMsgAsync(zmq::socket_t &sock, boost::shared_array<uint8_t> &data,
      bool *_more){
    zmq::message_t msgt;
    int nbytes;
    try{
      nbytes = sock.recv(&msgt, ZMQ_DONTWAIT);
    }catch(zmq::error_t &e){
      return -1;
    }

    if(nbytes == 0){
      if(zmq_errno() == EAGAIN)
        return 0;
      else
        return -1;
    }

    size_t len = msgt.size();
    uint8_t *dataptr;
    try{
      dataptr = new uint8_t[len];
    }catch(std::bad_alloc &e){
      return -1;
    }
    memcpy(dataptr, msgt.data(), len);
    data.reset(dataptr);

    if(_more != NULL){
      int more_recv;
      size_t s = sizeof(int);
      sock.getsockopt(ZMQ_RCVMORE, &more_recv, &s);
      *_more = (more_recv == 1) ? true : false;
    }

    return len;
  }
开发者ID:chonglinsun,项目名称:quiltdb,代码行数:37,代码来源:zmq_util.cpp

示例14: cloud

pcl::PointCloud<pcl::PointXYZ>::Ptr
pcl::OpenNIGrabber::convertToXYZPointCloud (const boost::shared_ptr<openni_wrapper::DepthImage>& depth_image) const
{
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud <pcl::PointXYZ>);

  cloud->height = depth_height_;
  cloud->width = depth_width_;
  cloud->is_dense = false;

  cloud->points.resize (cloud->height * cloud->width);

  register float constant = 1.0f / device_->getDepthFocalLength (depth_width_);

  if (device_->isDepthRegistered ())
    cloud->header.frame_id = rgb_frame_id_;
  else
    cloud->header.frame_id = depth_frame_id_;

  register int centerX = (cloud->width >> 1);
  int centerY = (cloud->height >> 1);

  float bad_point = std::numeric_limits<float>::quiet_NaN ();

  // we have to use Data, since operator[] uses assert -> Debug-mode very slow!
  register const unsigned short* depth_map = depth_image->getDepthMetaData ().Data ();
  if (depth_image->getWidth() != depth_width_ || depth_image->getHeight () != depth_height_)
  {
    static unsigned buffer_size = 0;
    static boost::shared_array<unsigned short> depth_buffer (0);

    if (buffer_size < depth_width_ * depth_height_)
    {
      buffer_size = depth_width_ * depth_height_;
      depth_buffer.reset (new unsigned short [buffer_size]);
    }
    depth_image->fillDepthImageRaw (depth_width_, depth_height_, depth_buffer.get ());
    depth_map = depth_buffer.get ();
  }

  register int depth_idx = 0;
  for (int v = -centerY; v < centerY; ++v)
  {
    for (register int u = -centerX; u < centerX; ++u, ++depth_idx)
    {
      pcl::PointXYZ& pt = cloud->points[depth_idx];
      // Check for invalid measurements
      if (depth_map[depth_idx] == 0 ||
          depth_map[depth_idx] == depth_image->getNoSampleValue () ||
          depth_map[depth_idx] == depth_image->getShadowValue ())
      {
        // not valid
        pt.x = pt.y = pt.z = bad_point;
        continue;
      }
      pt.z = depth_map[depth_idx] * 0.001f;
      pt.x = static_cast<float> (u) * pt.z * constant;
      pt.y = static_cast<float> (v) * pt.z * constant;
    }
  }
  cloud->sensor_origin_.setZero ();
  cloud->sensor_orientation_.w () = 0.0f;
  cloud->sensor_orientation_.x () = 1.0f;
  cloud->sensor_orientation_.y () = 0.0f;
  cloud->sensor_orientation_.z () = 0.0f;  
  return (cloud);
}
开发者ID:Bardo91,项目名称:pcl,代码行数:66,代码来源:openni_grabber.cpp

示例15:

 ~raw_buffer() {
     data.reset();
 }
开发者ID:monpetit,项目名称:dogma-snippets,代码行数:3,代码来源:raw_buffer.cpp


注:本文中的boost::shared_array::reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。