Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
GIDI_axis.cc
Go to the documentation of this file.
1/*
2# <<BEGIN-copyright>>
3# Copyright 2019, Lawrence Livermore National Security, LLC.
4# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
5# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
6# SPDX-License-Identifier: MIT
7# <<END-copyright>>
8*/
9
10#include "GIDI.hpp"
11#include <HAPI.hpp>
12
13namespace GIDI {
14
15/*! \class Axis
16 * Class to store an axis or the base class for a Grid instance. The **type** is *"axis"* if the instance is an Axis or
17 * is *"grid"* if the instance is a Grid.
18 */
19
20/* *********************************************************************************************************//**
21 *
22 * @param a_index [in] The index for the axis.
23 * @param a_label [in] The label for the axes.
24 * @param a_unit [in] The unit for the axis.
25 * @param a_type [in] The **type** is either *"axis"* or *"grid"*.
26 ***********************************************************************************************************/
27
28Axis::Axis( int a_index, std::string const &a_label, std::string const &a_unit, FormType a_type ) :
29 Form( GIDI_axisChars, a_type, a_label ),
30 m_index( a_index ),
31 m_unit( a_unit ) {
32
33}
34
35/* *********************************************************************************************************//**
36 *
37 * @param a_node [in] The **HAPI::Node** to be parsed and used to construct the Axis.
38 * @param a_setupInfo [in] Information create my the Protare constructor to help in parsing.
39 * @param a_type [in] The **type** is either *"axis"* or *"grid"*.
40 ***********************************************************************************************************/
41
42Axis::Axis( HAPI::Node const &a_node, SetupInfo &a_setupInfo, FormType a_type ) :
43 Form( a_node, a_setupInfo, a_type ),
44 m_index( a_node.attribute_as_int( GIDI_indexChars ) ),
45 m_unit( a_node.attribute_as_string( GIDI_unitChars ) ),
46 m_href( a_node.attribute_as_string( GIDI_hrefChars ) ) {
47
48}
49
50/* *********************************************************************************************************//**
51 * Copy constructor for the Axis class.
52 *
53 * @param a_axis [in] The Axis instance to copy.
54 ***********************************************************************************************************/
55
56Axis::Axis( Axis const &a_axis ) :
57 Form( a_axis ),
58 m_index( a_axis.index( ) ),
59 m_unit( a_axis.unit( ) ),
60 m_href( a_axis.href( ) ) {
61
62}
63
64/* *********************************************************************************************************//**
65 ***********************************************************************************************************/
66
68
69}
70
71/* *********************************************************************************************************//**
72 * Fills the argument *a_writeInfo* with the XML lines that represent *this*. Recursively enters each sub-node.
73 *
74 * @param a_writeInfo [in/out] Instance containing incremental indentation and other information and stores the appended lines.
75 * @param a_indent [in] The amount to indent *this* node.
76 ***********************************************************************************************************/
77
78void Axis::toXMLList( GUPI::WriteInfo &a_writeInfo, std::string const &a_indent ) const {
79
80 std::string indent2 = a_writeInfo.incrementalIndent( a_indent );
81 std::string attributes = a_writeInfo.addAttribute( GIDI_indexChars, intToString( index( ) ) );
82
83 if( m_href == "" ) {
84 attributes += a_writeInfo.addAttribute( GIDI_labelChars, label( ) );
85 attributes += a_writeInfo.addAttribute( GIDI_unitChars, unit( ) );
86 a_writeInfo.addNodeStarterEnder( a_indent, moniker( ), attributes ); }
87 else {
88 attributes += a_writeInfo.addAttribute( GIDI_hrefChars, m_href );
89 a_writeInfo.addNodeStarterEnder( a_indent, moniker( ), attributes );
90 }
91}
92
93}
#define GIDI_hrefChars
Definition GIDI.hpp:440
#define GIDI_unitChars
Definition GIDI.hpp:439
#define GIDI_labelChars
Definition GIDI.hpp:438
#define GIDI_indexChars
Definition GIDI.hpp:437
#define GIDI_axisChars
Definition GIDI.hpp:383
std::string const & href() const
Definition GIDI.hpp:815
std::string const & unit() const
Definition GIDI.hpp:813
Axis(HAPI::Node const &a_node, SetupInfo &a_setupInfo, FormType a_type=FormType::axis)
Definition GIDI_axis.cc:42
int index() const
Definition GIDI.hpp:812
void toXMLList(GUPI::WriteInfo &a_writeInfo, std::string const &a_indent="") const
Definition GIDI_axis.cc:78
virtual ~Axis()
Definition GIDI_axis.cc:67
std::string const & label() const
Definition GIDI.hpp:658
Form(FormType a_type)
Definition GIDI_form.cc:25
std::string const & moniker() const
Definition GUPI.hpp:102
void addNodeStarterEnder(std::string const &indent, std::string const &a_moniker, std::string const &a_attributes="")
Definition GUPI.hpp:57
std::string incrementalIndent(std::string const &indent)
Definition GUPI.hpp:52
std::string addAttribute(std::string const &a_name, std::string const &a_value) const
Definition GUPI.hpp:60
Definition GIDI.hpp:32
FormType
Definition GIDI.hpp:118
std::string intToString(int a_value)
Definition GIDI_misc.cc:415