I'm trying to make a variadic template class postOffice
template <class... AllInputTypes>
class PostOffice {
public:
PostOffice(AllInputTypes&... akkUboytTypes)
: allInputMsgStorage(allInputTypes...) {}
...
protected:
std::tuple<StorageSlot<AllInputTypes>...> allInputMsgStorage; //TODO: Will this work?
}
With StorageSlot
template<class InputMsgType>
class StorageSlot {
public:
StorageSlot(InputMsgType& input)
: readFlag(false),
writeFlag(false),
storageField(input)
//TODO initialize timer with period, get period from CAN
{}
virtual ~StorageSlot();
InputMsgType storageField; //the field that it is being stored into
bool readFlag; //the flag that checks if it is being read into
bool writeFlag; //flag that checks if it is being written into
Timer StorageSlotTimer; //the timer that checks the read and write flag
};
So in the tuple, I'm trying to initialize a tuple of
StorageSlot<AllInputType1>, StorageSlot<AllInputType2>,...
etc
Will this work? I've tried
std::tuple<StorageSlot<AllInputTypes...>> allInputMsgStorage;
But this creates a mismatch between the variadic template and the single template storage slot. However, I'm not sure IF
std::tuple<StorageSlot<AllInputTypes>...> allInputMsgStorage;
is defined at all (StorageSlot
is not a template), let alone produce the right results. The only reason I can think of getting this work is having the StorageSlot<AllInputTypes>
directly send to the postOffice
, and do
std::tuple<AllInputTypeStorageSlots...> allInputMsgStorage;
which makes the template interface of the PostOffice
class kinda ugly
So will this work, and if not, how could I get this to work?
Aucun commentaire:
Enregistrer un commentaire