Kallisto Linux API
Library for interacting with Kallisto devices
kallisto_factory.hpp
Go to the documentation of this file.
1 
42 #ifndef KALLISTO_FACTORY_HPP
43 #define KALLISTO_FACTORY_HPP
44 
45 #include <memory>
46 
47 #include "../util/log/easylogging++.h"
48 
49 #include "../bluetooth/adapter/bluetooth_adapter.hpp"
50 #include "kallisto.hpp"
51 #include "kallisto_impl.hpp"
53 
54 namespace kallisto {
55 namespace hardware {
56 
57 class KallistoFactory {
58 private:
60  SensorFactory& m_sensor_factory; //The sensor factory
61 
62 public:
67  KallistoFactory(SensorFactory& sensor_factory) : m_sensor_factory(sensor_factory) {}
68 
73 
84  std::unique_ptr<KallistoImpl> build(kallisto::bluetooth::BluetoothDevice& bluetooth_device, const bluetooth::BluetoothAdapter::ScanListener::ScanRecord& record, bool legacy_discovery,
85  util::Executor& event_dispatcher){
86 
87  try {
88  return std::unique_ptr<KallistoImpl>(new KallistoImpl(bluetooth_device, record, legacy_discovery, event_dispatcher, m_sensor_factory));
89  }
90  catch (std::exception& e) {
91  LOG(ERROR) << "Failed to create " << bluetooth_device.getName() << " @ " << bluetooth_device.getAddress() << ": " << e.what();
92  return nullptr;
93  }
94  }
95 
96 };
97 
98 } /* namespace hardware */
99 } /* namespace kallisto */
100 
101 #endif // KALLISTO_FACTORY_HPP
~KallistoFactory()
Definition: kallisto_factory.hpp:71
Definition: bluetooth_adapter.hpp:52
std::string getAddress() const
Definition: bluetooth_device.hpp:114
Definition: bluetooth_device.hpp:58
std::unique_ptr< KallistoImpl > build(kallisto::bluetooth::BluetoothDevice &bluetooth_device, const bluetooth::BluetoothAdapter::ScanListener::ScanRecord &record, bool legacy_discovery, util::Executor &event_dispatcher)
Definition: kallisto_factory.hpp:83
std::string getName() const
Definition: bluetooth_device.hpp:106
Definition: executor.hpp:71
Definition: sensor_factory.hpp:60
KallistoFactory(SensorFactory &sensor_factory)
Definition: kallisto_factory.hpp:66
Definition: kallisto_impl.hpp:70
Definition: kallisto_factory.hpp:56