예제 #1
0
visitor injector::
create_visitor(const object& o, const std::list<name>& leaves) const {
    name_builder b;
    b.simple_name(o.name().simple() + "_" + visitor_name);
    b.location(o.name().location());

    const auto n(b.build());
    BOOST_LOG_SEV(lg, debug) << "Creating visitor: " << n.qualified();

    visitor r;
    r.name(n);
    r.generation_type(o.generation_type());
    r.origin_type(origin_types::system);
    r.documentation(visitor_doc + o.name().simple());

    if (leaves.empty()) {
        const auto& qn(n.qualified());
        BOOST_LOG_SEV(lg, error) << no_visitees << qn;
        BOOST_THROW_EXCEPTION(injection_error(no_visitees + qn));
    }

    for (const auto& l : leaves)
        r.visits().push_back(l);

    BOOST_LOG_SEV(lg, debug) << "Created visitor: " << n.qualified();
    return r;
}
void modules_transform::create_modules(const std::unordered_map<std::string,
    std::list<std::string>>& internal_modules, meta_model::model& m) {

    helpers::name_factory f;
    for (const auto& pair : internal_modules) {
        const auto& ipp(pair.second);
        const auto n(f.build_module_name(m.name(), ipp));
        const auto i(m.structural_elements().modules().find(n.qualified().dot()));
        if (i == m.structural_elements().modules().end()) {
            auto mod(boost::make_shared<meta_model::structural::module>());
            mod->name(n);
            mod->origin_type(m.origin_type());
            mod->configuration(
                boost::make_shared<variability::meta_model::configuration>());
            mod->configuration()->name().simple(n.simple());
            mod->configuration()->name().qualified(n.qualified().dot());
            m.structural_elements().modules().insert(std::make_pair(n.qualified().dot(), mod));
        }
    }
}
예제 #3
0
void injector::inject_global_module(intermediate_model& m) {
    const auto gm(create_global_module());

    const auto gmn(gm.name());
    const auto i(m.modules().find(gmn.qualified()));
    if (i != m.modules().end()) {
        const auto qn(m.name().qualified());
        BOOST_LOG_SEV(lg, error) << model_already_has_global_module << qn;
        BOOST_THROW_EXCEPTION(injection_error(
                model_already_has_global_module + qn));
    }
    m.modules().insert(std::make_pair(gmn.qualified(), gm));

    add_containing_module_to_non_contained_entities(gmn, m.modules());
    add_containing_module_to_non_contained_entities(gmn, m.concepts());
    add_containing_module_to_non_contained_entities(gmn, m.primitives());
    add_containing_module_to_non_contained_entities(gmn, m.enumerations());
    add_containing_module_to_non_contained_entities(gmn, m.objects());
    add_containing_module_to_non_contained_entities(gmn, m.exceptions());
    add_containing_module_to_non_contained_entities(gmn, m.visitors());
}
예제 #4
0
char * xstrdup_name (void)
{
  if (qualified(name_of_file + 1))
    *log_line = '\0';
  else
  {
    (void) getcwd(log_line, sizeof(log_line));
    strcat(log_line, PATH_SEP_STRING);
  }

  strcat(log_line, (char *) name_of_file + 1);
  unixify(log_line);
  return xstrdup(log_line);
}
예제 #5
0
/* patch path if 
    (i)   path not empty
    (ii)  name not qualified
    (iii) ext match
*/
int prepend_path_if(ASCII_code * buffer, ASCII_code * name, const char * ext, char *path)
{
  if (path == NULL)
    return 0;

  if (*path == '\0')
    return 0;

  if (qualified(name))
    return 0;

  if (strstr((char *) name, ext) == NULL)
    return 0;

  patch_in_path(buffer, name, (ASCII_code *)path);

  return 1;
}
예제 #6
0
int main(){

    int t; scanf("%d\n", &t);
    while(t--){
        int n, k; scanf("%d %d\n", &n, &k);
        std::vector<int> votes(n + 1, 0);
        std::vector<bool> qualified(n + 1, 1);
        for(int p = 1; p <= n; p++){
            int x; scanf("%d", &x); 
            ++votes[x];
            qualified[p] = (x != p);
        }
        int count(0);
        for(int p = 1; p <= n; p++){if(qualified[p] && votes[p] >= k){++count;}}
        printf("%d\n", count);
    }

    return 0;
}
예제 #7
0
파일: main.c 프로젝트: yizha/projecteuler
int main(int argc, char* argv) {
    int i = 0;
    int cnt = 0;
    int b[500];
    int a[500];
    for (int i = 0; i < 500; i++) {
        a[i] = 0;
        b[i] = 0;
    }
    b[0] = 1;
    a[0] = 2;
    int b_len = 1;
    int a_len = 1;

    do {
        if (qualified(b, a, b_len, a_len) > 0) cnt++;
        step(b, a, &b_len, &a_len);
        i++;
    } while (i < 1000);
    printf("count = %d\n", cnt);

    //printf("max int = %llu\n", 0xFFFFFFFFFFFFFFFF);
}