陈清红
2025-04-14 880f3c0257eeb8c37761d484258fdd102a369a19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Quintiq file version 2.0
#parent: #root
StaticMethod GetRunControllerDataset () const as stream[LibOpt_OptimizerRunController]
{
  Description:
  [*
    This static method returns the `LibOpt_OptimizerRunController` object.
    If the number of loaded `LibOpt_OptimizerRunController` datasets is not exactly 1, then an error is thrown. This error is handled by `LibOpt_OptimizerRunController::HandleExceptionRunController`.
  *]
  TextBody:
  [*
    // evr3 Apr-29-2022 (created)
    
    // DatasetController::FindUnique throws and error if there is more than 1 loaded `LibOpt_OptimizerRunController`. 
    // We use this reactive code block to ensure that the error can be handled by HandleExceptionRunController. 
    key := void->()
    {
      options := DatasetFindOptions::Construct().Kind( typeof( LibOpt_OptimizerRunController ).Name() );
      key := DatasetController::FindUnique( options );
      return key;
    }
    
    // If no LibOpt_OptimizerRunController dataset is loaded, then 'key' is equal to [0.0.0].
    // This results in an error when calling MDSLibOpt_OptimizerRunController::Root(). This error is also handled by HandleExceptionRunController.
    datasetstream := key -> MDSLibOpt_OptimizerRunController::Root();
    
    return datasetstream;
  *]
  InterfaceProperties { Accessibility: 'Module' }
}