blob: dad9ffa4c8f2fa40624d8060fc900eb4e371cb23 [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
15// This is an object that creates and manages service objects. It provides
16// default implementations for each provider method so sublcasses do not
17// need to implement boilerplate unimplemented methods.
18class Provider {
19 public:
20 virtual ~Provider() {}
21
22 // Creates services from the entries within |profile|.
23 virtual void CreateServicesFromProfile(const ProfileRefPtr &profile);
24
25 // Find a Service with similar properties to |args|. The criteria
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(
30 const KeyValueStore &args, Error *error) const;
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.
36 virtual ServiceRefPtr GetService(const KeyValueStore &args, Error *error);
37
38 // Create a temporary service with the identifying properties populated
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(
43 const KeyValueStore &args, Error *error);
44
45 // Start the provider.
46 virtual void Start();
47
48 // Stop the provider (will de-register all services).
49 virtual void Stop();
50
51 protected:
52 Provider();
53
54 private:
55 friend class ProviderTest;
56
57 DISALLOW_COPY_AND_ASSIGN(Provider);
58};
59
60} // namespace shill
61
62#endif // SHILL_PROVIDER_INTERFACE_H_