Thyra Version of the Day
A:The class Teuchos::RCP implements a form of reference counting which, through the magic of smart pointers in C++, allows objects to be created and used without much concern for when and where they should be deleted. It is a form of garbage collection but is not as general or fail- safe as in languages with built in garbage collection. For more information see:
and click on:
A: You should only use RCP to wrap objects where a persisting relationship is being formed or maintained. For non-persisting relationships, use raw C++ references and pointers.
For more information see the main body and Appendix D of the document:
In many standard C++ classes students are told that the beauty of OOP is that functions and data can be put together into classes to combine the operations with the data on which they operate. Is this not correct?
A: Generally member functions should only be used over non-member functions when direct access to private or protected data for functions is required. By minimizing the amount of code that can access non-public data you greatly simplify maintenance. See Item 44 in "C++ Coding Standards" by Sutter and Alexandrescu for a discussion of this topic.
A: The 'Scalar' class is in a template argument in all of the core Thyra interface code. The goal of this template argument is to allow many abstract numerical algorithms to be written in a general form to support a number of different scalar types (e.g. real, complex, extended precision etc.). While the interfaces, the composite classes, and many of the concrete implementations are fully templated some are not and can only support one scalar type (e.g. see the Epetra/Thyra adapters).
sillyPowerMethod() examples for how this templating is used.
A: You must use the non-member functions
Thyra::createMembers() described here and also used in the examples