Object instantiation


The SDK Developer manual describes two ways to instantiate an object: static and dynamic.

The HOWTO manipulate Phases tutorial uses the first one:

PhaseIdeal<PhaseType::vapor> feed1;

while the HOWTO manipulate Streams uses the second one:

Stream *feed = my_cast<Stream *>(nodeFactory.create("StreamIdealLiquidVapor", Libpf::User::Defaults("test")), CURRENT_FUNCTION);

When should we use one or the other ?


Good question !

The difference is that PhaseIdeal<PhaseType::vapor> is a proper C++ class, whereas StreamIdealLiquidVapor is what we call a type alias that has been registered with the object factory with the function NodeFactory::registerAlias.

The rule is that for proper C++ classes you can use both instatiation methods, while for type aliases only dynamic instantation with the node factory is possible.