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