coolfluid / coolfluid3

COOLFluiD is a collaborative simulation environment focused on complex multi-physics simulations
http://coolfluid.github.com
76 stars 77 forks source link

type_name() should return the type with namespace #59

Open tlmquintino opened 13 years ago

tlmquintino commented 13 years ago

example:

std::string type_name()
{
  return LibMesh::namespace() +".Field";
}

not

{
  return "Field";
}

Question is, can we do this more automatically?

tbanyai commented 13 years ago

why? derived_type_name returns this info

tlmquintino commented 13 years ago

This will uniquely identify builders of components with same class name.

Example:

And it makes sense from the type mechanism point of view: if you want to ask a certain class what type it is, this will return the full qualified type.

Moreover (Willem points out) that this will allow to use regex to parse the namespace (and thus the library) from within the typename.

wdeconinck commented 13 years ago

I just found another bug because this is missing:

We have a components common::Action solver::Action

Making a factory for both is now impossible, as the factories only look at the typename "Action". A static knowledge of the full typename is necessary.

Tiago had made a private sandbox with "A" solution, but I still think it is best just to type the full namespace names in the returned type_name() function

tlmquintino commented 13 years ago

Yep. I agree. The sandbox solution is very complex. Putting the namespace there will be simpler.

But be sure to do it:

std::string type_name() { return LibMesh::namespace() +".Field"; }

tlmquintino commented 13 years ago

derived_type_name returns this info, true. but it has 2 flaws:

derived_type_name is useful to ensure that an existing (dynamic) component has a unique classname under different operating systems. Eventually, the CBuilder should register the name just using the type_name() directly, without needing to add the library namespace.