nidas  v1.2-1520
PSQLSampleOutput.h
Go to the documentation of this file.
1 /* vim: set shiftwidth=4 softtabstop=4 expandtab: */
2 /* -*- mode: c++; c-basic-offset: 4; -*- */
3 /*
4  ********************************************************************
5  ** NIDAS: NCAR In-situ Data Acquistion Software
6  **
7  ** 2005, Copyright University Corporation for Atmospheric Research
8  **
9  ** This program is free software; you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation; either version 2 of the License, or
12  ** (at your option) any later version.
13  **
14  ** This program is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** The LICENSE.txt file accompanying this software contains
20  ** a copy of the GNU General Public License. If it is not found,
21  ** write to the Free Software Foundation, Inc.,
22  ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  **
24  ********************************************************************
25 */
26 /********************************************************************
27 
28 */
29 
30 #ifndef NIDAS_DYNLD_PSQL_PSQLSAMPLEOUTPUT_H
31 #define NIDAS_DYNLD_PSQL_PSQLSAMPLEOUTPUT_H
32 
34 #include "PSQLChannel.h"
35 
36 #include <map>
37 
38 namespace nidas { namespace dynld { namespace psql {
39 
41 {
42 public:
43 
45 
47 
48  virtual ~PSQLSampleOutput();
49 
50  PSQLSampleOutput* clone(IOChannel* iochannel = 0) const;
51 
52  void setName(const std::string& val) { name = val; }
53 
54  const std::string& getName() const { return name; }
55 
56  bool isRaw() const { return false; }
57 
58  void setPseudoPort(int val) {}
59 
60  int getPseudoPort() const { return 0; }
61 
62  void setDSMConfigs(const std::list<const DSMConfig*>& val);
63 
64  void addDSMConfig(const DSMConfig*);
65 
66  const std::list<const DSMConfig*>& getDSMConfigs() const;
67 
68  void addSampleTag(const SampleTag* tag)
70 
72  throw(nidas::util::IOException);
73 
74  void connected(SampleOutput* origout, SampleOutput* newout) throw();
75 
76  void connect() throw(nidas::util::IOException);
77 
78  void connected(IOChannel* output) throw();
79 
80  void init() throw();
81 
82  bool receive(const Sample*) throw();
83 
84  int getFd() const { return -1; }
85 
86  void flush() throw(nidas::util::IOException);
87 
88  void close() throw(nidas::util::IOException);
89 
90  void fromDOMElement(const xercesc::DOMElement* node)
91  throw(nidas::util::InvalidParameterException);
92 
93 protected:
94 
95  void submitCommand(const std::string& command) throw(nidas::util::IOException);
96 
97  void createTables() throw(nidas::util::IOException);
98 
99  void dropAllTables() throw();
100 
101  void initializeGlobalAttributes() throw(nidas::util::IOException);
102 
103  void addVariable(const Variable* var) throw(nidas::util::IOException);
104 
105  void addCategory(const std::string& varName, const std::string& category)
106  throw(nidas::util::IOException);
107 
108  std::string name;
109 
111 
112  std::list<const DSMConfig*> dsms;
113 
115 
116  // std::list<const SampleTag*> sampleTags;
117 
118  std::map<float,const SampleTag*> tagsByRate;
119 
120  std::map<float,std::string> tablesByRate;
121 
123 
125 
126  bool first;
127 
128  int dberrors;
129 };
130 
131 }}}
132 
133 #endif // NIDAS_DYNLD_PSQL_PSQLSAMPLEOUTPUT_H
134 
Interface for an object that requests connections SampleOutputs.
Definition: ConnectionRequester.h:42
void initializeGlobalAttributes()
Definition: PSQLSampleOutput.cc:243
void requestConnection(SampleConnectionRequester *)
Request a connection, but don&#39;t wait for it.
Definition: PSQLSampleOutput.cc:67
void addCategory(const std::string &varName, const std::string &category)
Definition: PSQLSampleOutput.cc:332
std::map< float, std::string > tablesByRate
Definition: PSQLSampleOutput.h:120
void setPseudoPort(int val)
Definition: PSQLSampleOutput.h:58
unsigned int dsm_sample_id_t
Definition: Sample.h:63
void connected(SampleOutput *origout, SampleOutput *newout)
Definition: PSQLSampleOutput.cc:102
int getPseudoPort() const
Definition: PSQLSampleOutput.h:60
bool isRaw() const
Definition: PSQLSampleOutput.h:56
A class for serializing Samples on an OutputStream.
Definition: SampleOutputStream.h:40
std::string name
Definition: PSQLSampleOutput.h:108
Interface of an output stream of samples.
Definition: SampleOutput.h:47
Class describing a sampled variable.
Definition: Variable.h:46
void fromDOMElement(const xercesc::DOMElement *node)
Initialize myself from a xercesc::DOMElement.
Definition: PSQLSampleOutput.cc:428
Definition: PSQLChannel.h:38
Class that should include all that is configurable about a DSM.
Definition: DSMConfig.h:55
void addSampleTag(const SampleTag *tag)
PSQLChannel * psqlChannel
Definition: PSQLSampleOutput.h:114
A channel for Input or Output of data.
Definition: IOChannel.h:64
void setDSMConfigs(const std::list< const DSMConfig * > &val)
Definition: PSQLSampleOutput.cc:84
SampleConnectionRequester * connectionRequester
Definition: PSQLSampleOutput.h:110
void connect()
Definition: PSQLSampleOutput.cc:77
bool receive(const Sample *)
Method called to pass a sample to this client.
Definition: PSQLSampleOutput.cc:342
void submitCommand(const std::string &command)
Definition: PSQLSampleOutput.cc:174
PSQLSampleOutput * clone(IOChannel *iochannel=0) const
Definition: PSQLSampleOutput.cc:59
void createTables()
Definition: PSQLSampleOutput.cc:180
const std::list< const DSMConfig * > & getDSMConfigs() const
Definition: PSQLSampleOutput.cc:94
const std::string & getName() const
Definition: PSQLSampleOutput.h:54
void dropAllTables()
Definition: PSQLSampleOutput.cc:224
bool first
Definition: PSQLSampleOutput.h:126
void setName(const std::string &val)
Definition: PSQLSampleOutput.h:52
Interface to a data sample.
Definition: Sample.h:189
std::map< float, const SampleTag * > tagsByRate
Definition: PSQLSampleOutput.h:118
PSQLSampleOutput()
Definition: PSQLSampleOutput.cc:41
float missingValue
Definition: PSQLSampleOutput.h:124
Definition: IOException.h:37
std::list< const DSMConfig * > dsms
Definition: PSQLSampleOutput.h:112
Class describing a group of variables that are sampled and handled together.
Definition: SampleTag.h:87
int dberrors
Definition: PSQLSampleOutput.h:128
std::map< dsm_sample_id_t, const SampleTag * > tagsById
Definition: PSQLSampleOutput.h:122
void flush()
Ask that this SampleClient send out any buffered Samples that it may be holding.
Definition: PSQLSampleOutput.cc:119
void close()
Definition: PSQLSampleOutput.cc:126
virtual ~PSQLSampleOutput()
Definition: PSQLSampleOutput.cc:54
Definition: PSQLSampleOutput.h:40
int getFd() const
Definition: PSQLSampleOutput.h:84
void addDSMConfig(const DSMConfig *)
Definition: PSQLSampleOutput.cc:89
Definition: InvalidParameterException.h:35
void init()
Definition: PSQLSampleOutput.cc:159
void addVariable(const Variable *var)