forked from Open-CMSIS-Pack/devtools
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathRteInstance.h
More file actions
1643 lines (1379 loc) · 47.7 KB
/
Copy pathRteInstance.h
File metadata and controls
1643 lines (1379 loc) · 47.7 KB
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
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifndef RteInstance_H
#define RteInstance_H
/******************************************************************************/
/* RTE - CMSIS Run-Time Environment */
/******************************************************************************/
/** @file RteInstance.h
* @brief CMSIS RTE data model
*/
/******************************************************************************/
/*
* Copyright (c) 2020-2021 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
/******************************************************************************/
#include "RteItem.h"
#include "RteFile.h"
#include "RteComponent.h"
#include <stdio.h>
#include <map>
class RteModel;
class RteProject;
class RteFileInstance;
class RteTarget;
class RteProject;
/**
* @brief class to store settings per project target for an owning item: component, file, pack
*/
class RteInstanceTargetInfo : public RteItem
{
public:
/**
* @brief enumerator for option type
*/
enum RteOptType {
MEMOPT, // memory option
COPT, // C/C++ compiler option
ASMOPT, // assembler option
OPTCOUNT // number of option types for internal use in loops
};
/**
* @brief default constructor
*/
RteInstanceTargetInfo(RteItem* parent);
/**
* @brief copy constructor
* @param info pointer to RteInstanceTargetInfo to copy from
*/
RteInstanceTargetInfo(RteInstanceTargetInfo* info);
/**
* @brief constructor from attributes map
* @param attributes std::map with name-value pairs
*/
RteInstanceTargetInfo(const std::map<std::string, std::string>& attributes);
/**
* @brief check if item is excluded from target
* @return true if excluded
*/
bool IsExcluded() const { return m_bExcluded; }
/**
* @brief set item to be excluded from target
* @param excluded flag to exclude
* @return true if the setting has changed
*/
bool SetExcluded(bool excluded);
/**
* @brief check if the owning item is included in library build
* @return true if included in library build
*/
bool IsIncludeInLib() const { return m_bIncludeInLib; }
/**
* @brief set to include the owning item in library build
* @param include flag to include in library build
* @return true if the setting has changed
*/
bool SetIncludeInLib(bool include);
/**
* @brief get component instance count
* @return number of component instances
*/
int GetInstanceCount() const { return m_instanceCount; }
/**
* @brief set component instance count
* @param count component instance count to set
*/
void SetInstanceCount(int count);
/**
* @brief get version matching mode
* @return VersionCmp::MatchMode value
*/
VersionCmp::MatchMode GetVersionMatchMode() const { return m_VersionMatchMode; }
/**
* @brief set version matching mode
* @param mode VersionCmp::MatchMode value
* @return true if the setting has changed
*/
bool SetVersionMatchMode(VersionCmp::MatchMode mode);
/**
* @brief copy settings from another RteInstanceTargetInfo
* @param other reference to RteInstanceTargetInfo to copy settings from
*/
void CopySettings(const RteInstanceTargetInfo& other);
/**
* @brief get memory options
* @return memory options as a reference to RteItem
*/
const RteItem& GetMemOpt() const { return m_memOpt; }
/**
* @brief get C/C++ compiler options
* @return C/C++ compiler options as a reference to RteItem
*/
const RteItem& GetCOpt() const { return m_cOpt; }
/**
* @brief get assembler options
* @return assembler options as a reference to RteItem
*/
const RteItem& GetAsmOpt() const { return m_asmOpt; }
/**
* @brief get options of specified type (immutable)
* @param type options type as RteOptType value
* @return pointer to RteItem containing options, nullptr if no such options are supported
*/
const RteItem* GetOpt(RteOptType type) const;
/**
* @brief get options of specified type (mutable)
* @param type options type as RteOptType value
* @return pointer to RteItem containing options, nullptr if no such options are supported
*/
RteItem* GetOpt(RteOptType type);
/**
* @brief check if the instance contains specific options for compiler, assembler or memory
* @return true if has specific options
*/
bool HasOptions() const;
/**
* @brief create XMLTreeElement object to export this item to XML
* @param parentElement parent for created XMLTreeElement
* @param bCreateContent true to create XML content out of children
* @return created XMLTreeElement
*/
XMLTreeElement* CreateXmlTreeElement(XMLTreeElement* parentElement, bool bCreateContent = true) const override;
/**
* @brief called to construct the item with attributes and child elements
*/
void Construct() override;
protected:
/**
* @brief perform changes in internal data after calls to SetAttributes(), AddAttributes() and ClearAttributes()
*/
void ProcessAttributes() override;
private:
bool m_bExcluded;
bool m_bIncludeInLib;
int m_instanceCount;
VersionCmp::MatchMode m_VersionMatchMode;
RteItem m_memOpt;
RteItem m_cOpt;
RteItem m_asmOpt;
};
typedef std::map<std::string, RteInstanceTargetInfo*> RteInstanceTargetInfoMap;
/**
* @brief class describing an instantiated RteItem (component, file, used pack)
*/
class RteItemInstance : public RteItem
{
public:
/**
* @brief constructor
* @param parent pointer to RteItem parent
*/
RteItemInstance(RteItem* parent);
/**
* @brief virtual destructor
*/
~RteItemInstance() override;
/**
* @brief initializes this object from supplied RteItem
* @param item pointer to RteItem to initialize from
*/
virtual void InitInstance(RteItem* item);
/**
* @brief check if this item instance is used by specified target
* @param targetName target name
* @return true if used (not excluded)
*/
bool IsUsedByTarget(const std::string& targetName) const;
/**
* @brief check if this item is filtered by specified target
* @param targetName target name
* @return true if the instance has RteInstanceTargetInfo for specified target name
*/
bool IsFilteredByTarget(const std::string& targetName) const;
/**
* @brief get collection of all target infos
* @return map of target name to RteInstanceTargetInfo pairs
*/
const RteInstanceTargetInfoMap& GetTargetInfos() const { return m_targetInfos; }
/**
* @brief set collection of target infos
* @param infos map of target name to RteInstanceTargetInfo pairs
*/
void SetTargets(const RteInstanceTargetInfoMap& infos);
/**
* @brief remove all target infos
*/
void ClearTargets();
/**
* @brief remove unused target infos (for those with GetInstanceCount(targetName) == 0)
*/
void PurgeTargets();
/**
* @brief get number of target infos
* @return number of stored target infos
*/
int GetTargetCount() const { return (int)m_targetInfos.size(); }
/**
* @brief get instance count for specified target
* @param targetName target name
* @return instance count
*/
int GetInstanceCount(const std::string& targetName) const;
/**
* @brief get first target name in the collection.
* Method is intended for environments where only one target is supported by a project
* @return first target name in the internal collection
*/
const std::string& GetFirstTargetName() const;
/**
* @brief check if this object contains pack attributes directly rather than in a dedicated child
* @return true if this item is a pack info, default is false
*/
virtual bool IsPackageInfo() const { return false; }
/**
* @brief set to use the latest available version when resolving a component or a pack
* @param bUseLatest flag to use latest version
* @param targetName target name
* @return true if the setting has changed
*/
bool SetUseLatestVersion(bool bUseLatest, const std::string& targetName);
/**
* @brief set this item to be explicitly excluded from specified target
* @param excluded flag to exclude
* @param targetName target name
* @return true if the setting has changed
*/
bool SetExcluded(bool excluded, const std::string& targetName);
/**
* @brief check if this item is explicitly excluded from specified target
* @param targetName target name
* @return true if excluded
*/
bool IsExcluded(const std::string& targetName) const;
/**
* @brief set to include this item in library build for specified target
* @param include flag to include to library build
* @param targetName target name
* @return true if the setting has changed
*/
bool SetIncludeInLib(bool include, const std::string& targetName);
/**
* @brief check if the instance is included into library build for the specified target
* @param targetName target name
* @return true if included into library build
*/
bool IsIncludeInLib(const std::string& targetName) const;
/**
* @brief copy target info settings from another target
* @param other reference to RteInstanceTargetInfo to copy from
* @param targetName destination target name
*/
void CopyTargetSettings(const RteInstanceTargetInfo& other, const std::string& targetName);
/**
* @brief check if the item is excluded from all targets
* @return true if all targets have excluded flag
*/
virtual bool IsExcludedForAllTargets();
/**
* @brief check if item is removed, e.g. a config file
* @return true if removed
*/
virtual bool IsRemoved() const { return m_bRemoved; }
/**
* @brief set/reset removed state
* @param removed flag to set/reset removed state
*/
virtual void SetRemoved(bool removed) { m_bRemoved = removed; }
/**
* @brief get version matching mode for specified target
* @param targetName target name
* @return VersionCmp::MatchMode value
*/
VersionCmp::MatchMode GetVersionMatchMode(const std::string& targetName) const;
/**
* @brief create or reuse existing target info for specified target
* @param targetName target name
* @return pointer to RteInstanceTargetInfo, never nullptr
*/
virtual RteInstanceTargetInfo* AddTargetInfo(const std::string& targetName);
/**
* @brief create or reuse existing target info for specified target, copy settings from another target info
* @param targetName target name
* @param copyFrom target name to copy from
* @return pointer to RteInstanceTargetInfo, never nullptr
*/
virtual RteInstanceTargetInfo* AddTargetInfo(const std::string& targetName, const std::string& copyFrom);
/**
* @brief create or reuse existing target info for specified target, initialize it from supplied attributes
* @param targetName target name
* @param attributes map with name-value pairs to initialize the target info
* @return pointer to RteInstanceTargetInfo, never nullptr
*/
virtual RteInstanceTargetInfo* AddTargetInfo(const std::string& targetName, const std::map<std::string, std::string>& attributes);
/**
* @brief remove target info for specified target and delete it if requested
* @param targetName target name
* @param bDelete flag to request deletion
* @return true if the info has been removed
*/
virtual bool RemoveTargetInfo(const std::string& targetName, bool bDelete = true);
/**
* @brief rename target info for specified target (to reflect target rename)
* @param targetName target name
* @param newName new target name
* @return true if the info has been renamed
*/
virtual bool RenameTargetInfo(const std::string& oldName, const std::string& newName);
/**
* @brief return target info for specified target
* @param targetName target name
* @return pointer to RteInstanceTargetInfo, nullptr if does not exist
*/
virtual RteInstanceTargetInfo* GetTargetInfo(const std::string& targetName) const;
/**
* @brief return target info for specified target, create new one if does not exist
* @param targetName target name
* @return pointer to RteInstanceTargetInfo, never nullptr
*/
virtual RteInstanceTargetInfo* EnsureTargetInfo(const std::string& targetName);
public:
/**
* @brief clear internal data
*/
void Clear() override;
/**
* @brief called to construct the item with attributes and child elements
*/
void Construct() override;
/**
* @brief append a new child at the end of the list
* @param child pointer to a new child of template type RteItem
* @return pointer to the new child
*/
RteItem* AddChild(RteItem* child) override;
/**
* @brief create a new instance of type RteItem
* @param tag name of tag
* @return pointer to instance of type RteItem
*/
RteItem* CreateItem(const std::string& tag) override;
/**
* @brief get pack attributes
* @return pack attributes as RteItem reference
*/
virtual const RteItem& GetPackageAttributes() const { return m_packageAttributes; }
/**
* @brief set pack attributes
* @param attr attributes to set as XmlItem reference
* @return true if changed
*/
virtual bool SetPackageAttributes(const XmlItem& attr) { return m_packageAttributes.SetAttributes(attr); }
/**
* @brief get pointer to resolved RtePackage
* @return pointer to RtePackage if resolved, nullptr otherwise
*/
RtePackage* GetPackage() const override;
/**
* @brief get pointer to RteComponent
* @return pointer to RteComponent, nullptr by default
*/
RteComponent* GetComponent() const override { return GetComponent(EMPTY_STRING);}
/**
* @brief get resolved component, even if this item is not filtered by specified target
* @param targetName target name
* @return pointer to resolved RteComponent, nullptr if not resolved
*/
virtual RteComponent* GetComponent(const std::string& targetName) const;
/**
* @brief get resolved component, only if this item is filtered by specified target
* @param targetName target name
* @return pointer to resolved RteComponent, nullptr if not resolved
*/
virtual RteComponent* GetResolvedComponent(const std::string& targetName) const;
/**
* @brief get originating pack ID
* @param withVersion flag to get full (true) or common (false) pack ID
* @return full or common pack ID constructed from underlying pack info
*/
std::string GetPackageID(bool withVersion) const override;
/**
* @brief get originating pack URL
* @return "url" attribute value from underlying pack info
*/
const std::string& GetURL() const override;
/**
* @brief get pack vendor
* @return pack vendor from underlying pack info
*/
const std::string& GetVendorString() const override;
/**
* @brief get pack vendor
* @return pack vendor from underlying pack info
*/
virtual const std::string& GetPackageVendorName() const;
/**
* @brief get pointer to specified RteTarget
* @param targetName target name
* @return pointer to RteTarget if found, nullptr otherwise
*/
virtual RteTarget* GetTarget(const std::string& targetName) const;
public:
/**
* @brief get pointer to RteComponentInstance for specified target
* @param targetName target name
* @return pointer to RteComponentInstance if item is found and used in the target, nullptr otherwise
*/
virtual RteComponentInstance* GetComponentInstance(const std::string& targetName) const;
/**
* @brief get effectively used resolved pack for specified target
* @param targetName target name
* @return pointer to RtePackage if found, nullptr otherwise
*/
virtual RtePackage* GetEffectivePackage(const std::string& targetName) const;
/**
* @brief get effectively used pack ID for specified target (is available even if pack is not resolved)
* @param targetName target name
* @return pack ID string
*/
virtual std::string GetEffectivePackageID(const std::string& targetName) const;
protected:
/**
* @brief check if this item provides content to be stored in XML format
* @return true
*/
bool HasXmlContent() const override { return true; }
/**
* @brief creates child element for supplied XMLTreeElement
* @param parentElement XMLTreeElement to generate content for
*/
void CreateXmlTreeElementContent(XMLTreeElement* parentElement) const override;
protected:
RteItem m_packageAttributes;
RteInstanceTargetInfoMap m_targetInfos;
bool m_bRemoved;
};
/**
* @brief info about pack used in the project
*/
class RtePackageInstanceInfo : public RteItemInstance
{
public:
/**
* @brief constructor
* @param parent pointer to RteItem parent
*/
RtePackageInstanceInfo(RteItem* parent) : RteItemInstance(parent) {};
/**
* @brief constructor
* @param parent pointer to RteItem parent
* @param packId full pack ID
*/
RtePackageInstanceInfo(RteItem* parent, const std::string& packId);
/**
* @brief set pack ID and set corresponding attributes
* @param packId full pack ID
*/
void SetPackId(const std::string& packId);
/**
* @brief get resolved pack for specified target
* @param targetName target name
* @return pointer to RtePackage if resolved, nullptr otherwise
*/
RtePackage* GetEffectivePackage(const std::string& targetName) const override;
/**
* @brief construct package ID out of attributes
* @return constructed pack ID
*/
std::string ConstructID() override;
/**
* @brief get pack ID
* @param withVersion flag to include pack version to the ID
* @return full or common pack ID
*/
std::string GetPackageID(bool withVersion) const override;
/**
* @brief get common (family) pack ID
* @return pack ID without version
*/
virtual const std::string& GetCommonID() const { return m_commonID; }
/**
* @brief get pack attributes
* @return reference to this
*/
const RteItem& GetPackageAttributes() const override { return *this; }
/**
* @brief set pack attributes
* @param attr pack attributes to set
* @return true if attribute values have changed
*/
bool SetPackageAttributes(const XmlItem& attr) override { return SetAttributes(attr); }
/**
* @brief check if this object contains pack attributes directly rather than in a dedicated child
* @return true
*/
bool IsPackageInfo() const override { return true; }
/**
* @brief get pack URL
* @return value of "url" attribute
*/
const std::string& GetURL() const override { return GetAttribute("url"); }
/**
* @brief get resolved pack for specified target
* @param targetName target name
* @return pointer to RtePackage if resolved, nullptr otherwise
*/
RtePackage* GetResolvedPack(const std::string& targetName) const;
/**
* @brief set resolved back for specified target
* @param pack pointer to resolved RtePackage
* @param targetName target name
*/
void SetResolvedPack(RtePackage* pack, const std::string& targetName);
/**
* @brief resolve packs for all targets
* @return true if resolved for all targets
*/
bool ResolvePack();
/**
* @brief resolve pack for specified target
* @param targetName target name
* @return true if resolved
*/
bool ResolvePack(const std::string& targetName);
/**
* @brief clear pointers to resolved packs for all targets
*/
void ClearResolved();
protected:
void ProcessAttributes() override;
protected:
std::map<std::string, RtePackage*> m_resolvedPacks;
std::string m_commonID;
};
/**
* @brief class containing information about *.gpdsc file used in project
*/
class RteGpdscInfo : public RteItemInstance
{
public:
/**
* @brief constructor
* @param parent pointer to RteItem parent
* @param gpdscPack pointer to RtePackage representing gpdsc if available
*/
RteGpdscInfo(RteItem* parent, RtePackage* gpdscPack = nullptr);
/**
* @brief virtual destructor
*/
~RteGpdscInfo() override;
/**
* @brief get absolute path to *.gpdsc
* @return absolute path to *.gpdsc file including filename
*/
std::string GetAbsolutePath() const;
/**
* @brief return associated generator if any
* @return pointer to RteGenerator
*/
RteGenerator* GetGenerator() const { return m_generator; }
/**
* @brief set associated generator if any
* @param pointer to RteGenerator
*/
void SetGenerator(RteGenerator* generator) { m_generator = generator; }
/**
* @brief get files to add to project when using the generator
* @return pointer to RteFileContainer containing file items, nullptr if no files need to be added
*/
RteFileContainer* GetProjectFiles() const;
/**
* @brief get associated generator model
* @return pointer to generator RtePackage
*/
RtePackage* GetGpdscPack() const { return m_gpdscPack; }
/**
* @brief set associated generator model
* @param gpdscPack pointer to gpdsc RtePackage
*/
void SetGpdscPack(RtePackage* gpdscPack);
/**
* @brief get pack attributes
* @return reference to this
*/
const RteItem& GetPackageAttributes() const override { return *this; }
/**
* @brief set pack attributes
* @param attr pack attributes
* @return true if changed
*/
bool SetPackageAttributes(const XmlItem& attr) override { return SetAttributes(attr); }
/**
* @brief check if this object contains pack attributes directly rather than in a dedicated child
* @return true
*/
bool IsPackageInfo() const override { return true; }
protected:
RtePackage* m_gpdscPack; // generator pack
RteGenerator* m_generator; // generator item
};
class RteBoard;
/**
* @brief info about board assigned to a target
*/
class RteBoardInfo : public RteItemInstance
{
public:
/**
* @brief constructor
* @param parent pointer to RteItem parent
*/
RteBoardInfo(RteItem* parent);
/**
* @brief virtual destructor
*/
~RteBoardInfo() override;
/**
* @brief clear internal data
*/
void Clear() override;
/**
* @brief clear pointer to resolved board
*/
void ClearResolved();
/**
* @brief get actual board description
* @return pointer to RteBoard
*/
RteBoard* GetBoard() const { return m_board; }
/**
* @brief initialize info
* @param board pointer to RteBoard
*/
void Init(RteBoard* board);
public:
/**
* @brief initialize info
* @param item pointer to RteItem to initialize from
*/
void InitInstance(RteItem* item) override;
/**
* @brief construct board ID
* @return constructed board ID by calling GetDisplayName()
*/
std::string ConstructID() override;
/**
* @brief get board display name
* @return string constructed from attribute values in the format "Bname (Bversion)"
*/
std::string GetDisplayName() const override;
/**
* @brief get board name
* @return "Bname" attribute value
*/
const std::string& GetName() const override { return GetAttribute("Bname"); }
/**
* @brief get board version from its revision
* @return board revision
*/
const std::string& GetVersionString() const override { return GetRevision(); }
/**
* @brief get board revision
* @return revision string
*/
const std::string& GetRevision() const;
/**
* @brief get board vendor string
* @return vendor string
*/
const std::string& GetVendorString() const override { return GetAttribute("Bvendor"); }
/**
* @brief resolve board for all targets
*/
void ResolveBoard();
/**
* @brief resolve board for a specified target
* @param targetName target name
* @return pointer to RteBoard
*/
RteBoard* ResolveBoard(const std::string& targetName);
/**
* @brief get cached result of resolving board
* @param targetName target name
* @return RteItem::ConditionResult value
*/
ConditionResult GetResolveResult(const std::string& targetName) const;
/**
* @brief get the original board's pack
* @return pointer to RtePackage if resolved, nullptr otherwise
*/
RtePackage* GetPackage() const override;
/**
* @brief get the original board's pack ID
* @param withVersion flag to return full (true) or common (false) pack ID
* @return full or common pack ID
*/
std::string GetPackageID(bool withVersion) const override;
protected:
RteBoard* m_board; // in contrast to other instance classes, it can only be one resolution
};
/**
* @brief info about a component or API instantiated in a project
*/
class RteComponentInstance : public RteItemInstance
{
public:
/**
* @brief constructor
* @param parent pointer to RteItem parent
*/
RteComponentInstance(RteItem* parent = 0);
/**
* @brief virtual destructor
*/
~RteComponentInstance() override;
/**
* @brief clear internal data
*/
void Clear() override;
/**
* @brief initialize info from component
* @param c pointer to RteComponent
*/
void Init(RteComponent* c);
/**
* @brief check if component version matching mode is "fixed"
* @return true if component version matching mode is "fixed"
*/
bool IsVersionMatchFixed() const;
/**
* @brief check if component version matching mode is "latest"
* @return true if component version matching mode is "latest"
*/
bool IsVersionMatchLatest() const;
/**
* @brief get collection of resolved components per target
* @return map of target name to RteComponent pointer pairs
*/
const RteComponentMap& GetResolvedComponents() const { return m_resolvedComponents; }
/**
* @brief check if this component instance equals to another one
* @param ci pointer to RteComponentInstance to compare with
* @return true if equal
*/
bool Equals(RteComponentInstance* ci) const;
/**
* @brief check if this component instance is modified
* @return true if the instance has an internal copy that is not equal to this
*/
bool IsModified() const;
/**
* @brief check if the instance has a copy
* @return true if im_copy member is not a nullptr
*/
bool HasCopy() const { return m_copy != nullptr; }
/**
* @brief get internal copy
* @return pointer to RteComponentInstance (m_copy member)
*/
RteComponentInstance* GetCopy() const { return m_copy; }
/**
* @brief get internal copy
* @return pointer to RteComponentInstance (m_copy member)
*/
RteComponentInstance* GetCopyInstance() const { return m_copy; }
/**
* @brief make a copy of this member and assign to m_copy member, delete previous if exists
* @return pointer to created RteComponentInstance (m_copy member)
*/
RteComponentInstance* MakeCopy();
/**
* @brief get API instance associated with this component instance
* @return pointer to RteComponentInstance representing API associated with this component instance
*/
RteComponentInstance* GetApiInstance() const;
public:
/**
* @brief get full component name to display
* @return string in the format Cvendor.Cbundle::Cclass:Cgroup[:Csub]:Cvariant:Cversion
*/
virtual std::string GetFullDisplayName() const;
/**
* @brief get component name to display
* @return string in the format Cvendor.Cbundle::Cclass:Cgroup[:Csub]
*/
std::string GetDisplayName() const override;
/**
* @brief get short component name to display
* @return string in the format Cgroup[:Csub]
*/
virtual std::string GetShortDisplayName() const;
/**
* @brief get component instance version string (can differ from resolved component)
* @return version string
*/
const std::string& GetVersionString() const override;
/**
* @brief construct component ID
* @return constructed ID string
*/
std::string ConstructID() override;
/**
* @brief check if this component instance has the same aggregate ID as supplied one
* @param aggregateId component aggregate ID to compare to
* @return true if equal
*/
bool HasAggregateID(const std::string& aggregateId) const;
/**
* @brief get vendor
* @return component vendor string
*/
const std::string& GetVendorString() const override;
/**
* @brief check if the component is removed and not used by any target
* @return true if removed
*/
bool IsRemoved() const override;
/**
* @brief set this component as being removed from all project targets
* @param removed flag to indicate removed state
*/
void SetRemoved(bool removed) override;
/**
* @brief get path to doc file if any (for active target)
* @return absolute path to doc file or URL, empty string if component is not resolved