In my audio C++ project, I have a Mediator class between a base utility class…
- User
In my audio C++ project, I have a Mediator class between a base utility class ScoreReader and the class Scorer. Mediator is called in a controller class called AudioLogic. AudioLogic owns an instance of Scorer, an instance of Vocabulary and several classes that inherit from ScoreReader. After the setup configuration, I have the call to the following method of Mediator: void linkParameters(std::shared_ptr scorer) done inside AudioLogic. AudioLogic creates Scorer within the constructor and then provides it to Mediator at this stage. No other usage are done and the only user of Scorer is Mediator. For this reason I am wondering the following change: Vocabulary owns Scorer, and it is provided at constructor time. AudioLogic creates the instance as unique_ptr and then move it to Vocabulary, that takes the ownership. Cons: Consolidate and clear the ownership of Scorer. Bound the lifetime of Scorer to the one of its unique user. Pros: Couple Mediator and Scorer. The alternative is to change the method: void linkParameters(std::shared_ptr scorer) in void linkParameters(std::unique_ptr scorer), such that at the end of the usage Scorer will be released. Please provide feedback.
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.