[Trilinos-Users] Changing Teuchos::RefCountPtr to Teuchos::RCP and inserting 'using Teuchos::RCP'

Bartlett, Roscoe A rabartl at sandia.gov
Mon Mar 19 18:25:57 MDT 2007


Hello all,

I am sending out this email to alert developers and users of Trilinos
that we are planning on changing the name of the Teuchos smart reference
counted pointer class from Teuchos::RefCountPtr to Teuchos::RCP.  We
will then put in a lot of 'using Teuchos::RCP' declarations in many
different Trilinos namespaces so that we can avoid having to always
include the explicit namespace qualification 'Teuchos::'.  This will
make Trilinos code and user code that works with the smart pointer class
much less cluttered.

I have gripped all of the *.h, *.hop, *.H, *.cop, and *.C files in
Trilinos for '[^a-zA-Z_]RCP[^a-zA-Z0-9_]' to see if any package had used
RCP for some other purpose.  All of the 67 hits involve only the use of
'RCP' in documentation (mostly by me).  I do not have access to all user
code that uses Trilinos of course so I can't grep that code.  If any
user has code that uses 'RCP' and is not careful with namespaces, please
let me know right away.

The plan will be to provide a perl script that will use token
replacements to replace 'Teuchos::RefCountPtr' with 'Teuchos::RCP'.
Another perl script that is safe to use in Tirlinos will do a token
replacement of 'RefCountPtr' to 'RCP'.  Of course, the first script will
also change the include file name(s) from 'Teuchos_RefCountPtr*.hpp" to
'Teuchos_RCP*.hpp'.  I will take care of running these scripts on all of
Trilinos and make sure that all packages using the Teuchos::RefCountPtr
class are tested before checking in.

However, any user code that deals with Teuchos::RefCountPtr will have to
be updated at some point.  Running the above perl script on user's
source code should fix (nearly?) all of the user's code that currently
directly deals with Teuchos::RefCountPtr.  The only problem I see is if
people have used 'RCP' for something else in a way that would conflict
with this change.  This change will only be made in the development
branch of Trilinos of course so this will not affect most true users
until Trilinos 8.0 is released later this year.  Again, such users
should only have to run the provided perl script in order to update
their codes in order to upgrade from Trilinos 7.0 to Trilinos 8.0.

A more serious problem involves those codes that want to build against
multiple versions of Trilinos.  There are several Sandia applications,
for example, that currently build against Trilinos 7.0 and the
version-of-the-day of Trilinos.  To update such codes, one can run the
above perl script to change from RefCountPtr to RCP and then to support
the older Trilinos versions, the following #define could be added:

    #define RCP RefCountPtr

along with including 'Teuchos_RefCountPtr*.hpp' instead of
'Teuchos_RCP*.hpp'.  The above #define is a little dangerous so it
should be used with care or user codes should just avoid upgrading and
wait until Trilinos 8.0 is released and then drop support for older
versions of Trilinos.

I will not make this change in the development branch of Trilinos for a
few weeks so please take that time to think about what this change will
mean for you and your code and get back to me if you can think of any
problems this might cause.

Cheers,

Ross

------------------------------------------------------------------------
-----------
Dr. Roscoe A. Bartlett
Department of Optimization and Uncertainty Estimation
Sandia National Laboratories
rabartl at sandia.gov
Phone: (505) 275-6147
Fax (505) 845-7442
------------------------------------------------------------------------
-----------


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://software.sandia.gov/mailman/private/trilinos-users/attachments/20070319/8f2709cd/attachment.html


More information about the Trilinos-Users mailing list