blob: 3da67daeea27dd2a24daa5dd50c0c8aac56557af [file] [log] [blame]
Paul Stewart0e51ad92013-07-26 14:42:55 -07001// 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 Qiu18213652015-04-21 16:01:51 -07008#include <string>
9
Paul Stewart0e51ad92013-07-26 14:42:55 -070010#include "shill/refptr_types.h"
11
12namespace shill {
13
14class Error;
15class KeyValueStore;
16
Paul Stewartbc14fb72013-07-30 08:21:58 -070017// This is an interface for objects that creates and manages service objects.
18class ProviderInterface {
Paul Stewart0e51ad92013-07-26 14:42:55 -070019 public:
Paul Stewartbc14fb72013-07-30 08:21:58 -070020 virtual ~ProviderInterface() {}
Paul Stewart0e51ad92013-07-26 14:42:55 -070021
22 // Creates services from the entries within |profile|.
Paul Stewart1a212a62015-06-16 13:13:10 -070023 virtual void CreateServicesFromProfile(const ProfileRefPtr& profile) = 0;
Paul Stewart0e51ad92013-07-26 14:42:55 -070024
Paul Stewartbc14fb72013-07-30 08:21:58 -070025 // Finds a Service with similar properties to |args|. The criteria
Paul Stewart0e51ad92013-07-26 14:42:55 -070026 // 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 Stewart1a212a62015-06-16 13:13:10 -070030 const KeyValueStore& args, Error* error) const = 0;
Paul Stewart0e51ad92013-07-26 14:42:55 -070031
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 Stewart1a212a62015-06-16 13:13:10 -070036 virtual ServiceRefPtr GetService(const KeyValueStore& args, Error* error) = 0;
Paul Stewart0e51ad92013-07-26 14:42:55 -070037
Paul Stewartbc14fb72013-07-30 08:21:58 -070038 // Creates a temporary service with the identifying properties populated
Paul Stewart0e51ad92013-07-26 14:42:55 -070039 // 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 Stewart1a212a62015-06-16 13:13:10 -070043 const KeyValueStore& args, Error* error) = 0;
Paul Stewart0e51ad92013-07-26 14:42:55 -070044
Peter Qiu18213652015-04-21 16:01:51 -070045 // 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 Stewart1a212a62015-06-16 13:13:10 -070050 const ProfileRefPtr& profile,
51 const std::string& entry_name,
52 Error* error) = 0;
Peter Qiu18213652015-04-21 16:01:51 -070053
Paul Stewartbc14fb72013-07-30 08:21:58 -070054 // Starts the provider.
55 virtual void Start() = 0;
Paul Stewart0e51ad92013-07-26 14:42:55 -070056
Paul Stewartbc14fb72013-07-30 08:21:58 -070057 // Stops the provider (will de-register all services).
58 virtual void Stop() = 0;
Paul Stewart0e51ad92013-07-26 14:42:55 -070059};
60
61} // namespace shill
62
63#endif // SHILL_PROVIDER_INTERFACE_H_