File: statview.h

package info (click to toggle)
turqstat 3.0-2
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 2,112 kB
  • ctags: 1,328
  • sloc: cpp: 17,929; perl: 252; makefile: 223; ansic: 75; sh: 16
file content (122 lines) | stat: -rw-r--r-- 4,445 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Copyright (c) 1998-2007 Peter Karlsson
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

#ifndef __STATVIEW_H
#define __STATVIEW_H

#include <string>

#if !defined(HAVE_IMPLICIT_NAMESPACE)
using namespace std;
#endif

class StatEngine;
class Template;

/**
 * The class that saves the data. This is the class that saves the data
 * retrieved with the StatEngine to a text file, containing the toplists
 * that are specified as wanted.
 */
class StatView
{
public:
    /** Standard constructor. */
    StatView();

    // Format selectors
    /** Tell view which output template to use. */
    void SetTemplate(const Template *output_template) { m_template = output_template; };

    // Toggles for toplist selection
    /** Tell view whether or not to enable the quoters toplist. */
    inline void EnableQuoters(bool yes)     { quoters = yes;      };

    /** Tell view whether or not to enable the writers toplist. */
    inline void EnableTopWritten(bool yes)  { topwritten = yes;   };

    /** Tell view whether or not to enable the original content toplist. */
    inline void EnableTopOriginal(bool yes) { toporiginal = yes;  };

    /** Tell view whether or not to enable the Fidonet networks toplist. */
    inline void EnableTopNets(bool yes)     { topnets = yes;      };

    /** Tell view whether or not to enable the receivers toplist. */
    inline void EnableTopReceived(bool yes) { topreceived = yes;  };

    /** Tell view whether or not to enable the subjects toplist. */
    inline void EnableTopSubjects(bool yes) { topsubjects = yes;  };

    /** Tell view whether or not to enable the programs toplist. */
    inline void EnableTopPrograms(bool yes) { topprograms = yes;  };

    /** Tell view whether or not to enable the Internet topdomain toplist. */
    inline void EnableTopDomains(bool yes)  { topdomains = yes;   };

    /** Tell view whether or not to enable the weekday statistics. */
    inline void EnableWeekStats(bool yes)   { weekstats = yes;    };

    /** Tell view whether or not to enable the hour statistics. */
    inline void EnableDayStats(bool yes)    { daystats = yes;     };

    // Output format
#if defined(HAVE_LOCALE_H) || defined(HAVE_OS2_COUNTRYINFO) || defined(HAVE_WIN32_LOCALEINFO)
    /** Tell view whether dates should be written in locale format. */
    inline void UseLocale(bool yes)         { uselocale = yes;    };
#endif

    // Toplist flags
    /** Tell view whether to print details about versions of programs. */
    inline void ShowVersions(bool yes)      { showversions = yes; };

    /** Tell view whether to show all numbers in the toplist. */
    inline void ShowAllNums(bool yes)       { showallnums = yes;  };

    /** Tell view the maximum number of entries to display in toplist. */
    inline void SetMaxEntries(unsigned max) { maxnumber = max;    };

    /** Tell view which character set to use for output. */
    void SetCharset(const char *in_charset) { charset = in_charset; };

    // This does the actual work
    /**
     * Create a report. This method is the one that does the actual work,
     * it retrieves the information stored in the engine and saves it to the
     * named file.
     * @param engine   Pointer to engine containing data.
     * @param filename Name of file to create.
     * @return True if the file was created successfully.
     */
    bool CreateReport(StatEngine *engine, string filename);

protected:
    bool        quoters, topwritten, toporiginal, topnets, topreceived,
                topsubjects, topprograms, topdomains, weekstats, daystats;

    bool        showversions, showallnums;

#if defined(HAVE_LOCALE_H) || defined(HAVE_OS2_COUNTRYINFO) || defined(HAVE_WIN32_LOCALEINFO)
    bool        uselocale;
#endif

    unsigned    maxnumber;

    string      charset;
	string		m_dayname[7];

    const Template *m_template;
};

#endif