blob: 5de021aedf04262ba07771de72911ba7659d3787 [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
8#include "shill/refptr_types.h"
9
10namespace shill {
11
12class Error;
13class KeyValueStore;
14
Paul Stewartbc14fb72013-07-30 08:21:58 -070015// This is an interface for objects that creates and manages service objects.
16class ProviderInterface {
Paul Stewart0e51ad92013-07-26 14:42:55 -070017 public:
Paul Stewartbc14fb72013-07-30 08:21:58 -070018 virtual ~ProviderInterface() {}
Paul Stewart0e51ad92013-07-26 14:42:55 -070019
20 // Creates services from the entries within |profile|.
Paul Stewartbc14fb72013-07-30 08:21:58 -070021 virtual void CreateServicesFromProfile(const ProfileRefPtr &profile) = 0;
Paul Stewart0e51ad92013-07-26 14:42:55 -070022
Paul Stewartbc14fb72013-07-30 08:21:58 -070023 // Finds a Service with similar properties to |args|. The criteria
Paul Stewart0e51ad92013-07-26 14:42:55 -070024 // 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 Stewartbc14fb72013-07-30 08:21:58 -070028 const KeyValueStore &args, Error *error) const = 0;
Paul Stewart0e51ad92013-07-26 14:42:55 -070029
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 Stewartbc14fb72013-07-30 08:21:58 -070034 virtual ServiceRefPtr GetService(const KeyValueStore &args, Error *error) = 0;
Paul Stewart0e51ad92013-07-26 14:42:55 -070035
Paul Stewartbc14fb72013-07-30 08:21:58 -070036 // Creates a temporary service with the identifying properties populated
Paul Stewart0e51ad92013-07-26 14:42:55 -070037 // 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 Stewartbc14fb72013-07-30 08:21:58 -070041 const KeyValueStore &args, Error *error) = 0;
Paul Stewart0e51ad92013-07-26 14:42:55 -070042
Paul Stewartbc14fb72013-07-30 08:21:58 -070043 // Starts the provider.
44 virtual void Start() = 0;
Paul Stewart0e51ad92013-07-26 14:42:55 -070045
Paul Stewartbc14fb72013-07-30 08:21:58 -070046 // Stops the provider (will de-register all services).
47 virtual void Stop() = 0;
Paul Stewart0e51ad92013-07-26 14:42:55 -070048};
49
50} // namespace shill
51
52#endif // SHILL_PROVIDER_INTERFACE_H_