Develop Biology
The language of life
Observer.h
Go to the documentation of this file.
1/*
2 * This file is a part of the Biology project by eons LLC.
3 * Biology (aka Develop Biology) is a framework for approaching software
4 * development from a natural sciences perspective.
5 *
6 * Copyright (C) 2021 Séon O'Shannon & eons LLC
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as
10 * published by the Free Software Foundation, either version 3 of the
11 * License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include "Perspective.h"
27
28namespace bio {
29namespace physical {
30
38template < typename PERSPECTIVE >
39class Observer :
40 protected VirtualBase
41{
42public:
43 typedef PERSPECTIVE Perspective;
44
48 explicit Observer(Perspective* perspective = NULL)
49 :
50 m_perspective(perspective)
51 {
52 }
53
57 Observer(const Observer& other)
58 :
59 m_perspective(other.m_perspective)
60 {
61 }
62
66 virtual ~Observer()
67 {
68 }
69
74 virtual void SetPerspective(Perspective* perspective)
75 {
76 m_perspective = perspective;
77 }
78
79 virtual
83 {
84 return m_perspective;
85 }
86
87protected:
93 {
94 BIO_SANITIZE(args.size() == 1 && args[0].Is(m_perspective), ,
95 return);
96 m_perspective = args[0];
97 }
98
99private:
100 Perspective* m_perspective;
101};
102
103} //physical namespace
104} //bio namespace
#define BIO_SANITIZE(test, success, failure)
virtual Perspective * GetPerspective() const
Definition: Observer.h:82
virtual void SetPerspective(Perspective *perspective)
Definition: Observer.h:74
Observer(Perspective *perspective=NULL)
Definition: Observer.h:48
virtual void InitializeImplementation(ByteStreams args)
Definition: Observer.h:92
PERSPECTIVE Perspective
Definition: Observer.h:43
Observer(const Observer &other)
Definition: Observer.h:57
Definition: Cell.h:31
std::vector< ByteStream > ByteStreams
Definition: Types.h:52