Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
wire-cell-build
util
test
test_singleton.cxx
Go to the documentation of this file.
1
#include "
WireCellUtil/Singleton.h
"
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
14
typedef
WireCell::Singleton<Foo>
OnlyFoo
;
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
28
Foo
* foo3 = &
WireCell::Singleton<Foo>::Instance
();
29
Assert
(foo3 == foo1);
30
31
}
Foo
Foo.
Definition:
064_castoperator.cpp:20
spdlog::info
void info(const char *fmt, const Args &...args)
Definition:
spdlog.h:189
Logging.h
Foo::Foo
Foo()
Definition:
test_singleton.cxx:9
WireCell::Singleton::Instance
static T & Instance()
Definition:
Singleton.h:10
WireCell::Singleton
Definition:
Singleton.h:7
Assert
#define Assert
Definition:
Testing.h:7
Singleton.h
generate_datataset.info
info
Definition:
generate_datataset.py:142
Testing.h
Foo::chirp
virtual void chirp()
Definition:
test_singleton.cxx:11
OnlyFoo
WireCell::Singleton< Foo > OnlyFoo
Definition:
test_singleton.cxx:14
main
int main()
Definition:
test_singleton.cxx:16
Foo::~Foo
virtual ~Foo()
Definition:
test_singleton.cxx:10
Generated by
1.8.11