Models
Loading a model
After exporting a runtime model from fluxTrainer as a .fluxmdl
file, it may be loaded into fluxEngine. fluxEngine supports loading
the model directly from disk, as well as parsing a model in memory if
the byte sequence of the model was already loaded by the user.
The following example shows how to load a model:
1 try {
2 #if defined(_WIN32)
3 /* Windows: use wide filenames to be able to cope with
4 * characters not in the current code page
5 */
6 fluxEngine::Model model(handle, fluxEngine::Model::FromFile,
7 L"sample_model.fluxmdl");
8 #else
9 fluxEngine::Model model(handle, fluxEngine::Model::FromFile,
10 "sample_model.fluxmdl");
11 #endif
12 } catch (std::exception& e) {
13 std::cerr << "An error occurred: " << e.what() << std::endl;
14 exit(1);
15 }
Extracting information from a model
It is possible obtain information about the groups that were defined in a model and obtain both their name and their color. The following snippet will print the names of all groups and their colors:
1 try {
2 auto groupInfos = model.groupInfos();
3 for (auto const& groupInfo : groupInfos) {
4 std::cout << "Group with name " << groupInfo.name << " has color rgb("
5 << int(groupInfo.colorRedComponentValue()) << ", "
6 << int(groupInfo.greenRedComponentValue()) << ", "
7 << int(groupInfo.blueRedComponentValue()) << ")\n";
8 }
9 std::cout << std::flush;
10 } catch (std::exception& e) {
11 std::cerr << "An error occurred: " << e.what() << std::endl;
12 exit(1);
13 }