DLS  1.6
Job.h
1 /*****************************************************************************
2  *
3  * This file is part of the Data Logging Service (DLS).
4  *
5  * DLS is free software: you can redistribute it and/or modify it under the
6  * terms of the GNU General Public License as published by the Free Software
7  * Foundation, either version 3 of the License, or (at your option) any later
8  * version.
9  *
10  * DLS is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with DLS. If not, see <http://www.gnu.org/licenses/>.
17  *
18  ****************************************************************************/
19 
20 #ifndef LibDLSJobH
21 #define LibDLSJobH
22 
23 /****************************************************************************/
24 
25 #include <string>
26 #include <list>
27 #include <set>
28 
29 #include "Exception.h"
30 #include "Time.h"
31 #include "JobPreset.h"
32 #include "Channel.h"
33 #include "globals.h"
34 
35 /****************************************************************************/
36 
37 namespace DlsProto {
38  class Response;
39  class JobInfo;
40 }
41 
42 namespace LibDLS {
43 
44 class Directory;
45 class BaseMessageList;
46 
47 /****************************************************************************/
48 
52  public Exception
53 {
54  public:
55  JobException(const std::string &pmsg):
56  Exception(pmsg) {};
57 };
58 
59 /****************************************************************************/
60 
64 {
65  public:
66  Job(Directory *);
67  Job(Directory *, const DlsProto::JobInfo &);
68  ~Job();
69 
70  void import(const std::string &, unsigned int);
71  void fetch_channels();
72 
73  std::list<Channel> &channels() { return _channels; }
74  Channel *channel(unsigned int);
75  Channel *find_channel(unsigned int);
76  std::set<Channel *> find_channels_by_name(const std::string &);
77 
78  const std::string &path() const { return _path; }
79  unsigned int id() const { return _preset.id(); }
80  const JobPreset &preset() const { return _preset; }
81 
82  bool operator<(const Job &) const;
83 
84  struct DLS_PUBLIC Message
85  {
86  Message():
87  type(Unknown), index(-1) {}
88 
89  Time time;
90  enum Type {
91  Unknown = -1,
92  Info,
93  Warning,
94  Error,
95  Critical,
96  Broadcast,
97  Reset,
98  TypeCount
99  };
100  Type type;
101  std::string text;
102  int index;
103 
104  bool operator<(const Message &other) const {
105  return time < other.time;
106  }
107  bool operator==(const Message &other) const {
108  return time == other.time and
109  type == other.type and
110  text == other.text and
111  index == other.index;
112  }
113 
114  const std::string &type_str() const;
115  };
116 
117  std::list<Message> load_msg(Time, Time,
118  std::string = std::string()) const;
119  std::list<Message> load_msg_filtered(Time, Time,
120  const std::string &, std::string = std::string()) const;
121 
122  void set_job_info(DlsProto::JobInfo *, bool = true) const;
123  Directory *dir() const { return _dir; }
124 
125  private:
126  Directory * const _dir;
127  std::string _path;
128  JobPreset _preset;
129  std::list<Channel> _channels;
130  BaseMessageList *_messages;
132  void _fetch_channels_local();
133  void _fetch_channels_network();
134 
135  void _load_msg_local(std::list<Message> &, Time, Time,
136  const std::string &, std::string = std::string()) const;
137  void _load_msg_network(std::list<Message> &, Time, Time,
138  const std::string &, std::string = std::string()) const;
139 
140  Job(); // private
141 };
142 
143 /*****************************************************************************/
144 
145 } // namespace
146 
147 /*****************************************************************************/
148 
149 #endif
DLS Data Directory.
Definition: Dir.h:82
Base class for all LibDLS exceptions.
Definition: Exception.h:36
Darstellung eines Kanals in der Anzeige.
Definition: Channel.h:71
Auftragsvorgaben mit Liste der Kanalvorgaben.
Definition: JobPreset.h:64
Global data structures and functions.
Measuring job.
Definition: Job.h:63
Definition: Channel.h:44
Datentyp zur Speicherung der Zeit in Mikrosekunden.
Definition: Time.h:46
DLS_PUBLIC bool operator<(const RealChannel &a, const RealChannel &b)
Less operator for sorting RealChannel lists.
#define DLS_PUBLIC
Macro for public method definitions (empty on non-win32).
Definition: globals.h:57
Job exception.
Definition: Job.h:51