EPICS ARCHIVER V4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
GroupInfo.h
1 // --------------------- -*- c++ -*- ----------------------
2 // $Id: GroupInfo.h,v 1.11 2006/05/01 18:10:32 kasemir Exp $
3 //
4 // Please refer to NOTICE.txt,
5 // included as part of this distribution,
6 // for legal information.
7 //
8 // Kay-Uwe Kasemir, kasemir@lanl.gov
9 // --------------------------------------------------------
10 #ifndef __GROUPINFO_H__
11 #define __GROUPINFO_H__
12 
13 #include <stdlib.h>
14 
15 // epics
16 #include <epicsTime.h>
17 
19 #include "tools/ToolsConfig.h"
20 #include "tools/Guard.h"
21 #include "tools/FUX.h"
22 
23 class ArchiveChannel;
24 
25 // engine
26 #include "engine/Named.h"
27 
42 class GroupInfo : public NamedBase, public Guardable {
43 
44 public:
45 
47  GroupInfo(const std::string &name);
48 
50  virtual ~GroupInfo();
51 
53  inline OrderedMutex& getMutex();
54 
56  void addChannel(Guard &group_guard, ArchiveChannel* channel);
57 
59  const stdList<class ArchiveChannel *>&
60  getChannels(Guard& group_guard) const;
61 
63  void disable(Guard& group_guard,
64  ArchiveChannel* cause,
65  const epicsTime& when);
66 
68  void enable(Guard& group_guard,
69  ArchiveChannel* cause,
70  const epicsTime& when);
71 
73  inline bool isEnabled(Guard& group_guard) const;
74 
76  inline size_t getNumConnected(Guard &group_guard) const;
77 
79  void incConnected(Guard& group_guard, ArchiveChannel& pv);
80 
82  void decConnected(Guard& group_guard, ArchiveChannel& pv);
83 
85  void addToFUX(Guard& group_guard, FUX::Element* doc);
86 
87 private:
88 
89  GroupInfo(const GroupInfo &); // not impl.
90  GroupInfo & operator = (const GroupInfo &); // not impl.
91 
92  OrderedMutex mutex;
93 
94  stdList<ArchiveChannel *> channels;
95  size_t num_connected;
96  size_t disable_count; // disabled by how many channels?
97 };
98 
100  return mutex;
101 }
102 
103 inline bool GroupInfo::isEnabled(Guard& group_guard) const {
104  return disable_count <= 0;
105 }
106 
107 inline size_t GroupInfo::getNumConnected(Guard& group_guard) const {
108  return num_connected;
109 }
110 
111 #endif //__GROUPINFO_H__
bool isEnabled(Guard &group_guard) const
Check if enable.
Definition: GroupInfo.h:103
const stdList< class ArchiveChannel * > & getChannels(Guard &group_guard) const
Return current list of group members.
A mutex with informational name and lock order.
Definition: OrderedMutex.h:34
A named thingy.
Definition: Named.h:28
void addToFUX(Guard &group_guard, FUX::Element *doc)
Append this group to a FUX document.
OrderedMutex & getMutex()
Guardable interface.
Definition: GroupInfo.h:99
size_t getNumConnected(Guard &group_guard) const
Definition: GroupInfo.h:107
void decConnected(Guard &group_guard, ArchiveChannel &pv)
Invoked by ArchiveChannel to update connection count.
Automatically takes and releases an epicsMutex.
Definition: Guard.h:63
void enable(Guard &group_guard, ArchiveChannel *cause, const epicsTime &when)
Enable all channels of this group.
void incConnected(Guard &group_guard, ArchiveChannel &pv)
Invoked by ArchiveChannel to update connection count.
Interface for something that can be protected by a Guard.
Definition: Guard.h:49
One archived channel.
Definition: ArchiveChannel.h:19
virtual ~GroupInfo()
Destructor.
void addChannel(Guard &group_guard, ArchiveChannel *channel)
Add channel to this group.
One element in the FUX tree.
Definition: FUX.h:51
void disable(Guard &group_guard, ArchiveChannel *cause, const epicsTime &when)
Disable all channels of this group.
A Group of channels.
Definition: GroupInfo.h:42
GroupInfo(const std::string &name)
Constructor.