diff --git a/include/etl/observer.h b/include/etl/observer.h index 35e51dee9..32eee70ec 100644 --- a/include/etl/observer.h +++ b/include/etl/observer.h @@ -498,6 +498,19 @@ namespace etl virtual void notification(T1) = 0; }; + //********************************************************************* + /// The observer interface for void argument notification type. + ///\ingroup observer + //********************************************************************* + template <> + class observer + { + public: + + virtual ~observer() {} + virtual void notification() = 0; + }; + #endif } diff --git a/include/etl/version.h b/include/etl/version.h index 34db9c980..afdc63a74 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -40,7 +40,7 @@ SOFTWARE. #define ETL_VERSION_MAJOR 20 #define ETL_VERSION_MINOR 39 -#define ETL_VERSION_PATCH 0 +#define ETL_VERSION_PATCH 1 #define ETL_VERSION ETL_STRING(ETL_VERSION_MAJOR) "." ETL_STRING(ETL_VERSION_MINOR) "." ETL_STRING(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_WIDE_STRING(ETL_VERSION_MAJOR) L"." ETL_WIDE_STRING(ETL_VERSION_MINOR) L"." ETL_WIDE_STRING(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index bcb615a96..7e17ee746 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library", - "version": "20.39.0", + "version": "20.39.1", "authors": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index 719241acf..c18d09f36 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=20.39.0 +version=20.39.1 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index 1964ff912..2daac9be0 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,4 +1,10 @@ =============================================================================== +20.39.1 + +#940 Allow etl::observer notification without argument + Added a void specialisation to the < C++11 code. + +=============================================================================== 20.39.0 Refactored: diff --git a/test/test_observer.cpp b/test/test_observer.cpp index 48051c808..aff048f07 100644 --- a/test/test_observer.cpp +++ b/test/test_observer.cpp @@ -75,6 +75,11 @@ namespace // The observer base type that does not take a notification type. //***************************************************************************** typedef etl::observer ObserverVoidIntType; +#else + //***************************************************************************** + // The observer base type that does not take a notification type. + //***************************************************************************** + typedef etl::observer ObserverVoidType; #endif } @@ -141,6 +146,22 @@ class ObservableVoidInt : public etl::observable notify_observers(n); } }; +#else +//***************************************************************************** +// The concrete observable 3 class. +//***************************************************************************** +class ObservableVoid : public etl::observable +{ +public: + + //********************************* + // Notify all of the observers. + //********************************* + void send_notifications() + { + notify_observers(); + } +}; #endif //***************************************************************************** @@ -260,6 +281,32 @@ class ObserverVoidInt : public ObserverVoidIntType // Notification2 //******************************************* void notification(int) override + { + ++data2_count; + } + + int data1_count; + int data2_count; +}; +#else +//***************************************************************************** +// The third observer type. +// If any one of the overloads is missing or a parameter declaration is incorrect +// then the class will be 'abstract' and will not compile. +//***************************************************************************** +class ObserverVoid : public ObserverVoidType +{ +public: + + ObserverVoid() + : data1_count(0) + { + } + + //******************************************* + // Notification1 + //******************************************* + void notification() override { ++data1_count; } @@ -572,6 +619,21 @@ namespace observable.send_notifications(); observable.send_notifications(1); } +#else + //************************************************************************* + TEST(test_void_observable) + { + // The observable objects. + ObservableVoid observable; + + // The observer objects. + ObserverVoid observer; + + observable.add_observer(observer); + + // Send the notifications. + observable.send_notifications(); + } #endif } } diff --git a/version.txt b/version.txt index 4298195f6..f1d18b950 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -20.39.0 +20.39.1