EZC3D
Subframe.cpp
Go to the documentation of this file.
1 #define EZC3D_API_EXPORTS
2 
10 #include "Subframe.h"
11 
13 {
14 
15 }
16 
18 {
19  for (size_t i = 0; i < nbChannels(); ++i){
20  channel(i).print();
21  }
22 }
23 
24 void ezc3d::DataNS::AnalogsNS::SubFrame::write(std::fstream &f) const
25 {
26  for (size_t i = 0; i < nbChannels(); ++i){
27  channel(i).write(f);
28  }
29 }
30 
32 {
33  return _channels.size();
34 }
35 
37 {
38  _channels.resize(nChannels);
39 }
40 
42 {
43  try {
44  return _channels.at(idx);
45  } catch(std::out_of_range) {
46  throw std::out_of_range("Subframe::channel method is trying to access the channel "
47  + std::to_string(idx) +
48  " while the maximum number of channels is "
49  + std::to_string(nbChannels()) + ".");
50  }
51 }
52 
54 {
55  try {
56  return _channels.at(idx);
57  } catch(std::out_of_range) {
58  throw std::out_of_range("Subframe::channel method is trying to access the channel "
59  + std::to_string(idx) +
60  " while the maximum number of channels is "
61  + std::to_string(nbChannels()) + ".");
62  }
63 }
64 
66 {
67  if (idx == SIZE_MAX)
68  _channels.push_back(channel);
69  else{
70  if (idx >= nbChannels())
71  _channels.resize(idx+1);
72  _channels[idx] = channel;
73  }
74 }
75 
76 const std::vector<ezc3d::DataNS::AnalogsNS::Channel> &ezc3d::DataNS::AnalogsNS::SubFrame::channels() const
77 {
78  return _channels;
79 }
80 
82 {
83  for (Channel channel : channels())
84  if (!channel.isempty())
85  return false;
86  return true;
87 }
void print() const
Print the subframe.
Definition: Subframe.cpp:17
Declaration of Subframe class.
ezc3d::DataNS::AnalogsNS::Channel & channel_nonConst(size_t idx)
Get a particular analog channel of index idx from the analogous data with write access.
Definition: Subframe.cpp:53
const ezc3d::DataNS::AnalogsNS::Channel & channel(size_t idx) const
Get a particular analog channel of index idx from the analogous data.
Definition: Subframe.cpp:41
SubFrame()
Create an empty subframe for analogous data.
Definition: Subframe.cpp:12
size_t nbChannels() const
Get the number of analog channels.
Definition: Subframe.cpp:31
Channel of an analogous data.
Definition: Channel.h:16
bool isempty() const
Return if the subframe is empty.
Definition: Subframe.cpp:81
const std::vector< ezc3d::DataNS::AnalogsNS::Channel > & channels() const
Get all the analog channels from the analogous data.
Definition: Subframe.cpp:76
void write(std::fstream &f) const
Write the subframe to an opened file.
Definition: Subframe.cpp:24