60 throw error() <<
"Invalid preset: node is already present: <" + a_name +
"> of type <" + a_type +
">";
62 f_nodes.insert( nodes_t::value_type( a_name, a_type ) );
70 throw error() <<
"Invalid preset; connection is already present: <" + a_conn +
">";
95 *
this = *t_preset_it->second.f_preset_ptr.get();
118 if( ! a_preset_node.has(
"type" ) )
120 LERROR(
plog,
"Preset must have a type. Preset config:\n" << a_preset_node );
123 std::string t_preset_type = a_preset_node[
"type"]().as_string();
125 LDEBUG(
plog,
"Adding preset of type <" << t_preset_type <<
">" );
127 if( ! a_preset_node.has(
"nodes" ) )
129 LERROR(
plog,
"No \"nodes\" configuration was present for preset <" << t_preset_type <<
">" );
132 const scarab::param_array& t_nodes_array = a_preset_node[
"nodes"].as_array();
137 if( ! t_rp_pair.second )
139 LERROR(
plog,
"Unable to add new runtime preset <" << t_preset_type <<
">" );
142 runtime_presets::iterator t_new_rsp_creator = t_rp_pair.first;
145 for( scarab::param_array::const_iterator t_nodes_it = t_nodes_array.begin(); t_nodes_it != t_nodes_array.end(); ++t_nodes_it )
147 if( ! t_nodes_it->is_node() )
149 LERROR(
plog,
"Invalid node specification in preset <" << t_preset_type <<
">" );
150 scarab::factory< stream_preset, runtime_stream_preset, const std::string& >::get_instance()->remove_class( t_preset_type );
155 t_type = t_nodes_it->as_node().get_value(
"type",
"" );
158 LERROR(
plog,
"No type given for one of the nodes in preset <" << t_preset_type <<
">" );
159 scarab::factory< stream_preset, runtime_stream_preset, const std::string& >::get_instance()->remove_class( t_preset_type );
164 LDEBUG(
plog,
"Adding node <" << t_type <<
":" << t_nodes_it->as_node().get_value(
"name", t_type ) <<
"> to preset <" << t_preset_type <<
">" );
165 t_new_rsp_creator->second.f_preset_ptr->node( t_type, t_nodes_it->as_node().get_value(
"name", t_type ) );
168 if( ! a_preset_node.has(
"connections" ) )
170 LDEBUG(
plog,
"Preset <" << t_preset_type <<
"> is being setup with no connections" );
174 const scarab::param_array& t_conn_array = a_preset_node[
"connections"].as_array();
175 for( scarab::param_array::const_iterator t_conn_it = t_conn_array.begin(); t_conn_it != t_conn_array.end(); ++t_conn_it )
177 if( ! t_conn_it->is_value() )
179 LERROR(
plog,
"Invalid connection specification in preset <" << t_preset_type <<
">" );
180 scarab::factory< stream_preset, runtime_stream_preset, const std::string& >::get_instance()->remove_class( t_preset_type );
185 LDEBUG(
plog,
"Adding connection <" << t_conn_it->as_value().as_string() <<
"> to preset <" << t_preset_type <<
">");
186 t_new_rsp_creator->second.f_preset_ptr->connection( t_conn_it->as_value().as_string() );
190 LINFO(
plog,
"Preset <" << t_preset_type <<
"> is now available" );
virtual ~runtime_stream_preset()
static bool add_preset(const scarab::param_node &a_preset_node)
static runtime_presets s_runtime_presets
connections_t f_connections
static scarab::logger plog("batch_executor")
runtime_stream_preset & operator=(const runtime_stream_preset &a_rhs)
std::map< std::string, rsp_creator > runtime_presets
void connection(const std::string &a_conn)
stream_preset & operator=(const stream_preset &a_rhs)
LOGGER(plog, "egg_writer")
static std::mutex s_runtime_presets_mutex
void node(const std::string &a_type, const std::string &a_name)