Beispiel #1
0
void rels_files::add(std::wstring const & Id,
                     std::wstring const & Type,
                     std::wstring const & Target,
                     std::wstring const & TargetMode)
{
    return add(relationship(Id, Type, Target, TargetMode));
}
    void generate_attribute_relationships() {

        for(const std::shared_ptr<srcuml_class> & aclass : classes) {

            /** @todo may want set so same type not added twice */

            for(const srcuml_attribute & attribute : aclass->get_attributes()) {

                std::map<std::string, std::shared_ptr<srcuml_class>>::iterator parent = class_map.find(attribute.get_type().get_type_name());
                if(parent == class_map.end()) continue;

                relationship_type type = ASSOCIATION;
                if(attribute.get_type().get_is_composite())
                    type = COMPOSITION;
                else if(attribute.get_type().get_is_aggregate())
                    type = AGGREGATION;

                std::string relationship_label = attribute.get_name() + attribute.get_multiplicity();
                srcuml_relationship relationship(aclass->get_srcuml_name(), "", parent->second->get_srcuml_name(), relationship_label, type);
                add_relationship(relationship);

            }

        }

    }
    void resolve_inheritence() {

        for(std::pair<const std::string, std::shared_ptr<srcuml_class>> & map_pair : class_map) {
            resolve_inheritence_inner(map_pair.second);
        }

        for(const std::shared_ptr<srcuml_class> & aclass : classes) {

            for(const ClassPolicy::ParentData & parent_data : aclass->get_data().parents) {

                std::map<std::string, std::shared_ptr<srcuml_class>>::iterator parent = class_map.find(parent_data.name);

                /** @todo should I show these? */
                if(parent == class_map.end()) continue;

                relationship_type type = GENERALIZATION;
                if(!aclass->get_is_abstract() && parent->second->get_is_abstract()) {
                    type = REALIZATION;
                }

                srcuml_relationship relationship(parent->second->get_srcuml_name(), aclass->get_srcuml_name(), type);
                add_relationship(relationship);

            }

        }
 
    }
