28 std::function<bool ()>
isCreatable = []() ->
bool {
return true; };
43template<
class T,
class B>
46 if(!selectionId.has_value())
47 selectionId = T::info.id;
49 if constexpr(std::is_base_of<Singleton<T>, T>::value){
53 return { T::info,selectionId.value(), []() -> B * {
return new T; } , T::isCreatable };
69template<
class T,
class B>
72 if(!selectionId.has_value())
73 selectionId = T::info.id;
75 return { T::info,selectionId, [ref]() -> B * {
return ref; } ,T::isCreatable};
80 if(!selectionId.has_value())
81 selectionId = B::info.id;
82 return {
info,selectionId, [ref]() -> B * {
return ref; },ref->isCreatable };
104 if(e.selectionId ==
id && e.isCreatable()){
106 cls->selectionId =
id;
118 if(e.selectionId ==
id && e.isCreatable()){
132 if(ignoredCreatableId != cls.selectionId)
137 replyObj.
reply+= std::to_string(cls.selectionId);
138 replyObj.
reply+=
":";
139 replyObj.
reply+= (cls.isCreatable() || ignoredCreatableId == cls.selectionId) ?
"1" :
"0";
140 replyObj.
reply+=
":";
141 replyObj.
reply+= cls.info.name;
143 if(cls.isCreatable()){
145 replyObj.
adr = cls.selectionId;
146 replyObj.
val = cls.info.id;
151 replies.push_back(replyObj);
161 if(cls.selectionId ==
id){
constexpr class_entry< B > add_class(std::optional< uint16_t > selectionId=std::nullopt)
constexpr class_entry< B > add_class_ref(B *ref, std::optional< uint16_t > selectionId=std::nullopt)
constexpr class_entry< B > make_class_entry(ClassIdentifier info, B *ref, std::optional< uint16_t > selectionId=std::nullopt)
bool isCreatable(uint16_t id)
bool isValidClassId(uint16_t id)
void replyAvailableClasses(std::vector< CommandReply > &replies, int16_t ignoredCreatableId=255)
const std::vector< class_entry< T > > * class_registry
ClassChooser(const std::vector< class_entry< T > > &classes)
std::function< B *()> create
std::function< bool()> isCreatable