00001
00002
00003
00004
00006
00007 #ifndef ASGTOOLS_SETPROPERTY_H
00008 #define ASGTOOLS_SETPROPERTY_H
00009
00010 namespace asg {
00011
00015 template<typename W> static StatusCode setProperty(IAsgTool* tool, const std::string& property, W&& value) {
00016 AsgTool* asgtool = dynamic_cast<AsgTool*>(tool);
00017 if(!asgtool) return StatusCode::FAILURE;
00018 return asgtool->setProperty(property, value);
00019 }
00020 template<typename W> static StatusCode setProperty(IAsgTool& tool, const std::string& property, W&& value) {
00021 return asg::setProperty( &tool , property, value );
00022 }
00024 template<typename T,typename W> static StatusCode setProperty(std::unique_ptr<T>& tool, const std::string& property, W&& value) {
00025 return asg::setProperty( tool.get() , property, value );
00026 }
00027
00030 template<typename W> static StatusCode setProperty(IAsgTool* tool, const std::string& property, ToolHandle<W>&& value) {
00031 if(!tool) return StatusCode::FAILURE;
00032 std::string subToolName(value.name());
00033 size_t start_pos = subToolName.find(tool->name()+".");
00034 if(start_pos!=std::string::npos) { subToolName.replace( start_pos, tool->name().length()+1, "" ); }
00035 return asg::setProperty(tool, property, value.type()+"/"+subToolName);
00036 }
00037
00038
00039 }
00040
00041 #endif
00042
00043
00044