Skip to content

Commit

Permalink
publishers: remove hearsay about logger construction order
Browse files Browse the repository at this point in the history
The C++ standard specifies that all objects in the same translation unit
(i.e. source file) are constructed in order of declaration. Since this is
the most common case when using Modular Sensors, the described case cannot
occur.
  • Loading branch information
tpwrules committed Apr 11, 2023
1 parent 2c87ff0 commit f83a96f
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 74 deletions.
28 changes: 2 additions & 26 deletions src/dataPublisherBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@ class dataPublisher {
* @param baseLogger The logger supplying the data to be published
* @param sendEveryX Interval (in units of the logging interval) between
* attempted data transmissions. Not respected by all publishers.
*
* @note It is possible (though very unlikey) that using this constructor
* could cause errors if the compiler attempts to initialize the publisher
* instance before the logger instance. If you suspect you are seeing that
* issue, use the null constructor and a populated begin(...) within your
* set-up function.
*/
explicit dataPublisher(Logger& baseLogger, int sendEveryX = 1);
/**
Expand All @@ -104,12 +98,6 @@ class dataPublisher {
* single TinyGSM modem instance
* @param sendEveryX Interval (in units of the logging interval) between
* attempted data transmissions. Not respected by all publishers.
*
* @note It is possible (though very unlikey) that using this constructor
* could cause errors if the compiler attempts to initialize the publisher
* instance before the logger instance. If you suspect you are seeing that
* issue, use the null constructor and a populated begin(...) within your
* set-up function.
*/
dataPublisher(Logger& baseLogger, Client* inClient, int sendEveryX = 1);
/**
Expand Down Expand Up @@ -148,13 +136,7 @@ class dataPublisher {
* @brief Begin the publisher - linking it to the client and logger.
*
* This can be used as an alternative to adding the logger and client in the
* constructor. This is slightly "safer" because we expect the publishers
* to be created in the "global scope" and we cannot control the order in
* which objects in that global scope will be created. That is, we cannot
* guarantee that the logger will actually be created before the publisher
* that wants to attach to it unless we wait to attach the publisher until
* in the setup or loop function of the main program. In reality, it is
* very unlikely that this is necessary.
* constructor.
*
* @param baseLogger The logger supplying the data to be published
* @param inClient An Arduino client instance to use to print data to.
Expand All @@ -172,13 +154,7 @@ class dataPublisher {
* logger.
*
* This can be used as an alternative to adding the logger and client in the
* constructor. This is slightly "safer" because we expect the publishers
* to be created in the "global scope" and we cannot control the order in
* which objects in that global scope will be created. That is, we cannot
* guarantee that the logger will actually be created before the publisher
* that wants to attach to it unless we wait to attach the publisher until
* in the setup or loop function of the main program. In reality, it is
* very unlikely that this is necessary.
* constructor.
*
* @param baseLogger The logger supplying the data to be published
*/
Expand Down
12 changes: 0 additions & 12 deletions src/publishers/DreamHostPublisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ class DreamHostPublisher : public dataPublisher {
* @param baseLogger The logger supplying the data to be published
* @param sendEveryX Interval (in units of the logging interval) between
* attempted data transmissions. NOTE: not implemented by this publisher!
*
* @note It is possible (though very unlikey) that using this constructor
* could cause errors if the compiler attempts to initialize the publisher
* instance before the logger instance. If you suspect you are seeing that
* issue, use the null constructor and a populated begin(...) within your
* set-up function.
*/
explicit DreamHostPublisher(Logger& baseLogger, int sendEveryX = 1);
/**
Expand All @@ -70,12 +64,6 @@ class DreamHostPublisher : public dataPublisher {
* single TinyGSM modem instance
* @param sendEveryX Interval (in units of the logging interval) between
* attempted data transmissions. NOTE: not implemented by this publisher!
*
* @note It is possible (though very unlikey) that using this constructor
* could cause errors if the compiler attempts to initialize the publisher
* instance before the logger instance. If you suspect you are seeing that
* issue, use the null constructor and a populated begin(...) within your
* set-up function.
*/
DreamHostPublisher(Logger& baseLogger, Client* inClient,
int sendEveryX = 1);
Expand Down
12 changes: 0 additions & 12 deletions src/publishers/EnviroDIYPublisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ class EnviroDIYPublisher : public dataPublisher {
* @param baseLogger The logger supplying the data to be published
* @param sendEveryX Interval (in units of the logging interval) between
* attempted data transmissions. NOTE: not implemented by this publisher!
*
* @note It is possible (though very unlikey) that using this constructor
* could cause errors if the compiler attempts to initialize the publisher
* instance before the logger instance. If you suspect you are seeing that
* issue, use the null constructor and a populated begin(...) within your
* set-up function.
*/
explicit EnviroDIYPublisher(Logger& baseLogger, int sendEveryX = 1);
/**
Expand All @@ -70,12 +64,6 @@ class EnviroDIYPublisher : public dataPublisher {
* single TinyGSM modem instance
* @param sendEveryX Interval (in units of the logging interval) between
* attempted data transmissions. NOTE: not implemented by this publisher!
*
* @note It is possible (though very unlikey) that using this constructor
* could cause errors if the compiler attempts to initialize the publisher
* instance before the logger instance. If you suspect you are seeing that
* issue, use the null constructor and a populated begin(...) within your
* set-up function.
*/
EnviroDIYPublisher(Logger& baseLogger, Client* inClient,
int sendEveryX = 1);
Expand Down
12 changes: 0 additions & 12 deletions src/publishers/ThingSpeakPublisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ class ThingSpeakPublisher : public dataPublisher {
* @param baseLogger The logger supplying the data to be published
* @param sendEveryX Interval (in units of the logging interval) between
* attempted data transmissions. NOTE: not implemented by this publisher!
*
* @note It is possible (though very unlikey) that using this constructor
* could cause errors if the compiler attempts to initialize the publisher
* instance before the logger instance. If you suspect you are seeing that
* issue, use the null constructor and a populated begin(...) within your
* set-up function.
*/
explicit ThingSpeakPublisher(Logger& baseLogger, int sendEveryX = 1);
/**
Expand All @@ -95,12 +89,6 @@ class ThingSpeakPublisher : public dataPublisher {
* single TinyGSM modem instance
* @param sendEveryX Interval (in units of the logging interval) between
* attempted data transmissions. NOTE: not implemented by this publisher!
*
* @note It is possible (though very unlikey) that using this constructor
* could cause errors if the compiler attempts to initialize the publisher
* instance before the logger instance. If you suspect you are seeing that
* issue, use the null constructor and a populated begin(...) within your
* set-up function.
*/
ThingSpeakPublisher(Logger& baseLogger, Client* inClient,
int sendEveryX = 1);
Expand Down
12 changes: 0 additions & 12 deletions src/publishers/UbidotsPublisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ class UbidotsPublisher : public dataPublisher {
* @param baseLogger The logger supplying the data to be published
* @param sendEveryX Interval (in units of the logging interval) between
* attempted data transmissions. NOTE: not implemented by this publisher!
*
* @note It is possible (though very unlikey) that using this constructor
* could cause errors if the compiler attempts to initialize the publisher
* instance before the logger instance. If you suspect you are seeing that
* issue, use the null constructor and a populated begin(...) within your
* set-up function.
*/
explicit UbidotsPublisher(Logger& baseLogger, int sendEveryX = 1);
/**
Expand All @@ -69,12 +63,6 @@ class UbidotsPublisher : public dataPublisher {
* single TinyGSM modem instance
* @param sendEveryX Interval (in units of the logging interval) between
* attempted data transmissions. NOTE: not implemented by this publisher!
*
* @note It is possible (though very unlikey) that using this constructor
* could cause errors if the compiler attempts to initialize the publisher
* instance before the logger instance. If you suspect you are seeing that
* issue, use the null constructor and a populated begin(...) within your
* set-up function.
*/
UbidotsPublisher(Logger& baseLogger, Client* inClient, int sendEveryX = 1);
/**
Expand Down

0 comments on commit f83a96f

Please sign in to comment.