私のコードは、テンプレート パラメーターの型に基づいてオブジェクトを作成するファクトリです。これを「リスト」タイプに拡張したいと思います。
これは私が持っているものです: Algo1
タイプを定義しindata
ます。FASSubscriberFactory::Create()
へのポインタを返しますFASSubscriber<Algo1::indata,..>
。ここを参照してください:
struct Algo1
{
typedef DataType1 indata;
}
template <class T, class FEED = T::indata, class PROC = typename ProcessorFactory<T>::ptype>
struct FASSubscriberFactory
{
typedef FASSubscriber<typename PROC , typename FEED > fftype;
static fftype * Create()
{
return new fftype(FASConfig::Data2Feed<FEED>::name, ProcessorFactory<T>::Create());
}
}
void main()
{
auto myFASSubscriber4Algo1 FASSubscriberFactory<Algo1>::Create();
}
これが私が望むものです: Algo1
typedefs のリストを定義します indata
。FASSubscriberFactory::CreateList()
のforeach型のリストへのポインタを返します。以下の疑似コードの // コメントを参照してください。FASSubscriber<Algo1::indata,..>
Algo1:indata
struct Algo1
{
//Want to define a list of types
typedef std::list<types> indata = { DataType1, DateType2 }
}
template <class T, class FEEDs = T::indata, class PROC = typename ProcessorFactory<T>::ptype>
struct FASSubscriberFactory
{
//want to create a list FASSubscribers from list of types T::indata
typedef list<FASSubscriber<PROC, FEEDs::type> listoffftypes
static lisoftypes * CreateList()
{
listoffftypes mylot();
//for each type in FEEDs - want to lopp around list of types
foreach(feedtype in FEEDs )
{
mylot.push(Create<feedtype>());
}
return mylot;
}
template <class FEED>
static fftype * Create()
{
typedef FASSubscriber<typename PROC , typename FEED > fftype;
return new fftype(FASConfig::Data2Feed<FEED>::name, ProcessorFactory<T>::Create());
}
}
void main()
{
auto myListOfFASSubscriber4Algo1 FASSubscriberFactory<Algo1>::Create();
}
私が本当に欲しいのは、テンプレート引数クラスで定義されている「typelist」を定義して反復する方法だけです。A. Alexa の TYPELIST を見てみましたが、ループは見当たりませんでした。
ありがとう