00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00018 #ifndef LIBCWD_CLASS_CHANNEL_H
00019 #define LIBCWD_CLASS_CHANNEL_H
00020
00021 #ifndef LIBCWD_CONFIG_H
00022 #include <libcwd/config.h>
00023 #endif
00024 #ifndef LIBCWD_MAX_LABEL_LEN_H
00025 #include <libcwd/max_label_len.h>
00026 #endif
00027 #ifndef LIBCWD_CONTROL_FLAG_H
00028 #include <libcwd/control_flag.h>
00029 #endif
00030 #ifndef LIBCWD_PRIVATE_STRUCT_TSD_H
00031 #include <libcwd/private_struct_TSD.h>
00032 #endif
00033
00034 namespace libcwd {
00035
00082 class channel_ct {
00083 private:
00084 #if LIBCWD_THREAD_SAFE
00085 int WNS_index;
00086
00087 #else // !LIBCWD_THREAD_SAFE
00088 int off_cnt;
00089
00090
00091
00092 #endif // !LIBCWD_THREAD_SAFE
00093
00094 char WNS_label[max_label_len_c + 1];
00095
00096
00097
00098
00099 bool WNS_initialized;
00100
00101
00102 public:
00103
00104
00105
00106
00107
00108
00109
00110 explicit channel_ct(char const* label, bool add_to_channel_list = true);
00111
00112
00113 void NS_initialize(char const* label LIBCWD_COMMA_TSD_PARAM, bool add_to_channel_list);
00114
00115
00116
00117 public:
00118
00119
00120
00121
00122 void off(void);
00123 void on(void);
00124
00125 struct OnOffState {
00126 int off_cnt;
00127 };
00128
00129 void force_on(OnOffState& state, char const* label);
00130 void restore(OnOffState const& state);
00131
00132 public:
00133
00134
00135
00136
00137 char const* get_label(void) const;
00138 bool is_on(void) const;
00139 #if LIBCWD_THREAD_SAFE
00140 bool is_on(LIBCWD_TSD_PARAM) const;
00141 #endif
00142 };
00143
00144 }
00145
00146 #endif // LIBCWD_CLASS_CHANNEL_H
00147