cmSourceGroup.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Insight Consortium. All rights reserved.
  8. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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 "cmRegularExpression.h"
  17. #include "cmCustomCommand.h"
  18. /** \class cmSourceGroup
  19. * \brief Hold a group of sources as specified by a SOURCE_GROUP command.
  20. *
  21. * cmSourceGroup holds all the source files and corresponding commands
  22. * for files matching the regular expression specified for the group.
  23. */
  24. class cmSourceGroup
  25. {
  26. public:
  27. cmSourceGroup(const char* name, const char* regex);
  28. cmSourceGroup(const cmSourceGroup&);
  29. ~cmSourceGroup() {}
  30. struct CommandFiles
  31. {
  32. CommandFiles() {}
  33. CommandFiles(const CommandFiles& r):
  34. m_Outputs(r.m_Outputs), m_Depends(r.m_Depends) {}
  35. void Merge(const CommandFiles &r);
  36. std::string m_Command;
  37. std::string m_Arguments;
  38. std::set<std::string> m_Outputs;
  39. std::set<std::string> m_Depends;
  40. };
  41. /**
  42. * Map from command to its output/depends sets.
  43. */
  44. typedef std::map<cmStdString, CommandFiles> Commands;
  45. /**
  46. * Map from source to command map.
  47. */
  48. typedef std::map<cmStdString, Commands> BuildRules;
  49. bool Matches(const char* name);
  50. void SetGroupRegex(const char* regex)
  51. { m_GroupRegex.compile(regex); }
  52. void AddSource(const char* name);
  53. void AddCustomCommand(const cmCustomCommand &cmd);
  54. const char* GetName() const
  55. { return m_Name.c_str(); }
  56. const BuildRules& GetBuildRules() const
  57. { return m_BuildRules; }
  58. void Print() const;
  59. private:
  60. /**
  61. * The name of the source group.
  62. */
  63. std::string m_Name;
  64. /**
  65. * The regular expression matching the files in the group.
  66. */
  67. cmRegularExpression m_GroupRegex;
  68. /**
  69. * Map from source name to the commands to build from the source.
  70. * Some commands may build from files that the compiler also knows how to
  71. * build.
  72. */
  73. BuildRules m_BuildRules;
  74. };
  75. #endif