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