-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRtePackage.h
1188 lines (1003 loc) · 37.4 KB
/
RtePackage.h
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 RtePackage_H
#define RtePackage_H
/******************************************************************************/
/* RTE - CMSIS Run-Time Environment */
/******************************************************************************/
/** @file RtePackage.h
* @brief CMSIS RTE Data Model
*/
/******************************************************************************/
/*
* Copyright (c) 2020-2021 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
/******************************************************************************/
#include "RteItem.h"
#define PDSC_MIN_SUPPORTED_VERSION "1.0"
#define PDSC_MAX_SUPPORTED_VERSION "1.x" // we should only check for major version: x > any number => only major element is compared
class RteTarget;
class RtePackage;
class RtePackageComparator;
class RteExample;
class RteGeneratorContainer;
class RteGeneratorProject;
class RteBoard;
typedef std::map<std::string, RtePackage*, RtePackageComparator > RtePackageMap;
typedef std::map<std::string, RteItem*, RtePackageComparator > RteItemPackageMap;
/**
* @brief class representing <releases> element in *.pdsc files
*/
class RteReleaseContainer : public RteItem
{
public:
/**
* @brief constructor
* @param parent pointer to RteItem parent
*/
RteReleaseContainer(RteItem* parent);
/**
* @brief called to construct the item with attributes and child elements
*/
void Construct() override;
};
class RteGenerator;
class RteDeviceFamilyContainer;
/**
* @brief class represents CMSIS-Pack and corresponds to top-level <package> element in *.pdsc file. It also serves as a base for classes supporting *.gpdsc and *.cprj files.
*/
class RtePackage : public RteRootItem
{
public:
/**
* @brief constructor
* @param parent pointer to RteItem parent (pointer to RteModel)
*/
RtePackage(RteItem* parent, PackageState ps = PackageState::PS_UNKNOWN);
/**
* @brief constructor
* @param model pointer to parent RteModel
* @param attributes package attributes to assign
*/
RtePackage(RteItem* model, const std::map<std::string, std::string>& attributes);
/**
* @brief virtual destructor
*/
~RtePackage() override;
/**
* @brief get absolute filename of pack description file (pdsc)
* @return *.pdsc filename this <package> element is read from
*/
const std::string& GetPackageFileName() const override { return GetRootFileName(); }
/**
* @brief get pack common ID, also known as 'pack family ID', does not contain version
* @return ID string in the form PackVendor.PackName
*/
const std::string& GetCommonID() const { return m_commonID; }
/**
* @brief helper static method to extract common ID from full pack ID by stripping version information
* @param id full or common ID
* @return common pack ID
*/
static std::string CommonIdFromId(const std::string& id);
/**
* @brief helper static method to construct pack display name from IDconstruct
* @param id full or common pack ID
* @return string in the format PackVendor::PackName
*/
static std::string DisplayNameFromId(const std::string& id);
/**
* @brief helper static method to extract pack version from its ID
* @param id pack ID
* @return version string
*/
static std::string VersionFromId(const std::string& id);
/**
* @brief helper static method to extract release version from pack ID
* @param id full pack ID
* @return string containing only minor.major.patch without any suffix
*/
static std::string ReleaseVersionFromId(const std::string& id);
/**
* @brief helper static method to construct pack ID for release version
* @param id full pack ID
* @return string containing PackVendor::PackName.minor.major.patch
*/
static std::string ReleaseIdFromId(const std::string& id);
/**
* @brief helper static method to extract pack vendor from ID
* @param id full or common pack ID
* @return pack vendor string
*/
static std::string VendorFromId(const std::string& id);
/**
* @brief helper static method to extract pack name from ID
* @param id full or common pack ID
* @return pack name string
*/
static std::string NameFromId(const std::string& id);
/**
* @brief helper static method to construct pack ID from supplied path
* @param path pack absolute or relative path
* @return pack ID string
*/
static std::string PackIdFromPath(const std::string& path);
/**
* @brief helper static method to compare pack IDs.
* Alpha-numeric comparison for vendor and name.
* Semantic version comparison for pack version.
* @param id1 first pack ID
* @param id2 second pack ID
* @return 0 if both IDs are equal, less than 0 if id1 < id 2, greater than 0 if id1 > id2
*/
static int ComparePackageIDs(const std::string& id1, const std::string& id2);
/**
* @brief helper static method to compare pack filenames.
* Alpha-numeric comparison for vendor and name.
* Semantic version comparison for pack version.
* @param pdsc1 first pdsc file path
* @param pdsc2 second pdsc file path
* @return 0 if both files are equal, less than 0 if pdsc1 < pdsc2, greater than 0 if pdsc1 > pdsc2
*/
static int ComparePdscFileNames(const std::string& pdsc1, const std::string& pdsc2);
/**
* @brief get pack display name
* @return display string
*/
std::string GetDisplayName() const override;
/**
* @brief get collection of keywords described in the *.pdsc file
* @return set of keyword string collected from <keywords> element
*/
const std::set<std::string>& GetKeywords() const { return m_keywords; }
/**
* @brief get parent component
* @return nullptr since a package has no parent component
*/
RteComponent* GetComponent() const override { return nullptr;}
/**
* @brief get component described in this pack
* @param uniqueID component ID to search for
* @return pointer to RteComponent if found, nullptr otherwise
*/
RteComponent* GetComponent(const std::string& uniqueID) const;
/**
* @brief get number of APIs in the pack described under <apis> element
* @return number of <api> elements as integer
*/
size_t GetApiCount() const { return m_apis ? m_apis->GetChildCount() : 0; }
/**
* @brief get number of conditions in the pack described under <conditions> element
* @return number of <condition> elements as integer
*/
size_t GetConditionCount() const { return m_conditions ? m_conditions->GetChildCount() : 0; }
/**
* @brief get number of components in the pack described under <components> element
* @return number of <component> elements as integer
*/
size_t GetComponentCount() const { return m_components ? m_components->GetChildCount() : 0; }
/**
* @brief get number of examples in the pack described under <examples> element
* @return number of <example> elements as integer
*/
size_t GetExampleCount() const { return m_examples ? m_examples->GetChildCount() : 0; }
/**
* @brief get number of boards in the pack described under <boards> element
* @return number of <board> elements as integer
*/
size_t GetBoardCount() const { return m_boards ? m_boards->GetChildCount() : 0; }
/**
* @brief get <releases> element
* @return pointer to RteItem representing container for releases
*/
RteItem* GetReleases() const { return m_releases; }
/**
* @brief get <licensSets> element
* @return pointer to RteItem representing container for license sets
*/
RteItem* GetLicenseSets() const { return m_licenseSets; }
/**
* @brief get <requirements> element
* @return pointer to RteItem representing container for requirements
*/
RteItem* GetRequirements() const { return m_requirements; }
/**
* @brief get <conditions> element
* @return pointer to RteItem representing container for conditions
*/
RteItem* GetConditions() const { return m_conditions; }
/**
* @brief get <components> element
* @return pointer to RteItem representing container for components
*/
RteItem* GetComponents() const { return m_components; }
/**
* @brief collect components matching supplied attributes
* @param item reference to RteItem containing component attributes to match
* @param components container for components
* @return pointer to first component found if any, null otherwise
*/
RteComponent* FindComponents(const RteItem& item, std::list<RteComponent*>& components) const override;
/**
* @brief get <apis> element
* @return pointer to RteItem representing container for APIs
*/
RteItem* GetApis() const { return m_apis; }
/**
* @brief getter for api by given component attributes
* @param componentAttributes given component attributes
* @return RteApi pointer
*/
RteApi* GetApi(const std::map<std::string, std::string>& componentAttributes) const;
/**
* @brief getter for api by given api ID
* @param id api ID
* @return RteApi pointer
*/
RteApi* GetApi(const std::string& id) const;
/**
* @brief get <components> element
* @return pointer to RteItem representing container for examples
*/
RteItem* GetExamples() const { return m_examples; }
/**
* @brief get <taxonomy> element
* @return pointer to RteItem representing taxonomy container
*/
RteItem* GetTaxonomy() const { return m_taxonomy; }
/**
* @brief get <boards> element
* @return pointer to RteItem representing container for boards
*/
RteItem* GetBoards() const { return m_boards; }
/**
* @brief get collection of <cimage> elements
* @return list of pointers RteItem representing cimage elements
*/
const Collection<RteItem*>& GetImageDescriptors() const { return GetGrandChildren("cimage"); }
/**
* @brief get collection of <clayer> elements
* @return list of pointers RteItem representing clayer elements
*/
const Collection<RteItem*>& GetLayerDescriptors() const { return GetGrandChildren("clayers"); }
/**
* @brief get collection of <cproject> elements
* @return list of pointers RteItem representing cproject elements
*/
const Collection<RteItem*>& GetProjectDescriptors() const { return GetGrandChildren("cprojects"); }
/**
* @brief get collection of <csolution> elements
* @return list of pointers RteItem representing csolution elements
*/
const Collection<RteItem*>& GetSolutionDescriptors() const { return GetGrandChildren("csolutions"); }
/**
* @brief get <generators> element
* @return pointer to RteGeneratorContainer representing container for generators
*/
RteGeneratorContainer* GetGenerators() const { return m_generators; }
/**
* @brief get generator item for specified ID
* @param id generator ID
* @return pointer to RteGenerator if found, nullptr otherwise
*/
RteGenerator* GetGenerator(const std::string& id) const;
/**
* @brief get first generator item in the generator container (usually a pack defines only one)
* @return pointer to RteGenerator if exists, nullptr otherwise
*/
RteGenerator* GetFirstGenerator() const;
/**
* @brief get <devices> element
* @return pointer to RteDeviceFamilyContainer representing container for device families
*/
RteDeviceFamilyContainer* GetDeviceFamiles() const { return m_deviceFamilies; }
/**
* @brief get flat list of all devices specified in the pack
* @param list of pointers RteDeviceItem representing RteDevice or RteDeviceVariant
*/
void GetEffectiveDeviceItems(std::list<RteDeviceItem*>& devices) const;
/**
* @brief get <release> element for specified version
* @param version release version
* @return pointer to RteItem if found, or nullptr otherwise
*/
RteItem* GetRelease(const std::string& version) const;
/**
* @brief get release note text for specified version
* @param version release version
* @return release text if found, empty string otherwise
*/
const std::string& GetReleaseText(const std::string& version) const;
/**
* @brief get the latest release listed in the pack description
* @return pointer to RteItem representing the latest release, may be nullptr for old packs
*/
RteItem* GetLatestRelease() const;
/**
* @brief get text of the latest release
* @return release text if found, empty string otherwise
*/
const std::string& GetLatestReleaseText() const;
/**
* @brief check if specified release version is listed in the pack description
* @param version pack release version
* @return true if release description is found
*/
bool ReleaseVersionExists(const std::string& version);
/**
* @brief get "replacement" string for the latest release if any
* @return value of "replacement" attribute of the latest release item, empty string if not set
*/
const std::string& GetReplacement() const;
/**
* @brief get date of the latest release
* @return latest release date
*/
const std::string& GetReleaseDate() const;
/**
* @brief get release date of specified version
* @param version pack version to search for
* @return release date if found, empty string otherwise
*/
const std::string& GetReleaseDate(const std::string& version) const;
/**
* @brief construct string representing version and date of the latest release
* @return string in the format ReleaseVersion (ReleaseDate)
*/
std::string GetDatedVersion() const;
/**
* @brief construct string representing version and date of the specified release
* @return string in the format ReleaseVersion (ReleaseDate) if found, empty string otherwise
*/
std::string GetDatedVersion(const std::string& version) const;
/**
* @brief get date of pack deprecation if any
* @return "deprecated" attribute value of the latest release item, empty string if pack is not deprecated
*/
const std::string& GetDeprecationDate() const;
/**
* @brief create a pdsc-like XMLTreeElement with pack info
* @param parent pointer to XMLTreeElement parent for created element
* @return pointer to created XMLTreeElement
*/
XMLTreeElement* CreatePackXmlTreeElement(XMLTreeElement* parent = nullptr) const;
public:
/**
* @brief get collection of packs required by this one
* @param map of id to RtePackage pointers to fill
* @param model pointer to RteModel to resolve requirement
*/
void GetRequiredPacks(RtePackageMap& packs, RteModel* model) const;
/**
* @brief get list of packs required by this one
* @return list of pointers to RteItem objects with pack requirement information
*/
virtual const Collection<RteItem*>& GetPackRequirements() const;
/**
* @brief resolve packs for specified requirements
* @param originatingItem RteItem* supplying requirements, can be NULL
* @param requirements collection of RteItem pointers representing requirements
* @param RtePackageMap to fill
* @param model pointer to RteModel to resolve requirement
*/
static void ResolveRequiredPacks(const RteItem* originatingItem, const Collection<RteItem*>& requirements, RtePackageMap& packs, RteModel* model);
/**
* @brief get list of language requirements imposed by this pack
* @return list of pointers to RteItem objects with language requirement information
*/
virtual const Collection<RteItem*>& GetLanguageRequirements() const;
/**
* @brief get list of compiler requirements imposed by this pack
* @return list of pointers to RteItem objects with compiler requirement information
*/
virtual const Collection<RteItem*>& GetCompilerRequirements() const;
/**
* @brief get path to directory where this pack is or will be installed
* @param withVersion flag if to return the path with version segment
* @return path relative to CMSIS_PACK_ROOT directory in format: PackVendor/PackName/[PackVersion]/
*/
std::string GetPackagePath(bool withVersion = true) const override;
/**
* @brief get pack state
* @return PackageState value
*/
PackageState GetPackageState() const override { return m_packState; }
/**
* @brief set pack state
* @param packState PackageState value
*/
void SetPackageState(PackageState packState) { m_packState = packState; }
/**
* @brief get full or common pack ID
* @param withVersion flag to return full (true) or common (false) ID
* @return full or common pack ID depending on argument
*/
std::string GetPackageID(bool withVersion = true) const override;
/**
* @brief determine package ID by given list of attributes
* @param attr list of attributes
* @param withVersion true if version string should included
* @param useDots flag to use only dots as delimiters
* @return package ID
*/
static std::string GetPackageIDfromAttributes(const XmlItem& attr, bool withVersion = true, bool useDots = false);
/**
* @brief get fully specified package identifier composed from individual strings
* @param vendor pack vendor
* @param name pack name
* @param version pack version
* @param useDots flag to use only dots as delimiters
* @return string package identifier
*
*/
static std::string ComposePackageID(const std::string& vendor, const std::string& name,
const std::string& version, bool useDots = false);
/**
* @brief get pack file name in the format Vendor.Name.1.2.3.ext or Vendor.Name.ext
* @param withVersion flag to return the path with version segment
* @param extension file extension to use: ".pdsc" or ".pack"
* @return package file name in format: Vendor.Name[.1.2.3].ext
*/
static std::string GetPackageFileNameFromAttributes(const XmlItem& attr, bool withVersion, const char* extension);
/**
* @brief get URL to download this pack from
* @param withVersion flag to return url with this version, otherwise without
* @param extension file extension (with dot), usually ".pack"
* @return download URL if found in the description, empty string otherwise
*/
std::string GetDownloadUrl(bool withVersion, const char* extension) const override;
/**
* @brief get license set with given ID
* @param id license set ID to search for
* @return pointer to RteItem if found, nullptr otherwise
*/
RteItem* GetLicenseSet(const std::string& id) const;
using RteItem::GetLicenseSet; // that is also available
/**
* @brief get default license set for the package items
* @return pointer to RteItem if found, nullptr otherwise
*/
RteItem* GetDefaultLicenseSet() const;
/**
* @brief get relative path to default license file agreement
* @return text of <license> element if any
*/
const std::string& GetPackLicenseFile() const { return GetChildText("license");}
/**
* @brief get condition with specified ID
* @param id condition ID to search for
* @return pointer to RteCondition if found, nullptr otherwise
*/
RteCondition* GetCondition(const std::string& id) const override;
/**
* @brief get condition for this pack
* @return nullptr since pack has no condition
*/
RteCondition* GetCondition() const override { return nullptr; }
/**
* @brief get taxonomy with specified ID
* @param id given taxonomy ID
* @return pointer to RteItem if found, nullptr otherwise
*/
const RteItem* GetTaxonomyItem(const std::string& id) const;
/**
* @brief get taxonomy description with specified ID
* @param id given taxonomy ID
* @return description string of taxonomy empty if not found
*/
const std::string& GetTaxonomyDescription(const std::string& id) const;
/**
* @brief get taxonomy description with specified ID
* @param id given taxonomy ID
* @return description string of taxonomy empty if not found
*/
const std::string GetTaxonomyDoc(const std::string& id) const;
public:
/**
* @brief get top-level item corresponding to the pack
* @return this
*/
RtePackage* GetPackage() const override { return const_cast<RtePackage*>(this); }
/**
* @brief check if pack is deprecated
* @return true if pack is deprecated and should no longer be used
*/
bool IsDeprecated() const override;
/**
* @brief check if pack is dominating, i.e. has precedence over other pack when selecting components
* @return true if pack is dominating
*/
virtual bool IsDominating() const;
/**
* @brief check if the pack is generated by a program associated with an RteGenerator object
* @return true if package state is PackageState::PS_GENERATED
*/
bool IsGenerated() const override { return GetPackageState() == ::PackageState::PS_GENERATED; }
/**
* @brief clear all pack structure
*/
void Clear() 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 called to construct the item with attributes and child elements
*/
void Construct() override;
/**
* @brief validate this pack item and children. Checks for condition duplicates
* @return true if validation is successful
*/
bool Validate() override;
/**
* @brief insert components and API's described in this pack into supplied RTE model
* @param model pointer to RteModl to insert to
*/
void InsertInModel(RteModel* model) override;
protected:
/**
* @brief construct and cache pack full and custom ID
* @return full pack ID
*/
std::string ConstructID() override;
private:
PackageState m_packState;
int m_nDominating; // pack dominating flag (-1 if not set)
int m_nDeprecated; // pack deprecation flag (-1 if not set)
RteItem* m_releases; // <releases> element
RteItem* m_licenseSets; // <licenseSets> element
RteItem* m_conditions; // <conditions> element
RteItem* m_components; // <components> element
RteItem* m_apis; // <apis> element
RteItem* m_examples; // <examples> element
RteItem* m_taxonomy; // <taxonomy> element
RteItem* m_boards; // <boards> element
RteItem* m_requirements;// <requirements> element
RteGeneratorContainer* m_generators; // <generators> element
RteDeviceFamilyContainer* m_deviceFamilies; // <devices> element
std::set<std::string> m_keywords; // collected keyword
std::string m_commonID; // common or 'family' pack ID
};
/**
* @brief helper compare class for sorted pack maps.
* compares common ID alpha-numerically in ascending order and version semantically in descending order
*/
class RtePackageComparator
{
public:
/**
* @brief compare two pack IDs
* @param a first pack ID
* @param b second pack ID
* @return true if first pack is 'less' than the second one
*/
bool operator()(const std::string& a, const std::string& b) const { return RtePackage::ComparePackageIDs(a, b) < 0; }
};
/**
* @brief helper compare class for sorted pack maps
* compares common ID alpha-numerically in ascending order and version semantically in descending order
*/
class RtePdscComparator
{
public:
/**
* @brief compare two pdsc file names by their pack IDs
* @param a first absolute pdsc file name
* @param b second absolute pdsc file name
* @return true if first pack is 'less' than the second one
*/
bool operator()(const std::string& a, const std::string& b) const { return RtePackage::ComparePdscFileNames(a, b) < 0; }
};
/**
* @brief class that replicates frequently used information of a pack object or a pack release.
* contains a reference to the actual pack object that this info represents
*/
class RtePackageInfo : public RteItem
{
public:
/**
* @brief constructor
* @param pack pointer to RtePackage to represent, owns this info
*/
RtePackageInfo(RtePackage* pack);
/**
* @brief constructor
* @param pack pointer to RtePackage to represent, owns this info
* @param version release version this pack info represents
*/
RtePackageInfo(RtePackage* pack, const std::string& version);
/**
* @brief get common or 'family' pack ID
* @return pack ID without version
*/
const std::string& GetCommonID() const;
/**
* @brief get pack display name
* @return display string
*/
std::string GetDisplayName() const override;
/**
* @brief get full or common pack ID
* @param withVersion flag to return full (true) or common (false) ID
* @return full or common pack ID depending on argument
*/
std::string GetPackageID(bool withVersion = true) const override;
/**
* @brief get path to directory where this pack is or will be installed
* @param withVersion flag if return path segment corresponding to pack version (last segment)
* @return path relative to CMSIS_PACK_ROOT directory in format: PackVendor/PackName/[PackVersion]/
*/
std::string GetPackagePath(bool withVersion = true) const override;
/**
* @brief check if this info represents the latest pack release, i.e. this RtePackage object itself
* @return true if info represents the latest release
*/
virtual bool IsLatestRelease() const;
/**
* @brief get URL to download this pack or this release from
* @param withVersion flag to return url with this version, otherwise without
* @param extension file extension (with dot), usually ".pack"
* @return download url if found in the description, empty string otherwise
*/
std::string GetDownloadUrl(bool withVersion, const char* extension) const override;
/**
* @brief get <devices> element of the referenced pack
* @return pointer to RteDeviceFamilyContainer representing container for device families
*/
RteDeviceFamilyContainer* GetDeviceFamiles() const;
/**
* @brief get <devices> element of the referenced pack
* @return pointer to RteDeviceFamilyContainer representing container for device families
*/
RteItem* GetExamples() const;
/**
* @brief get <boards> element of the referenced pack
* @return pointer to RteItem representing container for boards
*/
RteItem* GetBoards() const;
/**
* @brief get absolute path to the directory where pack's *.pdsc file is located
* @return absolute path to pdsc file directory with trailing slash
*/
std::string GetAbsolutePackagePath() const override;
/**
* @brief get release text this info represents
* @return release text
*/
const std::string& GetReleaseText() const; // return release note text
/**
* @brief get release note text for specified version
* @param version release version
* @return release text if found, empty string otherwise
*/
const std::string& GetReleaseText(const std::string& version) const;
/**
* @brief get text of the latest release
* @return release text if found, empty string otherwise
*/
const std::string& GetLatestReleaseText() const;
/**
* @brief check if specified release version is listed in the pack description
* @param version pack release version
* @return true if release description is found
*/
bool ReleaseVersionExists(const std::string& version);
/**
* @brief get "replacement" string for the latest release if any
* @return value of "release" attribute of the latest release item, empty string if not set
*/
const std::string& GetReplacement() const;
/**
* @brief get date of the latest release
* @return latest release date
*/
const std::string& GetReleaseDate() const;
/**
* @brief get release date of specified version
* @param version pack version to search for
* @return release date if found, empty string otherwise
*/
const std::string& GetReleaseDate(const std::string& version) const;
/**
* @brief construct string representing version and date of the latest release
* @return string in the format ReleaseVersion (ReleaseDate)
*/
std::string GetDatedVersion() const;
/**
* @brief construct string representing version and date of the specified release
* @return string in the format ReleaseVersion (ReleaseDate) if found, empty string otherwise
*/
std::string GetDatedVersion(const std::string& version) const;
/**
* @brief get date of pack deprecation if any
* @return "deprecated" attribute value of the latest release item, empty string if pack is not deprecated
*/
const std::string& GetDeprecationDate() const;
/**
* @brief get pack repository URL
* @return pack repository URL if specified, empty string otherwise
*/
const std::string& GetRepository() const; // return repository url of the package or EMPTY_STRING if not specified
/**
* @brief get attribute value of a specified pack release
* @param attribute name of attribute
* @param version release version
* @param latest flag to ignore supplied version and get value from the latest release
* @return attribute value if found, empty string otherwise
*/
const std::string& GetReleaseAttributeValue( const std::string& attribute, const std::string &version, bool latest = true) const;
/**
* @brief get URL to download this release from
* @param withVersion flag to return url with this version, otherwise without
* @param extension file extension (with dot), usually ".pack"
* @param useReleaseUrl use data specified in release, ignore other arguments
* @return download url if found in the description, empty string otherwise
*/
std::string GetDownloadReleaseUrl(bool withVersion, const char* extension, bool useReleaseUrl) const;
protected:
/**
* @brief construct and cache common and full pack ID
* @return full pack ID constructed from this item attributes
*/
std::string ConstructID() override;
private:
/**
* @brief initialize the info
* @param pack pointer to RtePackage to represent
* @param version release version to represent
*/
void Init(RtePackage* pack, const std::string& version);
private:
std::string m_commonID; // common pack ID
};
typedef std::map<std::string, RtePackageInfo*, VersionCmp::Greater > RtePackageInfoMap;
typedef std::map<std::string, RtePackageInfo* > RtePackageInfoMapStdComp;
/**
* @brief class to aggregate package versions to manage pack selection in projects and to support pack filtering.
*/
class RtePackageAggregate : public RteItem
{
public:
/**
* @brief constructor
* @param parent pointer parent RteItem
*/
RtePackageAggregate(RteItem* parent);
/**
* @brief virtual destructor
*/
~RtePackageAggregate() override;
public:
/**
* @brief clear internal data
*/
void Clear() override;
/**
* @brief get display name for this aggregate
* @return display name constructed from common pack ID
*/
std::string GetDisplayName() const override { return m_displayName; }
/**
* @brief get sorted package collection
* @return reference to RteItemPackageMap map
*/
const RteItemPackageMap& GetPackages() const { return m_packages; }
/**
* @brief check if a pack from aggregate is used in the project
* @return true if at least one version of the pack is used in the project
*/
bool IsUsed() const { return !m_usedPackages.empty(); }
/**
* @brief check if aggregate uses selection of pack version
* @return
*/
bool HasFixedSelection() const { return !m_selectedPackages.empty(); }
/**
* @brief get version mode this pack aggregate uses
* @return VersionCmp::MatchMode value
*/
VersionCmp::MatchMode GetVersionMatchMode() const { return m_mode; }
/**
* @brief set version mode to use
* @param mode VersionCmp::MatchMode to use
*/
void SetVersionMatchMode(VersionCmp::MatchMode mode);
/**
* @brief adjust version mode according to pack usage
*/
void AdjustVersionMatchMode();
/**
* @brief get pointer to parent RtePackage item
* @return nullptr since this item does not have pack parent
*/
RtePackage* GetPackage() const override { return nullptr;}
/**
* @brief get pack for specified ID
* @param id full pack ID
* @return pointer to RteItem representing RtePackage or RtePackageInstanceInfo
*/
RteItem* GetPackage(const std::string& id) const;
/**
* @brief get the latest pack or its instance
* @return pointer to RteItem representing RtePackage or RtePackageInstanceInfo
*/
RteItem* GetLatestEntry() const;
/**
* @brief get the latest installed pack
* @return pointer to RteItem representing RtePackage or nullptr if no pack is installed
*/
RtePackage* GetLatestPackage() const;
/**
* @brief get latest pack ID
* @return full Id of the latest pack
*/
const std::string& GetLatestPackageID() const;
/**
* @brief check if pack specified pack release is used in the project target
* @param id full pack ID
* @return true if pack is used
*/
bool IsPackageUsed(const std::string& id) const;
/**