Paul Stewart | 0e51ad9 | 2013-07-26 14:42:55 -0700 | [diff] [blame] | 1 | // Copyright (c) 2013 The Chromium OS 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 SHILL_PROVIDER_INTERFACE_H_ |
| 6 | #define SHILL_PROVIDER_INTERFACE_H_ |
| 7 | |
Peter Qiu | 1821365 | 2015-04-21 16:01:51 -0700 | [diff] [blame] | 8 | #include <string> |
| 9 | |
Paul Stewart | 0e51ad9 | 2013-07-26 14:42:55 -0700 | [diff] [blame] | 10 | #include "shill/refptr_types.h" |
| 11 | |
| 12 | namespace shill { |
| 13 | |
| 14 | class Error; |
| 15 | class KeyValueStore; |
| 16 | |
Paul Stewart | bc14fb7 | 2013-07-30 08:21:58 -0700 | [diff] [blame] | 17 | // This is an interface for objects that creates and manages service objects. |
| 18 | class ProviderInterface { |
Paul Stewart | 0e51ad9 | 2013-07-26 14:42:55 -0700 | [diff] [blame] | 19 | public: |
Paul Stewart | bc14fb7 | 2013-07-30 08:21:58 -0700 | [diff] [blame] | 20 | virtual ~ProviderInterface() {} |
Paul Stewart | 0e51ad9 | 2013-07-26 14:42:55 -0700 | [diff] [blame] | 21 | |
| 22 | // Creates services from the entries within |profile|. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 23 | virtual void CreateServicesFromProfile(const ProfileRefPtr& profile) = 0; |
Paul Stewart | 0e51ad9 | 2013-07-26 14:42:55 -0700 | [diff] [blame] | 24 | |
Paul Stewart | bc14fb7 | 2013-07-30 08:21:58 -0700 | [diff] [blame] | 25 | // Finds a Service with similar properties to |args|. The criteria |
Paul Stewart | 0e51ad9 | 2013-07-26 14:42:55 -0700 | [diff] [blame] | 26 | // used are specific to the provider subclass. Returns a reference |
| 27 | // to a matching service if one exists. Otherwise it returns a NULL |
| 28 | // reference and populates |error|. |
| 29 | virtual ServiceRefPtr FindSimilarService( |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 30 | const KeyValueStore& args, Error* error) const = 0; |
Paul Stewart | 0e51ad9 | 2013-07-26 14:42:55 -0700 | [diff] [blame] | 31 | |
| 32 | // Retrieves (see FindSimilarService) or creates a service with the |
| 33 | // unique attributes in |args|. The remaining attributes will be |
| 34 | // populated (by Manager) via a later call to Service::Configure(). |
| 35 | // Returns a NULL reference and populates |error| on failure. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 36 | virtual ServiceRefPtr GetService(const KeyValueStore& args, Error* error) = 0; |
Paul Stewart | 0e51ad9 | 2013-07-26 14:42:55 -0700 | [diff] [blame] | 37 | |
Paul Stewart | bc14fb7 | 2013-07-30 08:21:58 -0700 | [diff] [blame] | 38 | // Creates a temporary service with the identifying properties populated |
Paul Stewart | 0e51ad9 | 2013-07-26 14:42:55 -0700 | [diff] [blame] | 39 | // from |args|. Callers outside of the Provider must never register |
| 40 | // this service with the Manager or connect it since it was never added |
| 41 | // to the provider's service list. |
| 42 | virtual ServiceRefPtr CreateTemporaryService( |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 43 | const KeyValueStore& args, Error* error) = 0; |
Paul Stewart | 0e51ad9 | 2013-07-26 14:42:55 -0700 | [diff] [blame] | 44 | |
Peter Qiu | 1821365 | 2015-04-21 16:01:51 -0700 | [diff] [blame] | 45 | // Create a temporary service for an entry |entry_name| within |profile|. |
| 46 | // Callers outside of the Provider must never register this service with the |
| 47 | // Manager or connect it since it was never added to the provider's service |
| 48 | // list. |
| 49 | virtual ServiceRefPtr CreateTemporaryServiceFromProfile( |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 50 | const ProfileRefPtr& profile, |
| 51 | const std::string& entry_name, |
| 52 | Error* error) = 0; |
Peter Qiu | 1821365 | 2015-04-21 16:01:51 -0700 | [diff] [blame] | 53 | |
Paul Stewart | bc14fb7 | 2013-07-30 08:21:58 -0700 | [diff] [blame] | 54 | // Starts the provider. |
| 55 | virtual void Start() = 0; |
Paul Stewart | 0e51ad9 | 2013-07-26 14:42:55 -0700 | [diff] [blame] | 56 | |
Paul Stewart | bc14fb7 | 2013-07-30 08:21:58 -0700 | [diff] [blame] | 57 | // Stops the provider (will de-register all services). |
| 58 | virtual void Stop() = 0; |
Paul Stewart | 0e51ad9 | 2013-07-26 14:42:55 -0700 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | } // namespace shill |
| 62 | |
| 63 | #endif // SHILL_PROVIDER_INTERFACE_H_ |