17 key(0), dataPtr(nullptr), numOfElements(0)
45 if (index < numOfElements) {
46 return dataPtr[index];
48 throw std::out_of_range(
"yarp::dev::impl::Buffer::getValue(index): index is out of range");
56 if (index < numOfElements) {
57 dataPtr[index] = value;
59 throw std::out_of_range(
"yarp::dev::impl::Buffer::setValue(index, value): index is out of range");
67 return dataPtr[index];
74 m_numElem = zizeOfBuffers;
77 for (
size_t i = 0; i < initialNumOfBuffers; i++) {
78 T* buff =
new T[m_numElem];
79 m_buffers.push_back(buff);
81 m_usedBuffers.resize(initialNumOfBuffers,
false);
94 bool needNewBuff =
true;
95 if (
false == m_usedBuffers[m_firstFreeBuff]) {
100 for (std::size_t p = 0; p < m_buffers.size(); p++) {
101 if (
false == m_usedBuffers[p]) {
112 dataPtr =
new T[m_numElem];
113 if (
nullptr == dataPtr) {
115 yError() <<
"FixedSizeBuffersManager::getBuffer() no more memory!!";
117 m_buffers.push_back(dataPtr);
118 m_usedBuffers.push_back(
true);
120 i = m_buffers.size() - 1;
125 dataPtr = m_buffers[i];
126 m_usedBuffers[i] =
true;
130 buffer.numOfElements = m_numElem;
155 template <
typename T>
160 if (
buffer.key >= m_buffers.size()) {
161 yError() <<
"FixedSizeBuffersManager::releaseBuffer((Buffer<T> &buffer) error in deallocation!!";
164 m_usedBuffers[
buffer.key] =
false;
165 m_firstFreeBuff =
buffer.key;
171 template <
typename T>
175 for (std::size_t i = 0; i < m_buffers.size(); i++) {
176 yDebug() <<
"buff[" << i <<
"]: addr = " << m_buffers[i] <<
"; it is used?" << m_usedBuffers[i];
183 template <
typename T>
186 for (
size_t i = 0; i < m_buffers.size(); i++) {
187 delete[] m_buffers[i];
192 template <
typename T>