Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
testDisablePrintActiveRcpNodesOnExit.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
14 #include "Teuchos_RCPNode.hpp"
15 
16 #include "TestClasses.hpp"
17 
18 int main(int argc, char* argv[])
19 {
20 
21  using Teuchos::RCP;
22  using Teuchos::rcp;
23 
24  Teuchos::GlobalMPISession mpiSession(&argc,&argv);
27 
28  bool printActiveRcpNodesOnExit = true;
29  bool success = true;
30 
31  try {
32 
33  // Read in commandline arguments
35  clp.setOption("print-active-rcp-nodes-on-exit", "no-print-active-rcp-nodes-on-exit",
36  &printActiveRcpNodesOnExit);
37  (void)clp.parse(argc, argv);
38 
39  // Create a circular reference that will result in dangling active
40  // RCPNodes at shutdown.
41  RCP<A> a = rcp(new A);
42  RCP<C> c = rcp(new C);
43  a->set_C(c);
44  c->set_A(a);
45 
46  } // try
47  TEUCHOS_STANDARD_CATCH_STATEMENTS(true, std::cerr, success);
48 
49  if(success) {
50  *out << "\nEnd Result: TEST PASSED" << std::endl;
51  }
52 
53  if (!printActiveRcpNodesOnExit) {
55  }
56  // ABOVE: If not set to 'fasle', we leave it at the default which should be
57  // true to make sure that the default is true!
58 
59  return ( success ? 0 : 1 );
60 }
RCP< T > rcp(const boost::shared_ptr< T > &sptr)
Conversion function that takes in a boost::shared_ptr object and spits out a Teuchos::RCP object...
Initialize, finalize, and query the global MPI session.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
Set a boolean option.
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)
Simple macro that catches and reports standard exceptions and other exceptions.
static RCP< FancyOStream > getDefaultOStream()
Get the default output stream object.
EParseCommandLineReturn parse(int argc, char *argv[], std::ostream *errout=&std::cerr) const
Parse a command line.
int main(int argc, char *argv[])
A MPI utilities class, providing methods for initializing, finalizing, and querying the global MPI se...
Basic command line parser for input from (argc,argv[])
Smart reference counting pointer class for automatic garbage collection.
Reference-counted pointer node classes.
Class that helps parse command line input arguments from (argc,argv[]) and set options.
static void setPrintActiveRcpNodesOnExit(bool printActiveRcpNodesOnExit)
Set if printActiveRCPNodes() is called on exit from the program.