| AAX SDK 2.8.0 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-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
49 template <AAX_CTypeID T, class D>
50 class AAX_CArrayDataBufferOfType : public AAX_IDataBuffer
51{
52 public:
53 explicit AAX_CArrayDataBufferOfType (std::vector<D> const & inData) : mData{inData} {}
54 explicit AAX_CArrayDataBufferOfType (std::vector<D> && inData) : mData{inData} {}
55
56 AAX_CArrayDataBufferOfType(AAX_CArrayDataBufferOfType const &) = default;
57 AAX_CArrayDataBufferOfType(AAX_CArrayDataBufferOfType &&) = default;
58
59 ~AAX_CArrayDataBufferOfType (void) AAX_OVERRIDE = default;
60
61 AAX_CArrayDataBufferOfType& operator= (AAX_CArrayDataBufferOfType const & other) = default;
62 AAX_CArrayDataBufferOfType& operator= (AAX_CArrayDataBufferOfType && other) = default;
63
64 AAX_Result Type(AAX_CTypeID * oType) const AAX_OVERRIDE {
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()) {
75 return AAX_ERROR_SIGNED_INT_OVERFLOW;
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 }
85 private:
86 std::vector<D> const mData;
87};
88
92 template <class D>
93 class AAX_CArrayDataBuffer : public AAX_IDataBuffer
94{
95 public:
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
99 AAX_CArrayDataBuffer(AAX_CArrayDataBuffer const &) = default;
100 AAX_CArrayDataBuffer(AAX_CArrayDataBuffer &&) = default;
101
102 ~AAX_CArrayDataBuffer (void) AAX_OVERRIDE = default;
103
104 AAX_CArrayDataBuffer& operator= (AAX_CArrayDataBuffer const & other) = default;
105 AAX_CArrayDataBuffer& operator= (AAX_CArrayDataBuffer && other) = default;
106
107 AAX_Result Type(AAX_CTypeID * oType) const AAX_OVERRIDE {
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()) {
118 return AAX_ERROR_SIGNED_INT_OVERFLOW;
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 }
128 private:
129 AAX_CTypeID const mType;
130 std::vector<D> const mData;
131};
132
133#endif
AAX_ERROR_SIGNED_INT_OVERFLOW
@ AAX_ERROR_SIGNED_INT_OVERFLOW
Definition: AAX_Errors.h:83
AAX_ERROR_NULL_ARGUMENT
@ AAX_ERROR_NULL_ARGUMENT
One or more required pointer arguments are null.
Definition: AAX_Errors.h:94
AAX_SUCCESS
@ AAX_SUCCESS
Definition: AAX_Errors.h:49
AAX.h
Various utility definitions for AAX.
AAX_Result
int32_t AAX_Result
Definition: AAX.h:347
AAX_CTypeID
uint32_t AAX_CTypeID
Matches type of OSType used in classic plugins.
Definition: AAX.h:346
AAX_IDataBuffer.h
AAX_CArrayDataBufferOfType
A convenience class for array data buffers.
Definition: AAX_CArrayDataBuffer.h:51
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:69
AAX_CArrayDataBufferOfType::AAX_CArrayDataBufferOfType
AAX_CArrayDataBufferOfType(AAX_CArrayDataBufferOfType &&)=default
AAX_CArrayDataBufferOfType::AAX_CArrayDataBufferOfType
AAX_CArrayDataBufferOfType(std::vector< D > const &inData)
Definition: AAX_CArrayDataBuffer.h:53
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:64
AAX_CArrayDataBufferOfType::Data
AAX_Result Data(void const **oBuffer) const AAX_OVERRIDE
Definition: AAX_CArrayDataBuffer.h:80
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:54
AAX_CArrayDataBuffer
Definition: AAX_CArrayDataBuffer.h:94
AAX_CArrayDataBuffer::Size
AAX_Result Size(int32_t *oSize) const AAX_OVERRIDE
Definition: AAX_CArrayDataBuffer.h:112
AAX_CArrayDataBuffer::Data
AAX_Result Data(void const **oBuffer) const AAX_OVERRIDE
Definition: AAX_CArrayDataBuffer.h:123
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:107
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:96
AAX_CArrayDataBuffer::AAX_CArrayDataBuffer
AAX_CArrayDataBuffer(AAX_CTypeID inType, std::vector< D > &&inData)
Definition: AAX_CArrayDataBuffer.h:97
AAX_IDataBuffer
Interface for reference counted data buffers.
Definition: AAX_IDataBuffer.h:50
AAX_IDataBuffer::AAX_OVERRIDE
void **ppvObjOut AAX_OVERRIDE
Definition: AAX_IDataBuffer.h:55