Skip to content
Snippets Groups Projects
Commit ee3f64d5 authored by Andrea Dell'Acqua's avatar Andrea Dell'Acqua
Browse files

Merge branch 'master-GDMLextension' into 'master'

GDMLtoGM: adding handlers for <variable... />,<constant... />, <quantity......

See merge request !68
parents 9aae075b 9879bc9a
Branches
Tags
1 merge request!68GDMLtoGM: adding handlers for <variable... />,<constant... />, <quantity......
#ifndef constantHandler_H
#define constantHandler_H
#include "GDMLInterface/GDMLHandler.h"
#include "GDMLInterface/GDMLController.h"
#include <string>
class constantHandler:public GDMLHandler {
public:
constantHandler(std::string, GDMLController*);
void ElementHandle();
};
#endif /* end of include guard: */
#ifndef variableHandler_H
#define variableHandler_H
#include "GDMLInterface/GDMLHandler.h"
#include "GDMLInterface/GDMLController.h"
#include <string>
class variableHandler:public GDMLHandler {
public:
variableHandler(std::string, GDMLController*);
void ElementHandle();
};
#endif /* end of include guard: */
......@@ -246,6 +246,8 @@ GeoVolume GDMLController::retrieveLogicalVolume(std::string name)
#include "GDMLInterface/setupHandler.h"
#include "GDMLInterface/worldHandler.h"
#include "GDMLInterface/physvolHandler.h"
#include "GDMLInterface/variableHandler.h"
#include "GDMLInterface/constantHandler.h"
void GDMLController::registerHandlers()
......@@ -282,5 +284,7 @@ void GDMLController::registerHandlers()
new physvolHandler("physvol",this);
new setupHandler("setup",this);
new worldHandler("world",this);
new variableHandler("variable",this);
new constantHandler("constant",this);
new constantHandler("quantity",this);
}
#include "GDMLInterface/constantHandler.h"
#include "GDMLInterface/GDMLHandler.h"
#include <iostream>
constantHandler::constantHandler(std::string s,GDMLController* g):GDMLHandler(s,g)
{
// std::cout<<"constructing constantHandler!"<<std::endl;
}
void constantHandler::ElementHandle()
{
std::string name=getAttributeAsString("name");
double value=getAttributeAsDouble("value");
double lunit=1.;
if (this->GetName()=="quantity")
{
bool unitTest=true;
lunit=getAttributeAsDouble("unit",unitTest);
if (!unitTest)
std::cout<<" Warning, <quantity /> tag requires an unit attribute to be defined!!!!"<<std::endl;
std::string type=getAttributeAsString("type","density");
}
ExpressionEvaluator::GetEvaluator()->RegisterConstant(name,value*lunit);
}
#include "GDMLInterface/variableHandler.h"
#include "GDMLInterface/GDMLHandler.h"
#include <iostream>
variableHandler::variableHandler(std::string s,GDMLController* g):GDMLHandler(s,g)
{
// std::cout<<"variableHandler!"<<std::endl;
}
void variableHandler::ElementHandle()
{
std::string name=getAttributeAsString("name");
//std::cout << "handling for variable: name "<< name <<'\n';
double value=getAttributeAsDouble("value");
Evaluator()->RegisterVariable(name,value);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment