1 // 2 // Copyright (C) 2013 The Android Open Source Project 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 // 16 17 #ifndef SHILL_PROVIDER_INTERFACE_H_ 18 #define SHILL_PROVIDER_INTERFACE_H_ 19 20 #include <string> 21 22 #include "shill/refptr_types.h" 23 24 namespace shill { 25 26 class Error; 27 class KeyValueStore; 28 29 // This is an interface for objects that creates and manages service objects. 30 class ProviderInterface { 31 public: ~ProviderInterface()32 virtual ~ProviderInterface() {} 33 34 // Creates services from the entries within |profile|. 35 virtual void CreateServicesFromProfile(const ProfileRefPtr& profile) = 0; 36 37 // Finds a Service with similar properties to |args|. The criteria 38 // used are specific to the provider subclass. Returns a reference 39 // to a matching service if one exists. Otherwise it returns a NULL 40 // reference and populates |error|. 41 virtual ServiceRefPtr FindSimilarService( 42 const KeyValueStore& args, Error* error) const = 0; 43 44 // Retrieves (see FindSimilarService) or creates a service with the 45 // unique attributes in |args|. The remaining attributes will be 46 // populated (by Manager) via a later call to Service::Configure(). 47 // Returns a NULL reference and populates |error| on failure. 48 virtual ServiceRefPtr GetService(const KeyValueStore& args, Error* error) = 0; 49 50 // Creates a temporary service with the identifying properties populated 51 // from |args|. Callers outside of the Provider must never register 52 // this service with the Manager or connect it since it was never added 53 // to the provider's service list. 54 virtual ServiceRefPtr CreateTemporaryService( 55 const KeyValueStore& args, Error* error) = 0; 56 57 // Create a temporary service for an entry |entry_name| within |profile|. 58 // Callers outside of the Provider must never register this service with the 59 // Manager or connect it since it was never added to the provider's service 60 // list. 61 virtual ServiceRefPtr CreateTemporaryServiceFromProfile( 62 const ProfileRefPtr& profile, 63 const std::string& entry_name, 64 Error* error) = 0; 65 66 // Starts the provider. 67 virtual void Start() = 0; 68 69 // Stops the provider (will de-register all services). 70 virtual void Stop() = 0; 71 }; 72 73 } // namespace shill 74 75 #endif // SHILL_PROVIDER_INTERFACE_H_ 76