summaryrefslogtreecommitdiff
path: root/src/pmview/launch.h
blob: 2f048b173f242a1b687ae12087652953759fd609 (plain)
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
/*
 * Copyright (c) 1997 Silicon Graphics, Inc.  All Rights Reserved.
 * Copyright (c) 2009 Aconex.  All Rights Reserved.
 * 
 * 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; either version 2 of the License, or (at your
 * option) any later version.
 * 
 * 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.
 */
#ifndef _LAUNCH_H_
#define _LAUNCH_H_

#include "main.h"
#include <QtCore/QStringList>

class SbColor;
class ColorScale;

class Launch
{
private:

    static const QString	theVersion1Str;
    static const QString	theVersion2Str;
    
    QStringList		_strings;
    int			_groupMetric;
    int			_groupCount;
    QString		_groupHint;
    int			_metricCount;
    int			_version;

public:

    ~Launch();

    Launch(const QString &version = "");	// defaults to version 2.0
    Launch(const Launch &rhs);
    const Launch &operator=(const Launch &rhs);

    static const char *launchPath();

    void setDefaultOptions(int interval = 5,
			   int debug = 0,
			   const char *timeport = NULL,
			   const char *starttime = NULL,
			   const char *endtime = NULL,
			   const char *offset = NULL,
			   const char *timezone = NULL,
			   const char *defsourcetype = NULL,
			   const char *defsourcename = NULL,
			   bool selected = false);

    void addOption(const char *name, const char *value);
    void addOption(const char *name, int value);

    void addMetric(const QmcMetric &metric, 
		   const SbColor &color,
		   int instance,
		   bool useSocks = false);

    void addMetric(const QmcMetric &metric, 
		   const ColorScale &scale,
		   int instance,
		   bool useSocks = false);

    void addMetric(int context,
		   const QString &source,
		   const QString &host,
		   const QString &metric,
		   const char *instance,
		   const QmcDesc &desc,
		   const SbColor &color,
		   double scale,
		   bool useSocks = false);
    // Add metric with static color and scale

    void addMetric(int context,
		   const QString &source,
		   const QString &host,
		   const QString &metric,
		   const char *instance,
		   const QmcDesc &desc,
		   const ColorScale &scale,
		   bool useSocks = false);
    // Add metric with dynamic color range

    void startGroup(const char *hint = "none");
    void endGroup();

    void append(Launch const& rhs);

    void output(int fd) const;

    friend QTextStream& operator<<(QTextStream& os, Launch const& rhs);

private:

    void preColor(int context, 
    		  const QString &source, 
		  const QString &host,
		  const QString &metric,
		  bool useSocks,
		  QString &str);
    void postColor(const QmcDesc &desc, const char *instance, QString &str);
};

#endif /* _LAUNCH_H_ */