cmSourceGroup.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 "cmCustomCommand.h"
  16. #include <set>
  17. /** \class cmSourceGroup
  18. * \brief Hold a group of sources as specified by a SOURCE_GROUP command.
  19. *
  20. * cmSourceGroup holds all the source files and corresponding commands
  21. * for files matching the regular expression specified for the group.
  22. */
  23. class cmSourceGroup
  24. {
  25. public:
  26. cmSourceGroup(const char* name, const char* regex);
  27. cmSourceGroup(const cmSourceGroup&);
  28. ~cmSourceGroup() {}
  29. struct CommandFiles
  30. {
  31. CommandFiles() {}
  32. CommandFiles(const CommandFiles& r):
  33. m_Outputs(r.m_Outputs), m_Depends(r.m_Depends) {}
  34. std::set<std::string> m_Outputs;
  35. std::set<std::string> m_Depends;
  36. };
  37. /**
  38. * Map from command to its output/depends sets.
  39. */
  40. typedef std::map<std::string, CommandFiles> Commands;
  41. /**
  42. * Map from source to command map.
  43. */
  44. typedef std::map<std::string, Commands> CustomCommands;
  45. bool Matches(const char* name);
  46. void SetGroupRegex(const char* regex)
  47. { m_GroupRegex.compile(regex); }
  48. void AddSource(const char* name)
  49. { m_Sources.push_back(name); }
  50. void AddCustomCommand(const cmCustomCommand &cmd);
  51. const char* GetName() const
  52. { return m_Name.c_str(); }
  53. const std::vector<std::string>& GetSources() const
  54. { return m_Sources; }
  55. const CustomCommands& GetCustomCommands() const
  56. { return m_CustomCommands; }
  57. private:
  58. /**
  59. * The name of the source group.
  60. */
  61. std::string m_Name;
  62. /**
  63. * The regular expression matching the files in the group.
  64. */
  65. cmRegularExpression m_GroupRegex;
  66. /**
  67. * The sources in this group that the compiler will know how to build.
  68. */
  69. std::vector<std::string> m_Sources;
  70. /**
  71. * The custom commands in this group and their corresponding sources.
  72. */
  73. CustomCommands m_CustomCommands;
  74. };
  75. #endif