configuration - Implement global application settings in C++ -
i have relatively big academic simulation software (50 classes). user selects configuration file contains on 20 items. these constant variables used on simulation platform (almost in every class). simulation runs hundreds of thousands of agent objects few times per second performance important.
currently use singleton settings class. use instance values have been read file class @ program start (i did not want add reference settings class in every other classe).
1- ran profiler , found excessive calls getinstance().getsomesetting() hugging performance.
2- every time talked singleton use, received lot of condemnations.
what best practice of accessing settings in such scenario? should use global variables these 20+ configuration items?
you can keep configuration object in shared_ptr , pass anywhere want, in way have single settings object
Comments
Post a Comment