BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
newcolour.h
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2023.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef NEWCOLOUR_H
20#define NEWCOLOUR_H
21
22#include <iomanip>
23#include <iostream>
24#include <string>
25
26#include "published.h"
27
28namespace GMAD
29{
39 class NewColour: public Published<NewColour>
40 {
41 public:
42 std::string name;
43 double red;
44 double green;
45 double blue;
46 double alpha;
47
49 NewColour();
51 void clear();
53 void print() const;
55 template <typename T>
56 void set_value(std::string property, T value);
57
58 private:
60 void PublishMembers();
61 };
62
63 template <typename T>
64 void NewColour::set_value(std::string property, T value)
65 {
66#ifdef BDSDEBUG
67 std::cout << "colour> Setting value " << std::setw(25) << std::left << property << value << std::endl;
68#endif
69 // member method can throw runtime_error, catch and exit gracefully
70 try
71 {set(this,property,value);}
72 catch(const std::runtime_error&)
73 {
74 std::cerr << "Error: crystal> unknown option \"" << property << "\" with value \"" << value << "\"" << std::endl;
75 exit(1);
76 }
77 }
78}
79
80#endif
Colour definition for parser.
Definition: newcolour.h:40
void print() const
Print some properties.
Definition: newcolour.cc:47
void set_value(std::string property, T value)
Set methods by property name and value.
Definition: newcolour.h:64
NewColour()
Constructor.
Definition: newcolour.cc:23
void PublishMembers()
publish members
Definition: newcolour.cc:38
void clear()
Reset.
Definition: newcolour.cc:29
Class that provides introspection to its members.
Definition: published.h:47
void set(NewColour *instance, const std::string &name, double value)
Definition: published.h:99
Parser namespace for GMAD language. Combination of Geant4 and MAD.