Page 1 of 1

${namespace} substitution not done in generated file

PostPosted: Tue 9 Sep 2014 16:40
by valade
I use ${namespace} in the generation settings C++[1]
It substitutes when i look at the artefact in bouml
but it's not in the generated file ?!
what'wrong ?

see below for details

===== namespace is ev

within BOUML ************************************************************
--------------------------before substitution
#include <assert.h>
#ifdef _${name}_UT_
#ifdef _CLASSE_ABSTRAITE_
class Test: public ${namespace}::${name}{
public:
Test(parametres):${name}(parametres){} // si aucun parametres effacer : parametres

//définir toutes les méthodes abstraites (i.e. =0 dans le fichier en tête) avec un corps vide
};
--------------------------after substitution

#include <assert.h>

#ifdef _NoeudReseau_UT_
#ifdef _CLASSE_ABSTRAITE_
class Test: public ev::NoeudReseau{
public:
Test(parametres):NoeudReseau(parametres){} // si aucun parametres effacer : parametres

//définir toutes les méthodes abstraites (i.e. =0 dans le fichier en tête) avec un corps vide
};
outsite BOUML generated file ************************************************************
#include <assert.h>
#ifdef _NoeudReseau_UT_
#ifdef _CLASSE_ABSTRAITE_
class Test: public ${namespace}::NoeudReseau{
public:
Test(parametres):NoeudReseau(parametres){} // si aucun parametres effacer : parametres

//définir toutes les méthodes abstraites (i.e. =0 dans le fichier en tête) avec un corps vide
};

Re: ${namespace} substitution not done in generated file

PostPosted: Tue 9 Sep 2014 17:24
by Bruno Pagès
${namespace} and ${NAMESPACE} must be used in an artifact generation only for the documentation part

The code generator manages the namespaces by itself, you don't have to add this prefix by yourself

The namespace is set at a package level, in the tab C++ when you edit it (other tabs allow to specify the Java package, the Php namespace, the Python package and IDL module)
Image

When a package specifies a namespace all the classes in the sub classviews are considered to be in this namespace

Re: ${namespace} substitution not done in generated file

PostPosted: Fri 12 Sep 2014 06:42
by valade
I know this !
but as you can read in my previous post, I've added some personal code (unit tests) into the generation settings I want to be included in all
generated source files. This code is for unit test thus no link with UML to C++ conversion.
(it Is not o easy to explain)
The fact is that in bouml ${namespace} is subsituted but not in the generated file.

Re: ${namespace} substitution not done in generated file

PostPosted: Tue 16 Sep 2014 13:05
by Bruno Pagès
Ok I will add this management

But I still think you don't use the right way, it it better to add/update your test classes as modelled classes thanks to a dedicated plug-out, to have standard code generation concerning the namespaces and to not have to do manual changes like you seem to have for "parametres". Your way is also incompatible with roundtriping

Re: ${namespace} substitution not done in generated file

PostPosted: Sun 21 Sep 2014 16:56
by Bruno Pagès
Available in release 6.6.3

Re: ${namespace} substitution not done in generated file

PostPosted: Mon 22 Sep 2014 10:07
by valade
Thanks

Re: ${namespace} substitution not done in generated file

PostPosted: Mon 29 Sep 2014 11:57
by valade
When the namespace is empty the :: is generated !
::ClassName...

Re: ${namespace} substitution not done in generated file

PostPosted: Mon 29 Sep 2014 14:08
by Bruno Pagès
of course, any text which is not a keyword ${..} or a users definition @{...} is always generated without any change, so "::" in your definition is generated

I don't proposed a new keyword also managing the "::" because "::" as a prefix is legal and indicates the next symbol is out of namespace

so what is your problem ?

Re: ${namespace} substitution not done in generated file

PostPosted: Mon 29 Sep 2014 15:05
by valade
it is not a real problem for me, but I'm teacher, I think it could be confusing for my students at this moment

Re: ${namespace} substitution not done in generated file

PostPosted: Mon 29 Sep 2014 16:18
by Bruno Pagès
ok

As I already said I think the way you use is not the right one, the right way is to create/update/delete the test classes by automatic modification of the model through a plug-out, and its implementation can be a good exercise for your students ... ;)