|
ATLAS Offline Software
|
Go to the documentation of this file.
18 #ifdef XAOD_STANDALONE
24 #include <TInterpreter.h>
25 #include <boost/format.hpp>
29 #include "Gaudi/Interfaces/IOptionsSvc.h"
30 #include <GaudiKernel/ServiceHandle.h>
48 std::string makeArrayName (
const std::string&
name, std::size_t
index)
82 setType (
const std::string& val_type)
98 setName (
const std::string& val_name)
118 const auto split = val_typeAndName.find (
'/');
119 if (
split == std::string::npos)
134 const std::string&
value)
137 if (
split == std::string::npos)
143 subtool.config->setPropertyFromString (subtool.name,
value);
151 const std::string& toolType)
160 const std::string& toolType)
171 using namespace msgComponentConfig;
174 if (
split == std::string::npos)
178 return StatusCode::SUCCESS;
182 return subtool.config->addPrivateTool (subtool.name, std::move (toolConfig));
192 using namespace msgComponentConfig;
195 if (
split == std::string::npos)
198 auto myname = makeArrayName (
name, arrayData.size());
201 arrayData.push_back (myname);
206 return subtool.prefix + subtool.config
207 ->addPrivateToolInArray (subtool.name, std::move (toolConfig));
216 using namespace msgComponentConfig;
218 std::regex typeExpr (
"[A-Za-z_][A-Za-z0-9_]*(::[A-Za-z_][A-Za-z0-9_]*)*");
219 if (!std::regex_match (
m_type, typeExpr))
222 return StatusCode::FAILURE;
226 nameExpr =
std::regex (
"[A-Za-z_][A-Za-z0-9_]*(\\.[A-Za-z_][A-Za-z0-9_]*)*(@[0-9]+)?");
228 nameExpr =
std::regex (
"[A-Za-z_][A-Za-z0-9_]*(@[0-9]+)?");
229 if (!std::regex_match (
m_name, nameExpr))
232 return StatusCode::FAILURE;
234 return StatusCode::SUCCESS;
245 throw std::runtime_error (
"trying to access unknown private tool: " +
name.substr (0,
split));
246 result.config = &(subtool->second.m_config);
254 #ifdef XAOD_STANDALONE
258 const std::string&
type,
259 const std::string&
name,
260 const std::string& newCommand)
262 using namespace msgComponentConfig;
264 const auto *factory = getComponentFactory (
type);
268 component = (*factory) (
name);
269 if (component ==
nullptr)
272 return StatusCode::FAILURE;
274 return StatusCode::SUCCESS;
282 TClass* componentClass = TClass::GetClass (
type.c_str());
286 return StatusCode::FAILURE;
289 AsgComponent *
comp =
reinterpret_cast<AsgComponent*
>
290 (gInterpreter->Calc((
"dynamic_cast<asg::AsgComponent*>(" + (
boost::format (newCommand) %
type %
name).
str() +
")").c_str()));
294 ANA_MSG_ERROR (
"make sure you created a dictionary for your component");
295 return StatusCode::FAILURE;
297 component.reset (
comp);
299 return StatusCode::SUCCESS;
306 makeComponentExpert<AsgComponent> (std::unique_ptr<AsgComponent>& component,
307 const std::string& newCommand,
308 bool nestedNames, std::string
prefix)
const
310 using namespace msgComponentConfig;
317 return StatusCode::FAILURE;
321 ToolHandle<AsgTool>
th (toolInfo.first, component.get());
322 std::shared_ptr<void> mycleanup;
323 if (AsgToolConfig(toolInfo.second.m_config).makeTool (
th, mycleanup).isFailure())
325 ANA_MSG_ERROR (
"failed to create subtool \"" << toolInfo.first <<
"\" on component \"" << component->name() <<
"\"");
326 return StatusCode::FAILURE;
328 component->addCleanup (mycleanup);
329 if (toolInfo.second.m_propName.empty())
331 if (component->setProperty (toolInfo.first,
th->name()).isFailure())
333 ANA_MSG_ERROR (
"failed to set ToolHandle property \"" << toolInfo.first <<
"\" on component \"" << component->name() <<
"\"");
334 return StatusCode::FAILURE;
341 std::vector<std::string> valueArray;
342 for (
const auto&
tool : toolArray.second)
343 valueArray.emplace_back (component->name() +
"." +
tool);
344 std::string valueString;
345 ANA_CHECK (asg::detail::GetCastStringHelper<std::vector<std::string>>::
get (valueArray, valueString));
346 ANA_CHECK (component->setProperty (toolArray.first, valueString));
351 ANA_CHECK (component->setProperty (property.first, property.second));
355 return StatusCode::SUCCESS;
366 bool nestedNames)
const
368 using namespace msgComponentConfig;
378 if (
tool.second.m_propName.empty())
381 joSvc->set (toolPath,
tool.second.m_config.typeAndName());
387 std::vector<std::string> valueArray;
388 for (
const auto&
tool : toolArray.second)
395 return StatusCode::FAILURE;
397 valueArray.push_back (toolConfig->second.m_config.typeAndName());
400 std::string propertyPath =
prefix +
m_name +
"." + toolArray.first;
401 joSvc->set (propertyPath, valueString);
406 std::string propertyPath =
prefix +
m_name +
"." +
property.first;
407 joSvc->set (propertyPath, property.second);
410 return StatusCode::SUCCESS;
an object that stores the configuration for an AsgComponent and is able to create one from it
void setType(const std::string &val_type)
set the value of type
bool empty() const noexcept
whether all properties are unset
std::map< std::string, std::string > m_propertyValues
the map of property values
std::string m_name
the value of name
bool const RAWDATA *ch2 const
std::map< std::string, std::vector< std::string > > m_toolArrays
the map of (private) tool handle arrays to manage, and the tools they contain
AsgComponentConfig()=default
standard constructor
std::string m_type
the value of type
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
StatusCode checkTypeName(bool nestedNames) const
check that the type and name members have the correct format
::StatusCode StatusCode
StatusCode definition for legacy code.
std::string addPrivateToolInArray(const std::string &name, AsgComponentConfig toolConfig)
the array version of addPrivateTool
const std::string & type() const noexcept
the type of the component
std::string createPrivateToolInArray(const std::string &name, const std::string &toolType)
the array version of createPrivateTool
void setTypeAndName(const std::string &val_typeAndName)
set type and name at the same time
std::string to_string(const DetectorType &type)
StatusCode configureComponentExpert(const std::string &prefix, bool nestedNames) const
add component configuration to configuration service (expert only)
void setName(const std::string &val_name)
set the value of name
std::string typeAndName() const
get type and name at the same time
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
void setPropertyFromString(const std::string &name, const std::string &value)
set a given property from a string value
def createComponent(typeName, instanceName, componentType)
const std::string & name() const noexcept
the name of the component
StatusCode addPrivateTool(const std::string &name, AsgComponentConfig toolConfig)
add a private tool from the given configuration
AccessSubtoolData accessSubtool(const std::string &name, std::size_t split)
StatusCode createPrivateTool(const std::string &name, const std::string &toolType)
create a private tool of the given name and type
std::map< std::string, details::AsgComponentPrivateToolConfig > m_privateTools
the map of (private) tools to create