| AAX SDK 2.6.1 Avid Audio Extensions Development Kit

- Welcome
- Manual
- Classes
- Files
- Lists
- Support

- File List
- File Members

Loading...
Searching...
No Matches
AAX_CArrayDataBuffer.h
Go to the documentation of this file.
1/*================================================================================================*/
2/*
3 *
4 * Copyright 2023 Avid Technology, Inc.
5 * All rights reserved.
6 *
7 * CONFIDENTIAL: this document contains confidential information of Avid. Do
8 * not disclose to any third party. Use of the information contained in this
9 * document is subject to an Avid SDK license.
10 *
11 */
12
16/*================================================================================================*/
17
18#pragma once
19
20#ifndef AAX_CArrayDataBuffer_H
21#define AAX_CArrayDataBuffer_H
22
23#include "AAX_IDataBuffer.h"
24#include "AAX.h"
25
26#include <string>
27#include <limits>
28#include <type_traits>
29
30
36 template <AAX_CTypeID T, class D>
37 class AAX_CArrayDataBufferOfType : public AAX_IDataBuffer
38{
39 public:
40 explicit AAX_CArrayDataBufferOfType (std::vector<D> const & inData) : mData{inData} {}
41 explicit AAX_CArrayDataBufferOfType (std::vector<D> && inData) : mData{inData} {}
42
43 AAX_CArrayDataBufferOfType(AAX_CArrayDataBufferOfType const &) = default;
44 AAX_CArrayDataBufferOfType(AAX_CArrayDataBufferOfType &&) = default;
45
46 ~AAX_CArrayDataBufferOfType (void) AAX_OVERRIDE = default;
47
48 AAX_CArrayDataBufferOfType& operator= (AAX_CArrayDataBufferOfType const & other) = default;
49 AAX_CArrayDataBufferOfType& operator= (AAX_CArrayDataBufferOfType && other) = default;
50
51 AAX_Result Type(AAX_CTypeID * oType) const AAX_OVERRIDE {
52 if (!oType) { return AAX_ERROR_NULL_ARGUMENT; }
53 *oType = T;
54 return AAX_SUCCESS;
55 }
56 AAX_Result Size(int32_t * oSize) const AAX_OVERRIDE {
57 if (!oSize) { return AAX_ERROR_NULL_ARGUMENT; }
58 auto const size = mData.size() * sizeof(D);
59 static_assert(std::numeric_limits<decltype(size)>::max() >= std::numeric_limits<std::remove_pointer<decltype(oSize)>::type>::max(),
60 "size variable may not represent all positive values of oSize");
61 if (size > std::numeric_limits<std::remove_pointer<decltype(oSize)>::type>::max()) {
62 return AAX_ERROR_SIGNED_INT_OVERFLOW;
63 }
64 *oSize = static_cast<std::remove_pointer<decltype(oSize)>::type>(size);
65 return AAX_SUCCESS;
66 }
67 AAX_Result Data(void const ** oBuffer) const AAX_OVERRIDE {
68 if (!oBuffer) { return AAX_ERROR_NULL_ARGUMENT; }
69 *oBuffer = mData.data();
70 return AAX_SUCCESS;
71 }
72 private:
73 std::vector<D> const mData;
74};
75
79 template <class D>
80 class AAX_CArrayDataBuffer : public AAX_IDataBuffer
81{
82 public:
83 AAX_CArrayDataBuffer (AAX_CTypeID inType, std::vector<D> const & inData) : mType{inType}, mData{inData} {}
84 AAX_CArrayDataBuffer (AAX_CTypeID inType, std::vector<D> && inData) : mType{inType}, mData{inData} {}
85
86 AAX_CArrayDataBuffer(AAX_CArrayDataBuffer const &) = default;
87 AAX_CArrayDataBuffer(AAX_CArrayDataBuffer &&) = default;
88
89 ~AAX_CArrayDataBuffer (void) AAX_OVERRIDE = default;
90
91 AAX_CArrayDataBuffer& operator= (AAX_CArrayDataBuffer const & other) = default;
92 AAX_CArrayDataBuffer& operator= (AAX_CArrayDataBuffer && other) = default;
93
94 AAX_Result Type(AAX_CTypeID * oType) const AAX_OVERRIDE {
95 if (!oType) { return AAX_ERROR_NULL_ARGUMENT; }
96 *oType = mType;
97 return AAX_SUCCESS;
98 }
99 AAX_Result Size(int32_t * oSize) const AAX_OVERRIDE {
100 if (!oSize) { return AAX_ERROR_NULL_ARGUMENT; }
101 auto const size = mData.size() * sizeof(D);
102 static_assert(std::numeric_limits<decltype(size)>::max() >= std::numeric_limits<std::remove_pointer<decltype(oSize)>::type>::max(),
103 "size variable may not represent all positive values of oSize");
104 if (size > std::numeric_limits<std::remove_pointer<decltype(oSize)>::type>::max()) {
105 return AAX_ERROR_SIGNED_INT_OVERFLOW;
106 }
107 *oSize = static_cast<std::remove_pointer<decltype(oSize)>::type>(size);
108 return AAX_SUCCESS;
109 }
110 AAX_Result Data(void const ** oBuffer) const AAX_OVERRIDE {
111 if (!oBuffer) { return AAX_ERROR_NULL_ARGUMENT; }
112 *oBuffer = mData.data();
113 return AAX_SUCCESS;
114 }
115 private:
116 AAX_CTypeID const mType;
117 std::vector<D> const mData;
118};
119
120#endif
AAX_ERROR_SIGNED_INT_OVERFLOW
@ AAX_ERROR_SIGNED_INT_OVERFLOW
Definition: AAX_Errors.h:70
AAX_ERROR_NULL_ARGUMENT
@ AAX_ERROR_NULL_ARGUMENT
One or more required pointer arguments are null.
Definition: AAX_Errors.h:81
AAX_SUCCESS
@ AAX_SUCCESS
Definition: AAX_Errors.h:36
AAX.h
Various utility definitions for AAX.
AAX_Result
int32_t AAX_Result
Definition: AAX.h:334
AAX_CTypeID
uint32_t AAX_CTypeID
Matches type of OSType used in classic plugins.
Definition: AAX.h:333
AAX_IDataBuffer.h
AAX_CArrayDataBufferOfType
A convenience class for array data buffers.
Definition: AAX_CArrayDataBuffer.h:38
AAX_CArrayDataBufferOfType::~AAX_CArrayDataBufferOfType
~AAX_CArrayDataBufferOfType(void) AAX_OVERRIDE=default
AAX_CArrayDataBufferOfType::Size
AAX_Result Size(int32_t *oSize) const AAX_OVERRIDE
Definition: AAX_CArrayDataBuffer.h:56
AAX_CArrayDataBufferOfType::AAX_CArrayDataBufferOfType
AAX_CArrayDataBufferOfType(AAX_CArrayDataBufferOfType &&)=default
AAX_CArrayDataBufferOfType::AAX_CArrayDataBufferOfType
AAX_CArrayDataBufferOfType(std::vector< D > const &inData)
Definition: AAX_CArrayDataBuffer.h:40
AAX_CArrayDataBufferOfType::AAX_CArrayDataBufferOfType
AAX_CArrayDataBufferOfType(AAX_CArrayDataBufferOfType const &)=default
AAX_CArrayDataBufferOfType::Type
AAX_Result Type(AAX_CTypeID *oType) const AAX_OVERRIDE
Definition: AAX_CArrayDataBuffer.h:51
AAX_CArrayDataBufferOfType::Data
AAX_Result Data(void const **oBuffer) const AAX_OVERRIDE
Definition: AAX_CArrayDataBuffer.h:67
AAX_CArrayDataBufferOfType::operator=
AAX_CArrayDataBufferOfType & operator=(AAX_CArrayDataBufferOfType const &other)=default
AAX_CArrayDataBufferOfType::AAX_CArrayDataBufferOfType
AAX_CArrayDataBufferOfType(std::vector< D > &&inData)
Definition: AAX_CArrayDataBuffer.h:41
AAX_CArrayDataBuffer
Definition: AAX_CArrayDataBuffer.h:81
AAX_CArrayDataBuffer::Size
AAX_Result Size(int32_t *oSize) const AAX_OVERRIDE
Definition: AAX_CArrayDataBuffer.h:99
AAX_CArrayDataBuffer::Data
AAX_Result Data(void const **oBuffer) const AAX_OVERRIDE
Definition: AAX_CArrayDataBuffer.h:110
AAX_CArrayDataBuffer::operator=
AAX_CArrayDataBuffer & operator=(AAX_CArrayDataBuffer const &other)=default
AAX_CArrayDataBuffer::~AAX_CArrayDataBuffer
~AAX_CArrayDataBuffer(void) AAX_OVERRIDE=default
AAX_CArrayDataBuffer::Type
AAX_Result Type(AAX_CTypeID *oType) const AAX_OVERRIDE
Definition: AAX_CArrayDataBuffer.h:94
AAX_CArrayDataBuffer::AAX_CArrayDataBuffer
AAX_CArrayDataBuffer(AAX_CArrayDataBuffer const &)=default
AAX_CArrayDataBuffer::AAX_CArrayDataBuffer
AAX_CArrayDataBuffer(AAX_CArrayDataBuffer &&)=default
AAX_CArrayDataBuffer::AAX_CArrayDataBuffer
AAX_CArrayDataBuffer(AAX_CTypeID inType, std::vector< D > const &inData)
Definition: AAX_CArrayDataBuffer.h:83
AAX_CArrayDataBuffer::AAX_CArrayDataBuffer
AAX_CArrayDataBuffer(AAX_CTypeID inType, std::vector< D > &&inData)
Definition: AAX_CArrayDataBuffer.h:84
AAX_IDataBuffer
Interface for reference counted data buffers.
Definition: AAX_IDataBuffer.h:37
AAX_IDataBuffer::AAX_OVERRIDE
void **ppvObjOut AAX_OVERRIDE
Definition: AAX_IDataBuffer.h:42