Trying to do something completely perfectly in C++ but it's becoming an epic struggle. Templatised things must be kept in a list, processed by template class (invoked two different threads). But the templatisation must be exposed to interface in and out of class.
Just one of numerous problems seem to be with a typedef of a hash map of templatised types ... The kind of typedef used here works if the HashMap params aren't templatised params. I might be missing some relatively basic C++ template knowledge or, well the why doesn't it just do what I mean! :'(
template<typename QIdType, typename SeqType>
class CRetxLink
{
typedef struct retx_data
...
SeqType m_retx_seq_no;
...
} retx_data_t;
typedef dts::HashMap<QIdType, retx_data_t*> HashTypeData;
boost::shared_ptr<HashTypeData> p_retx_list;
// compiler doesn't like this:
HashTypeData::iterator iterData = p_retx_list->begin();
// e.g. this is okay outside of class
typedef struct retx_data
...
unsigned int m_retx_seq_no;
...
} retx_data_t;
typedef dts::HashMap<unsigned int, retx_data_t*> HashTypeData;
Need to go back and start with the basics again .....
// essentially a generic interface to the templatized classes would be a start.
#include <string>
#include <iostream>
//g++ ~/c/templateInterface.cpp -o ~/c/templateInterface
class CTempInterface
{
public:
CTempInterface()
{
};
~CTempInterface()
{
};
virtual void Method()
{
printf("Method %s\n", __FUNCTION__);
}
};
template<typename T>
class TTemp : public CTempInterface
{
public:
TTemp()
{
};
~TTemp()
{
};
void Method()
{
printf("Method %s\n", __FUNCTION__);
std::cout << "two: " << thingywotsit << "\n";
}
T thingywotsit;
};
int main()
{
TTemp<int> tt_i;
TTemp<std::string> tt_s;
//TTemp &p;
CTempInterface *p;
p = &tt_i;
p->Method();
p = &tt_s;
p->Method();
}
No comments:
Post a Comment