Esempio n. 1
0
    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);

            }

        }

    }
Esempio n. 2
0
    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);

            }

        }
 
    }
Esempio n. 3
0
static void read_cache_file(const char *path)
{
	FILE *file = fopen(path, "r");
	char line[100];

	if (!file)
		usage("bad revtree cache file (%s)", path);

	while (fgets(line, sizeof(line), file)) {
		unsigned char sha1[20], parent[20];
		struct revision *rev;

		if (get_sha1_hex(line, sha1) || get_sha1_hex(line + 41, parent))
			usage("bad rev-tree cache file %s", path);
		rev = lookup_rev(sha1);
		rev->flags |= SEEN;
		add_relationship(rev, parent);
	}
	fclose(file);
}
Esempio n. 4
0
static int parse_commit(unsigned char *sha1)
{
	struct revision *rev = lookup_rev(sha1);

	if (!(rev->flags & SEEN)) {
		void *buffer;
		unsigned long size;
		char type[20];
		unsigned char parent[20];

		rev->flags |= SEEN;
		buffer = read_sha1_file(sha1, type, &size);
		if (!buffer || strcmp(type, "commit"))
			return -1;
		buffer += 46; /* "tree " + "hex sha1" + "\n" */
		while (!memcmp(buffer, "parent ", 7) && !get_sha1_hex(buffer+7, parent)) {
			add_relationship(rev, parent);
			parse_commit(parent);
			buffer += 48;	/* "parent " + "hex sha1" + "\n" */
		}
	}
	return 0;	
}
Esempio n. 5
0
    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);
            } 
        }
    }