void Configurator::Init() {
#ifndef NO_XML
    if(xmlFileName!="") {
        doc = xmlReadFile(xmlFileName.c_str(), NULL, 0);
        if (doc==NULL) throw configfile_exception();
        root_element = xmlDocGetRootElement(doc);
    }
#else
    printf("[Configurator]::[Init] NO_XML: action Forbid\n");
    throw config_exception();
#endif
    return;
}
/* assuming there's no sub-structure in the searched note */
string Configurable::getElementContent (xmlDocPtr doc, const char * key, const xmlNode * node)
{
#ifndef NO_XML
    char * content = "NULL" ;
    xmlNode *cur_node = NULL;
    for (cur_node = node->children; cur_node ; cur_node = cur_node->next)
    {
        if ((!xmlStrcmp (cur_node->name, (const xmlChar *) key)))
        {
            content = (char *) xmlNodeListGetString (doc, cur_node->xmlChildrenNode, 1);
            break ;
        }
    }
    return string (content) ;
#else
    printf("[Configurator]::[getElementContent] NO_XML: action Forbid\n");
    throw config_exception();
    return string("");
#endif
}
/** assuming there's only one sub-structure in the searched node,
composed by the replication of the same pattern */
vector<pair<string, string> >
Configurable::getNodeContentList (xmlDocPtr doc, const xmlNode * node)
{
    string name ;
    string content ;
    vector<pair<string, string> > output ;
#ifndef NO_XML
    xmlNode *cur_node = NULL;
    for (cur_node = node->children; cur_node ; cur_node = cur_node->next)
    {
        name    = (char *) cur_node->name ;
        content = (char *) xmlNodeListGetString (doc, cur_node->xmlChildrenNode, 1) ;
        output.push_back (pair<string, string> (name, content)) ;
    }
#else
    printf("[Configurator]::[getNodeContentList] NO_XML: action Forbid\n");
    throw config_exception();
#endif
    return output ;
}
vector<string> Configurable::getElementVector (xmlDocPtr doc, const char * key, const xmlNode * node)
{
    vector<string> R;
#ifndef NO_XML
    char * content ;
    xmlNode *cur_node = NULL;
    for (cur_node = node->children; cur_node ; cur_node = cur_node->next)
    {
        if ((!xmlStrcmp (cur_node->name, (const xmlChar *) key)))
        {
            content = (char *) xmlNodeListGetString (doc, cur_node->xmlChildrenNode, 1);
            R.push_back(content);
        }
    }
#else
    printf("[Configurator]::[getElementVector] NO_XML: action Forbid\n");
    throw config_exception();
#endif
    return R ;
}
Exemple #5
0
cls_op::cls_op (source* src, synops_param_t params)
	: qoperator(src)
{
	LOG_METHOD_TRACE;

	bool init_d = false;
	bool init_k = false;
	bool init_q = false;
	bool init_o = false;
	bool init_n = false;

	m_output_version = 0;

	for (synops_param_t::iterator it = params.begin(); it!=params.end(); it++) {
		if(       it->first == "d" || it->first == "dimension") {
			m_value_d = (int) strtol(it->second.data(), NULL, 10);
			init_d = true;
		} else if(it->first == "k" || it->first == "outputcluster") {
			m_value_k = (int) strtol(it->second.data(), NULL, 10);
			init_k = true;
		} else if(it->first == "q" || it->first == "microcluster") {
			m_value_q = (int) strtol(it->second.data(), NULL, 10);
			init_q = true;
		} else if(it->first == "o" || it->first == "outputperiode") {
			m_value_o = (int) strtol(it->second.data(), NULL, 10);
			init_o = true;
		} else if(it->first == "n" || it->first == "numberofinitpoints") {
			m_value_n = (int) strtol(it->second.data(), NULL, 10);
			init_n = true;
		} else if(it->first == "onlydifference") {
			if (it->second == "true")
				m_output_version = 1;
		} else {
			throw syntax_exception("Unknown Synopsis Parameter");
		}
	}

	if (!init_d)
		throw config_exception("No Dimension initialized");
	if (!init_k)
		throw config_exception("No Number of Output-Clusters initialized");
	if (!init_q)
		m_value_q = 10 * m_value_k;
	if (!init_o)
		throw config_exception("No Output-Period initialized");
	if (!init_n)
		m_value_n = 1000;

	if (m_value_d < 1)
		throw config_exception("Wrong Dimension: d < 1");
	if (m_value_k < 2)
		throw config_exception("Wrong Number of Output-Clusters: k < 2");
	if (m_value_q < m_value_k)
		throw config_exception("Wrong Number of MicroClusters: q < k");
	if (m_value_n < m_value_q)
		throw config_exception("Wrong Number of Init-Points: n < q");
	if (m_value_n < 1)
		throw config_exception("Wrong Output-Period: o < 1");

	m_id = 0;

	m_first_output_done = false;

	m_clustream = new clustream_operator(m_value_d, m_value_q, m_value_o, m_value_n);
}
 void operator()(Key const& key)
 {
   if (std::find(allowed.begin(),allowed.end(),key)==allowed.end())
     throw config_exception(to_string(key)+" not allowed - must be one of "+graehl::to_string_sep(allowed));
 }
 void operator()(Path const& pathname)
 {
   boost::filesystem::path path((pathname));
   if (!boost::filesystem::exists(path)) throw config_exception("file "+path.string()+" not found.");
   if (is_directory(path)) throw config_exception(path.string()+" is a directory. Need a file.");
 }
 void operator()(Path const& pathname)
 {
   boost::filesystem::path path(pathname);
   if (!is_directory(path)) throw config_exception("directory "+path.string()+" not found.");
 }
 void operator()(Path const& pathname)
 {
   boost::filesystem::path path(pathname);
   if (!boost::filesystem::exists(path)) throw config_exception(path.string()+" not found.");
 }
 void operator()(I2 const& i2)
 {
   if (i2<begin || end<i2)
     throw config_exception(desc+" value "+graehl::to_string(i2)+" - should have ["+graehl::to_string(begin)+" <= value <=  "+graehl::to_string(end)+"]");
 }
Exemple #11
0
 static inline void missing(graehl::string_consumer const& o, std::string const& name, bool warn_only) {
   std::string complaint("missing configuration key ");
   o(complaint += name);
   if (!warn_only) throw config_exception(complaint);
 }