core
lib
FileHandling
SINEX
SinexBlock.hpp
Go to the documentation of this file.
1
//==============================================================================
2
//
3
// This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4
//
5
// The GNSSTk is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU Lesser General Public License as published
7
// by the Free Software Foundation; either version 3.0 of the License, or
8
// any later version.
9
//
10
// The GNSSTk is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU Lesser General Public License for more details.
14
//
15
// You should have received a copy of the GNU Lesser General Public
16
// License along with GNSSTk; if not, write to the Free Software Foundation,
17
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18
//
19
// This software was developed by Applied Research Laboratories at the
20
// University of Texas at Austin.
21
// Copyright 2004-2022, The Board of Regents of The University of Texas System
22
//
23
//==============================================================================
24
25
//==============================================================================
26
//
27
// This software was developed by Applied Research Laboratories at the
28
// University of Texas at Austin, under contract to an agency or agencies
29
// within the U.S. Department of Defense. The U.S. Government retains all
30
// rights to use, duplicate, distribute, disclose, or release this software.
31
//
32
// Pursuant to DoD Directive 523024
33
//
34
// DISTRIBUTION STATEMENT A: This software has been approved for public
35
// release, distribution is unlimited.
36
//
37
//==============================================================================
38
44
#ifndef GNSSTK_SINEXBLOCK_HPP
45
#define GNSSTK_SINEXBLOCK_HPP
46
47
#include <vector>
48
#include <map>
49
#include "
SinexBase.hpp
"
50
#include "
SinexTypes.hpp
"
51
52
namespace
gnsstk
53
{
54
namespace
Sinex
55
{
57
58
63
class
BlockBase
64
{
65
/* Sinex:Data calls the protected putBlock() and
66
* getBlock() methods. */
67
friend
class
Data
;
68
69
public
:
70
71
virtual
~BlockBase
() {}
72
74
std::string
comment
;
75
78
virtual
std::string
getTitle
()
const
= 0;
79
82
virtual
size_t
getSize
()
const
= 0;
83
84
protected
:
85
94
virtual
size_t
putBlock
(
Sinex::Stream
& s)
const
= 0;
95
108
virtual
size_t
getBlock
(
Sinex::Stream
& s) = 0;
109
110
};
// class BlockBase
111
112
116
template
<
class
T>
117
class
Block
:
public
BlockBase
118
{
119
public
:
120
121
virtual
~Block
() {}
122
123
static
BlockBase
*
create
() {
return
new
Block<T>
; }
124
125
std::string
getTitle
()
const
{
return
T::BLOCK_TITLE; }
126
129
size_t
getSize
()
const
{
return
dataVec
.size(); }
130
133
void
push_back
(
const
T& x) {
dataVec
.push_back(x); }
134
135
std::vector<T>&
getData
() {
return
dataVec
; }
136
137
protected
:
138
139
std::vector<T>
dataVec
;
// Data storage
140
145
virtual
size_t
putBlock
(
Sinex::Stream
& s)
const
146
{
147
size_t
lineNum = 0;
148
typename
std::vector<T>::const_iterator i =
dataVec
.begin();
149
for
( ; i !=
dataVec
.end(); ++i, ++lineNum)
150
{
151
try
152
{
153
const
Sinex::DataType
& d = *i;
154
s << (std::string)d << std::endl;
155
}
156
catch
(
Exception
& exc)
157
{
158
FFStreamError
err
(exc);
159
GNSSTK_THROW
(
err
);
160
}
161
}
162
return
lineNum;
163
};
164
170
virtual
size_t
getBlock
(
Sinex::Stream
& s)
171
{
172
size_t
lineNum = 0;
173
char
c;
174
while
(s.good() )
175
{
176
c = s.get();
177
if
(s.good() )
178
{
179
if
(c ==
DATA_START
)
180
{
182
std::string line;
183
s.
formattedGetLine
(line);
184
try
185
{
186
dataVec
.push_back(
187
T(line.insert( (
size_t
)0, (
size_t
)1, c),
188
lineNum) );
189
}
190
catch
(
Exception
& exc)
191
{
192
FFStreamError
err
(exc);
193
GNSSTK_THROW
(
err
);
194
}
195
++lineNum;
196
}
197
else
198
{
200
s.putback(c);
201
break
;
202
}
203
}
204
}
205
return
lineNum;
206
};
207
208
};
// class Block<T>
209
210
212
typedef
std::vector<const BlockBase*>
Blocks
;
213
215
typedef
Blocks::iterator
BlockIter
;
216
218
typedef
BlockBase
* (*BlockCreateFunc)();
219
221
typedef
std::map<std::string, BlockCreateFunc>
BlockFactory
;
222
224
225
}
// namespace Sinex
226
227
}
// namespace gnsstk
228
229
#endif // GNSSTK_SINEXBLOCK_HPP
gnsstk::Sinex::BlockFactory
std::map< std::string, BlockCreateFunc > BlockFactory
Mapping from block titles to block create functions.
Definition:
SinexBlock.hpp:221
gnsstk::Sinex::Block::getSize
size_t getSize() const
Definition:
SinexBlock.hpp:129
gnsstk::Sinex::Stream
Definition:
SinexStream.hpp:62
gnsstk::Sinex::Block::dataVec
std::vector< T > dataVec
Definition:
SinexBlock.hpp:139
gnsstk::Sinex::Block::~Block
virtual ~Block()
Definition:
SinexBlock.hpp:121
gnsstk::FFTextStream::formattedGetLine
void formattedGetLine(std::string &line, const bool expectEOF=false)
Definition:
FFTextStream.cpp:149
gnsstk::Sinex::Block
Definition:
SinexBlock.hpp:117
gnsstk::Sinex::BlockBase::comment
std::string comment
Comments that apply to an entire block.
Definition:
SinexBlock.hpp:74
SinexBase.hpp
gnsstk::Sinex::BlockBase::getBlock
virtual size_t getBlock(Sinex::Stream &s)=0
SinexTypes.hpp
gnsstk::Sinex::BlockIter
Blocks::iterator BlockIter
Block iterator.
Definition:
SinexBlock.hpp:215
gnsstk::Sinex::Blocks
std::vector< const BlockBase * > Blocks
Block storage type.
Definition:
SinexBlock.hpp:212
gnsstk::Sinex::Block::getBlock
virtual size_t getBlock(Sinex::Stream &s)
Definition:
SinexBlock.hpp:170
gnsstk
For Sinex::InputHistory.
Definition:
BasicFramework.cpp:50
gnsstk::Exception
Definition:
Exception.hpp:151
gnsstk::Sinex::DataType
Definition:
SinexTypes.hpp:67
gnsstk::Sinex::Block::getData
std::vector< T > & getData()
Definition:
SinexBlock.hpp:135
gnsstk::Sinex::Data
Definition:
SinexData.hpp:67
gnsstk::Sinex::Block::push_back
void push_back(const T &x)
Definition:
SinexBlock.hpp:133
example4.err
err
Definition:
example4.py:126
gnsstk::Sinex::BlockBase::getSize
virtual size_t getSize() const =0
gnsstk::Sinex::BlockBase::putBlock
virtual size_t putBlock(Sinex::Stream &s) const =0
gnsstk::Sinex::BlockBase::getTitle
virtual std::string getTitle() const =0
gnsstk::Sinex::Block::getTitle
std::string getTitle() const
Definition:
SinexBlock.hpp:125
GNSSTK_THROW
#define GNSSTK_THROW(exc)
Definition:
Exception.hpp:366
gnsstk::Sinex::BlockBase::~BlockBase
virtual ~BlockBase()
Definition:
SinexBlock.hpp:71
gnsstk::Sinex::BlockBase
Definition:
SinexBlock.hpp:63
gnsstk::Sinex::Block::putBlock
virtual size_t putBlock(Sinex::Stream &s) const
Definition:
SinexBlock.hpp:145
gnsstk::Sinex::DATA_START
const char DATA_START
Definition:
SinexBase.hpp:64
gnsstk::Sinex::Block::create
static BlockBase * create()
Definition:
SinexBlock.hpp:123
gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:41