From c28954844f943cc2dfcb21bcdbb22992fdd40489 Mon Sep 17 00:00:00 2001 From: Todd Treece Date: Fri, 1 May 2015 12:36:20 -0400 Subject: [PATCH 1/4] adds library.properties --- library.properties | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 library.properties diff --git a/library.properties b/library.properties new file mode 100644 index 0000000..991b839 --- /dev/null +++ b/library.properties @@ -0,0 +1,9 @@ +name=Adafruit Unified Sensor +version=1.0.0 +author=Adafruit +maintainer=Adafruit +sentence=Required for all Adafruit Unified Sensor based libraries. +paragraph=A unified sensor abstraction layer used by many Adafruit sensor libraries. +category=Sensors +url=https://github.com/adafruit/Adafruit_Sensor +architectures=* From 1a266c24bf33ff7188d549268d8c5fd055194792 Mon Sep 17 00:00:00 2001 From: Sarah Tappon Date: Wed, 6 May 2015 22:59:21 -0700 Subject: [PATCH 2/4] add virtual destructor base classes without virtual destructors risk undefined behavior if their children are deleted through a pointer to base. see https://isocpp.org/wiki/faq/virtual-functions#virtual-dtors --- Adafruit_Sensor.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Adafruit_Sensor.h b/Adafruit_Sensor.h index beb51c8..4e10868 100644 --- a/Adafruit_Sensor.h +++ b/Adafruit_Sensor.h @@ -140,6 +140,7 @@ class Adafruit_Sensor { public: // Constructor(s) void constructor(); + virtual ~Adafruit_Sensor() {} // These must be defined by the subclass virtual void enableAutoRange(bool enabled) {}; From c7b5e92311244679388554aa95f7336567e720c0 Mon Sep 17 00:00:00 2001 From: Sarah Tappon Date: Wed, 6 May 2015 23:14:39 -0700 Subject: [PATCH 3/4] add default constructor in place of constructor() method --- Adafruit_Sensor.cpp | 3 --- Adafruit_Sensor.h | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Adafruit_Sensor.cpp b/Adafruit_Sensor.cpp index 2977b27..ee59b27 100644 --- a/Adafruit_Sensor.cpp +++ b/Adafruit_Sensor.cpp @@ -1,5 +1,2 @@ #include "Adafruit_Sensor.h" #include - -void Adafruit_Sensor::constructor() { -} diff --git a/Adafruit_Sensor.h b/Adafruit_Sensor.h index 4e10868..e6b2c3d 100644 --- a/Adafruit_Sensor.h +++ b/Adafruit_Sensor.h @@ -139,7 +139,7 @@ typedef struct class Adafruit_Sensor { public: // Constructor(s) - void constructor(); + Adafruit_Sensor() {} virtual ~Adafruit_Sensor() {} // These must be defined by the subclass From 73a4e73c87ddda47e82a9d9d2ecf53c1641324db Mon Sep 17 00:00:00 2001 From: Sarah Tappon Date: Wed, 6 May 2015 23:15:56 -0700 Subject: [PATCH 4/4] mark unimplemented virtual functions as abstract --- Adafruit_Sensor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Adafruit_Sensor.h b/Adafruit_Sensor.h index e6b2c3d..7742afc 100644 --- a/Adafruit_Sensor.h +++ b/Adafruit_Sensor.h @@ -144,8 +144,8 @@ class Adafruit_Sensor { // These must be defined by the subclass virtual void enableAutoRange(bool enabled) {}; - virtual bool getEvent(sensors_event_t*); - virtual void getSensor(sensor_t*); + virtual bool getEvent(sensors_event_t*) = 0; + virtual void getSensor(sensor_t*) = 0; private: bool _autoRange;