VISR  0.11.8
Versatile Interactive Scene Renderer
communication_area.hpp
Go to the documentation of this file.
1 /* Copyright Institute of Sound and Vibration Research - All rights reserved */
2 
3 #ifndef VISR_RRL_COMMUNICATION_AREA_HPP_INCLUDED
4 #define VISR_RRL_COMMUNICATION_AREA_HPP_INCLUDED
5 
6 #include "export_symbols.hpp"
7 
9 
10 #include <stdexcept>
11 #include <valarray>
12 
13 namespace visr
14 {
15 namespace rrl
16 {
17 
18 
19 class VISR_RRL_LIBRARY_SYMBOL AudioSignalPool
20 {
21 public:
22  explicit AudioSignalPool( std::size_t size, std::size_t alignment );
23 
24  ~AudioSignalPool();
25 
26  char * basePointer() { return mPool.data(); }
27 
28  char const * basePointer() const { return mPool.data(); }
29 
30 private:
32 };
33 
37 template<typename SampleType>
38 class VISR_RRL_LIBRARY_SYMBOL CommunicationArea
39 {
40 public:
47  explicit CommunicationArea( std::size_t numberOfSignals, std::size_t signalLength,
48  std::size_t alignmentElements /* = 0 */ );
50  ~CommunicationArea();
51 
52  std::size_t numberOfSignals() const { return mNumberOfSignals; }
53 
54  std::size_t signalLength() const { return mSignalLength; }
55 
56  std::size_t signalStride() const { return mSignalStride; }
57 
58  SampleType * data() { return mStorage.data(); }
59 
60  SampleType const * data( ) const { return mStorage.data( ); }
61 
62  SampleType * operator[]( std::size_t index )
63  {
64  return data() + mSignalStride * index;
65  }
66 
67  SampleType const * operator[]( std::size_t index ) const
68  {
69  return data( ) + mSignalStride * index;
70  }
71 
72  SampleType * at( std::size_t index )
73  {
74  if( index >= mNumberOfSignals )
75  {
76  throw std::out_of_range( "Index exceeds the number of signals" );
77  }
78  return operator[]( index );
79  }
80 
81  SampleType const * at( std::size_t index ) const
82  {
83  if( index >= mNumberOfSignals )
84  {
85  throw std::out_of_range( "Index exceeds the number of signals" );
86  }
87  return operator[]( index );
88  }
89 
90 private:
91  const std::size_t mNumberOfSignals;
92  const std::size_t mSignalLength;
93  const std::size_t mSignalStride;
95 
96 };
97 
98 } // namespace rrl
99 } // namespace visr
100 
101 #endif // VISR_RRL_COMMUNICATION_AREA_HPP_INCLUDED
char const * basePointer() const
Definition: communication_area.hpp:28
char * basePointer()
Definition: communication_area.hpp:26
SampleType const * operator[](std::size_t index) const
Definition: communication_area.hpp:67
Definition: communication_area.hpp:19
SampleType * at(std::size_t index)
Definition: communication_area.hpp:72
Definition: options.cpp:10
SampleType * operator[](std::size_t index)
Definition: communication_area.hpp:62
std::size_t signalLength() const
Definition: communication_area.hpp:54
SampleType const * at(std::size_t index) const
Definition: communication_area.hpp:81
SampleType const * data() const
Definition: communication_area.hpp:60
std::size_t numberOfSignals() const
Definition: communication_area.hpp:52
float SampleType
Definition: constants.hpp:14
SampleType * data()
Definition: communication_area.hpp:58
std::size_t signalStride() const
Definition: communication_area.hpp:56