Commit | Line | Data |
---|---|---|
970ed795 | 1 | /////////////////////////////////////////////////////////////////////////////// |
3abe9331 | 2 | // Copyright (c) 2000-2015 Ericsson Telecom AB |
970ed795 EL |
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 | #ifndef USAGE_STATS_H_ | |
9 | #define USAGE_STATS_H_ | |
10 | ||
11 | /***************************************************** | |
12 | // Usage: | |
13 | // include usage_stats.hh before dbgnew.hh!! | |
14 | // XYSender sender; // XYSender is a subclass of Sender | |
15 | // int timeout = 200; // timeout in msec for the data sender thread | |
16 | // UsageData::getInstance().sendDataThreaded("info", timeout, &sender); | |
17 | ||
18 | // Lib requirement: | |
19 | // for Solaris -lnsl -lsocket -lresolv | |
20 | // for Linux -lpthread -lrt | |
21 | ||
22 | // iodine: use iodine as a library from /etc/dns/iodine/lib/libiodine.a | |
23 | // or via pipe as an outside process | |
24 | // uncomment this and the DNSSender::send function | |
25 | //#include "../etc/dns/iodine/src/iodine.h" | |
26 | *****************************************************/ | |
27 | ||
28 | #include <string> | |
29 | ||
30 | #include "version_internal.h" | |
31 | ||
32 | class Sender { | |
33 | public: | |
34 | Sender() {}; | |
35 | virtual ~Sender() {}; | |
36 | virtual void send(const char*) = 0; | |
37 | }; | |
38 | ||
39 | class DNSSender: public Sender { | |
40 | public: | |
41 | DNSSender(); | |
42 | ~DNSSender() {}; | |
43 | void send(const char*); | |
44 | ||
45 | private: | |
46 | const char* nameserver; | |
47 | const char* domain; | |
48 | }; | |
49 | ||
50 | class HttpSender: public Sender { | |
51 | public: | |
52 | HttpSender() {}; | |
53 | ~HttpSender() {}; | |
54 | void send(const char*); | |
55 | }; | |
56 | ||
57 | ||
58 | class UsageData { | |
59 | public: | |
60 | static UsageData& getInstance() | |
61 | { | |
62 | static UsageData instance; // Guaranteed to be destroyed. | |
63 | return instance; // Instantiated on first use. | |
64 | } | |
65 | static void sendDataThreaded(std::string msg, Sender* sender); | |
66 | ||
67 | private: | |
68 | ||
69 | UsageData(); | |
70 | ~UsageData(); | |
71 | UsageData(UsageData const&); // Don't Implement | |
72 | void operator=(UsageData const&); // Don't implement | |
73 | ||
74 | static void* sendData(void*); | |
75 | ||
76 | static std::string id; | |
77 | static std::string host; | |
78 | static std::string platform; | |
79 | }; | |
80 | ||
81 | #endif /* USAGE_STATS_H_ */ |