~sil2100/location-service/gps-arm64

« back to all changes in this revision

Viewing changes to include/location_service/com/ubuntu/location/provider_factory.h

  • Committer: Thomas Voß
  • Date: 2013-05-28 14:20:45 UTC
  • Revision ID: thomas.voss@canonical.com-20130528142045-kq5umqdmm4o53vwk
Initial push.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_FACTORY_H_
 
2
#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_FACTORY_H_
 
3
 
 
4
#include "com/ubuntu/location/provider.h"
 
5
 
 
6
#include <functional>
 
7
#include <map>
 
8
#include <memory>
 
9
#include <mutex>
 
10
#include <string>
 
11
 
 
12
namespace com
 
13
{
 
14
namespace ubuntu
 
15
{
 
16
namespace location
 
17
{
 
18
class Provider;
 
19
 
 
20
class ProviderFactory
 
21
{
 
22
  public:
 
23
    typedef std::map<std::string, std::string> Configuration; // TODO(tvoss): Make this a little more sophisticated.
 
24
    typedef std::function<Provider::Ptr(const Configuration&)> Factory;
 
25
 
 
26
    static ProviderFactory& instance();
 
27
 
 
28
    void add_factory_for_name(const std::string& name, const Factory& factory);
 
29
 
 
30
    Provider::Ptr create_provider_for_name_with_config(const std::string& name, const Configuration& config);
 
31
 
 
32
    void enumerate(const std::function<void(const std::string&, const Factory&)>& enumerator);
 
33
 
 
34
  private:
 
35
    ProviderFactory() = default;
 
36
    ~ProviderFactory() = default;
 
37
 
 
38
    ProviderFactory(const ProviderFactory&) = delete;
 
39
    ProviderFactory& operator=(const ProviderFactory&) = delete;
 
40
 
 
41
    std::mutex guard;
 
42
    std::map<std::string, Factory> factory_store;    
 
43
};
 
44
}
 
45
}
 
46
}
 
47
 
 
48
#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_FACTORY_H_