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


C++ DCBuffer::getPtr方法代码示例

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


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

示例1: malloc

DCBuffer * DCFilter::readany(std::string *exceptionPorts, int numExc, std::string * port) {
	char *inPortName;
	int i;

	// Reads the data using Anthill
	char **c_exceptionPorts = (char **) malloc(numExc);
	for(i = 0; i < numExc; i++) {
		c_exceptionPorts[i] = (char *) (exceptionPorts[i]).c_str();
	}
	int bufSz = dsReadBufferAnyPort(&inPortName, c_exceptionPorts, numExc, recvBuf->getBufPtr(), recvBuf->getSize());

	if(port != NULL)
		*port = inPortName;

	if (bufSz != EOW) {
		// Pack the data in a DCBuffer
		DCBuffer * dcBuf = new DCBuffer(bufSz);
		memcpy(dcBuf->getPtr(), recvBuf->getBufPtr(), bufSz);
		dcBuf->setUsedSize(bufSz);
		return dcBuf;
	}

	// Received an EOW. There isn't more data to be received.
	return NULL;
}
开发者ID:barroca,项目名称:Anthill,代码行数:25,代码来源:api_cpp.cpp

示例2: dsGetInputPortByName

// Returns NULL or non-NULL, depending on if anything is available or not
// when it is called.
DCBuffer * DCFilter::read_non_blocking(const std::string & portName) {
	// Gets Anthill input port handler
	InputPortHandler inPort = dsGetInputPortByName((char *) portName.c_str());

	if(inPort == -1) {
		string exitMsg = "read_non_blocking: There is no port "+portName+" in filter "+get_filter_name();
		dsExit((char *)exitMsg.c_str());
	}

	// Reads the data using Anthill
	int bufSz = dsReadNonBlockingBuffer(inPort, recvBuf->getBufPtr(), recvBuf->getSize());

	if (bufSz == 0) {
		// There is no data to be received now.
		return NULL;
	}

	if (bufSz != EOW) {
		// Pack the data in a DCBuffer
		DCBuffer * dcBuf = new DCBuffer(bufSz);
		memcpy(dcBuf->getPtr(), recvBuf->getBufPtr(), bufSz);
		dcBuf->setUsedSize(bufSz);
		return dcBuf;
	}

	// Received an EOW. There isn't more data to be received.
	return NULL;
}
开发者ID:barroca,项目名称:Anthill,代码行数:30,代码来源:api_cpp.cpp

示例3: process

 int process()
 {
     int i;
     int j;
     DCBuffer * work = get_init_filter_broadcast();
     std::string packet_size_and_num_packets;
     work->Extract(& packet_size_and_num_packets);
     std::vector<std::string> toks =
         dcmpi_string_tokenize(packet_size_and_num_packets);
     int num_packets = dcmpi_csnum(toks[1]);
     for (i = 0; i < num_packets; i++) {
         DCBuffer * b = readany();
         char * p = b->getPtr();
         for (j = 0; j < b->getUsedSize(); j++) {
             char expected = (char)(j%256);
             if (p[j] != expected) {
                 sleep(2);
                 std::cerr << "ERROR: expecting " << (int)expected
                           << ", got " << (int)p[j]
                           << ", j=" << j
                           << " at " << __FILE__ << ":" << __LINE__
                           << std::endl << std::flush;
                 std::cerr << *b;
                 // b->extended_print(cerr);
                 assert(0);
             }
         }
         b->consume();
         printf(".");
         fflush(stdout);
     }
     printf("\n");
     return 0;
 }
开发者ID:vijayskumar,项目名称:dcmpi,代码行数:34,代码来源:memfilters.cpp

示例4: void_to_dcbuffer

DCBuffer* void_to_dcbuffer(void *buf, int bufSz) {
	DCBuffer * dcBuf = new DCBuffer(bufSz);
	memcpy(dcBuf->getPtr(), buf, bufSz);
	dcBuf->setUsedSize(bufSz);
	return dcBuf;
}
开发者ID:barroca,项目名称:Anthill,代码行数:6,代码来源:api_cpp.cpp

示例5: do_tess

