aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/model/RBAModelImpl.cpp
blob: 081607c5fa754a4069a2219c12d761422924355e (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
/**
 * Copyright (c) 2019 DENSO CORPORATION.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/// @file  RBAModelmpl.cpp
/// @brief Model implementation class 

#include "RBAModelImpl.hpp"
#include "RBAConstraintImpl.hpp"

namespace rba
{

const RBAContentState*
RBAModelImpl::findContentState(const std::string& stateName)
{
  const auto elem = findModelElementImpl(stateName);
  auto contentState = dynamic_cast<const RBAContentState*>(elem);
  if (contentState == nullptr) {
    const auto content = dynamic_cast<const RBAContent*>(elem);
    if (content != nullptr) {
      contentState = content->getStates().front();
    }
  }
  return contentState;
}
  
const RBAArea*
RBAModelImpl::findArea(const std::string& areaName) const
{
  return findAreaImpl(areaName);
}
  
const RBAViewContent*
RBAModelImpl::findViewContent(const std::string& contName) const
{
  return findViewContentImpl(contName);
}
  
const RBAViewContentState*
RBAModelImpl::findViewContentState(const std::string& stateName) const
{
  return findViewContentStateImpl(stateName);
}
  
const RBASize*
RBAModelImpl::findSize(const std::string& sizeName) const
{
  return findSizeImpl(sizeName);
}
  
const RBAZone*
RBAModelImpl::findZone(const std::string& zoneName) const
{
  return findZoneImpl(zoneName);
}
  
const RBASoundContent*
RBAModelImpl::findSoundContent(const std::string& contName) const
{
  return findSoundContentImpl(contName);
}
  
const RBASoundContentState*
RBAModelImpl::findSoundContentState(const std::string& stateName) const
{
  return findSoundContentStateImpl(stateName);
}
  
const RBAScene*
RBAModelImpl::findScene(const std::string& sceneName) const
{
  return findSceneImpl(sceneName);
}

const RBADisplay*
RBAModelImpl::findDisplay(const std::string& displayName) const
{
  return findDisplayImpl(displayName);
}

const RBAModelElement*
RBAModelImpl::findModelElement(const std::string& elementName) const
{
  return findModelElementImpl(elementName);
}

const std::list<const RBAArea*>&
RBAModelImpl::getAreas() const
{
  // @Deviation (A5-2-4)
  // [Contents that deviate from the rules]
  //  reinterpret_cast shall not be used.
  // [Reason that there is no problem if the rule is deviated]
  //  There is no problem because RBAArea is the base class of RBAAreaImpl.
  //  Since the conversion process is costly, it deviates because it hides 
  //  the internal structure.
  return reinterpret_cast<const std::list<const RBAArea*>&>(getAreaImpls());
}

const std::list<const RBAViewContent*>&
RBAModelImpl::getViewContents() const
{
  // @Deviation (A5-2-4)
  // [Contents that deviate from the rules]
  //  reinterpret_cast shall not be used.
  // [Reason that there is no problem if the rule is deviated]
  //  There is no problem because RBAViewContent is the base class of 
  //  RBAViewContentImpl.
  //  Since the conversion process is costly, it deviates because it hides 
  //  the internal structure.
  return reinterpret_cast<const std::list<const RBAViewContent*>&>(getViewContentImpls());
}
  
const std::list<const RBAViewContentState*>&
RBAModelImpl::getViewContentStates() const
{
  // @Deviation (A5-2-4)
  // [Contents that deviate from the rules]
  //  reinterpret_cast shall not be used.
  // [Reason that there is no problem if the rule is deviated]
  //  There is no problem because RBAViewContentState is the base class of 
  //  RBAViewContentStateImpl.
  //  Since the conversion process is costly, it deviates because it hides 
  //  the internal structure.
  return reinterpret_cast<const std::list<const RBAViewContentState*>&>(getViewContentStateImpls());
}
  
const std::list<const RBASize*>&
RBAModelImpl::getSizes() const
{
  // @Deviation (A5-2-4)
  // [Contents that deviate from the rules]
  //  reinterpret_cast shall not be used.
  // [Reason that there is no problem if the rule is deviated]
  //  There is no problem because RBASize is the base class of RBASizeImpl.
  //  Since the conversion process is costly, it deviates because it hides 
  //  the internal structure.
  return reinterpret_cast<const std::list<const RBASize*>&>(getSizeImpls());
}

const std::list<const RBAZone*>&
RBAModelImpl::getZones() const
{
  // @Deviation (A5-2-4)
  // [Contents that deviate from the rules]
  //  reinterpret_cast shall not be used.
  // [Reason that there is no problem if the rule is deviated]
  //  There is no problem because RBAZone is the base class of RBAZoneImpl.
  //  Since the conversion process is costly, it deviates because it hides 
  //  the internal structure.
  return reinterpret_cast<const std::list<const RBAZone*>&>(getZoneImpls());
}

const std::list<const RBASoundContent*>&
RBAModelImpl::getSoundContents() const
{
  // @Deviation (A5-2-4)
  // [Contents that deviate from the rules]
  //  reinterpret_cast shall not be used.
  // [Reason that there is no problem if the rule is deviated]
  //  There is no problem because RBASoundContent is the base class of 
  //  RBASoundContentImpl.
  //  Since the conversion process is costly, it deviates because it hides 
  //  the internal structure.
  return reinterpret_cast<const std::list<const RBASoundContent*>&>(getSoundContentImpls());
}
  
const std::list<const RBASoundContentState*>&
RBAModelImpl::getSoundContentStates() const
{
  // @Deviation (A5-2-4)
  // [Contents that deviate from the rules]
  //  reinterpret_cast shall not be used.
  // [Reason that there is no problem if the rule is deviated]
  //  There is no problem because RBASoundContentState is the base class of 
  //  RBASoundContentStateImpl.
  //  Since the conversion process is costly, it deviates because it hides 
  //  the internal structure.
  return reinterpret_cast<const std::list<const RBASoundContentState*>&>(getSoundContentStateImpls());
}
  
const std::list<const RBAScene*>&
RBAModelImpl::getScenes() const
{
  // @Deviation (A5-2-4)
  // [Contents that deviate from the rules]
  //  reinterpret_cast shall not be used.
  // [Reason that there is no problem if the rule is deviated]
  //  There is no problem because RBAScene is the base class of 
  //  RBASceneImpl.
  //  Since the conversion process is costly, it deviates because it hides 
  //  the internal structure.
  return reinterpret_cast<const std::list<const RBAScene*>&>(getSceneImpls());
}

const std::list<const RBAAreaSet*>&
RBAModelImpl::getAreaSets() const
{
  return getAreaSetImpls();
}

const std::list<const RBAViewContentSet*>&
RBAModelImpl::getViewContentSets() const
{
  return getViewContentSetImpls();
}

const std::list<const RBAZoneSet*>&
RBAModelImpl::getZoneSets() const
{
  return getZoneSetImpls();
}

const std::list<const RBASoundContentSet*>&
RBAModelImpl::getSoundContentSets() const
{
  return getSoundContentSetImpls();
}

const std::list<const RBAPositionContainer*>&
RBAModelImpl::getPositionContainers() const
{
  // @Deviation (A5-2-4)
  // [Contents that deviate from the rules]
  //  reinterpret_cast shall not be used.
  // [Reason that there is no problem if the rule is deviated]
  //  There is no problem because RBAPositionContainer is the base class of 
  //  RBAPositionContainerImpl.
  //  Since the conversion process is costly, it deviates because it hides 
  //  the internal structure.
  return reinterpret_cast<const std::list<const RBAPositionContainer*>&>(getPositionContainerImpls());
}

const std::list<const RBADisplay*>&
RBAModelImpl::getDisplays() const
{
  // @Deviation (A5-2-4)
  // [Contents that deviate from the rules]
  //  reinterpret_cast shall not be used.
  // [Reason that there is no problem if the rule is deviated]
  //  There is no problem because RBADisplay is the base class of RBADisplayImpl. 
  //  Since the conversion process is costly, it deviates because it hides 
  //  the internal structure.
  return reinterpret_cast<const std::list<const RBADisplay*>&>(getDisplayImpls());
}

std::list<RBAConstraint*>&
RBAModelImpl::getConstraints()
{
  // @Deviation (A5-2-4)
  // [Contents that deviate from the rules]
  //  reinterpret_cast shall not be used.
  // [Reason that there is no problem if the rule is deviated]
  //  There is no problem because RBAConstraint is the base class of 
  //  RBAConstraintImpl. 
  //  Since the conversion process is costly, it deviates because it hides 
  //  the internal structure.
  return reinterpret_cast<std::list<RBAConstraint*>&>(getConstraintImpls());
}

void RBAModelImpl::clearElementsStatus()
{
  for (auto& o : unnamedObjects_) {
    o->clearStatus();
  }
  for (auto& o : nameToObject_) {
    o.second->clearStatus();
  }
}

const RBAAllocatable*
RBAModelImpl::findAllocatable(const std::string& allocatableName) const
{
  auto it = nameToObject_.find(allocatableName);
  if(it != nameToObject_.end()) {
    return dynamic_cast<const RBAAllocatable*>(it->second.get());
  }

  return nullptr;
}

const RBAContent*
RBAModelImpl::findContent(const std::string& contentName) const
{
  auto it = nameToObject_.find(contentName);
  if(it != nameToObject_.end()) {
    return dynamic_cast<const RBAContent*>(it->second.get());
  }

  return nullptr;
}

const RBAAreaImpl*
RBAModelImpl::findAreaImpl(const std::string& areaName) const
{
  auto it = nameToObject_.find(areaName);
  if(it != nameToObject_.end()) {
    return dynamic_cast<const RBAAreaImpl*>(it->second.get());
  }

  return nullptr;
}
  
const RBAViewContentImpl*
RBAModelImpl::findViewContentImpl(const std::string& contName) const
{
  auto it = nameToObject_.find(contName);
  if(it != nameToObject_.end()) {
    return dynamic_cast<const RBAViewContentImpl*>(it->second.get());
  }

  return nullptr;
}
  
const RBAViewContentStateImpl*
RBAModelImpl::findViewContentStateImpl(const std::string& stateName) const
{
  const RBAViewContentStateImpl* ret {nullptr};
  if(RBAViewContentState::isUniqueName(stateName)) {
    auto it = nameToObject_.find(stateName);
    if(it != nameToObject_.end()) {
      ret = dynamic_cast<const RBAViewContentStateImpl*>(it->second.get());
    }
  }
  else {
    const RBAViewContentImpl* const content {findViewContentImpl(stateName)};
    if(content != nullptr) {
      const RBAContentState* const state {content->getStates().front()};
      ret = dynamic_cast<const RBAViewContentStateImpl*>(state);
    }
  }

  return ret;
}
  
const RBASizeImpl*
RBAModelImpl::findSizeImpl(const std::string& sizeName) const
{
  auto it = nameToObject_.find(sizeName);
  if(it != nameToObject_.end()) {
    return dynamic_cast<const RBASizeImpl*>(it->second.get());
  }

  return nullptr;
}
  
const RBAZoneImpl*
RBAModelImpl::findZoneImpl(const std::string& zoneName) const
{
  auto it = nameToObject_.find(zoneName);
  if(it != nameToObject_.end()) {
    return dynamic_cast<const RBAZoneImpl*>(it->second.get());
  }

  return nullptr;
}
  
const RBASoundContentImpl*
RBAModelImpl::findSoundContentImpl(const std::string& contName) const
{
  auto it = nameToObject_.find(contName);
  if(it != nameToObject_.end()) {
    return dynamic_cast<const RBASoundContentImpl*>(it->second.get());
  }

  return nullptr;
}
  
const RBASoundContentStateImpl*
RBAModelImpl::findSoundContentStateImpl(const std::string& stateName) const
{
  const RBASoundContentStateImpl* ret {nullptr};
  if(RBASoundContentState::isUniqueName(stateName)) {
    auto it = nameToObject_.find(stateName);
    if(it != nameToObject_.end()) {
      ret = dynamic_cast<const RBASoundContentStateImpl*>(it->second.get());
    }
  }
  else {
    const RBASoundContentImpl* const content {findSoundContentImpl(stateName)};
    if(content != nullptr) {
      const RBAContentState* const state {content->getStates().front()};
      ret = dynamic_cast<const RBASoundContentStateImpl*>(state);
    }
  }

  return ret;
}
  
const RBASceneImpl*
RBAModelImpl::findSceneImpl(const std::string& sceneName) const
{
  auto it = nameToObject_.find(sceneName);
  if(it != nameToObject_.end()) {
    return dynamic_cast<const RBASceneImpl*>(it->second.get());
  }

  return nullptr;
}

const RBADisplayImpl*
RBAModelImpl::findDisplayImpl(const std::string& displayName) const
{
  auto it = nameToObject_.find(displayName);
  if(it != nameToObject_.end()) {
    return dynamic_cast<const RBADisplayImpl*>(it->second.get());
  }

  return nullptr;
}

const RBAModelElement*
RBAModelImpl::findModelElementImpl(const std::string& elementName) const
{
  auto it = nameToObject_.find(elementName);
  if(it != nameToObject_.end()) {
    return dynamic_cast<const RBAModelElement*>(it->second.get());
  }

  return nullptr;
}

const std::list<const RBAAllocatable*>&
RBAModelImpl::getAllocatables() const
{
  return allocatables_;
}

const std::list<const RBAContent*>&
RBAModelImpl::getContents() const
{
  return contents_;
}

const std::list<const RBAContentState*>&
RBAModelImpl::getContentStates() const
{
  return contentStates_;
}

const std::list<const RBAAreaImpl*>&
RBAModelImpl::getAreaImpls() const
{
  return areas_;
}

const std::list<const RBAViewContentImpl*>&
RBAModelImpl::getViewContentImpls() const
{
  return viewContents_;
}
  
const std::list<const RBAViewContentStateImpl*>&
RBAModelImpl::getViewContentStateImpls() const
{
  return viewContentStates_;
}
  
const std::list<const RBASizeImpl*>&
RBAModelImpl::getSizeImpls() const
{
  return sizes_;
}

const std::list<const RBAZoneImpl*>&
RBAModelImpl::getZoneImpls() const
{
  return zones_;
}

const std::list<const RBASoundContentImpl*>&
RBAModelImpl::getSoundContentImpls() const
{
  return soundContents_;
}
  
const std::list<const RBASoundContentStateImpl*>&
RBAModelImpl::getSoundContentStateImpls() const
{
  return soundContentStates_;
}

const std::list<const RBASceneImpl*>&
RBAModelImpl::getSceneImpls() const
{
  return scenes_;
}

const std::list<const RBAPositionContainerImpl*>&
RBAModelImpl::getPositionContainerImpls() const
{
  return positionContainers_;
}

const std::list<const RBADisplayImpl*>&
RBAModelImpl::getDisplayImpls() const
{
  return displays_;
}

void
RBAModelImpl::createSortedAllocatables()
{
  if(!(sortedAllocatables_.empty())) {
    sortedAllocatables_.clear();
  }

  for(auto& alloc : allocatables_) {
    sortedAllocatables_.push_back(const_cast<RBAAllocatable*>(alloc));
  }
  sortedAllocatables_.sort(&RBAAllocatable::compare);

  std::int32_t index{0};
  for(RBAAllocatable* const allocatable : sortedAllocatables_) {
    allocatable->setIndex(index);
    index++;
  }
}

std::list<RBAAllocatable*>&
RBAModelImpl::getSortedAllocatables()
{
  return sortedAllocatables_;
}

RBAConstraintImpl*
RBAModelImpl::findConstraintImpl(const std::string& consName) const
{
  auto it = nameToObject_.find(consName);
  if(it != nameToObject_.end()) {
    return dynamic_cast<RBAConstraintImpl*>(it->second.get());
  }

  return nullptr;
}

const RBAAreaSet*
RBAModelImpl::findAreaSetImpl(const std::string& areaSetName) const
{
  auto it = nameToObject_.find(areaSetName);
  if(it != nameToObject_.end()) {
    return dynamic_cast<const RBAAreaSet*>(it->second.get());
  }

  return nullptr;
}

const RBAZoneSet*
RBAModelImpl::findZoneSetImpl(const std::string& zoneSetName) const
{
  auto it = nameToObject_.find(zoneSetName);
  if(it != nameToObject_.end()) {
    return dynamic_cast<const RBAZoneSet*>(it->second.get());
  }

  return nullptr;
}

const RBAViewContentSet*
RBAModelImpl::findViewContentSetImpl(const std::string& contSetName) const
{
  auto it = nameToObject_.find(contSetName);
  if(it != nameToObject_.end()) {
    return dynamic_cast<const RBAViewContentSet*>(it->second.get());
  }

  return nullptr;
}

const RBASoundContentSet*
RBAModelImpl::findSoundContentSetImpl(const std::string& contSetName) const
{
  auto it = nameToObject_.find(contSetName);
  if(it != nameToObject_.end()) {
    return dynamic_cast<const RBASoundContentSet*>(it->second.get());
  }

  return nullptr;
}

const RBAPositionContainerImpl*
RBAModelImpl::findPositionContainerImpl(const std::string& areaName) const
{
  auto it = areaNameToPositionContainer_.find(areaName);
  if(it != areaNameToPositionContainer_.end()) {
    return dynamic_cast<const RBAPositionContainerImpl*>(it->second);
  }

  return nullptr;
}

/*
 * get list functions
 */

std::list<const RBAConstraintImpl*>&
RBAModelImpl::getConstraintImpls()
{
  return constraints_;
}

const std::list<const RBAAreaSet*>&
RBAModelImpl::getAreaSetImpls() const
{
  return areaSets_;
}

const std::list<const RBAZoneSet*>&
RBAModelImpl::getZoneSetImpls() const
{
  return zoneSets_;
}

const std::list<const RBAViewContentSet*>&
RBAModelImpl::getViewContentSetImpls() const
{
  return viewContentSets_;
}

const std::list<const RBASoundContentSet*>&
RBAModelImpl::getSoundContentSetImpls() const
{
  return soundContentSets_;
}

RBAModelElement*
RBAModelImpl::addModelElement(std::unique_ptr<RBAModelElement> newElement)
{
  RBAModelElement* const element {newElement.get()};
  unnamedObjects_.push_back(std::move(newElement));
  return element;
}

RBANamedElement*
RBAModelImpl::addNamedElement(std::unique_ptr<RBAModelElement> newElement)
{
  RBANamedElement* const element {dynamic_cast<RBANamedElement*>(newElement.get())};
  nameToObject_[element->getUniqueName()] = std::move(newElement);
  return element;
}

void
RBAModelImpl::addAllocatable(const RBAAllocatable* newAlloc)
{
  allocatables_.push_back(newAlloc);
  if(newAlloc->isArea()) {
    areas_.push_back(dynamic_cast<const RBAAreaImpl*>(newAlloc));
  }
  else if (newAlloc->isZone()) {
    zones_.push_back(dynamic_cast<const RBAZoneImpl*>(newAlloc));
  } else {
    ;
  }
}

void
RBAModelImpl::addContent(const RBAContent* newContent)
{
  contents_.push_back(newContent);
  if(newContent->isViewContent()) {
    viewContents_.push_back(dynamic_cast<const RBAViewContentImpl*>(newContent));
  }
  else if (newContent->isSoundContent()) {
    soundContents_.push_back(dynamic_cast<const RBASoundContentImpl*>(newContent));
  } else {
    ;
  }
}

void
RBAModelImpl::addContentState(const RBAContentState* newState)
{
  contentStates_.push_back(newState);
  if(newState->isViewContentState()) {
    viewContentStates_.push_back(dynamic_cast<const RBAViewContentStateImpl*>(newState));
  }
  else {
    soundContentStates_.push_back(dynamic_cast<const RBASoundContentStateImpl*>(newState));
  }
}

void
RBAModelImpl::addAreaSet(const RBAAreaSet* newAreaSet)
{
  areaSets_.push_back(newAreaSet);
}

void
RBAModelImpl::addZoneSet(const RBAZoneSet* newZoneSet)
{
  zoneSets_.push_back(newZoneSet);
}

void
RBAModelImpl::addConstraint(const RBAConstraintImpl* newConstraint)
{
  constraints_.push_back(newConstraint);
}

void
RBAModelImpl::addViewContentSet(const RBAViewContentSet* newContentSet)
{
  viewContentSets_.push_back(newContentSet);
}

void
RBAModelImpl::addSoundContentSet(const RBASoundContentSet* newContentSet)
{
  soundContentSets_.push_back(newContentSet);
}

void
RBAModelImpl::addScene(const RBASceneImpl* newScene)
{
  scenes_.push_back(newScene);
}

RBASizeImpl*
RBAModelImpl::addSizeInstance(const std::string& ownerName,
                              std::unique_ptr<RBAModelElement> newSize)
{
  RBASizeImpl* sizeImpl {dynamic_cast<RBASizeImpl*>(newSize.get())};
  sizes_.push_back(sizeImpl);
  nameToObject_[ownerName+std::string("/")+sizeImpl->getName()]
    = std::move(newSize);
  return sizeImpl;
}

void
RBAModelImpl::addPositionContainer(const RBAPositionContainerImpl* newPositionContainer)
{
  positionContainers_.push_back(newPositionContainer);
  areaNameToPositionContainer_[newPositionContainer->getArea()->getName()]
    = newPositionContainer;
}

void
RBAModelImpl::addDisplay(const RBADisplayImpl* newDisplay)
{
  displays_.push_back(newDisplay);
}

void
RBAModelImpl::addLabeledElement(const std::string& label,
                                RBAModelElement* element)
{
  labelToElements_[label].push_back(element);
}

void
RBAModelImpl::addLabeledConstraint(const std::string& label,
                                   RBAAbstractConstraint* constraint)
{
  labelToConstraints_[label].push_back(constraint);
}

const std::list<const RBAModelElement*>
RBAModelImpl::getLabeledElements(const std::string& label) const
{
  auto it = labelToElements_.find(label);
  if(it != labelToElements_.end()) {
    return it->second;
  }

  const std::list<const RBAModelElement*> emp;
  return emp;
}

const std::list<RBAAbstractConstraint*>
RBAModelImpl::getLabeledConstraints(const std::string& label) const
{
  auto it = labelToConstraints_.find(label);
  if(it != labelToConstraints_.end()) {
    return it->second;
  }

  const std::list<RBAAbstractConstraint*> emp;
  return emp;
}

const RBAModelElement*
RBAModelImpl::findLabeledElement(const std::string& label,
                                 const std::string& name) const
{
  const std::list<const RBAModelElement*> elems {getLabeledElements(label)};
  for(const RBAModelElement* const elem : elems) {
    if(dynamic_cast<const RBANamedElement*>(elem)->getElementName() == name) {
      return elem;
    }
  }

  return nullptr;
}

void
RBAModelImpl::addAffectedAllocsMap(const RBAModelElement* const owner, RBAAllocatable* const alloc)
{
  affectedAllocsMap_[owner].push_back(alloc);
}

const std::list<RBAAllocatable*>*
RBAModelImpl::getAffectedAllocs(const RBAModelElement* const owner)
{
  auto itr = affectedAllocsMap_.find(owner);
  if (itr != affectedAllocsMap_.end()) {
    return &itr->second;
  }
  return nullptr;
}

}