AAX SDK 2.8.0
Avid Audio Extensions Development Kit
Loading...
Searching...
No Matches
AAX_CArrayDataBuffer.h
Go to the documentation of this file.
1/*================================================================================================*/
2/*
3 *
4 * Copyright 2023-2024 Avid Technology, Inc.
5 * All rights reserved.
6 *
7 * This file is part of the Avid AAX SDK.
8 *
9 * The AAX SDK is subject to commercial or open-source licensing.
10 *
11 * By using the AAX SDK, you agree to the terms of both the Avid AAX SDK License
12 * Agreement and Avid Privacy Policy.
13 *
14 * AAX SDK License: https://developer.avid.com/aax
15 * Privacy Policy: https://www.avid.com/legal/privacy-policy-statement
16 *
17 * Or: You may also use this code under the terms of the GPL v3 (see
18 * www.gnu.org/licenses).
19 *
20 * THE AAX SDK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21 * EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22 * DISCLAIMED.
23 *
24 */
25
29/*================================================================================================*/
30
31#pragma once
32
33#ifndef AAX_CArrayDataBuffer_H
34#define AAX_CArrayDataBuffer_H
35
36#include "AAX_IDataBuffer.h"
37#include "AAX.h"
38
39#include <string>
40#include <limits>
41#include <type_traits>
42
43
49template <AAX_CTypeID T, class D>
51{
52public:
53 explicit AAX_CArrayDataBufferOfType (std::vector<D> const & inData) : mData{inData} {}
54 explicit AAX_CArrayDataBufferOfType (std::vector<D> && inData) : mData{inData} {}
55
58
60
63
65 if (!oType) { return AAX_ERROR_NULL_ARGUMENT; }
66 *oType = T;
67 return AAX_SUCCESS;
68 }
69 AAX_Result Size(int32_t * oSize) const AAX_OVERRIDE {
70 if (!oSize) { return AAX_ERROR_NULL_ARGUMENT; }
71 auto const size = mData.size() * sizeof(D);
72 static_assert(std::numeric_limits<decltype(size)>::max() >= std::numeric_limits<std::remove_pointer<decltype(oSize)>::type>::max(),
73 "size variable may not represent all positive values of oSize");
74 if (size > std::numeric_limits<std::remove_pointer<decltype(oSize)>::type>::max()) {
76 }
77 *oSize = static_cast<std::remove_pointer<decltype(oSize)>::type>(size);
78 return AAX_SUCCESS;
79 }
80 AAX_Result Data(void const ** oBuffer) const AAX_OVERRIDE {
81 if (!oBuffer) { return AAX_ERROR_NULL_ARGUMENT; }
82 *oBuffer = mData.data();
83 return AAX_SUCCESS;
84 }
85private:
86 std::vector<D> const mData;
87};
88
92template <class D>
94{
95public:
96 AAX_CArrayDataBuffer (AAX_CTypeID inType, std::vector<D> const & inData) : mType{inType}, mData{inData} {}
97 AAX_CArrayDataBuffer (AAX_CTypeID inType, std::vector<D> && inData) : mType{inType}, mData{inData} {}
98
101
103
106
108 if (!oType) { return AAX_ERROR_NULL_ARGUMENT; }
109 *oType = mType;
110 return AAX_SUCCESS;
111 }
112 AAX_Result Size(int32_t * oSize) const AAX_OVERRIDE {
113 if (!oSize) { return AAX_ERROR_NULL_ARGUMENT; }
114 auto const size = mData.size() * sizeof(D);
115 static_assert(std::numeric_limits<decltype(size)>::max() >= std::numeric_limits<std::remove_pointer<decltype(oSize)>::type>::max(),
116 "size variable may not represent all positive values of oSize");
117 if (size > std::numeric_limits<std::remove_pointer<decltype(oSize)>::type>::max()) {
119 }
120 *oSize = static_cast<std::remove_pointer<decltype(oSize)>::type>(size);
121 return AAX_SUCCESS;
122 }
123 AAX_Result Data(void const ** oBuffer) const AAX_OVERRIDE {
124 if (!oBuffer) { return AAX_ERROR_NULL_ARGUMENT; }
125 *oBuffer = mData.data();
126 return AAX_SUCCESS;
127 }
128private:
129 AAX_CTypeID const mType;
130 std::vector<D> const mData;
131};
132
133#endif
@ AAX_ERROR_SIGNED_INT_OVERFLOW
Definition: AAX_Errors.h:83
@ AAX_ERROR_NULL_ARGUMENT
One or more required pointer arguments are null.
Definition: AAX_Errors.h:94
@ AAX_SUCCESS
Definition: AAX_Errors.h:49
Various utility definitions for AAX.
int32_t AAX_Result
Definition: AAX.h:347
uint32_t AAX_CTypeID
Matches type of OSType used in classic plugins.
Definition: AAX.h:346
A convenience class for array data buffers.
Definition: AAX_CArrayDataBuffer.h:51
~AAX_CArrayDataBufferOfType(void) AAX_OVERRIDE=default
AAX_Result Size(int32_t *oSize) const AAX_OVERRIDE
Definition: AAX_CArrayDataBuffer.h:69
AAX_CArrayDataBufferOfType(AAX_CArrayDataBufferOfType &&)=default
AAX_CArrayDataBufferOfType(std::vector< D > const &inData)
Definition: AAX_CArrayDataBuffer.h:53
AAX_CArrayDataBufferOfType(AAX_CArrayDataBufferOfType const &)=default
AAX_Result Type(AAX_CTypeID *oType) const AAX_OVERRIDE
Definition: AAX_CArrayDataBuffer.h:64
AAX_Result Data(void const **oBuffer) const AAX_OVERRIDE
Definition: AAX_CArrayDataBuffer.h:80
AAX_CArrayDataBufferOfType & operator=(AAX_CArrayDataBufferOfType const &other)=default
AAX_CArrayDataBufferOfType(std::vector< D > &&inData)
Definition: AAX_CArrayDataBuffer.h:54
Definition: AAX_CArrayDataBuffer.h:94
AAX_Result Size(int32_t *oSize) const AAX_OVERRIDE
Definition: AAX_CArrayDataBuffer.h:112
AAX_Result Data(void const **oBuffer) const AAX_OVERRIDE
Definition: AAX_CArrayDataBuffer.h:123
AAX_CArrayDataBuffer & operator=(AAX_CArrayDataBuffer const &other)=default
~AAX_CArrayDataBuffer(void) AAX_OVERRIDE=default
AAX_Result Type(AAX_CTypeID *oType) const AAX_OVERRIDE
Definition: AAX_CArrayDataBuffer.h:107
AAX_CArrayDataBuffer(AAX_CArrayDataBuffer const &)=default
AAX_CArrayDataBuffer(AAX_CArrayDataBuffer &&)=default
AAX_CArrayDataBuffer(AAX_CTypeID inType, std::vector< D > const &inData)
Definition: AAX_CArrayDataBuffer.h:96
AAX_CArrayDataBuffer(AAX_CTypeID inType, std::vector< D > &&inData)
Definition: AAX_CArrayDataBuffer.h:97
Interface for reference counted data buffers.
Definition: AAX_IDataBuffer.h:50
void **ppvObjOut AAX_OVERRIDE
Definition: AAX_IDataBuffer.h:55