Need to create UML diagrams for C ++ plugin modules
I need various UML diagrams (sequence / collaboration, class, package and system component) from some C ++ files. However, these files are plugins in the broader programming framework. I tried to create UML from Rational Rose 7 (2002 version), but I'm not very experienced and I'm not sure if RR just can't create the diagram, I am doing something wrong or the diagrams are not displaying correctly because the plugin source files instead of standalone programs. I've also tried Star Modeler with little success and there seem to be no tutorials on how to create these models.
Is there a simple, bulletproof way to get UML diagrams for C ++ files?
a source to share
Most UML tools only support a subset of C ++. Any UML tool that does not include a C preprocessor will miss a significant amount of information, and because of the complexity of C ++ it is very easy to confuse them.
The primary example of reverse engineering in UML tools is rounding technology - first create the UML model, then generate the code, then modify it slightly, but not too much, and then import the changes again.
It's also worth noting that there are many constructs in C ++ that simply don't have a direct representation in the UML. C ++ is a language with multiple paradigms; UML is the OO Modeling Language. There are many C ++ idioms that map to the same UML constructs (is a composition a auto_ptr
or a value? Is a member variable an std::vector<int>
association with a parameterized class or a type property int[0..*]
)
So the short answer is no, there is no simple, bulletproof way to get UML diagrams from C ++.
a source to share
I know this doesn't answer the question, but you can mock something about the graph point. To motivate, here's a Ruby script that generates a dot script that itself can be used to create an image that expresses the dependencies of the title:
puts "digraph {"
ARGV.each_index do |i|
File.open ARGV[i] do |f|
while line = f.gets
if line =~ /^#\s*include\s*[<"](.*)[>"]/
puts " \"#{File.basename ARGV[i]}\"->\"#{$1}\";"
end
end
end
end
puts "}"
If the script is named headers.rb and you are using Bash for your shell, you can use it like this:
ruby headers.rb *.cc |dot -Tpng >header_deps.png
This will result in a png image of the header dependencies. You can do similar things with class inheritance. You can use ctags for more complex scenarios.
Final result? You reinvented the wheel and enjoyed it.: R
a source to share
If you are a Windows user, you can try StarUML . Although, as stated here , the project appears to be dead, the program works fine on my Windows 7 machine.
I found that StarUML can create a good class diagram for classes and their inheritance relationships in a set of C ++ source codes. However, I was unable to get it to create any associations between the classes. I am still learning StarUML, so I might be doing something wrong.
Also, I don't think he can reverse engineer anything other than class diagrams, but this might be a start for you.
a source to share