blob: 9a3971d58cad4f610505c885528989d7b77f1384 [file] [log] [blame]
// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WIMAX_MANAGER_NETWORK_H_
#define WIMAX_MANAGER_NETWORK_H_
#include <map>
#include <string>
#include <base/basictypes.h>
#include <base/memory/ref_counted.h>
#include "wimax_manager/dbus_adaptable.h"
namespace wimax_manager {
enum NetworkType {
kNetworkHome,
kNetworkPartner,
kNetworkRoamingParnter,
kNetworkUnknown,
};
class NetworkDBusAdaptor;
class Network : public base::RefCounted<Network>,
public DBusAdaptable<Network, NetworkDBusAdaptor> {
public:
typedef uint32 Identifier;
static const int kMaxCINR;
static const int kMinCINR;
static const int kMaxRSSI;
static const int kMinRSSI;
static const Identifier kInvalidIdentifier;
Network(Identifier identifier, const std::string &name, NetworkType type,
int cinr, int rssi);
static int DecodeCINR(int encoded_cinr);
static int DecodeRSSI(int encoded_rssi);
void UpdateFrom(const Network &network);
int GetSignalStrength() const;
// Returns a string description that comprises |name_| and |identifier_|.
// If |name_| is empty, returns "network (<8-digit hexadecimal identifier>)".
// Otherwise, returns "network '<name>' (<8-digit hexadecimal identifier>)".
std::string GetNameWithIdentifier() const;
Identifier identifier() const { return identifier_; }
const std::string &name() const { return name_; }
NetworkType type() const { return type_; }
int cinr() const { return cinr_; }
int rssi() const { return rssi_; }
private:
friend class base::RefCounted<Network>;
~Network();
Identifier identifier_;
std::string name_;
NetworkType type_;
int cinr_;
int rssi_;
DISALLOW_COPY_AND_ASSIGN(Network);
};
typedef scoped_refptr<Network> NetworkRefPtr;
typedef std::map<Network::Identifier, NetworkRefPtr> NetworkMap;
} // namespace wimax_manager
#endif // WIMAX_MANAGER_NETWORK_H_