Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
PoPI_pq_suite.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 "PoPI.hpp"
11
12namespace PoPI {
13
14/*! \class PQ_suite
15 * Suite for storing the values in an physical quantity.
16 */
17
18/* *********************************************************************************************************//**
19 * @param a_node [in] The **HAPI::Node** node to be parsed.
20 ***********************************************************************************************************/
21
23 m_label( a_node.name( ) ) {
24
25 for( HAPI::Node child = a_node.first_child( ); !child.empty( ); child.to_next_sibling( ) ) {
26 std::string name( child.name( ) );
27 PhysicalQuantity *quantity;
28
29 if( name == PoPI_doubleChars ) {
30 quantity = new PQ_double( child ); }
31 else if( name == PoPI_integerChars ) {
32 quantity = new PQ_integer( child ); }
33 else if( name == PoPI_fractionChars ) {
34 quantity = new PQ_fraction( child ); }
35 else if( name == PoPI_stringChars ) {
36 quantity = new PQ_string( child ); }
37 else if( name == PoPI_shellChars ) {
38 quantity = new PQ_shell( child ); }
39 else {
40 continue;
41 }
42 push_back( quantity );
43 }
44}
45
46/* *********************************************************************************************************//**
47 ***********************************************************************************************************/
48
50
51 std::string::size_type i1, __size = size( );
52
53 for( i1 = 0; i1 < __size; ++i1 ) delete (*this)[i1];
54}
55
56/* *********************************************************************************************************//**
57 * Adds the contents of *this* to *a_XMLList* where each item in *a_XMLList* is one line (without linefeeds) to output as an XML representation of *this*.
58 *
59 * @param a_XMLList [in] The list to add an XML output representation of *this* to.
60 * @param a_indent1 [in] The amount of indentation to added to each line added to *a_XMLList*.
61 ***********************************************************************************************************/
62
63void PQ_suite::toXMLList( std::vector<std::string> &a_XMLList, std::string const &a_indent1 ) const {
64
65 std::string indent2 = a_indent1 + " ";
66
67 if( size( ) == 0 ) return;
68 std::string header = a_indent1 + "<" + m_label + ">";
69 a_XMLList.push_back( std::move( header ) );
70 for( std::vector<PhysicalQuantity *>::const_iterator iter = begin( ); iter != end( ); ++iter )
71 (*iter)->toXMLList( a_XMLList, indent2 );
72 appendXMLEnd( a_XMLList, m_label );
73}
74
75}
#define PoPI_fractionChars
Definition PoPI.hpp:81
#define PoPI_integerChars
Definition PoPI.hpp:80
#define PoPI_stringChars
Definition PoPI.hpp:82
#define PoPI_shellChars
Definition PoPI.hpp:83
bool empty() const
Definition HAPI_Node.cc:150
Node first_child() const
Definition HAPI_Node.cc:82
PQ_suite(HAPI::Node const &a_node)
void toXMLList(std::vector< std::string > &a_XMLList, std::string const &a_indent1) const
Definition PoPI.hpp:28
void appendXMLEnd(std::vector< std::string > &a_XMLList, std::string const &a_label)
Definition PoPI_misc.cc:53