[Insight-developers] ClassifierBase::SetDecisionRule
Miller, James V (Research)
millerjv at crd . ge . com
Tue, 29 Jul 2003 09:19:06 -0400
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C355D3.FD033268
Content-Type: text/plain;
charset="iso-8859-1"
I notice the Classifier code in ITK has methods like SetDecisionRule() that
take as an argument a SmartPointer.
Shouldn't the argument be a raw pointer? Using a raw pointer as an argument
allows the casting up through the superclass chain. You can still pass in a
SmartPointer when the routine is called and it should be automatically
converted to a raw pointer. Using a raw pointer as a parameter also avoids
making unnecessary calls to Mutex locks etc.
With the exception of the New() method, I think ITK always takes raw pointer
as parameters and returns raw pointers on access methods. It is the
responsibility of the method to stash parameters passed as raw pointers into
SmartPointers if they need to be maintained past the lifetime of the method.
It is the responsibility of the caller to stash return values into
SmartPointer is they need a persistent handle to the object. The exception
to this rule is any method which allocates objects and returns them as
return values. In this case, the return type should be a SmartPointer in
order to make sure the object persists long enough for the caller to stash
the return value in another SmartPointer.
I haven't looked through the rest of the Statistics library. There may be
other cases of this. We probably should align this library with the rest of
the toolkit.
Jim Miller
_____________________________________
Visualization & Computer Vision
GE Research
Bldg. KW, Room C218B
P.O. Box 8, Schenectady NY 12301
millerjv at research . ge . com <mailto:millerjv at research . ge . com>
james . miller at research . ge . com
(518) 387-4005, Dial Comm: 8*833-4005,
Cell: (518) 505-7065, Fax: (518) 387-6981
------_=_NextPart_001_01C355D3.FD033268
Content-Type: text/html;
charset="iso-8859-1"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1141" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=390580913-29072003><FONT size=2>I notice the Classifier code in
ITK has methods like SetDecisionRule() that take as an argument a
SmartPointer.</FONT></SPAN></DIV>
<DIV><SPAN class=390580913-29072003><FONT size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=390580913-29072003><FONT size=2>Shouldn't the argument be a raw
pointer? Using a raw pointer as an argument allows the casting up through
the superclass chain. You can still pass in a SmartPointer when the
routine is called and it should be automatically converted to a raw pointer.
Using a raw pointer as a parameter also avoids making unnecessary calls to Mutex
locks etc.</FONT></SPAN></DIV>
<DIV><SPAN class=390580913-29072003><FONT size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=390580913-29072003><FONT size=2>With the exception of the New()
method, I think ITK always takes raw pointer as parameters and returns raw
pointers on access methods. It is the responsibility of the method to
stash parameters passed as raw pointers into SmartPointers if they need to be
maintained past the lifetime of the method. It is the responsibility of
the caller to stash return values into SmartPointer is they need a persistent
handle to the object. The exception to this rule is any method which
allocates objects and returns them as return values. In this case, the
return type should be a SmartPointer in order to make sure the object persists
long enough for the caller to stash the return value in another
SmartPointer.</FONT></SPAN></DIV>
<DIV><SPAN class=390580913-29072003><FONT size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=390580913-29072003><FONT size=2>I haven't looked through the
rest of the Statistics library. There may be other cases of this. We
probably should align this library with the rest of the
toolkit.</FONT></SPAN></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV>
<P style="MARGIN: 0in 0in 0pt"><B><SPAN
style="COLOR: navy; FONT-FAMILY: 'Comic Sans MS'">Jim Miller</SPAN></B>
<BR><B><I><SPAN
style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Arial">_____________________________________</SPAN></I></B><BR><EM><SPAN
style="FONT-SIZE: 7.5pt; COLOR: black; FONT-FAMILY: Arial">Visualization &
Computer Vision</SPAN></EM><I><SPAN
style="FONT-SIZE: 7.5pt; COLOR: black; FONT-FAMILY: Arial"><BR><EM>GE
Research</EM><BR><EM>Bldg. KW, Room C218B</EM><BR><EM>P.O. Box 8, Schenectady NY
12301</EM><BR><BR></SPAN></I><EM><U><SPAN
style="FONT-SIZE: 7.5pt; COLOR: blue"><A
href="mailto:millerjv at research . ge . com">millerjv at research . ge . com</A></SPAN></U></EM></P>
<P style="MARGIN: 0in 0in 0pt"><EM><U><SPAN
style="FONT-SIZE: 7.5pt; COLOR: blue">james . miller at research . ge . com</SPAN></U></EM><BR><I><SPAN
style="FONT-SIZE: 7.5pt; COLOR: black; FONT-FAMILY: Arial">(518) 387-4005, Dial
Comm: 8*833-4005, </SPAN></I><BR><I><SPAN
style="FONT-SIZE: 7.5pt; COLOR: black; FONT-FAMILY: Arial">Cell: (518) 505-7065,
Fax: (518) 387-6981</SPAN></I> </P></DIV>
<DIV> </DIV></BODY></HTML>
------_=_NextPart_001_01C355D3.FD033268--