Beispiel #4
0
void combat(DATA* player1, int atk1, int def1, DATA* player2, int atk2, int def2) {
	int i;
	int check_r;
	srand(time(NULL));
	if((i = rand() % 2 + 1) == 1) {
		check_r = relationship(atk1, def2);
		player2->hp = player2->hp - hploss(player1->damage, player2->armor, check_r);
		if(player2->hp > 0) {
			check_r = relationship(atk2, def1);
			player1->hp = player1->hp - hploss(player2->damage, player1->armor, check_r);
		}
	} else {
		check_r = relationship(atk2, def1);
		player1->hp = player1->hp - hploss(player2->damage, player1->armor, check_r);
		if(player1->hp > 0) {
			check_r = relationship(atk1, def2);
			player2->hp = player2->hp - hploss(player1->damage, player2->armor, check_r);
		}
	}
}
Beispiel #5
0
int main(int argc, char** argv)
{
	std::cout << "Enter an actor file to load" << std::endl;
	std::cout << ">";
	std::string file;
	std::getline(std::cin, file);
	
	std::cout << "Loading file..." << std::endl;
	IMDBData data(file);

	std::cout << "Creating graph..." << std::endl;
	data.createGraph();

	while (true)
	{
		std::cout << "Main Menu" << std::endl;
		std::cout << "1. Get movies from actor" << std::endl;
		std::cout << "2. Get actors from movies" << std::endl;
		std::cout << "3. Find relationship between actors" << std::endl;
		std::cout << "4. Quit" << std::endl;
		std::cout << ">";
		
		std::string option;
		std::getline(std::cin, option);
		if (option == "1")
		{
			moviesFromActor(data);
		}
		else if (option == "2")
		{
			actorsFromMovie(data);
		}
		else if (option == "3")
		{
			relationship(data);
		}
		else if (option == "4")
		{
			std::cout << "Goodbye!" << std::endl;
			break;
		}
		else
		{
			std::cout << "Invalid option, please try again." << std::endl;
		}
	}
	return 0;
}
Beispiel #6
0
libvisio::VSDXRelationships::VSDXRelationships(librevenge::RVNGInputStream *input)
  : m_relsByType(), m_relsById()
{
  if (input)
  {
    const std::shared_ptr<xmlTextReader> reader(
      xmlReaderForStream(input, nullptr, nullptr, XML_PARSE_NOBLANKS|XML_PARSE_NOENT|XML_PARSE_NONET|XML_PARSE_RECOVER),
      xmlFreeTextReader);
    if (reader)
    {
      bool inRelationships = false;
      int ret = xmlTextReaderRead(reader.get());
      while (ret == 1)
      {
        const xmlChar *name = xmlTextReaderConstName(reader.get());
        if (name)
        {
          if (xmlStrEqual(name, BAD_CAST("Relationships")))
          {
            if (xmlTextReaderNodeType(reader.get()) == 1)
            {
              // VSD_DEBUG_MSG(("Relationships ON\n"));
              inRelationships = true;
            }
            else if (xmlTextReaderNodeType(reader.get()) == 15)
            {
              // VSD_DEBUG_MSG(("Relationships OFF\n"));
              inRelationships = false;
            }
          }
          else if (xmlStrEqual(name, BAD_CAST("Relationship")))
          {
            if (inRelationships)
            {
              VSDXRelationship relationship(reader.get());
              m_relsByType[relationship.getType()] = relationship;
              m_relsById[relationship.getId()] = relationship;
            }
          }
        }
        ret = xmlTextReaderRead(reader.get());
      }
    }
  }
}
Beispiel #7
0
relationship worksheet::create_relationship(relationship::type type, const std::string &target_uri)
{
    std::string r_id = "rId" + std::to_string(d_->relationships_.size() + 1);
    d_->relationships_.push_back(relationship(type, r_id, target_uri));
    return d_->relationships_.back();
}
    void generate_dependency_relationships(){//dependency is local variables or parameters
        for(const std::shared_ptr<srcuml_class>& aclass : classes){
            //create set of already add dependecies so no repeats
            std::set<std::string> catalogued_dependencies;
            //obtain current class type
            std::string current_class_type = aclass->get_srcuml_name();
            catalogued_dependencies.insert(current_class_type);

            for(const std::pair<std::string, const FunctionPolicy::FunctionData *> func : aclass->get_implemented_functions_map()){
                //Parameter dependencies
                for(const ParamTypePolicy::ParamTypeData* aparam : func.second->parameters){
                    //iterate over parameters
                    //obtain param_type which is a nice string form of the type
                    //==================================================
                    srcuml_type* temp = new srcuml_type(aparam->type);
                    std::string param_type = temp->get_type_name();
                    //==================================================

                    std::map<std::string, std::shared_ptr<srcuml_class>>::iterator related_class = class_map.find(param_type);
                    if(related_class == class_map.end()) continue;
                    std::string working_dep = related_class->second->get_srcuml_name();
                    std::set<std::string>::iterator catalogued_class = catalogued_dependencies.find(working_dep);
                    
                    //remove last condition to re-add multi dependencies
                    if(related_class == class_map.end() || current_class_type == working_dep )// || catalogued_class != catalogued_dependencies.end())
                        continue;

                    srcuml_relationship relationship(current_class_type, working_dep, DEPENDENCY);
                    catalogued_dependencies.insert(working_dep); //add param_type is std::string 
                    add_relationship(relationship);                   
                }
                //decleration dependencies   
                for(const DeclTypePolicy::DeclTypeData* arelation : func.second->relations){
                    srcuml_type* temp = new srcuml_type(arelation->type);
                    std::string relate_type = temp->get_type_name();

                    std::map<std::string, std::shared_ptr<srcuml_class>>::iterator related_class = class_map.find(relate_type);
                    if(related_class == class_map.end()) continue;
                    std::string working_dep = related_class->second->get_srcuml_name();//get heuristic version of dependency name
                    std::set<std::string>::iterator catalogued_class = catalogued_dependencies.find(working_dep);

                    //remove last condition to re-add multi dependencies
                    if(related_class == class_map.end() || current_class_type == working_dep )// || catalogued_class != catalogued_dependencies.end())
                        continue;

                    srcuml_relationship relationship(current_class_type, working_dep, DEPENDENCY);
                    catalogued_dependencies.insert(working_dep);
                    add_relationship(relationship);
                }
                //Return type dependency
                srcuml_type* temp = new srcuml_type(func.second->returnType);
                std::string return_type = temp->get_type_name();

                std::map<std::string, std::shared_ptr<srcuml_class>>::iterator related_class = class_map.find(return_type);
                if(related_class == class_map.end()) continue;
                std::string working_dep = related_class->second->get_srcuml_name();
                std::set<std::string>::iterator catalogued_class = catalogued_dependencies.find(working_dep);

                //remove last condition to re-add multi dependencies
                if(related_class == class_map.end() || current_class_type == working_dep )// || catalogued_class != catalogued_dependencies.end())
                    continue;

                srcuml_relationship relationship(current_class_type, working_dep, DEPENDENCY);
                catalogued_dependencies.insert(working_dep);
                add_relationship(relationship);
            } 
        }
    }
