11#pragma once
22#include " Particle.h"
33#include " LoggerFunctionReturns.h"
4+ #include " LoggerModule.h"
45
56/* *
67 * extension of return codes
@@ -115,12 +116,17 @@ class LoggerFunction {
115116 */
116117 template <typename T>
117118 // defined here instead of in cpp for full flexibility
118- void registerCommand (T* instance, bool (T::*method)(Variant&), const char* module, const char* cmd) {
119+ void registerCommand (T* instance, bool (T::*method)(Variant&), const char* cmd) {
119120 std::function<bool (Variant&)> cb = [instance, method](Variant& v) {
120121 return (instance->*method)(v);
121122 };
122123 const Vector<String> empty = {};
123- registerCommand (cb, module , cmd, empty, false , empty, false );
124+ if constexpr (std::is_convertible_v<T*, LoggerModule*>) {
125+ LoggerModule* m = static_cast <LoggerModule*>(instance);
126+ registerCommand (cb, m->getName (), cmd, empty, false , empty, false );
127+ } else {
128+ registerCommand (cb, " " , cmd, empty, false , empty, false );
129+ }
124130 }
125131
126132 /* *
@@ -129,12 +135,17 @@ class LoggerFunction {
129135 */
130136 template <typename T>
131137 // defined here instead of in cpp for full flexibility
132- void registerCommandWithTextValues (T* instance, bool (T::*method)(Variant&), const char* module, const char* cmd, const Vector<String>& text_values, bool value_optional = false) {
138+ void registerCommandWithTextValues (T* instance, bool (T::*method)(Variant&), const char* cmd, const Vector<String>& text_values, bool value_optional = false) {
133139 std::function<bool (Variant&)> cb = [instance, method](Variant& v) {
134140 return (instance->*method)(v);
135141 };
136142 const Vector<String> empty = {};
137- registerCommand (cb, module , cmd, text_values, false , empty, value_optional);
143+ if constexpr (std::is_convertible_v<T*, LoggerModule*>) {
144+ LoggerModule* m = static_cast <LoggerModule*>(instance);
145+ registerCommand (cb, m->getName (), cmd, text_values, false , empty, value_optional);
146+ } else {
147+ registerCommand (cb, " " , cmd, text_values, false , empty, value_optional);
148+ }
138149 }
139150
140151 /* *
@@ -143,12 +154,17 @@ class LoggerFunction {
143154 */
144155 template <typename T>
145156 // defined here instead of in cpp for full flexibility
146- void registerCommandWithNumericValues (T* instance, bool (T::*method)(Variant&), const char* module, const char* cmd, const Vector<String>& numeric_units = {}, bool value_optional = false ) {
157+ void registerCommandWithNumericValues (T* instance, bool (T::*method)(Variant&), const char* cmd, const Vector<String>& numeric_units = {}, bool value_optional = false ) {
147158 std::function<bool (Variant&)> cb = [instance, method](Variant& v) {
148159 return (instance->*method)(v);
149160 };
150161 const Vector<String> empty = {};
151- registerCommand (cb, module , cmd, empty, true , numeric_units, value_optional);
162+ if constexpr (std::is_convertible_v<T*, LoggerModule*>) {
163+ LoggerModule* m = static_cast <LoggerModule*>(instance);
164+ registerCommand (cb, m->getName (), cmd, empty, true , numeric_units, value_optional);
165+ } else {
166+ registerCommand (cb, " " , cmd, empty, true , numeric_units, value_optional);
167+ }
152168 }
153169
154170 /* *
@@ -157,11 +173,16 @@ class LoggerFunction {
157173 */
158174 template <typename T>
159175 // defined here instead of in cpp for full flexibility
160- void registerCommandWithMixedValues (T* instance, bool (T::*method)(Variant&), const char* module, const char* cmd, const Vector<String>& text_values, const Vector<String>& numeric_units = {}, bool value_optional = false ) {
176+ void registerCommandWithMixedValues (T* instance, bool (T::*method)(Variant&), const char* cmd, const Vector<String>& text_values, const Vector<String>& numeric_units = {}, bool value_optional = false ) {
161177 std::function<bool (Variant&)> cb = [instance, method](Variant& v) {
162178 return (instance->*method)(v);
163179 };
164- registerCommand (cb, module , cmd, text_values, true , numeric_units, value_optional);
180+ if constexpr (std::is_convertible_v<T*, LoggerModule*>) {
181+ LoggerModule* m = static_cast <LoggerModule*>(instance);
182+ registerCommand (cb, m->getName (), cmd, text_values, true , numeric_units, value_optional);
183+ } else {
184+ registerCommand (cb, " " , cmd, text_values, true , numeric_units, value_optional);
185+ }
165186 }
166187
167188 /* *
0 commit comments