Updated Russian documentation by Morse.
[amule.git] / src / StatTree.h
blob01ccbb2bdb09c0b080b6e3926618a41dc77c9d7d
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2005-2011 Dévai Tamás ( gonosztopi@amule.org )
6 //
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
9 // respective authors.
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #ifndef STATTREE_H
27 #define STATTREE_H
29 /**
30 * @file StatTree.h
32 * Interface to stat tree nodes.
34 * This file defines various classes representing
35 * statistics tree nodes.
39 #ifndef CLIENT_GUI
40 # define VIRTUAL virtual
41 #else
42 # define VIRTUAL
43 #endif
46 #include <list> // Needed for std::list
47 #include <wx/string.h> // Needed for wxString
48 #include <wx/thread.h> // Needed for wxMutex
49 #include "Types.h"
51 #ifndef CLIENT_GUI
53 #include <wx/datetime.h> // Needed for wxDateTime
54 #include "GetTickCount.h" // Needed for GetTickCount64()
57 /**
58 * Stat tree flags
60 enum EStatTreeFlags
62 stNone = 0, ///< Nothing. Really.
63 stSortChildren = 1, ///< Childrens are sorted descending by their ID.
64 stShowPercent = 2, /*!< Shows percentage compared to parent.
65 * Counters only, whose parent is also counter! (khmm...)
67 stHideIfZero = 4, ///< Hides item (and children) if value is zero.
68 stSortByValue = 8, /*!< Together with stSortChildren, sorts children by their value.
69 * WARNING! This assumes that value-sorted children are
70 * counters!
71 * Sort-by-value works only on children with ID between 0x00000100-0x7fffffff.
72 * @note CStatTreeItemBase::ReSortChildren() must be called to get sort order right.
74 stCapChildren = 16 ///< Caps children list.
75 /*!< Shows only top n children, where n is set by CStatisticsDlg::FillTree() to thePrefs::GetMaxClientVersions().
76 * The list itself is not changed, only visibility is ignored on items
77 * outside the top n visible.
79 * On an EC request, visibility range can be set with the EC_TAG_STATTREE_CAPPING tag.
83 enum EValueType
85 vtUnknown,
86 vtString,
87 vtInteger,
88 vtFloat
91 /**
92 * Display modes for Simple and Counter items
94 enum EDisplayMode
96 dmDefault, ///< Default display mode.
97 dmTime, ///< Treat integer value as time in seconds.
98 dmBytes ///< Treat integer value as bytes count.
101 #endif /* !CLIENT_GUI */
104 class CStatTreeItemBase;
105 typedef std::list<CStatTreeItemBase*>::iterator StatTreeItemIterator;
108 class CECTag;
110 uint32_t NewStatTreeItemId();
114 * Base tree item class
116 class CStatTreeItemBase
118 public:
120 #ifndef CLIENT_GUI
122 * Creates an item with a constant label.
124 * @param label Visible text for the item.
125 * @param flags Flags to use.
127 CStatTreeItemBase(const wxString &label, unsigned flags = stNone)
128 : m_label(label), m_parent(NULL), m_flags(flags), m_id(0),
129 m_uniqueid(NewStatTreeItemId())
131 #else
133 * Creates an item with a constant label.
135 * @param label Visible text for the item.
137 CStatTreeItemBase(const wxString &label, uint32_t uniqueid)
138 : m_label(label), m_uniqueid(uniqueid)
142 * Creates an item (and the whole subtree) from an EC tag.
144 * @param tag EC tag containing a stat subtree.
146 CStatTreeItemBase(const CECTag *tag);
147 #endif
150 * Deletes all children.
152 VIRTUAL ~CStatTreeItemBase();
154 #ifndef CLIENT_GUI
156 * Adds a new child node.
158 * @param child child to add.
159 * @param id an optional ID for the new item.
160 * @param skipOneLevel activates a trick to let the code work for aMule OSInfo and Version trees.
162 * @return the newly added item.
164 CStatTreeItemBase *AddChild(
165 CStatTreeItemBase* child,
166 uint32_t id = 0,
167 bool skipOneLevel = false);
168 #endif
171 * Check for children.
173 * @return true if this node has children, false otherwise.
175 bool HasChildren() { wxMutexLocker lock(m_lock); return !m_children.empty(); }
178 * Check for visible children.
180 * @return true if this node has children and at least one of them is visible.
182 bool HasVisibleChildren();
184 #ifndef CLIENT_GUI
187 * Check for a given child.
189 * @return true if this node has a child with the given ID.
191 bool HasChildWithId(uint32_t id);
194 * Access a specific child.
196 * @return the child with the given ID, or NULL if not found.
198 CStatTreeItemBase *GetChildById(uint32_t id);
201 * Get the first visible child.
203 * @param max_children The maximum number of children to show, when the stCapChildren flag is set. Otherwise it has no effect. (0 = unlimited)
205 * @return An iterator, that should be passed to GetNextVisibleChild() and IsAtEndOfList().
207 StatTreeItemIterator GetFirstVisibleChild(uint32_t max_children);
210 * Get the next visible child.
212 void GetNextVisibleChild(StatTreeItemIterator& it);
214 #else /* CLIENT_GUI */
217 * Get the first visible child.
219 * @return An iterator, that should be passed to GetNextVisibleChild() and IsAtEndOfList().
221 * @note On a remote list every item is visible.
223 StatTreeItemIterator GetFirstVisibleChild() { return m_children.begin(); }
226 * Get the next visible child.
228 * @note On a remote list every item is visible.
230 void GetNextVisibleChild(StatTreeItemIterator& it) { ++it; }
232 #endif /* !CLIENT_GUI / CLIENT_GUI */
235 * Check if we are past the end of child list.
237 bool IsAtEndOfList(StatTreeItemIterator& it) { return it == m_children.end(); }
239 #ifndef CLIENT_GUI
241 * Resorts children for the stSortByValue flag.
243 void ReSortChildren() { wxMutexLocker lock(m_lock); m_children.sort(ValueSort); }
244 #endif
246 #ifndef AMULE_DAEMON
247 #ifndef CLIENT_GUI
249 * Returns a string that will be displayed on the GUI tree.
251 virtual wxString GetDisplayString() const;
252 #else
254 * Returns the associated text (GUI item label).
256 const wxString& GetDisplayString() const { return m_label; }
257 #endif /* !CLIENT_GUI / CLIENT_GUI */
260 * Returns the mutex used to lock the child list of this node.
262 * This function is used by CStatisticsDlg to be able to lock the
263 * core tree while updating the GUI tree.
265 wxMutex& GetLock() { return m_lock; }
268 * Returns the unique ID of this node.
270 uint32_t GetUniqueId() const { return m_uniqueid; }
271 #endif /* !AMULE_DAEMON */
274 * Check whether this node is visible.
276 VIRTUAL bool IsVisible() const { return true; }
278 #ifndef CLIENT_GUI
280 * Create an EC tag from this node (and children).
282 * @param max_children The maximum number of children to show, when the stCapChildren flag is set. Otherwise it has no effect. (0 = unlimited)
284 * @return A EC tag containing this node and all its children.
286 virtual CECTag *CreateECTag(uint32_t max_children);
287 #endif
289 protected:
291 #ifndef CLIENT_GUI
293 * Add values to the EC tag being generated.
295 * Should have a real implementation in children which have some value.
296 * The given parameter is the tag to which values should be added.
298 virtual void AddECValues(CECTag*) const {}
299 #endif
301 //! Unformatted and untranslated label of the node. Note: On remote gui it is already formatted and translated.
302 const wxString m_label;
303 #ifndef CLIENT_GUI
305 //! Parent of this node.
306 CStatTreeItemBase *m_parent;
308 //! Flags for the node.
309 unsigned m_flags;
310 #endif
312 private:
314 #ifndef CLIENT_GUI
315 //! Function used when sorting children by value.
316 static bool ValueSort(const CStatTreeItemBase* a, const CStatTreeItemBase* b);
318 //! ID of this node.
319 uint32_t m_id;
321 //! Counter to keep track of displayed visible items
322 // (needed for the stCapChildren flag)
323 uint32_t m_visible_counter;
324 #endif
326 //! Unique ID of this node.
327 uint32_t m_uniqueid;
329 //! Children of this node.
330 std::list<CStatTreeItemBase*> m_children;
332 //! Lock to protect list from simultanous access.
333 wxMutex m_lock;
338 // Anything below is only for core.
340 #ifndef CLIENT_GUI
343 * Simple tree item.
345 * This tree item has one value and nothing speciality. :)
346 * The value might be an arbitrary integer or floating point type,
347 * or a wxString string.
349 * The item is able to display value in different formats, see SetDisplayMode().
351 * @note that you have to specify the right format code on 'label', i.e.:
352 * %s for string and integers with displayMode dmTime or dmBytes,
353 * %u or similar for integers, and
354 * %f or similar for floating point types.
356 * @note You have to call SetValue() after creation for non-integer values, otherwise
357 * you'll get undesired results.
359 class CStatTreeItemSimple : public CStatTreeItemBase
361 public:
364 * Constructor.
366 * @see CStatTreeItemBase::CStatTreeItemBase
368 CStatTreeItemSimple(
369 const wxString &label,
370 unsigned flags = stNone,
371 enum EDisplayMode displaymode = dmDefault)
373 CStatTreeItemBase(label, flags),
374 m_valuetype(vtUnknown),
375 m_displaymode(displaymode)
377 SetValue((uint64_t)0);
381 * Sets the desired display mode of value.
383 void SetDisplayMode(enum EDisplayMode mode)
385 m_displaymode = mode;
389 * Sets an integer type value.
391 * @param value the value to be set.
393 void SetValue(uint64_t value)
395 m_valuetype = vtInteger;
396 m_intvalue = value;
400 * Sets a floating point type value.
402 * @param value the value to be set.
404 void SetValue(double value)
406 m_valuetype = vtFloat;
407 m_floatvalue = value;
411 * Sets a string type value.
413 * @param value the value to be set.
415 void SetValue(const wxString& value)
417 m_valuetype = vtString;
418 m_stringvalue = value;
421 #ifndef AMULE_DAEMON
423 * @see CStatTreeItemBase::GetDisplayString()
425 virtual wxString GetDisplayString() const;
426 #endif
429 * @see CStatTreeItemBase::IsVisible()
431 virtual bool IsVisible() const;
433 protected:
435 * Add values to EC tag being generated.
437 * @param tag The tag to which values should be added.
439 * @see CStatTreeItemBase::AddECValues
441 virtual void AddECValues(CECTag *tag) const;
443 //! Type of the value.
444 enum EValueType m_valuetype;
445 //! Display mode of the value.
446 enum EDisplayMode m_displaymode;
447 //! Union to save space.
448 union
450 uint64_t m_intvalue; ///< Integer value.
451 double m_floatvalue; ///< Floating point value.
453 wxString m_stringvalue; ///< String value.
458 * Counter-type tree item template.
460 * Able to show percentage compared to parent, hide itself
461 * when value is zero, and nice functions for changing the value.
462 * stShowPercent and stHideIfZero flags take effect only on
463 * this node.
465 template<typename _Tp>
466 class CStatTreeItemCounterTmpl : public CStatTreeItemBase
468 public:
470 * Constructor.
472 * @see CStatTreeItemBase::CStatTreeItemBase
474 CStatTreeItemCounterTmpl(
475 const wxString &label,
476 unsigned flags = stNone)
478 CStatTreeItemBase(label, flags),
479 m_value(0),
480 m_displaymode(dmDefault) {}
483 * Retrieve counter value.
485 _Tp GetValue() const { return m_value; }
488 * Retrieve counter value.
490 operator _Tp() const { return m_value; }
493 * Set counter to given value.
495 void SetValue(_Tp value) { m_value = value; }
498 * Set counter to given value.
500 void operator=(_Tp value) { m_value = value; }
503 * Increase value by 1.
505 void operator++() { ++m_value; }
508 * Decrease value by 1.
510 void operator--() { --m_value; }
513 * Increase value by given amount.
515 void operator+=(_Tp value) { m_value += value; }
518 * Decrease value by given amount.
520 void operator-=(_Tp value) { m_value -= value; }
523 * Sets the desired display mode of value.
525 void SetDisplayMode(enum EDisplayMode mode) { m_displaymode = mode; }
527 #ifndef AMULE_DAEMON
529 * @see CStatTreeItemBase::GetDisplayString()
531 virtual wxString GetDisplayString() const;
532 #endif
535 * @see CStatTreeItemBase::IsVisible()
537 virtual bool IsVisible() const
539 return (m_flags & stHideIfZero) ? (m_value != 0) : true;
542 protected:
544 * Add values to EC tag being generated.
546 * @param tag The tag to which values should be added.
548 * @see CStatTreeItemBase::AddECValues
550 virtual void AddECValues(CECTag *tag) const;
552 //! Actual value of the counter.
553 _Tp m_value;
555 //! Display mode of the value.
556 enum EDisplayMode m_displaymode;
559 typedef CStatTreeItemCounterTmpl<uint64_t> CStatTreeItemCounter;
560 typedef CStatTreeItemCounterTmpl<uint32_t> CStatTreeItemNativeCounter;
564 * A counter, which does not display its value :P
566 class CStatTreeItemHiddenCounter : public CStatTreeItemCounter
568 public:
570 * Constructor.
572 * @see CStatTreeItemCounter::CStatTreeItemCounter
574 CStatTreeItemHiddenCounter(
575 const wxString &label,
576 unsigned flags = stNone)
578 CStatTreeItemCounter(label, flags) {}
580 #ifndef AMULE_DAEMON
582 * @see CStatTreeItemBase::GetDisplayString()
584 virtual wxString GetDisplayString() const
586 return CStatTreeItemBase::GetDisplayString();
588 #endif
591 * @see CStatTreeItemBase::IsVisible()
593 virtual bool IsVisible() const { return true; }
595 protected:
596 //! Do nothing here.
597 virtual void AddECValues(CECTag*) const {}
602 * Item for the session/total upload/download counter
604 class CStatTreeItemUlDlCounter : public CStatTreeItemCounter
606 public:
608 * @param label format text for item.
609 * @param totalfunc function that will return the totals.
611 CStatTreeItemUlDlCounter(
612 const wxString &label,
613 uint64_t (*totalfunc)(),
614 unsigned flags = stNone)
616 CStatTreeItemCounter(label, flags),
617 m_totalfunc(totalfunc) {}
619 #ifndef AMULE_DAEMON
621 * @see CStatTreeBase::GetDisplayString()
623 virtual wxString GetDisplayString() const;
624 #endif
626 protected:
628 * Add values to EC tag being generated.
630 * @param tag The tag to which values should be added.
632 * @see CStatTreeItemBase::AddECValues
634 virtual void AddECValues(CECTag *tag) const;
636 //! A function whose return value is the total (without current) value.
637 uint64_t (*m_totalfunc)();
642 * Counter-like tree item which remembers its max value.
644 * Used for active connections counter, to be able to get peak connections.
646 class CStatTreeItemCounterMax : public CStatTreeItemBase
648 public:
650 * @see CStatTreeItemBase::CStatTreeItemBase
652 CStatTreeItemCounterMax(const wxString &label)
654 CStatTreeItemBase(label),
655 m_value(0),
656 m_max_value(0)
660 * Increase value
662 void operator++()
664 if (++m_value > m_max_value) {
665 m_max_value = m_value;
670 * Decrease value
672 void operator--() { --m_value; }
675 * Retrieve actual value
677 uint32_t GetValue() { return m_value; }
680 * Retrieve max value
682 uint32_t GetMaxValue() { return m_max_value; }
684 #ifndef AMULE_DAEMON
686 * @see CStatTreeItemBase::GetDisplayString()
688 virtual wxString GetDisplayString() const;
689 #endif
691 protected:
693 * Add values to EC tag being generated.
695 * @param tag The tag to which values should be added.
697 * @see CStatTreeItemBase::AddECValues
699 virtual void AddECValues(CECTag *tag) const;
701 //! Actual value of the counter.
702 uint32_t m_value;
704 //! Maximal value the counter has ever reached.
705 uint32_t m_max_value;
710 * Tree item for counting packets
712 class CStatTreeItemPackets : public CStatTreeItemBase
714 friend class CStatTreeItemPacketTotals;
716 public:
718 * @see CStatTreeItemBase::CStatTreeItemBase
720 CStatTreeItemPackets(const wxString &label)
722 CStatTreeItemBase(label, stNone),
723 m_packets(0),
724 m_bytes(0) {}
727 * Add a packet of size 'size'.
729 void operator+=(long size)
731 ++m_packets;
732 m_bytes += size;
735 #ifndef AMULE_DAEMON
737 * @see CStatTreeItemBase::GetDisplayString()
739 virtual wxString GetDisplayString() const;
740 #endif
742 protected:
744 * Add values to EC tag being generated.
746 * @param tag The tag to which values should be added.
748 * @see CStatTreeItemBase::AddECValues
750 virtual void AddECValues(CECTag *tag) const;
752 //! Total number of packets.
753 uint32_t m_packets;
755 //! Total bytes in the packets.
756 uint64_t m_bytes;
761 * Tree item for counting totals on packet counters.
763 * This item sums up a number of packet counters, plus adds its own values.
765 class CStatTreeItemPacketTotals : public CStatTreeItemPackets
767 public:
769 * @see CStatTreeItemPackets::CStatTreeItemPackets
771 CStatTreeItemPacketTotals(const wxString &label)
773 CStatTreeItemPackets(label) {}
776 * Adds a packet counter, whose values should be counted in the totals.
778 void AddPacketCounter(CStatTreeItemPackets* counter)
780 m_counters.push_back(counter);
783 #ifndef AMULE_DAEMON
785 * @see CStatTreeItemPackets::GetDisplayString()
787 virtual wxString GetDisplayString() const;
788 #endif
790 protected:
792 * Add values to EC tag being generated.
794 * @param tag The tag to which values should be added.
796 * @see CStatTreeItemBase::AddECValues
798 virtual void AddECValues(CECTag *tag) const;
800 //! List of packet counters to sum.
801 std::vector<CStatTreeItemPackets*> m_counters;
806 * Tree item for timer type nodes.
808 class CStatTreeItemTimer : public CStatTreeItemBase
810 public:
813 * @see CStatTreeItemBase::CStatTreeItemBase
815 CStatTreeItemTimer(
816 const wxString &label,
817 unsigned flags = stNone)
819 CStatTreeItemBase(label, flags),
820 m_value(0) {}
823 * Sets timer start time (and thus starts timer).
825 void SetStartTime(uint64_t value) { m_value = value; }
828 * Starts the timer if it's not running.
830 void StartTimer() { if (!m_value) m_value = GetTickCount64(); }
833 * Stops the timer.
835 void StopTimer() { m_value = 0; }
838 * Check whether the timer is running.
840 bool IsRunning() const { return m_value != 0; }
843 * Reset timer unconditionally.
845 void ResetTimer() { m_value = GetTickCount64(); }
848 * Get timer value.
850 uint64_t GetTimerValue() const
852 return m_value ? GetTickCount64() - m_value : 0;
856 * Get timer value (in ticks).
858 operator uint64_t() const
860 return m_value ? GetTickCount64() - m_value : 0;
864 * Get elapsed time in seconds.
866 uint64_t GetTimerSeconds() const
868 return m_value ? (GetTickCount64() - m_value) / 1000 : 0;
872 * Get start time of the timer.
874 uint64_t GetTimerStart() const { return m_value; }
876 #ifndef AMULE_DAEMON
878 * @see CStatTreeItemBase::GetDisplayString()
880 virtual wxString GetDisplayString() const;
881 #endif
884 * @see CStatTreeItemBase::IsVisible()
886 virtual bool IsVisible() const
888 return (m_flags & stHideIfZero) ? m_value != 0 : true;
891 protected:
893 * Add values to EC tag being generated.
895 * @param tag The tag to which values should be added.
897 * @see CStatTreeItemBase::AddECValues
899 virtual void AddECValues(CECTag *tag) const;
901 //! Tick count value when timer was started.
902 uint64_t m_value;
907 * Tree item for shared files average size.
909 * Average is counted as dividend / divisor, if divisor is non-zero.
911 class CStatTreeItemAverage : public CStatTreeItemBase
913 public:
915 * @see CStatTreeItemBase::CStatTreeItemBase
917 * @param dividend What to divide.
918 * @param divisor Divide by what.
920 CStatTreeItemAverage(
921 const wxString &label,
922 const CStatTreeItemCounter *dividend,
923 const CStatTreeItemCounter *divisor,
924 enum EDisplayMode displaymode)
926 CStatTreeItemBase(label, stNone),
927 m_dividend(dividend),
928 m_divisor(divisor),
929 m_displaymode(displaymode) {}
931 #ifndef AMULE_DAEMON
933 * @see CStatTreeItemBase::GetDisplayString()
935 virtual wxString GetDisplayString() const;
936 #endif
939 * @see CStatTreeItemBase::IsVisible()
941 virtual bool IsVisible() const { return (*m_divisor) != 0; }
943 protected:
945 * Add values to EC tag being generated.
947 * @param tag The tag to which values should be added.
949 * @see CStatTreeItemBase::AddECValues
951 virtual void AddECValues(CECTag *tag) const;
953 //! What to divide.
954 const CStatTreeItemCounter *m_dividend;
956 //! Divide by what.
957 const CStatTreeItemCounter *m_divisor;
959 //! Display mode.
960 enum EDisplayMode m_displaymode;
965 * Tree item for average up/down speed.
967 class CStatTreeItemAverageSpeed : public CStatTreeItemBase
969 public:
972 * @see CStatTreeItemBase::CStatTreeItemBase
974 * @param counter Session up/down counter.
975 * @param timer Session uptime timer.
977 CStatTreeItemAverageSpeed(
978 const wxString &label,
979 const CStatTreeItemUlDlCounter *counter,
980 const CStatTreeItemTimer *timer)
982 CStatTreeItemBase(label, stNone),
983 m_counter(counter),
984 m_timer(timer) {}
986 #ifndef AMULE_DAEMON
988 * @see CStatTreeItemBase::GetDisplayString()
990 virtual wxString GetDisplayString() const;
991 #endif
993 protected:
995 * Add values to EC tag being generated.
997 * @param tag The tag to which values should be added.
999 * @see CStatTreeItemBase::AddECValues
1001 virtual void AddECValues(CECTag *tag) const;
1003 //! Session sent/received bytes counter.
1004 const CStatTreeItemUlDlCounter *m_counter;
1006 //! Session uptime.
1007 const CStatTreeItemTimer *m_timer;
1012 * Tree item for displaying ratio between two counters.
1014 * Ratio is counted as counter1:counter2.
1016 class CStatTreeItemRatio : public CStatTreeItemBase
1018 public:
1020 * @see CStatTreeItemBase::CStatTreeItemBase
1022 * @param cnt1 First counter to use.
1023 * @param cnt2 Second counter to use.
1025 CStatTreeItemRatio(
1026 const wxString &label,
1027 const CStatTreeItemCounter *cnt1,
1028 const CStatTreeItemCounter* cnt2,
1029 uint64_t (*totalfunc1)() = NULL,
1030 uint64_t (*totalfunc2)() = NULL)
1032 CStatTreeItemBase(label, stNone),
1033 m_counter1(cnt1),
1034 m_counter2(cnt2),
1035 m_totalfunc1(totalfunc1),
1036 m_totalfunc2(totalfunc2){}
1038 #ifndef AMULE_DAEMON
1040 * @see CStatTreeItemBase::GetDisplayString()
1042 virtual wxString GetDisplayString() const;
1043 #endif
1045 protected:
1047 * Add values to EC tag being generated.
1049 * @param tag The tag to which values should be added.
1051 * @see CStatTreeItemBase::AddECValues
1053 virtual void AddECValues(CECTag *tag) const;
1055 //! First counter.
1056 const CStatTreeItemCounter *m_counter1;
1058 //! Second counter.
1059 const CStatTreeItemCounter *m_counter2;
1061 //! A function for each whose return value is the total (without current) value.
1062 uint64_t (*m_totalfunc1)();
1063 uint64_t (*m_totalfunc2)();
1065 private:
1066 //! Formatted String for display or EC
1067 wxString GetString() const;
1072 * Special counter for reconnects.
1074 class CStatTreeItemReconnects : public CStatTreeItemNativeCounter {
1075 public:
1077 * @see CStatTreeItemBase::CStatTreeItemBase
1079 CStatTreeItemReconnects(const wxString &label)
1081 CStatTreeItemNativeCounter(label, stNone) {}
1083 #ifndef AMULE_DAEMON
1085 * @see CStatTreeItemBase::GetDisplayString()
1087 virtual wxString GetDisplayString() const;
1088 #endif
1090 protected:
1092 * Add values to EC tag being generated.
1094 * @param tag The tag to which values should be added.
1096 * @see CStatTreeItemBase::AddECValues
1098 virtual void AddECValues(CECTag *tag) const;
1102 * Special item for Max Connection Limit Reached
1104 class CStatTreeItemMaxConnLimitReached : public CStatTreeItemBase
1106 public:
1108 * @see CStatTreeItemBase::CStatTreeItemBase
1110 CStatTreeItemMaxConnLimitReached(const wxString &label)
1112 CStatTreeItemBase(label),
1113 m_count(0) {}
1116 * Increase counter and save time.
1118 void operator++()
1120 ++m_count;
1121 m_time.SetToCurrent();
1124 #ifndef AMULE_DAEMON
1126 * Returns a string to be displayed on GUI.
1128 * For m_count == 0 it will display "Never",
1129 * for other values it will display the counter value and the
1130 * date & time of the event.
1132 virtual wxString GetDisplayString() const;
1133 #endif
1135 protected:
1137 * Add values to EC tag being generated.
1139 * @param tag The tag to which values should be added.
1141 * @see CStatTreeItemBase::AddECValues
1143 virtual void AddECValues(CECTag *tag) const;
1145 //! Number of times max conn limit reached.
1146 uint32_t m_count;
1148 //! Last time when max conn limit reached.
1149 wxDateTime m_time;
1153 * Special item for total client count
1155 class CStatTreeItemTotalClients : public CStatTreeItemBase
1157 public:
1159 * @see CStatTreeItemBase::CStatTreeItemBase
1161 * @param known Counter that counts known clients.
1162 * @param unknown Counter that counts unknown clients.
1164 CStatTreeItemTotalClients(
1165 const wxString &label,
1166 const CStatTreeItemCounter *known,
1167 const CStatTreeItemCounter *unknown)
1169 CStatTreeItemBase(label),
1170 m_known(known),
1171 m_unknown(unknown) {}
1173 #ifndef AMULE_DAEMON
1175 * @see CStatTreeItemBase::GetDisplayString()
1177 virtual wxString GetDisplayString() const;
1178 #endif
1180 protected:
1182 * Add values to EC tag being generated.
1184 * @param tag The tag to which values should be added.
1186 * @see CStatTreeItemBase::AddECValues
1188 virtual void AddECValues(CECTag *tag) const;
1190 //! Counter counting known clients.
1191 const CStatTreeItemCounter *m_known;
1193 //! Counter counting unknown clients.
1194 const CStatTreeItemCounter *m_unknown;
1197 #endif /* !CLIENT_GUI */
1199 #endif /* STATTREE_H */
1200 // File_checked_for_headers