OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef REMOTING_BASE_CAPABILITIES_H_ |
| 6 #define REMOTING_BASE_CAPABILITIES_H_ |
| 7 |
| 8 #include <set> |
| 9 #include <string> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 |
| 14 namespace base { |
| 15 class ListValue; |
| 16 } // namespace base |
| 17 |
| 18 namespace remoting { |
| 19 |
| 20 namespace protocol { |
| 21 class Capabilities; |
| 22 } // namespace protocol |
| 23 |
| 24 // Represents a set of capabilities. Each capability is represented by a unique |
| 25 // string that may not contain spaces. |
| 26 class Capabilities { |
| 27 public: |
| 28 Capabilities(); |
| 29 explicit Capabilities(const std::string& value); |
| 30 ~Capabilities(); |
| 31 |
| 32 // Returs the number of capabilities in the set. |
| 33 size_t Size() const { |
| 34 return capabilities_.size(); |
| 35 } |
| 36 |
| 37 // Returns true if |this| contains |capability|. |
| 38 bool HasCapability(const std::string& capability) const; |
| 39 |
| 40 // Returns a set of capabilities contained in both |this| and |other| sets. |
| 41 Capabilities Intersect(const Capabilities& other) const; |
| 42 |
| 43 // Initializes |this| from |base::ListValue|. Returns false if |value| |
| 44 // contains anything else than valid capability strings. |
| 45 bool FromListValue(const base::ListValue& value); |
| 46 |
| 47 // Initializes |this| from |message|. Returns false if |message| contains |
| 48 // anything else than valid capability strings. |
| 49 bool FromProtocolMessage(const protocol::Capabilities& message); |
| 50 |
| 51 // Initializes |this| from |message|. |
| 52 void FromString(const std::string& value); |
| 53 |
| 54 // Converts |this| into |base::ListValue|. |
| 55 scoped_ptr<base::ListValue> ToListValue() const; |
| 56 |
| 57 // Converts |this| into |protocol::Capabilities|. |
| 58 scoped_ptr<protocol::Capabilities> ToProtocolMessage() const; |
| 59 |
| 60 // Converts |this| into |std::string|. |
| 61 std::string ToString() const; |
| 62 |
| 63 protected: |
| 64 std::set<std::string> capabilities_; |
| 65 }; |
| 66 |
| 67 } // namespace remoting |
| 68 |
| 69 #endif // REMOTING_BASE_CAPABILITIES_H_ |
OLD | NEW |