nidas v1.2.3
NidasApp.h
Go to the documentation of this file.
1// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4; -*-
2// vim: set shiftwidth=4 softtabstop=4 expandtab:
3/*
4 ********************************************************************
5 Copyright 2016 UCAR, NCAR, All Rights Reserved
6 ********************************************************************
7*/
8#ifndef NIDAS_CORE_NIDASAPP_H
9#define NIDAS_CORE_NIDASAPP_H
10
11#include "SampleTag.h"
12#include "SampleMatcher.h"
13#include "Datasets.h"
14#include <nidas/util/UTime.h>
15#include <nidas/util/Socket.h>
16#include <nidas/util/auto_ptr.h>
17
18#include <string>
19#include <list>
20
21
22
23namespace nidas { namespace core {
24
25class Project;
26class FileSet;
27class SampleOutputBase;
28
34{
35public:
36 NidasAppException(const std::string& what) :
38 {}
39};
40
41
42class NidasApp;
43class NidasAppArg;
44
49typedef std::vector<NidasAppArg*> nidas_app_arglist_t;
50
55typedef std::vector<std::string> ArgVector;
56
57inline std::string
58expectArg(const ArgVector& args, int i)
59{
60 if (i < (int)args.size())
61 {
62 return args[i];
63 }
64 throw NidasAppException("expected argument for option " + args[i-1]);
65}
66
76{
77public:
120 NidasAppArg(const std::string& flags,
121 const std::string& syntax = "",
122 const std::string& usage = "",
123 const std::string& default_ = "",
124 bool required = false);
125
126 virtual
127 ~NidasAppArg();
128
138 void
139 setRequired(bool isRequired=true);
140
144 bool
145 isRequired();
146
152 void
153 acceptShortFlag(bool enable)
154 {
155 _enableShortFlag = enable;
156 }
157
162 void
163 addFlag(const std::string& flag);
164
171 void
172 setFlags(const std::string& flags);
173
179 {
181 args.push_back(this);
182 return args;
183 }
184
196 std::string
197 usage(const std::string& indent = " ", bool brief = false);
198
205 bool
206 specified();
207
213 const std::string&
214 getValue();
215
221 const std::string&
222 getFlag();
223
228 bool
229 asBool();
230
237 int
238 asInt();
239
243 float
244 asFloat();
245
256 virtual bool
257 parse(const ArgVector& argv, int* argi = 0);
258
263 bool
264 accept(const std::string& flag);
265
266 void
267 setUsageString(const std::string& text)
268 {
269 _usage = text;
270 }
271
276 std::string
278
279 void
280 setDefault(const std::string& dvalue)
281 {
283 }
284
285 std::string
287 {
288 return _default;
289 }
290
291protected:
292
293 std::string _flags;
294 std::string _syntax;
295 std::string _usage;
296 std::string _default;
297 std::string _arg;
298 std::string _value;
301
308 bool
309 single();
310
311private:
312
313 // Prevent the public NidasAppArg members of NidasApp from being
314 // replaced with other arguments.
318
319 friend class NidasApp;
320};
321
322
328{
329public:
332
341 void
342 setDefaultInput(const std::string& spec, int port=0)
343 {
345 if (port)
347 updateUsage();
348 }
349
350private:
351
353 NidasAppArg("", "input-url [...]"),
354 allowFiles(true),
355 allowSockets(true),
357 default_port(0)
358 {
359 }
360
361 void
362 updateUsage();
363
364 std::string default_input;
366
367 virtual
370
371 friend class NidasApp;
372};
373
374
382
383
576{
577public:
578
593
601 {
602 public:
604 _idFormat(idfmt),
605 _width(0)
606 {
607 }
608
609 IdFormat(const IdFormat& right) :
610 _idFormat(right._idFormat),
611 _width(right._width)
612 {
613 }
614
615 IdFormat&
617 {
618 _width = width;
619 return *this;
620 }
621
622 IdFormat&
623 operator=(const IdFormat& right)
624 {
625 if (right._idFormat != NOFORMAT_ID)
626 _idFormat = right._idFormat;
627 if (right._width != 0)
628 _width = right._width;
629 return *this;
630 }
631
632 int
634 {
635 if (_width)
636 return _width;
637 return 6;
638 }
639
642 {
643 if (_idFormat != NOFORMAT_ID)
644 return _idFormat;
645 return AUTO_ID;
646 }
647
648 bool
650 {
651 return (_idFormat == NOFORMAT_ID && _width == 0);
652 }
653
656 };
657
680
686
696 loggingArgs();
697
702 NidasApp(const std::string& name);
703
708 ~NidasApp();
709
710 std::string
712 {
713 return _appname;
714 }
715
721 void
722 setProcessName(const std::string& argv0);
723
728 std::string
730
736 void
738
743 static NidasApp*
745
753 void
754 allowUnrecognized(bool allow);
755
759 bool
761
787 void
788 enableArguments(const nidas_app_arglist_t& arglist);
789
797 void
799
804 void
806
813 getArguments();
814
819 void
820 requireLongFlag(const nidas_app_arglist_t& arglist, bool require=true)
821 {
822 nidas_app_arglist_t::const_iterator it;
823 for (it = arglist.begin(); it != arglist.end(); ++it)
824 {
825 (*it)->acceptShortFlag(!require);
826 }
827 }
828
846 void
847 startArgs(const ArgVector& args);
848
856 void
857 startArgs(int argc, const char* const argv[]);
858
880 parseNext();
881
891 bool
892 nextArg(std::string& arg);
893
894
896 unparsedArgs();
897
929 parseArgs(const ArgVector& args);
930
939 parseArgs(int argc, const char* const argv[]);
940
947 void
948 parseLogConfig(const std::string& optarg);
949
956 void
957 parseLogLevel(const std::string& optarg)
958 {
959 parseLogConfig(optarg);
960 }
961
963 parseTime(const std::string& optarg);
964
965 void
966 parseUsername(const std::string& username);
967
978 void
979 parseInputs(const std::vector<std::string>& inputs,
980 std::string default_input = "",
981 int default_port = 0);
982
985 bool
987 {
988 return _dataFileNames.size() > 0 || _sockAddr.get();
989 }
990
997 void
998 parseOutput(const std::string& optarg);
999
1004 std::string
1006 {
1007 return _outputFileName;
1008 }
1009
1013 int
1015 {
1016 return _outputFileLength;
1017 }
1018
1022 int
1023 logLevel();
1024
1030 void
1031 resetLogging();
1032
1036 void
1037 setProcessData(bool process)
1038 {
1039 _processData = process;
1040 }
1041
1045 bool
1047 {
1048 return _processData;
1049 }
1050
1051 std::string
1053 {
1054 return _xmlFileName;
1055 }
1056
1070 std::string
1071 getConfigsXML();
1072
1087 getDataset(const std::string& datasetname);
1088
1098 {
1099 return _startTime;
1100 }
1101
1111 {
1112 return _endTime;
1113 }
1114
1119 void
1121 const nidas::util::UTime& end,
1123
1124 void
1126 const nidas::util::UTime& end,
1127 nidas::core::FileSet* fset);
1128
1137 bool
1138 interrupted(bool allow_exception=true);
1139
1145 static void
1147
1159 void
1161
1165 bool
1166 hasException();
1167
1174 getException();
1175
1180 Project*
1181 getProject();
1182
1188 std::string
1189 usage(const std::string& indent, bool brief);
1190
1195 std::string
1196 usage(const std::string& indent = " ");
1197
1202 static void
1203 setupSignals(void (*callback)(int signum) = 0);
1204
1222 static void
1223 addSignal(int signum, void (*callback)(int signum) = 0, bool nolog=false);
1224
1229 bool
1231 {
1232 return _help;
1233 }
1234
1238 bool
1240 {
1241 return _brief;
1242 }
1243
1247 void
1248 setIdFormat(IdFormat idt);
1249
1250 IdFormat
1252 {
1253 return _idFormat;
1254 }
1255
1261 static
1262 std::ostream&
1263 formatSampleId(std::ostream& out, IdFormat idfmt, dsm_sample_id_t sid);
1264
1271 std::ostream&
1272 formatSampleId(std::ostream& out, dsm_sample_id_t sid);
1273
1279 std::string
1281
1301 {
1302 return _sampleMatcher;
1303 }
1304
1310 std::list<std::string>&
1312 {
1313 return _dataFileNames;
1314 }
1315
1323 {
1324 return _sockAddr.get();
1325 }
1326
1331 std::string
1332 getHostName();
1333
1338 std::string
1340
1345 std::string
1347 {
1348 return _username;
1349 }
1350
1355 uid_t
1357 {
1358 return _userid;
1359 }
1360
1365 uid_t
1367 {
1368 return _groupid;
1369 }
1370
1375 void
1376 setupProcess();
1377
1386 void
1387 setupDaemonLogging(bool daemon_mode);
1388
1393 void
1395
1400 void
1401 setupDaemon(bool daemon_mode);
1402
1407 void
1408 setupDaemon();
1409
1414 void
1415 lockMemory();
1416
1431 int
1432 checkPidFile();
1433
1441 float
1442 getSorterLength(float min, float max);
1443
1444private:
1445
1446 void
1448
1450
1451 std::string _appname;
1452
1453 std::string _argv0;
1454
1456
1457 std::string _xmlFileName;
1458
1460
1462
1464
1466
1467 std::list<std::string> _dataFileNames;
1468
1469 nidas::util::auto_ptr<nidas::util::SocketAddress> _sockAddr;
1470
1471 std::string _outputFileName;
1473
1474 bool _help;
1476
1477 std::string _username;
1478
1479 std::string _hostname;
1480
1481 uid_t _userid;
1482
1484
1486
1488
1491
1494
1496
1499};
1500
1501
1520{
1521 NidasAppArgv(const std::string& argv0,
1522 const std::vector<std::string>& args) :
1523 vargv(), argv(0), argc(0)
1524 {
1525 vargv.push_back(strdup(argv0.c_str()));
1526 for (unsigned int i = 0; i < args.size(); ++i)
1527 {
1528 vargv.push_back(strdup(args[i].c_str()));
1529 }
1530 argv = &(vargv.front());
1531 argc = (int)vargv.size();
1532 }
1533
1539 ArgVector
1540 unparsedArgs(int optindex)
1541 {
1542 return std::vector<std::string>(vargv.begin()+optindex, vargv.end());
1543 }
1544
1546 {
1547 for (int i = 0; i < argc; ++i)
1548 {
1549 free(vargv[i]);
1550 }
1551 }
1552
1553 std::vector<char*> vargv;
1554 char** argv;
1555 int argc;
1556
1557private:
1558
1561
1562};
1563
1564
1565
1566}} // namespace nidas namespace core
1567
1568#endif // NIDAS_CORE_NIDASAPP_H
A Dataset is a named collection of parameters, that are used in data processing.
Definition Datasets.h:48
Implementation of an IOChannel using an nidas::util::FileSet.
Definition FileSet.h:42
A NidasAppArg is command-line argument which can be handled by NidasApp.
Definition NidasApp.h:76
const std::string & getFlag()
Return the command-line flag which this argument consumed.
Definition NidasApp.cc:137
NidasAppArg(const std::string &flags, const std::string &syntax="", const std::string &usage="", const std::string &default_="", bool required=false)
Construct a NidasAppArg from a list of accepted short and long flags, the syntax for any arguments to...
Definition NidasApp.cc:78
NidasAppArg & operator=(const NidasAppArg &)
std::string _default
Definition NidasApp.h:296
std::string getUsageFlags()
Return the string of flags accepted by this NidasAppArg according to the acceptShortFlag() setting.
Definition NidasApp.cc:316
virtual ~NidasAppArg()
Definition NidasApp.cc:95
bool asBool()
An argument is true if it is a stand-alone flag and was specified in the arguments,...
Definition NidasApp.cc:165
void setUsageString(const std::string &text)
Definition NidasApp.h:267
bool accept(const std::string &flag)
Return true if the given command-line flag matches one of this argument's flags.
Definition NidasApp.cc:274
std::string _value
Definition NidasApp.h:298
std::string _flags
Definition NidasApp.h:293
void addFlag(const std::string &flag)
Add a flag which this argument should accept.
Definition NidasApp.cc:145
bool isRequired()
Return whether this argument is required.
Definition NidasApp.cc:109
std::string _usage
Definition NidasApp.h:295
const std::string & getValue()
If this argument has been parsed from a command line list (specified() returns true),...
Definition NidasApp.cc:125
int asInt()
Parse the argument value as an integer, where the value could be the default if no value has been exp...
Definition NidasApp.cc:187
float asFloat()
Same as asInt(), except parse the argument value as a float.
Definition NidasApp.cc:214
virtual bool parse(const ArgVector &argv, int *argi=0)
If argv[argi] matches this argument, then set the flag that was found and also the value if this argu...
Definition NidasApp.cc:242
std::string _syntax
Definition NidasApp.h:294
void setRequired(bool isRequired=true)
Set whether this argument is required.
Definition NidasApp.cc:101
std::string usage(const std::string &indent=" ", bool brief=false)
Render the usage string for this particular argument, taking into account which flags are enabled.
Definition NidasApp.cc:349
bool _enableShortFlag
Definition NidasApp.h:299
bool _required
Definition NidasApp.h:300
std::string getDefault()
Definition NidasApp.h:286
bool single()
Return true for arguments which are only a single argument.
Definition NidasApp.cc:266
void setDefault(const std::string &dvalue)
Definition NidasApp.h:280
std::string _arg
Definition NidasApp.h:297
bool specified()
Return true if this argument has been filled in from a command-line argument list,...
Definition NidasApp.cc:117
NidasAppArg(const NidasAppArg &)
void setFlags(const std::string &flags)
Completely replace the flags which this argument should accept.
Definition NidasApp.cc:157
void acceptShortFlag(bool enable)
Set whether short flags are enabled or not.
Definition NidasApp.h:153
The NidasApp class throws a NidasAppException when command-line options do not parse.
Definition NidasApp.h:34
NidasAppException(const std::string &what)
Definition NidasApp.h:36
Extend NidasAppArg so the default input specifier and port can be customized, which in turn updates t...
Definition NidasApp.h:328
bool allowSockets
Definition NidasApp.h:331
void updateUsage()
Definition NidasApp.cc:1271
void setDefaultInput(const std::string &spec, int port=0)
Set a default input.
Definition NidasApp.h:342
std::string default_input
Definition NidasApp.h:364
bool allowFiles
Definition NidasApp.h:330
int default_port
Definition NidasApp.h:365
NidasAppInputFilesArg()
Definition NidasApp.h:352
virtual ~NidasAppInputFilesArg()
Definition NidasApp.h:368
An IdFormat specifies the format for the SPS ID plus other characteristics, like the width when using...
Definition NidasApp.h:601
IdFormat(id_format_t idfmt=NOFORMAT_ID)
Definition NidasApp.h:603
id_format_t _idFormat
Definition NidasApp.h:654
int decimalWidth()
Definition NidasApp.h:633
IdFormat & operator=(const IdFormat &right)
Definition NidasApp.h:623
bool unset()
Definition NidasApp.h:649
id_format_t idFormat()
Definition NidasApp.h:641
IdFormat(const IdFormat &right)
Definition NidasApp.h:609
IdFormat & setDecimalWidth(int width)
Definition NidasApp.h:616
int _width
Definition NidasApp.h:655
NidasApp handles common options for NIDAS applications.
Definition NidasApp.h:576
NidasAppInputFilesArg InputFiles
Definition NidasApp.h:671
bool _deleteProject
Definition NidasApp.h:1485
SampleMatcher & sampleMatcher()
Use this method to access the SampleMatcher instance for this NidasApp.
Definition NidasApp.h:1300
bool _allowUnrecognized
Definition NidasApp.h:1495
bool briefHelp()
Return true if brief help requested, such as with -h.
Definition NidasApp.h:1239
std::string _appname
Definition NidasApp.h:1451
int _argi
Definition NidasApp.h:1490
bool _brief
Definition NidasApp.h:1475
std::string getName()
Definition NidasApp.h:711
static NidasApp * getApplicationInstance()
Return the current application instance.
Definition NidasApp.cc:658
nidas::util::UTime parseTime(const std::string &optarg)
Definition NidasApp.cc:764
nidas_app_arglist_t _app_arguments
Definition NidasApp.h:1487
void enableArguments(const nidas_app_arglist_t &arglist)
Add the list of NidasAppArg pointers to the set of arguments accepted by this NidasApp instance.
Definition NidasApp.cc:694
void parseUsername(const std::string &username)
Definition NidasApp.cc:1546
nidas::core::Dataset getDataset(const std::string &datasetname)
Derive a path to an XML datasets file according to the current environment settings,...
Definition NidasApp.cc:1582
void setProcessName(const std::string &argv0)
Set the name of this particular process, usually argv[0].
Definition NidasApp.cc:665
bool helpRequested()
Return true when a help option was parsed, meaning the usage info has been requested.
Definition NidasApp.h:1230
NidasApp(const std::string &name)
Construct a NidasApp instance and give it a name to be used for the usage info.
Definition NidasApp.cc:448
static void setInterrupted(bool interrupted)
Set the global interrupted state for NidasApp.
Definition NidasApp.cc:1163
std::string getHostName()
Return the hostname passed to the Hostname argument, if any, otherwise return the current hostname as...
Definition NidasApp.cc:1631
NidasAppArg FormatHexId
Definition NidasApp.h:668
std::string _username
Definition NidasApp.h:1477
NidasAppArg StartTime
Definition NidasApp.h:665
nidas::util::Exception getException()
Return the current exception.
Definition NidasApp.cc:1155
static NidasApp * application_instance
Definition NidasApp.h:1449
NidasAppArg ProcessData
Definition NidasApp.h:664
std::string getShortHostName()
Like getHostName(), but any '.
Definition NidasApp.cc:1658
bool allowUnrecognized()
Return whether unrecognized flags are allowed or not.
Definition NidasApp.cc:1372
void startArgs(const ArgVector &args)
Set the list of command-line argument strings to be parsed and handled by successive calls to nextArg...
Definition NidasApp.cc:788
ArgVector parseArgs(const ArgVector &args)
Parse all arguments accepted by this NidasApp in the command-line argument list args,...
Definition NidasApp.cc:966
NidasAppArg FormatSampleId
Definition NidasApp.h:669
int outputFileLength()
Return the output file length in seconds.
Definition NidasApp.h:1014
std::string getProcessName()
Get the process name, as set by setProcessName(), or else return the app name from getName().
Definition NidasApp.cc:672
void setException(const nidas::util::Exception &ex)
Like setInterrupted(true), but also allows an exception to be stored which can be tested and retrieve...
Definition NidasApp.cc:1137
NidasAppArg DebugDaemon
Definition NidasApp.h:675
NidasAppArg LogShow
Definition NidasApp.h:659
std::string getUserName()
Return the username passed to the Username argument, if enabled, otherwise return an empty string.
Definition NidasApp.h:1346
bool _processData
Definition NidasApp.h:1455
NidasAppArg * parseNext()
Parse the next recognized argument from the list set in startArgs().
Definition NidasApp.cc:824
void parseLogLevel(const std::string &optarg)
This is an alias for parseLogConfig(), since the LogConfig string syntax is backwards compatible with...
Definition NidasApp.h:957
std::string usage(const std::string &indent, bool brief)
Return a usage string describing the arguments accepted by this application, rendering each argument ...
Definition NidasApp.cc:1245
bool nextArg(std::string &arg)
If the next argument to be parsed does not start with '-', then copy it into arg and remove it from t...
Definition NidasApp.cc:809
void setupLogScheme()
Definition NidasApp.cc:603
int _outputFileLength
Definition NidasApp.h:1472
int logLevel()
Return LogScheme::logLevel() for the current log scheme.
Definition NidasApp.cc:1354
IdFormat getIdFormat()
Definition NidasApp.h:1251
void setupDaemon()
Call setupDaemon(daemon_mode), where daemon_mode is true only if DebugDaemon is false.
Definition NidasApp.cc:1420
bool hasException()
See setException().
Definition NidasApp.cc:1147
uid_t getUserID()
Return the userid of the username passed to the Username argument, otherwise 0.
Definition NidasApp.h:1356
NidasAppArg Help
Definition NidasApp.h:663
bool inputsProvided()
Definition NidasApp.h:986
NidasAppArg LogFields
Definition NidasApp.h:661
void setupProcess()
Setup a process with the user and group specified by the Username argument, and attempt to set relate...
Definition NidasApp.cc:1469
bool processData()
Return the current process-data setting for this NidasApp.
Definition NidasApp.h:1046
NidasAppArg OutputFiles
Definition NidasApp.h:672
std::string _argv0
Definition NidasApp.h:1453
void parseInputs(const std::vector< std::string > &inputs, std::string default_input="", int default_port=0)
Parse one or more input URLs from a list of non-option command-line arguments.
Definition NidasApp.cc:980
std::string _hostname
Definition NidasApp.h:1479
void requireLongFlag(const nidas_app_arglist_t &arglist, bool require=true)
Call acceptShortFlag(false) on the given list of NidasApp instances, meaning only the long flag will ...
Definition NidasApp.h:820
uid_t _userid
Definition NidasApp.h:1481
void parseOutput(const std::string &optarg)
Parse an output specifier in the form <strptime-filename-pattern>[<length>[smh]].
Definition NidasApp.cc:1048
bool _help
Definition NidasApp.h:1474
nidas::util::Exception _exception
Definition NidasApp.h:1493
NidasAppArg Hostname
Definition NidasApp.h:674
gid_t _groupid
Definition NidasApp.h:1483
nidas::util::UTime getEndTime()
Return the EndTime as a UTime.
Definition NidasApp.h:1110
void setupDaemonLogging()
Call setupDaemonLogging(daemon_mode), where daemon_mode is true only if DebugDaemon is false.
Definition NidasApp.cc:1389
std::string outputFileName()
Return just the output file pattern specified by an output option, without the file length specifier.
Definition NidasApp.h:1005
nidas::util::UTime _startTime
Definition NidasApp.h:1463
NidasAppArg Clipping
Definition NidasApp.h:678
void setProcessData(bool process)
Set the process-data setting in this NidasApp.
Definition NidasApp.h:1037
int checkPidFile()
Create a pid file for this process and return 0.
Definition NidasApp.cc:1667
NidasAppArg ConfigsArg
Definition NidasApp.h:676
NidasAppArg XmlHeaderFile
Definition NidasApp.h:658
NidasAppArg PidFile
It is not enough to enable this arg in an app, the app must must call checkPidFile() as well.
Definition NidasApp.h:685
std::list< std::string > & dataFileNames()
Return the list of filenames parsed from the input URLs with parseInputs().
Definition NidasApp.h:1311
Project * getProject()
Return a pointer to the application-wide Project instance.
Definition NidasApp.cc:1262
ArgVector _argv
Definition NidasApp.h:1489
nidas::util::auto_ptr< nidas::util::SocketAddress > _sockAddr
Definition NidasApp.h:1469
NidasAppArg LogConfig
Definition NidasApp.h:660
NidasAppArg SampleRanges
Definition NidasApp.h:667
nidas::util::UTime _endTime
Definition NidasApp.h:1465
void setApplicationInstance()
An instance of NidasApp can be set as an application-wide instance, like an application context,...
Definition NidasApp.cc:650
nidas_app_arglist_t loggingArgs()
This is a convenience method to return all of the logging-related options in a list,...
Definition NidasApp.cc:1212
void setIdFormat(IdFormat idt)
Store the format in which sample IDs should be shown.
Definition NidasApp.cc:1295
NidasAppArg Version
Definition NidasApp.h:670
void setFileSetTimes(const nidas::util::UTime &start, const nidas::util::UTime &end, nidas::core::FileSet *fset)
Definition NidasApp.cc:1731
NidasAppArg LogParam
Definition NidasApp.h:662
void requireArguments(const nidas_app_arglist_t &arglist)
Add arguments to this NidasApp same as enableArguments() but also set them as required.
Definition NidasApp.cc:702
std::string _xmlFileName
Definition NidasApp.h:1457
NidasAppArg Username
Definition NidasApp.h:673
void parseLogConfig(const std::string &optarg)
Parse a LogConfig from the given argument using the LogConfig string syntax, and add that LogConfig t...
Definition NidasApp.cc:742
NidasAppArg SorterLength
Definition NidasApp.h:679
std::string getConfigsXML()
Derive the path to the XML file which lists project configs.
Definition NidasApp.cc:411
ArgVector unparsedArgs()
Definition NidasApp.cc:780
static std::ostream & formatSampleId(std::ostream &out, IdFormat idfmt, dsm_sample_id_t sid)
Write the sensor-plus-sample ID part of sid to stream out using the format specified in idfmt.
Definition NidasApp.cc:1303
std::list< std::string > _dataFileNames
Definition NidasApp.h:1467
void setOutputClipping(const nidas::util::UTime &start, const nidas::util::UTime &end, nidas::core::SampleOutputBase *output)
If Clipping has been enabled, call setTimeClippingWindow() on the given output using start and end.
Definition NidasApp.cc:1714
std::string _outputFileName
Definition NidasApp.h:1471
void lockMemory()
Attempt mlockall() for this process, first adding the CAP_IPC_LOCK capability if possible.
Definition NidasApp.cc:1445
std::string formatId(dsm_sample_id_t sid)
A more convenient form of formatSampleId() which just returns a string, and also includes the DSM id ...
Definition NidasApp.cc:1343
nidas::util::LogScheme _logscheme
NidasApp keeps track of the LogScheme built up from arguments.
Definition NidasApp.h:1498
nidas::util::UTime getStartTime()
Return the StartTime as a UTime.
Definition NidasApp.h:1097
NidasAppArg DatasetName
Definition NidasApp.h:677
IdFormat _idFormat
Definition NidasApp.h:1459
NidasAppArg EndTime
Definition NidasApp.h:666
~NidasApp()
If this instance is the current application instance, then the application instance is reset to null ...
Definition NidasApp.cc:626
id_format_t
The four possible output formats for sensor-plus-sample IDs:
Definition NidasApp.h:590
@ OCTAL_ID
Definition NidasApp.h:591
@ AUTO_ID
Definition NidasApp.h:591
@ HEX_ID
Definition NidasApp.h:591
@ DECIMAL_ID
Definition NidasApp.h:591
@ NOFORMAT_ID
Definition NidasApp.h:591
bool _hasException
Definition NidasApp.h:1492
std::string xmlHeaderFile()
Definition NidasApp.h:1052
nidas::util::SocketAddress * socketAddress()
If parseInputs() parsed a network socket specifier, then this method returns a pointer to the corresp...
Definition NidasApp.h:1322
float getSorterLength(float min, float max)
Return sorter length value, or throw std::invalid_argument.
Definition NidasApp.cc:1700
static void addSignal(int signum, void(*callback)(int signum)=0, bool nolog=false)
Add the given signal signum to the list of signals handled by the NidasApp signal handler,...
Definition NidasApp.cc:1183
uid_t getGroupID()
Return the groupid of the username passed to the Username argument, otherwise 0.
Definition NidasApp.h:1366
nidas_app_arglist_t getArguments()
Return the list of arguments which are supported by this NidasApp, in other words,...
Definition NidasApp.cc:734
void resetLogging()
Reset logging to the NidasApp default.
Definition NidasApp.cc:1380
SampleMatcher _sampleMatcher
Definition NidasApp.h:1461
void checkRequiredArguments()
Verify that all NidasAppArg arguments required by this NidasApp have been specified,...
Definition NidasApp.cc:715
Definition Project.h:60
Match samples according to DSM and Sample ID ranges, and configure the ranges with criteria in text f...
Definition SampleMatcher.h:21
Implementation of portions of SampleOutput.
Definition SampleOutput.h:160
Definition Exception.h:35
virtual const char * what() const
Definition Exception.h:98
Exception(const std::string &type, const std::string &n, const std::string &m)
Definition Exception.h:41
A LogScheme is a vector of LogConfig's and the vector of fields to show in log messages.
Definition Logger.h:680
An interface for a socket address.
Definition SocketAddress.h:36
A class for parsing, formatting and doing operations on time, based on Unix time conventions,...
Definition UTime.h:95
void setupSignals()
Definition dmd_mmat_test.cc:286
Sample * getSample(sampleType type, unsigned int len)
A convienence method for getting a sample of an enumerated type from a pool.
Definition Sample.cc:70
std::vector< NidasAppArg * > nidas_app_arglist_t
Lists of arguments can be manipulated together by putting them into this container type.
Definition NidasApp.h:49
nidas_app_arglist_t operator|(nidas_app_arglist_t arglist1, nidas_app_arglist_t arglist2)
Combine two arglists into a single arglist without any duplicates.
Definition NidasApp.cc:1221
std::vector< std::string > ArgVector
Convenience typedef for handling the command-line argv as a vector of strings.
Definition NidasApp.h:55
std::string expectArg(const ArgVector &args, int i)
Definition NidasApp.h:58
unsigned int dsm_sample_id_t
Definition Sample.h:64
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31
static bool interrupted
Definition nidas_udp_relay.cc:76
static n_u::SerialPort port
Definition sing.cc:68
Convert vector<string> args to dynamically allocated (argc, argv) pair which will be freed when the i...
Definition NidasApp.h:1520
char ** argv
Definition NidasApp.h:1554
ArgVector unparsedArgs(int optindex)
Given the opt index after getopt() finishes, return a vector of any remaining arguments,...
Definition NidasApp.h:1540
int argc
Definition NidasApp.h:1555
~NidasAppArgv()
Definition NidasApp.h:1545
std::vector< char * > vargv
Definition NidasApp.h:1553
NidasAppArgv(const std::string &argv0, const std::vector< std::string > &args)
Definition NidasApp.h:1521
NidasAppArgv(const NidasAppArgv &)
NidasAppArgv & operator=(const NidasAppArgv &)