CorTeX Core ABI 7
ToolTech Software · C++ library reference
Loading...
Searching...
No Matches
ctxInputBuffer.h
Go to the documentation of this file.
1//*****************************************************************************
2// File : ctxInputBuffer.h
3// Description : Managers input 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_INPUT_BUFFER_H__
22#define __CTX_INPUT_BUFFER_H__
23
24#include "ctxBuffer.h"
25
26template <class T> class ctxInputBuffer
27{
28public:
29
30 inline ctxInputBuffer(T *data,gzUInt32 size,ctxBuffer *old=NULL);
31
32 inline gzBool setInputData(T *data, gzUInt32 size,gzUInt32 offset=0);
33
34 inline gzBool valid() const;
35
36 operator ctxBuffer * () const
37 {
38 return m_buffer;
39 }
40
41private:
42
43 ctxBufferPtr m_buffer;
44};
45
46
47template <class T> inline ctxInputBuffer<T>::ctxInputBuffer(T *data, gzUInt32 size,ctxBuffer *old)
48{
49 if (old && (old->getBufferType()==getBufferType<T>()) && (old->getBufferSize()==sizeof(T)*size))
50 m_buffer = old;
51 else
52 m_buffer = ctxBuffer::create(getBufferType<T>(), sizeof(T)*size);
53
54 if(m_buffer)
55 setInputData(data, sizeof(T)*size);
56}
57
58template <class T> inline gzBool ctxInputBuffer<T>::valid() const
59{
60 return m_buffer != NULL;
61}
62
63template <class T> inline gzBool ctxInputBuffer<T>::setInputData(T *data, gzUInt32 size,gzUInt32 offset)
64{
65 if (data && m_buffer)
66 return m_buffer->setBufferData(data, size*sizeof(T),offset*sizeof(T));
67 else
68 return FALSE;
69}
70
71#endif //__CTX_INPUT_BUFFER_H__
72
73
virtual gzUInt32 getBufferSize() const =0
static ctxBuffer * create(ctxBufferType type, gzUInt32 size)
virtual ctxBufferType getBufferType() const =0
gzBool valid() const
gzBool setInputData(T *data, gzUInt32 size, gzUInt32 offset=0)
ctxInputBuffer(T *data, gzUInt32 size, ctxBuffer *old=NULL)
ctxBufferType getBufferType()