cmSourceGroup.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2000 National Library of Medicine
  8. All rights reserved.
  9. See COPYRIGHT.txt for copyright details.
  10. =========================================================================*/
  11. #ifndef cmSourceGroup_h
  12. #define cmSourceGroup_h
  13. #include "cmStandardIncludes.h"
  14. #include "cmRegularExpression.h"
  15. #include <set>
  16. /** \class cmSourceGroup
  17. * \brief Hold a group of sources as specified by a SOURCE_GROUP command.
  18. *
  19. * cmSourceGroup holds all the source files and corresponding commands
  20. * for files matching the regular expression specified for the group.
  21. */
  22. class cmSourceGroup
  23. {
  24. public:
  25. cmSourceGroup(const char* name, const char* regex);
  26. cmSourceGroup(const cmSourceGroup&);
  27. ~cmSourceGroup() {}
  28. struct CommandFiles
  29. {
  30. CommandFiles() {}
  31. CommandFiles(const CommandFiles& r):
  32. m_Outputs(r.m_Outputs), m_Depends(r.m_Depends) {}
  33. std::set<std::string> m_Outputs;
  34. std::set<std::string> m_Depends;
  35. };
  36. /**
  37. * Map from command to its output/depends sets.
  38. */
  39. typedef std::map<std::string, CommandFiles> Commands;
  40. /**
  41. * Map from source to command map.
  42. */
  43. typedef std::map<std::string, Commands> CustomCommands;
  44. bool Matches(const char* name);
  45. void SetGroupRegex(const char* regex)
  46. { m_GroupRegex.compile(regex); }
  47. void AddSource(const char* name)
  48. { m_Sources.push_back(name); }
  49. void AddCustomCommand(const char* source,
  50. const char* command,
  51. const std::vector<std::string>& depends,
  52. const std::vector<std::string>& outputs);
  53. const char* GetName() const
  54. { return m_Name.c_str(); }
  55. const std::vector<std::string>& GetSources() const
  56. { return m_Sources; }
  57. const CustomCommands& GetCustomCommands() const
  58. { return m_CustomCommands; }
  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. * The sources in this group that the compiler will know how to build.
  70. */
  71. std::vector<std::string> m_Sources;
  72. /**
  73. * The custom commands in this group and their corresponding sources.
  74. */
  75. CustomCommands m_CustomCommands;
  76. };
  77. #endif