cmSourceGroup.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmSourceGroup_h
  14. #define cmSourceGroup_h
  15. #include "cmStandardIncludes.h"
  16. #include <cmsys/RegularExpression.hxx>
  17. class cmSourceFile;
  18. class cmSourceGroupInternals;
  19. /** \class cmSourceGroup
  20. * \brief Hold a group of sources as specified by a SOURCE_GROUP command.
  21. *
  22. * cmSourceGroup holds a regular expression and a list of files. When
  23. * local generators are about to generate the rules for a target's
  24. * files, the set of source groups is consulted to group files
  25. * together. A file is placed into the last source group that lists
  26. * the file by name. If no group lists the file, it is placed into
  27. * the last group whose regex matches it.
  28. */
  29. class cmSourceGroup
  30. {
  31. public:
  32. cmSourceGroup(const char* name, const char* regex);
  33. cmSourceGroup(cmSourceGroup const& r);
  34. ~cmSourceGroup();
  35. cmSourceGroup& operator=(cmSourceGroup const&);
  36. /**
  37. * Set the regular expression for this group.
  38. */
  39. void SetGroupRegex(const char* regex);
  40. /**
  41. * Add a file name to the explicit list of files for this group.
  42. */
  43. void AddGroupFile(const char* name);
  44. /**
  45. * Add child to this sourcegroup
  46. */
  47. void AddChild(cmSourceGroup child);
  48. /**
  49. * Looks up child and returns it
  50. */
  51. cmSourceGroup *lookupChild(const char *name);
  52. /**
  53. * Get the name of this group.
  54. */
  55. const char* GetName() const;
  56. /**
  57. * Check if the given name matches this group's regex.
  58. */
  59. bool MatchesRegex(const char* name);
  60. /**
  61. * Check if the given name matches this group's explicit file list.
  62. */
  63. bool MatchesFiles(const char* name);
  64. /**
  65. * Check if the given name matches this group's explicit file list
  66. * in children.
  67. */
  68. cmSourceGroup *MatchChildrenFiles(const char *name);
  69. /**
  70. * Check if the given name matches this group's regex in children.
  71. */
  72. cmSourceGroup *MatchChildrenRegex(const char *name);
  73. /**
  74. * Assign the given source file to this group. Used only by
  75. * generators.
  76. */
  77. void AssignSource(const cmSourceFile* sf);
  78. /**
  79. * Get the list of the source files that have been assigned to this
  80. * source group.
  81. */
  82. const std::vector<const cmSourceFile*>& GetSourceFiles() const;
  83. std::vector<const cmSourceFile*>& GetSourceFiles();
  84. std::vector<cmSourceGroup> const& GetGroupChildren() const;
  85. private:
  86. /**
  87. * The name of the source group.
  88. */
  89. std::string Name;
  90. /**
  91. * The regular expression matching the files in the group.
  92. */
  93. cmsys::RegularExpression GroupRegex;
  94. /**
  95. * Set of file names explicitly added to this group.
  96. */
  97. std::set<cmStdString> GroupFiles;
  98. /**
  99. * Vector of all source files that have been assigned to
  100. * this group.
  101. */
  102. std::vector<const cmSourceFile*> SourceFiles;
  103. cmSourceGroupInternals* Internal;
  104. };
  105. #endif