Program Listing for File buffer.h

Return to documentation for file (rc_genicam_api/buffer.h)

/*
 * This file is part of the rc_genicam_api package.
 *
 * Copyright (c) 2017 Roboception GmbH
 * All rights reserved
 *
 * Author: Heiko Hirschmueller
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * 3. Neither the name of the copyright holder nor the names of its contributors
 * may be used to endorse or promote products derived from this software without
 * specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef RC_GENICAM_API_BUFFER
#define RC_GENICAM_API_BUFFER

#include <GenApi/GenApi.h>
#include <GenApi/ChunkAdapter.h>

#include <memory>
#include <string>

namespace rcg
{

class Stream;
class GenTLWrapper;

enum PAYLOADTYPE_INFO_IDS
{
  PAYLOAD_TYPE_UNKNOWN         =  0,   /* GenTL v1.2 */
  PAYLOAD_TYPE_IMAGE           =  1,   /* GenTL v1.2 */
  PAYLOAD_TYPE_RAW_DATA        =  2,   /* GenTL v1.2 */
  PAYLOAD_TYPE_FILE            =  3,   /* GenTL v1.2 */
  PAYLOAD_TYPE_CHUNK_DATA      =  4,   /* GenTL v1.2, Deprecated in GenTL 1.5*/
  PAYLOAD_TYPE_JPEG            =  5,   /* GenTL v1.4 */
  PAYLOAD_TYPE_JPEG2000        =  6,   /* GenTL v1.4 */
  PAYLOAD_TYPE_H264            =  7,   /* GenTL v1.4 */
  PAYLOAD_TYPE_CHUNK_ONLY      =  8,   /* GenTL v1.4 */
  PAYLOAD_TYPE_DEVICE_SPECIFIC =  9,   /* GenTL v1.4 */
  PAYLOAD_TYPE_MULTI_PART      =  10,  /* GenTL v1.5 */

  PAYLOAD_TYPE_CUSTOM_ID       = 1000  /* Starting value for GenTL Producer custom IDs. */
};

enum PIXELFORMAT_NAMESPACE_IDS
{
  PIXELFORMAT_NAMESPACE_UNKNOWN      = 0,   /* GenTL v1.2 */
  PIXELFORMAT_NAMESPACE_GEV          = 1,   /* GenTL v1.2 */
  PIXELFORMAT_NAMESPACE_IIDC         = 2,   /* GenTL v1.2 */
  PIXELFORMAT_NAMESPACE_PFNC_16BIT   = 3,   /* GenTL v1.4 */
  PIXELFORMAT_NAMESPACE_PFNC_32BIT   = 4,   /* GenTL v1.4 */

  PIXELFORMAT_NAMESPACE_CUSTOM_ID    = 1000 /* Starting value for GenTL Producer custom IDs. */
};

enum PARTDATATYPE_IDS
{
  PART_DATATYPE_UNKNOWN              =  0,   /* Unknown data type */
  PART_DATATYPE_2D_IMAGE             =  1,   /* Color or monochrome 2D image. */
  PART_DATATYPE_2D_PLANE_BIPLANAR    =  2,   /* Single color plane of a planar 2D image consisting of 2 planes. */
  PART_DATATYPE_2D_PLANE_TRIPLANAR   =  3,   /* Single color plane of a planar 2D image consisting of 3 planes. */
  PART_DATATYPE_2D_PLANE_QUADPLANAR  =  4,   /* Single color plane of a planar 2D image consisting of 4 planes. */
  PART_DATATYPE_3D_IMAGE             =  5,   /* 3D image (pixel coordinates). */
  PART_DATATYPE_3D_PLANE_BIPLANAR    =  6,   /* Single plane of a planar 3D image consisting of 2 planes. */
  PART_DATATYPE_3D_PLANE_TRIPLANAR   =  7,   /* Single plane of a planar 3D image consisting of 3 planes. */
  PART_DATATYPE_3D_PLANE_QUADPLANAR  =  8,   /* Single plane of a planar 3D image consisting of 4 planes. */
  PART_DATATYPE_CONFIDENCE_MAP       =  9,   /* Confidence of the individual pixel values. */
  PART_DATATYPE_CHUNKDATA            = 10,   /* Chunk data type */

  PART_DATATYPE_CUSTOM_ID            = 1000  /* Starting value for GenTL Producer custom IDs. */
};

class Buffer
{
  public:

    Buffer(const std::shared_ptr<const GenTLWrapper> &gentl, Stream *parent);
    ~Buffer();

    void setNodemap(const std::shared_ptr<GenApi::CNodeMapRef> nodemap, const std::string &tltype);

    void setHandle(void *handle);

    uint32_t getNumberOfParts() const;

    void *getGlobalBase() const;

    size_t getGlobalSize() const;

    void *getBase(uint32_t part) const;

    size_t getSize(uint32_t part) const;

    void *getUserPtr() const;

    uint64_t getTimestamp() const;

    bool getNewData() const;

    bool getIsQueued() const;

    bool getIsAcquiring() const;

    bool getIsIncomplete() const;

    std::string getTLType() const;

    size_t getSizeFilled() const;

    size_t getPartDataType(uint32_t part) const;

    size_t getWidth(uint32_t part) const;

    size_t getHeight(uint32_t part) const;

    size_t getXOffset(uint32_t part) const;

    size_t getYOffset(uint32_t part) const;

    size_t getXPadding(uint32_t part) const;

    size_t getYPadding() const;

    uint64_t getFrameID() const;

    bool getImagePresent(uint32_t part) const;

    size_t getPayloadType() const;

    uint64_t getPixelFormat(uint32_t part) const;

    uint64_t getPixelFormatNamespace(uint32_t part) const;

    uint64_t getPartSourceID(uint32_t part) const;

    uint64_t getPartRegionID(uint32_t part) const;

    uint64_t getPartDataPurposeID(uint32_t part) const;

    size_t getDeliveredImageHeight(uint32_t part) const;

    size_t getDeliveredChunkPayloadSize() const;

    uint64_t getChunkLayoutID() const;

    std::string getFilename() const;

    bool isBigEndian() const;

    size_t getDataSize() const;

    uint64_t getTimestampNS() const;

    bool getDataLargerThanBuffer() const;

    bool getContainsChunkdata() const;

    void *getHandle() const;

  private:

    Buffer(class Buffer &); // forbidden
    Buffer &operator=(const Buffer &); // forbidden

    Stream *parent;
    std::shared_ptr<const GenTLWrapper> gentl;
    void *buffer;
    size_t payload_type;
    bool multipart;

    std::shared_ptr<GenApi::CNodeMapRef> nodemap;
    std::shared_ptr<GenApi::CChunkAdapter> chunkadapter;
};

bool isHostBigEndian();

}

#endif