CorTeX Core ABI 7
ToolTech Software · C++ library reference
Loading...
Searching...
No Matches
ctxOutputBuffer.h
Go to the documentation of this file.
1//*****************************************************************************
2// File : ctxOutputBuffer.h
3// Description : Managers output for typed buffers
4// Author : Anders Modén
5// Product : CorTeX 2.0.1
6//
7// Copyright © 2015- Anders Modén, Sweden
8//
9// NOTE: CorTeX is a software development kit (SDK)
10// for neural networks and genetic programming.
11// Licensed by Anders Modén.
12//
13//
14// Revision History...
15//
16// Who Date Description
17//
18// AMO 150708 Created file (1.0.0)
19//
20//******************************************************************************
21#ifndef __CTX_OUTPUT_BUFFER_H__
22#define __CTX_OUTPUT_BUFFER_H__
23
24#include "ctxBuffer.h"
25
26template <class T> class ctxOutputBuffer
27{
28public:
29
30 inline ctxOutputBuffer(ctxBuffer *buffer);
31
32 inline gzBool getOutputData(T *data, gzUInt32 size,gzUInt32 offset=0);
33
34 inline gzBool getOutputData(gzArray<T> &data);
35
36 inline gzBool valid() const;
37
38private:
39
40 ctxBufferPtr m_buffer;
41};
42
43template <class T> inline ctxOutputBuffer<T>::ctxOutputBuffer(ctxBuffer *buffer):m_buffer(buffer)
44{
45}
46
47template <class T> inline gzBool ctxOutputBuffer<T>::valid() const
48{
49 if (!m_buffer)
50 return FALSE;
51
52 if (m_buffer->getBufferType() != getBufferType<T>())
53 return FALSE;
54
55 return TRUE;
56}
57
58template <class T> inline gzBool ctxOutputBuffer<T>::getOutputData(T *data, gzUInt32 size, gzUInt32 offset)
59{
60 if (!valid())
61 return FALSE;
62
63 return m_buffer->getBufferData(data,size*sizeof(T),offset*sizeof(T));
64}
65
66template <class T> inline gzBool ctxOutputBuffer<T>::getOutputData(gzArray<T> &data)
67{
68 if (!valid())
69 return FALSE;
70
71 data.setSize(m_buffer->getBufferSize()/sizeof(T));
72
73 if(!m_buffer->getBufferData(data.getAddress(),data.getSize()*sizeof(T)))
74 return FALSE;
75
76 return TRUE;
77}
78
79#endif //__CTX_OUTPUT_BUFFER_H__
80
81
gzBool getOutputData(T *data, gzUInt32 size, gzUInt32 offset=0)
ctxOutputBuffer(ctxBuffer *buffer)
gzBool valid() const
ctxBufferType getBufferType()