test_singleton.cxx
Go to the documentation of this file.
2 #include "WireCellUtil/Testing.h"
3 #include "WireCellUtil/Logging.h"
4 
5 using spdlog::info;
6 
7 class Foo {
8 public:
9  Foo() { info("Foo() at {:p}", (void*)this); }
10  virtual ~Foo() { info("~Foo() at {:p}", (void*)this); }
11  virtual void chirp() { info("Foo::chirp() at {:p}", (void*)this); }
12 };
13 
15 
16 int main()
17 {
18  info("First time:");
19  Foo* foo1 = &OnlyFoo::Instance();
20  Foo* foo2 = &OnlyFoo::Instance();
21 
22  Assert(foo1 == foo2);
23 
24  OnlyFoo::Instance().chirp();
25  info("Second time:");
26  OnlyFoo::Instance().chirp();
27 
29  Assert(foo3 == foo1);
30 
31 }
void info(const char *fmt, const Args &...args)
Definition: spdlog.h:189
static T & Instance()
Definition: Singleton.h:10
#define Assert
Definition: Testing.h:7
virtual void chirp()
WireCell::Singleton< Foo > OnlyFoo
int main()
virtual ~Foo()