For starters, I will admit that I am still a bit fuzzy on when to use Package and when to use component, as both seem to have the same properties.Join the club Thomas! However, our reading of the [size=13]UML 2.1.1 Superstructure (formal)[/size] (http://www.omg.org/cgi-bin/doc?formal/07-02-03) Specification is that packages are essentially namespaces and as consequence are containers. Elsewhere we've (not the "Royal" we - but a number of us) argued for grouping packages that don't generate namespaces (but below the namespace root). At present we use a stereotyped "node" for this purpose - since you can't place a package under a non-package (in EA).
Reading the specifications seems like the long road to enlightenment!Or madness!
If we have a physical container of some kind (such as the output of a compilation unit), we use more "physical" elements than packages as the container.
Take your pick from anything in tObject - that is, an Element. Diagrams exist in tDiagram and are not elements, packages exist in tPackage and have an equivalent tObject. Anything in tPackage can only have a tPackage as a parent. Anything in tObject (but not also in tPackage) can have another tObject as a parent (so long as it's not a (t)Package).
What type of physical container?
%if packagePath == "" or genOptCPPGenNamespace != "T" or packageStereotype == "container"%
%endTemplate%
namespace %packageName%
using namespace::classname
$RSFileHeaders = %fileHeaders%
$eolPos = %FIND($RSFileHeaders, "\n")%
$RSFileHeaders = "\n" + %LEFT($RSFileHeaders, $eolPos)% + "\n\n"
$RSFileHeaders
%if packagePath == "" or genOptCPPGenNamespace != "T" or packageStereotype == "container"%
%list="NamespaceImpl" @separator="\n\n\n" @indent=""%
%list="ClassImpl" @separator="\n\n\n" @indent=""%
%endTemplate%
namespace %packageName%
{
%list="NamespaceImpl" @separator="\n\n\n" @indent=" "%
%list="ClassImpl" @separator="\n\n\n" @indent=" "%
}
There you go, you have non-namespace packages. There is a caveat however, it only works for forward engineering, if you decide to sync code changes back the other way, then I'm pretty sure it will relocate the classes outside the 'container' package.
For this reason I think it still needs the new 'This package isnt a namespace' feature.
You're correct, it won't work for forward synchronization and the 'Package Per Namespace' option in the Directory import will move it.Then... Could we have a proper fix please?