node_type add_convert_node(node_type subject, value_type newtype) { value_type type = subject->get_type(); if (type == newtype) return subject; if (type != newtype && type != type_tbd) { node_type subnode = factory::create_conversion(subject); subnode->set_type(newtype); return subnode; } // Not same type, and new is tbd (so just digest the new type) subject->set_type(newtype); return subject; }
RemoteHandlerPtr InterfaceTree::m_setHandler(node_type &node, RemoteHandlerPtr const &handler) { auto ret = m_removeHandler(node); node.value().handler = handler; m_handlers.add(handler); return ret; }
virtual perf_list_type get_performance_data(object_factory context, std::string alias, node_type warn, node_type crit, node_type minimum, node_type maximum) { perf_list_type ret; native_context_type native_context = reinterpret_cast<native_context_type>(context.get()); if (native_context != NULL && native_context->has_object()) { long long warn_value = 0; long long crit_value = 0; long long current_value = get_int_value(context); if (warn) warn_value = warn->get_int_value(context); if (crit) crit_value = crit->get_int_value(context); BOOST_FOREACH(int_performance_generator &p, perfgen) { if (!p->is_configured()) p->configure(name_, context); p->eval(ret, context, alias, current_value, warn_value, crit_value, native_context->get_object()); } }
node_type get_column_fun(const value_type, evaluation_context context, const node_type subject) { std::list<node_type> l = subject->get_list_value(context); if (l.size() != 1) { context->error("Invalid number of arguments for function"); return factory::create_false(); } node_type f = l.front(); long long idx = f->get_int_value(context); logfile_filter::native_context* n_context = reinterpret_cast<logfile_filter::native_context*>(context.get()); std::string value = n_context->get_object()->get_column(idx); return factory::create_string(value); }
void HuffmanTree::generate_code_table(node_type node, code_type map, std::string code) { if(node.left == nullptr){ // leaf node map.insert({node.get_data(), code}); // add leadf to code table return; } else{ // not a leaf so has left and right child std::string left = code + "0"; std::string right = code + "1"; HuffmanTree::generate_code_table(*(node.left), map, left ); HuffmanTree::generate_code_table(*(node.right), map, right); } }
FEELPP_NO_EXPORT bool r1_ge_r2( const node_type& min1, const node_type& max1, const node_type& min2, const node_type& max2 ) { for ( size_type i=0; i < min1.size(); ++i ) { if ( !( min1[i] <= min2[i] && max1[i] >= max2[i] ) ) return false; } return true; }
FEELPP_NO_EXPORT bool r1_inter_r2( const node_type& min1, const node_type& max1, const node_type& min2, const node_type& max2 ) { for ( size_type i=0; i < min1.size(); ++i ) { if ( max1[i] < min2[i] || min1[i] > max2[i] ) return false; } return true; }
Geo0D<Dim, T>::Geo0D( size_type id, node_type const& __p, bool boundary, bool is_vertex ) : super( id, MESH_ENTITY_INTERNAL ), super2( __p ), M_master_id( id ), M_is_vertex( is_vertex ), M_is_parametric( false ), M_mesh( nullptr ), M_gdim( 0 ), M_gtag( 0 ), M_uv( 2 ) { FEELPP_ASSERT( __p.size() == Dim )( __p )( Dim ).error( "invalid node" ); this->setOnBoundary( boundary ); }
value_type infer_binary_type(object_converter factory, node_type &left, node_type &right) { value_type rt = right->infer_type(factory); value_type lt = left->infer_type(factory); if (lt == type_multi || rt == type_multi) { if (lt == rt) return type_tbd; if (lt == type_multi) lt = left->infer_type(factory, rt); else rt = right->infer_type(factory, lt); } if (lt == rt) return lt; if (type_is_float(lt) && type_is_int(rt)) rt = right->infer_type(factory, lt); if (type_is_float(rt) && type_is_int(lt)) lt = left->infer_type(factory, rt); if (lt == rt) return lt; if (rt == type_invalid || lt == type_invalid) return type_invalid; if (rt == type_tbd && lt == type_tbd) return type_tbd; if (factory->can_convert(rt, lt)) { right = add_convert_node(right, lt); return lt; } if (factory->can_convert(lt, rt)) { left = add_convert_node(left, rt); return rt; } if (can_convert(rt, lt)) { right = add_convert_node(right, lt); return lt; } if (can_convert(lt, rt)) { left = add_convert_node(left, rt); return rt; } factory->error("Cannot compare " + left->to_string() + " to " + right->to_string() + " (" + type_to_string(lt) + " to " + type_to_string(rt) + ")"); return type_invalid; }
node_type fun_convert_status(boost::shared_ptr<tasksched_filter::filter_obj> object, evaluation_context context, node_type subject) { std::string status = subject->get_string_value(context); long long istat = 0; if (object->is_new()) { if (status == "queued") istat = TASK_STATE_QUEUED; else if (status == "unknown") istat = TASK_STATE_UNKNOWN; else if (status == "ready") istat = TASK_STATE_READY; else if (status == "running") istat = TASK_STATE_RUNNING; else if (status == "disabled") istat = TASK_STATE_DISABLED; else context->error("Failed to convert: " + status); } else { if (status == "ready") istat = SCHED_S_TASK_READY; else if (status == "running") istat = SCHED_S_TASK_RUNNING; else if (status == "not_scheduled") istat = SCHED_S_TASK_NOT_SCHEDULED; else if (status == "has_not_run") istat = SCHED_S_TASK_HAS_NOT_RUN; else if (status == "disabled") istat = SCHED_S_TASK_DISABLED; else if (status == "no_more_runs") istat = SCHED_S_TASK_NO_MORE_RUNS; else if (status == "no_valid_triggers") istat = SCHED_S_TASK_NO_VALID_TRIGGERS; else context->error("Failed to convert: " + status); } return factory::create_int(istat); }
/** Sets node's name. See the s11n lib manual for what conventions to follow. In short: the "variable name" rules from most programming languages are a good guideline. */ static void name( node_type & node, const std::string & name ) { node.name( name ); }
RemoteHandlerPtr InterfaceTree::m_removeHandler(node_type &node) { auto ret = node.value().handler; node.value().handler.reset(); m_handlers.remove(ret); return ret; }
int2 get_output_location(size_t index) const { return type->get_output_location(placement, index); }
void draw(draw_buffer_2d & buffer) const { type->draw(buffer, placement); }
static void set( node_type & node, const std::string & key, const ValueT & value ) { node.set( key, value ); }
} typedef boost::graph_traits<Graph>::vertex_descriptor Vertex; std::vector<Vertex> sorted; sorted.reserve (nodes.size ()); topological_sort (G, back_inserter (sorted)); #if 0 printf ("sorted size: %ld, input set size: %ld\n", sorted.size (), nodes.size ()); assert (sorted.size () == nodes.size ()); #endif std::vector<node_type> result; foreach (Vertex const &v, sorted) { if (v < nodes.size ()) { #if 0 printf ("%ld[%s]\n", v, nodes[v].c_str ()); #endif result.push_back (nodes[v]); } } foreach (node_type const &node, nodes) assert (find (result.begin (), result.end (), node) != result.end ()); foreach (node_type const &node, result) assert (find (nodes.begin (), nodes.end (), node) != nodes.end ()); return result; }
/** Unsets (removes) the given property from node. It is not an error to unset an non-existing key. */ static void unset( node_type & node, const std::string & key ) { node.unset( key ); }
/** Swaps all publically-visible internal state of lhs with that of rhs. This includes: - class_name() - name() - children() - properties() Added in version 1.1.3. */ static void swap( node_type & lhs, node_type & rhs ) { return lhs.swap( rhs ); }
/** Returns true if this object has no properties and no children. The name() and class_name() are *not* considered. Added in version 1.1.3. */ static bool empty( const node_type & node ) { return node.empty(); }
/** Removes all children and properties from node, freeing up their resources. Whether the node's name() and class_name() are cleared is implementation-defined. In practice, those are overwritten by algos as needed, so it has not been a concern. */ static void clear( node_type & node ) { node.clear(); }
/** Returns true if node contains a property named key, else returns false. */ static bool is_set( const node_type & node, const std::string & key ) { return node.is_set( key ); }
/** Returns the class name of the type for which node holds serialized data. */ static std::string class_name( const node_type & node ) { return node.class_name(); }
/** Sets the class name of the type for which node holds serialized data. */ static void class_name( node_type & node, const std::string & classname ) { node.class_name( classname ); }
inline bool operator()(const node_type& x, const node_type& y) const { return comp(x.value(), y.value()); }
/** Returns node's name. */ static std::string name( const node_type & node ) { return node.name(); }