pocolog_cpp
InputDataStream.hpp
Go to the documentation of this file.
1 #ifndef INPUTDATASTREAM_H
2 #define INPUTDATASTREAM_H
3 
4 #include "Stream.hpp"
5 #include <string>
6 #include <typelib/value_ops.hh>
7 
8 namespace Typelib
9 {
10  class Registry;
11  class Type;
12 }
13 
14 namespace pocolog_cpp
15 {
16 
17 class InputDataStream : public Stream
18 {
19 
20 protected:
21  const Typelib::Type* m_type;
22  Typelib::Registry* m_registry;
23 
24  void loadTypeLib();
25 
26 public:
28  virtual ~InputDataStream();
29 
30  Typelib::Type const* getType() const;
31 
32  const std::string getCXXType() const;
33 
34  size_t getTypeMemorySize() const
35  {
36  return m_type->getSize();
37  }
38 
39  Typelib::Registry &getStreamRegistry()
40  {
41  return *m_registry;
42  }
43 
44  template<typename T>
45  bool getSample(T& out, size_t sampleNr)
46  {
47  std::vector<uint8_t> buffer;
48  if(!getSampleData(buffer, sampleNr))
49  return false;
50 
51 // Typelib::Value v(&out, sizeof(T), *m_type);
52  Typelib::Value v(&out, *m_type);
53  Typelib::load(v, buffer);
54  return true;
55  }
56 
57  Typelib::Value getTyplibValue(void *memoryOfType, size_t memorySize, size_t sampleNr);
58 };
59 
60 }
61 
62 
63 #endif // INPUTDATASTREAM_H
Definition: Index.hpp:15
const std::string getCXXType() const
Definition: InputDataStream.cpp:65
void loadTypeLib()
Definition: InputDataStream.cpp:29
size_t getTypeMemorySize() const
Definition: InputDataStream.hpp:34
virtual ~InputDataStream()
Definition: InputDataStream.cpp:23
InputDataStream(const StreamDescription &desc, Index &index)
Definition: InputDataStream.cpp:18
Definition: InputDataStream.hpp:17
bool getSampleData(std::vector< uint8_t > &result, size_t sampleNr)
Definition: Stream.cpp:25
const StreamDescription & desc
Definition: Stream.hpp:16
Typelib::Registry * m_registry
Definition: InputDataStream.hpp:22
const Typelib::Type * m_type
Definition: InputDataStream.hpp:21
bool getSample(T &out, size_t sampleNr)
Definition: InputDataStream.hpp:45
Typelib::Registry & getStreamRegistry()
Definition: InputDataStream.hpp:39
Typelib::Type const * getType() const
Definition: InputDataStream.cpp:42
Index & index
Definition: Stream.hpp:17
Typelib::Value getTyplibValue(void *memoryOfType, size_t memorySize, size_t sampleNr)
Definition: InputDataStream.cpp:47
Definition: StreamDescription.hpp:13
Definition: Read.hpp:91