void ocvm_tessellator::do_tess(DCBuffer * input)
{
    int4 sentinel;
    int8 width, height;
    int4 x, y, z;
    uint1 threshold;
    int4 color;
    input->unpack("iBlliiii", &sentinel, &threshold,
                  &width, &height, &x, &y, &z,
                  &color);
    const int hdrsz = 64;
    input->resetExtract(hdrsz);
    int8 cells_per_row = width / user_tessellation_x;
    if (width % user_tessellation_x) {
        cells_per_row++;
    }
    int8 total_cell_rows = height / user_tessellation_y;
    if (height % user_tessellation_y) {
        total_cell_rows++;
    }
    int new_sz = cells_per_row * total_cell_rows*sizeof(ocvm_sum_integer_type);
    DCBuffer * out = new DCBuffer(
        hdrsz + new_sz);
    memset(out->getPtr(), 0, hdrsz + new_sz);
    out->pack("iBlliiii", sentinel, threshold, cells_per_row, total_cell_rows,
              x, y, z, color);
//     std::cout << "tessellation: active on x,y,z of "
//               << x << "," << y << "," << z << ", color " << color
//               << " on host " << dcmpi_get_hostname(true) << endl;
    out->setUsedSize(hdrsz + new_sz);
    uint1 * src_base = (uint1*)input->getPtrExtract();
    uint1 * src = src_base;
    uint1 * src_end = src_base + width * height;
    ocvm_sum_integer_type * dest = (ocvm_sum_integer_type*)(out->getPtr()+hdrsz);
    ocvm_sum_integer_type * dest_end = (ocvm_sum_integer_type*)((char*)dest + new_sz);
    register ocvm_sum_integer_type count;
    int8 input_rows_covered = 0;
    int cell, cell_member;
    while (input_rows_covered < height) {
        assert (dest < dest_end);
        uint1 * row_end = src + width;
        for (cell = 0; cell < cells_per_row; cell++) {
            memcpy(&count, dest + cell, sizeof(ocvm_sum_integer_type));
            for (cell_member = 0;
                 cell_member < user_tessellation_x && src < row_end;
                 cell_member++) {
                count += *src;
                src++;
            }
            memcpy(dest + cell, &count, sizeof(ocvm_sum_integer_type));
        }
        input_rows_covered++;
        if (input_rows_covered % user_tessellation_y == 0) {
            dest += cells_per_row;
        }
    }
//     cout << "te2: " << *out << endl;
//     std::cout << "tess sending out ";
//     out->extended_print(cout);
    write_nocopy(out, "0");
    delete input;
}
开发者ID:vijayskumar,项目名称:bigdata-virtual-microscope,代码行数:62,代码来源:f-tessellator.cpp

示例6: process

int ocvm_dim_writer::process()
{
    std::string output_directory;
    int x1, y1, x2, y2, z;
    int i, j;
    DCBuffer * in;
    const char * mode;
    //while (1) {
        //in = read_until_upstream_exit("0");
        in = read("0");
        //if (!in) {
        //    break;
        //}
        in->unpack("siiiii", 
                   &output_directory, &x1, &y1,
                   &x2, &y2, &z);
        in->consume();
//         cout << "dimwriter on " << dcmpi_get_hostname()
//              << ": writing to "
//              << output_filename << endl;
        std::string containing_dir = dcmpi_file_dirname(output_directory);
        if (!dcmpi_file_exists(containing_dir)) {
            if (dcmpi_mkdir_recursive(containing_dir)) {
                std::cerr << "ERROR: making directories on "
                          << dcmpi_get_hostname()
                          << " at " << __FILE__ << ":" << __LINE__
                          << std::endl << std::flush;
            }
        }
        assert(dcmpi_file_exists(containing_dir));

        FILE * f;
        mode = "w";

        for (i = y1; i <= y2; i++) {
            for (j = x1; j <= x2; j++) {
                std::string output_filename = output_directory + tostr(j) + "_" + tostr(i) + "_0";
                if ((f = fopen(output_filename.c_str(), mode)) == NULL) {
                    std::cerr << "ERROR: opening " << output_filename
                              << " for mode " << mode
                              << " on host " << dcmpi_get_hostname()
                              << " at " << __FILE__ << ":" << __LINE__
                              << std::endl << std::flush;
                    exit(1);
                }

                in = read("0");
                if (compress) {
                    in->decompress();
                }

                if (fwrite(in->getPtr(), in->getUsedSize(), 1, f) < 1) {
                    std::cerr << "ERROR: calling fwrite()"
                              << " at " << __FILE__ << ":" << __LINE__
                              << std::endl << std::flush;
                    exit(1);
                }

                in->consume();
                
                if (fclose(f) != 0) {
                    std::cerr << "ERROR: calling fclose()"
                              << " at " << __FILE__ << ":" << __LINE__
                              << std::endl << std::flush;
                    exit(1);
                }
            }
        }

    //}
    return 0;
}
开发者ID:vijayskumar,项目名称:bigdata-virtual-microscope,代码行数:72,代码来源:f-dimwriter.cpp


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