Commit | Line | Data |
---|---|---|
d44e3c4f | 1 | /****************************************************************************** |
2 | * Copyright (c) 2000-2016 Ericsson Telecom AB | |
3 | * All rights reserved. This program and the accompanying materials | |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | * | |
8 | * Contributors: | |
9 | * | |
10 | * Balasko, Jeno | |
11 | * Baranyi, Botond | |
12 | * Ormandi, Matyas | |
13 | * | |
14 | ******************************************************************************/ | |
970ed795 EL |
15 | #ifndef USAGE_STATS_H_ |
16 | #define USAGE_STATS_H_ | |
17 | ||
18 | /***************************************************** | |
19 | // Usage: | |
20 | // include usage_stats.hh before dbgnew.hh!! | |
21 | // XYSender sender; // XYSender is a subclass of Sender | |
22 | // int timeout = 200; // timeout in msec for the data sender thread | |
23 | // UsageData::getInstance().sendDataThreaded("info", timeout, &sender); | |
24 | ||
25 | // Lib requirement: | |
26 | // for Solaris -lnsl -lsocket -lresolv | |
27 | // for Linux -lpthread -lrt | |
28 | ||
29 | // iodine: use iodine as a library from /etc/dns/iodine/lib/libiodine.a | |
30 | // or via pipe as an outside process | |
31 | // uncomment this and the DNSSender::send function | |
32 | //#include "../etc/dns/iodine/src/iodine.h" | |
33 | *****************************************************/ | |
34 | ||
35 | #include <string> | |
36 | ||
37 | #include "version_internal.h" | |
38 | ||
39 | class Sender { | |
40 | public: | |
41 | Sender() {}; | |
42 | virtual ~Sender() {}; | |
43 | virtual void send(const char*) = 0; | |
44 | }; | |
45 | ||
46 | class DNSSender: public Sender { | |
47 | public: | |
48 | DNSSender(); | |
49 | ~DNSSender() {}; | |
50 | void send(const char*); | |
51 | ||
52 | private: | |
53 | const char* nameserver; | |
54 | const char* domain; | |
55 | }; | |
56 | ||
57 | class HttpSender: public Sender { | |
58 | public: | |
59 | HttpSender() {}; | |
60 | ~HttpSender() {}; | |
61 | void send(const char*); | |
62 | }; | |
63 | ||
64 | ||
65 | class UsageData { | |
66 | public: | |
67 | static UsageData& getInstance() | |
68 | { | |
69 | static UsageData instance; // Guaranteed to be destroyed. | |
70 | return instance; // Instantiated on first use. | |
71 | } | |
72 | static void sendDataThreaded(std::string msg, Sender* sender); | |
73 | ||
74 | private: | |
75 | ||
76 | UsageData(); | |
77 | ~UsageData(); | |
78 | UsageData(UsageData const&); // Don't Implement | |
79 | void operator=(UsageData const&); // Don't implement | |
80 | ||
81 | static void* sendData(void*); | |
82 | ||
83 | static std::string id; | |
84 | static std::string host; | |
85 | static std::string platform; | |
86 | }; | |
87 | ||
88 | #endif /* USAGE_STATS_H_ */ |