Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
evilMain.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 
10 
11 // The client just includes the basic *.hpp forms without having the worry
12 // about implicit or explicit instantiation!
13 #include "EvilBase.hpp"
14 #include "AEvil.hpp"
15 #include "BEvil.hpp"
16 
17 
18 template<class T>
19 void testEvil(const T& obj)
20 {
21 
22  using Teuchos::RCP;
23  using Teuchos::rcp_dynamic_cast;
24  using EvilPack::EvilBase;
25  using EvilPack::AEvil;
26  using EvilPack::BEvil;
27 
28  RCP<AEvil<T> > aEvil =
29  rcp_dynamic_cast<AEvil<T> >(EvilBase<T>::createEvil("AEvil"));
30  RCP<BEvil<T> > bEvil =
31  rcp_dynamic_cast<BEvil<T> >(EvilBase<T>::createEvil("BEvil"));
32 
33  aEvil->soundOff(obj);
34  bEvil->soundOff(obj);
35  aEvil->callBEvil(*bEvil, obj);
36  bEvil->callAEvil(*aEvil, obj);
37 
38 }
39 
40 
41 int main()
42 {
43  testEvil<double>(1.0);
44  testEvil<int>(2);
45  return 0;
46 }
RCP< T2 > rcp_dynamic_cast(const RCP< T1 > &p1, bool throw_on_fail=false)
Dynamic cast of underlying RCP type from T1* to T2*.
A subclass of EvilBase that calls BEvil.
Definition: AEvil_decl.hpp:28
void testEvil(const T &obj)
Definition: evilMain.cpp:19
RCP< AEvil< T > > aEvil()
Nonmember constructor.
Definition: AEvil_decl.hpp:43
int main(int argc, char *argv[])
Smart reference counting pointer class for automatic garbage collection.
Evil base class that people often write with a factory function to all of the subclasses in the inter...
RCP< BEvil< T > > bEvil()
Nonmember constructor.
Definition: BEvil_decl.hpp:43
A subclass of EvilBase that calls AEvil.
Definition: AEvil_decl.hpp:22