Stimfit @PACKAGE_VERSION@
Loading...
Searching...
No Matches
section.h
Go to the documentation of this file.
1// This program is free software; you can redistribute it and/or
2// modify it under the terms of the GNU General Public License
3// as published by the Free Software Foundation; either version 2
4// of the License, or (at your option) any later version.
5
6// This program is distributed in the hope that it will be useful,
7// but WITHOUT ANY WARRANTY; without even the implied warranty of
8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9// GNU General Public License for more details.
10
11// You should have received a copy of the GNU General Public License
12// along with this program; if not, write to the Free Software
13// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14
20
21/*------------------------------------------------------------------------
22 * References:
23 * [1] Stroustrup, B.: The C++ Programming Language. 3rd ed. 1997
24 * [2] Meyers, S.: Effective C++. 3rd ed. 2005
25--------------------------------------------------------------------------*/
26// only compile once, even if included more often:
27#ifndef _SECTION_H
28#define _SECTION_H
29#include "./core.h"
30#include "./annotation.h"
34
37public:
38 // Construction/Destruction-----------------------------------------------
40 explicit Section();
41
43
46 explicit Section(
47 const Vector_double& valA,
48 const std::string& label="\0"
49 );
50
52
55 explicit Section(
56 std::size_t size,
57 const std::string& label="\0"
58 );
59
62
63 // Operators--------------------------------------------------------------
65
68 double& operator[](std::size_t at) { return data[at]; }
69
71
74 double operator[](std::size_t at) const { return data[at]; }
75
76 // Public member functions------------------------------------------------
77
79
83 double at(std::size_t at_) const;
84
86
90 double& at(std::size_t at_);
91
93
97 const Vector_double& get() const { return data; }
98
100
104 Vector_double& get_w() { return data; }
105
107
111 void resize(std::size_t new_size) { data.resize(new_size); }
112
114
116 size_t size() const { return data.size(); }
117
119
121 void SetXScale(double value);
122
124
126 double GetXScale() const { return x_scale; }
127
129
131 const std::string& GetSectionDescription() const { return section_description; }
132
134
136 void SetSectionDescription(const std::string& value) { section_description=value; }
137
139
143
145
147 std::size_t GetSectionSize();
148
149 // Annotation operations //
150 // Add Annotation to the current section
151 void AddAnnotation(Annotation annotation);
152 // Change position of Annotation[index] to new sample number 'position'
153 void MoveAnnotation(size_t index, int new_position);
154 // Remove Annotation[index] from list of Annotations
155 void RemoveAnnotation(size_t index);
156 //Erase all annotation in the list of Annotations
158 //Get list of all annotation in this section.
159 std::vector<Annotation> GetAnnotationList();
160
163
164 private:
165 //Private members-------------------------------------------------------
166
167 // A description that is specific to this section:
168 std::string section_description;
169
170 // The sampling interval:
171 double x_scale;
172
173 // The data:
174 Vector_double data;
175
176 // list of annotations in this section
177 std::size_t firstAnnotationPos, lastAnnotationPos;
178 std::vector<Annotation> AnnotationsList;
179};
180
182
183#endif
184
185
186
187
Describes the attributes of an annotation.
Definition annotation.h:7
Lightweight core definitions shared by libstfio model classes.
std::vector< double > Vector_double
Definition core.h:55
#define StfioDll
Defines dll export or import functions for Windows.
Definition core.h:49
void SetSectionDescription(const std::string &value)
Sets a section description.
Definition section.h:136
std::size_t GetSectionSize()
Range-checked access. Returns a non-const reference.
std::size_t GetLastAnnotationPosition()
void MoveAnnotation(size_t index, int new_position)
size_t size() const
Retrieve the number of data points.
Definition section.h:116
void EraseAllAnnotations()
std::size_t GetFirstAnnotationPosition()
void SetXScale(double value)
Sets the x scaling.
Vector_double & get_w()
Low-level access to the valarray (read and write).
Definition section.h:104
double & at(std::size_t at_)
Range-checked access. Returns a non-const reference.
double GetXScale() const
Retrieves the x scaling.
Definition section.h:126
double operator[](std::size_t at) const
Unchecked access. Returns a copy.
Definition section.h:74
void resize(std::size_t new_size)
Resize the Section to a new number of data points; deletes all previously stored data when gcc is use...
Definition section.h:111
const Vector_double & get() const
Low-level access to the valarray (read-only).
Definition section.h:97
Section()
Default constructor.
Section(std::size_t size, const std::string &label="\0")
Yet another constructor.
std::vector< Annotation > GetAnnotationList()
void AddAnnotation(Annotation annotation)
Section(const Vector_double &valA, const std::string &label="\0")
Constructor.
double at(std::size_t at_) const
Range-checked access. Returns a copy.
~Section()
Destructor.
double & operator[](std::size_t at)
Unchecked access. Returns a non-const reference.
Definition section.h:68
void RemoveAnnotation(size_t index)
const std::string & GetSectionDescription() const
Retrieves a section description.
Definition section.h:131