cmSourceGroup.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 cmSourceGroup
  19. * \brief Hold a group of sources as specified by a SOURCE_GROUP command.
  20. *
  21. * cmSourceGroup holds a regular expression and a list of files. When
  22. * local generators are about to generate the rules for a target's
  23. * files, the set of source groups is consulted to group files
  24. * together. A file is placed into the last source group that lists
  25. * the file by name. If no group lists the file, it is placed into
  26. * the last group whose regex matches it.
  27. */
  28. class cmSourceGroup
  29. {
  30. public:
  31. cmSourceGroup(const char* name, const char* regex);
  32. ~cmSourceGroup() {}
  33. /**
  34. * Set the regular expression for this group.
  35. */
  36. void SetGroupRegex(const char* regex);
  37. /**
  38. * Add a file name to the explicit list of files for this group.
  39. */
  40. void AddGroupFile(const char* name);
  41. /**
  42. * Add child to this sourcegroup
  43. */
  44. void AddChild(cmSourceGroup child);
  45. /**
  46. * Looks up child and returns it
  47. */
  48. cmSourceGroup *lookupChild(const char *name);
  49. /**
  50. * Get the name of this group.
  51. */
  52. const char* GetName() const;
  53. /**
  54. * Check if the given name matches this group's regex.
  55. */
  56. bool MatchesRegex(const char* name);
  57. /**
  58. * Check if the given name matches this group's explicit file list.
  59. */
  60. bool MatchesFiles(const char* name);
  61. /**
  62. * Check if the given name matches this group's explicit file list
  63. * in children.
  64. */
  65. cmSourceGroup *MatchChildrenFiles(const char *name);
  66. /**
  67. * Check if the given name matches this group's regex in children.
  68. */
  69. cmSourceGroup *MatchChildrenRegex(const char *name);
  70. /**
  71. * Assign the given source file to this group. Used only by
  72. * generators.
  73. */
  74. void AssignSource(const cmSourceFile* sf);
  75. /**
  76. * Get the list of the source files that have been assigned to this
  77. * source group.
  78. */
  79. const std::vector<const cmSourceFile*>& GetSourceFiles() const;
  80. std::vector<const cmSourceFile*>& GetSourceFiles();
  81. std::vector<cmSourceGroup> GetGroupChildren() const;
  82. private:
  83. /**
  84. * The name of the source group.
  85. */
  86. std::string Name;
  87. /**
  88. * The regular expression matching the files in the group.
  89. */
  90. cmsys::RegularExpression GroupRegex;
  91. /**
  92. * Set of file names explicitly added to this group.
  93. */
  94. std::set<cmStdString> GroupFiles;
  95. /**
  96. * Vector of all source files that have been assigned to
  97. * this group.
  98. */
  99. std::vector<const cmSourceFile*> SourceFiles;
  100. std::vector<cmSourceGroup> GroupChildren;
  101. };
  102. #endif