serversummary.h
1 //------------------------------------------------------------------------------
2 // serversummary.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2013 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef idAA369F27_B8AD_4120_8889175B56406459
24 #define idAA369F27_B8AD_4120_8889175B56406459
25 
26 #include <QDateTime>
27 #include <QString>
28 #include <QVariant>
29 
30 class Server;
31 
33 {
34  public:
35  static ServerSummary deserializeQVariant(const QVariant& var);
36 
38  {
39  d.port = 0;
40  }
41 
42  ServerSummary(const Server *server);
43 
44  const QString& address() const
45  {
46  return d.address;
47  }
48 
49  const QString& game() const
50  {
51  return d.game;
52  }
53 
54  bool isValid() const
55  {
56  return !d.address.isEmpty() && d.port != 0;
57  }
58 
59  const QString& name() const
60  {
61  return d.name;
62  }
63 
64  unsigned short port() const
65  {
66  return d.port;
67  }
68 
69  void setAddress(const QString& v)
70  {
71  d.address = v;
72  }
73 
74  void setGame(const QString& v)
75  {
76  d.game = v;
77  }
78 
79  void setName(const QString& v)
80  {
81  d.name = v;
82  }
83 
84  void setPort(unsigned short v)
85  {
86  d.port = v;
87  }
88 
89  void setTime(const QDateTime& v)
90  {
91  d.time = v;
92  }
93 
94  QVariant serializeQVariant() const;
104  float similarity(const ServerSummary& other) const;
105 
106  QDateTime time() const
107  {
108  return d.time;
109  }
110 
111  private:
112  class PrivData
113  {
114  public:
115  QString address;
116  QString game;
117  QString name;
118  unsigned short port;
119  QDateTime time;
120  };
121 
122  PrivData d;
123 };
124 
125 #endif
A representation of a server for a given game.
Definition: server.h:93
float similarity(const ServerSummary &other) const
Similarity to the &#39;other&#39; server; between 0.0 and 1.0.