Beispiel #9
0
int main(int argc, char** argv){
	if(tomahawk::utility::IsBigEndian()){
		std::cerr << tomahawk::utility::timestamp("ERROR") << "Tomahawk does not support big endian systems..." << std::endl;
		return(1);
	}

	if(argc == 1){
		tomahawk::ProgramMessage();
		tomahawk::ProgramHelpDetailed();
		return(1);
	}

	// Literal string input line
	tomahawk::LITERAL_COMMAND_LINE = tomahawk::TOMAHAWK_PROGRAM_NAME;
	for(int i = 1; i < argc; ++i)
		tomahawk::LITERAL_COMMAND_LINE += " " + std::string(&argv[i][0]);

	if(strcmp(&argv[1][0], "import") == 0){
		return(import(argc, argv));

	}

	else if(strcmp(&argv[1][0], "calc") == 0){
		return(calc(argc, argv));

	} else if(strcmp(&argv[1][0], "calc-single") == 0 || strcmp(&argv[1][0], "scalc") == 0){
		return(scalc(argc, argv));
	}

	else if(strcmp(&argv[1][0], "view") == 0){
		return(view(argc, argv));

	}

	else if(strncmp(&argv[1][0], "sort", 4) == 0){
		return(sort(argc, argv));

	}

	else if(strncmp(&argv[1][0], "concat", 6) == 0){
		return(concat(argc, argv));

	}
	else if(strncmp(&argv[1][0], "stats", 5) == 0){
		return(stats(argc, argv));

	}
	else if(strncmp(&argv[1][0], "aggregate", 8) == 0){
		return(aggregate(argc, argv));
	}
	else if(strncmp(&argv[1][0], "haplotype", 9) == 0){
		return(haplotype(argc, argv));
	}
	else if(strncmp(&argv[1][0], "relationship", 9) == 0){
		return(relationship(argc, argv));
	}
	else if(strncmp(&argv[1][0], "decay", 5) == 0){
		return(decay(argc, argv));
	}
	else if(strcmp(&argv[1][0], "--version") == 0 || strcmp(&argv[1][0], "version") == 0){
		tomahawk::ProgramMessage(false);
		return(0);

	} else if(strcmp(&argv[1][0], "--help") == 0 || strcmp(&argv[1][0], "help") == 0){
		tomahawk::ProgramMessage();
		tomahawk::ProgramHelpDetailed();
		return(0);

	} else {
		tomahawk::ProgramMessage();
		tomahawk::ProgramHelpDetailed();
		std::cerr << tomahawk::utility::timestamp("ERROR") << "Illegal command" << std::endl;
		return(1);
	}
	return(1);
}