#ifndef PLATFORM_API_PLATFORM_H_ #define PLATFORM_API_PLATFORM_H_ #include #include "platform/api/atomic_boolean.h" #include "platform/api/atomic_reference_def.h" #include "platform/api/ble.h" #include "platform/api/ble_v2.h" #include "platform/api/bluetooth_adapter.h" #include "platform/api/bluetooth_classic.h" #include "platform/api/condition_variable.h" #include "platform/api/count_down_latch.h" #include "platform/api/hash_utils.h" #include "platform/api/input_file.h" #include "platform/api/lock.h" #include "platform/api/output_file.h" #include "platform/api/scheduled_executor.h" #include "platform/api/server_sync.h" #include "platform/api/settable_future_def.h" #include "platform/api/submittable_executor_def.h" #include "platform/api/system_clock.h" #include "platform/api/thread_utils.h" //#include "platform/api/webrtc.h" #include "platform/api/wifi.h" #include "platform/api/wifi_lan.h" // Project-specific basic types, that are not part of API. // TODO(apolyudov): replace with c++ standard types. #include "platform/port/string.h" #include "platform/ptr.h" #include "absl/types/any.h" namespace location { namespace nearby { namespace platform { // API rework notes: // https://docs.google.com/spreadsheets/d/1erZNkX7pX8s5jWTHdxgjntxTMor3BGiY2H_fC_ldtoQ/edit#gid=381357998 class ImplementationPlatform { public: // Class Templates in platform code. // // Platform interface does not support templates directly. // This is a design decision. The purpose is to have type isolation // between platform library (or simply platform) and core library. // Another goal is to make a platform implementation a black box, // which does not leak implementation details in any form, be that types, // methods, or variables. // // Core library code does provide platform-specific class templates // on top of (a non-templated) platform support. // // For every common library template that needs platform support, // platform must provide an absl::any specialization of class template: template static Ptr> createAtomicReference(T initial_value = T{}); template static Ptr> createSettableFuture(); // AtomicReference static Ptr> createAtomicReferenceAny( absl::any initial_value); // SettableFuture static Ptr> createSettableFutureAny(); // Non-template methods: general platform support. static Ptr createAtomicBoolean(bool initial_value); static Ptr createCountDownLatch(std::int32_t count); static Ptr createLock(); static Ptr createConditionVariable(Ptr lock); static Ptr createHashUtils(); static Ptr createThreadUtils(); static Ptr createSystemClock(); static Ptr createInputFile(std::int64_t payload_id, std::int64_t total_size); static Ptr createOutputFile(std::int64_t payload_id); // Java-like Executors // Type aliases used to API 1.0 compatibility. // They will be retired soon. // TODO(apolyudov): cleanup. using SingleThreadExecutorType = SubmittableExecutor; using MultiThreadExecutorType = SubmittableExecutor; using ScheduledExecutorType = ScheduledExecutor; static Ptr createSingleThreadExecutor(); static Ptr createMultiThreadExecutor( std::int32_t max_concurrency); static Ptr createScheduledExecutor(); // Protocol implementations, domain-specific support static Ptr createBluetoothAdapter(); static Ptr createWifiMedium(); static Ptr createBluetoothClassicMedium(); static Ptr createBLEMedium(); static Ptr createBLEMediumV2(); static Ptr createServerSyncMedium(); static Ptr createWifiLanMedium(); // static Ptr createWebRtcSignalingMessenger( // const std::string& self_id); static std::string getDeviceId(); }; } // namespace platform } // namespace nearby } // namespace location #endif // PLATFORM_API_PLATFORM_H_