Hi Hendrik,<br><br>Thanks for your reply. But the &#39;type&#39; of data is defined only at runtime!<br><br>For
example, if you have a Nifti file, the underlying type whether it is
char, short, float or what have you is only defined at run time!<br>
<br>So what I did is following:<br><br>template&lt;typename DataType, unsigned int dimensions=3&gt;<br>class MyReader<br>{<br>&nbsp;&nbsp;&nbsp; typedef itk::ImportImageFilter&lt;DataType<div id="mb_4">, dimensions&gt; ImportFilterType;<br>
&nbsp;&nbsp;&nbsp; // This class uses the itk::ImportImageFilter<br>
&nbsp;&nbsp;&nbsp; private:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; typename ImportFilterType::Pointer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_importer; ///&lt; The ITK data importer<br>};<br><br>And I can have a factory object that creates the instance with the correct template arguments....<br>

<br>However, how can I return such a dynamic object from the class
factory and how can I store this created object in another class member
variable?<br><br>Thanks,<br>Anja<br></div><br><br><div><span class="gmail_quote">On 20/02/2008, <b class="gmail_sendername">Hendrik Belitz</b> &lt;<a href="mailto:hbelitz@darkon.info">hbelitz@darkon.info</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Anja,<span class="q"><br><br><blockquote type="cite" style="border-left: 1px solid blue; margin-left: 0px; padding-left: 10px;">However, with this scheme you are unable to have &lt;i&gt;class member variables&lt;/i&gt; that are of templated type. Say for example, I need to read data from a file inside a class method. So, I find the underlying data type and dimensions and read the data. However, if I want to access this data later or basically store it in the class, how can I do that?<br>
<br></blockquote></span><div>You do not need templated class members since you can just hold a pointer to the data in a (less or even non-templated) base class like itk::ImageBase (which is not templated by data type). If you also<br>
need independence of dimension, use itk::DataObject instead. Of course this means that you have to downcast it using dynamic_cast&lt;&gt; again later. <br><br>Hope this helps,<br>&nbsp;Hendrik<br><br>-------------------------------------------------------------------<br>
Brilliance is typically the act of an individual, but incredible<br>stupidity can usually be traced to an organization. - Jon Bentley<br><br>Hendrik Belitz, Computer Scientist<br>email: <a href="mailto:hbelitz@computer.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">hbelitz@computer.org</a> or <a href="mailto:hbelitz@ieee.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">hbelitz@ieee.org</a></div>
<br><br>_______________________________________________<br>Insight-users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Cheers,<br><br>Anja