packaging: Initial packaging
[platform/upstream/cmake.git] / Source / cmSourceGroup.h
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12 #ifndef cmSourceGroup_h
13 #define cmSourceGroup_h
14
15 #include "cmStandardIncludes.h"
16 #include <cmsys/RegularExpression.hxx>
17
18 class cmSourceFile;
19
20 class cmSourceGroupInternals;
21
22 /** \class cmSourceGroup
23  * \brief Hold a group of sources as specified by a SOURCE_GROUP command.
24  *
25  * cmSourceGroup holds a regular expression and a list of files.  When
26  * local generators are about to generate the rules for a target's
27  * files, the set of source groups is consulted to group files
28  * together.  A file is placed into the last source group that lists
29  * the file by name.  If no group lists the file, it is placed into
30  * the last group whose regex matches it.
31  */
32 class cmSourceGroup
33 {
34 public:
35   cmSourceGroup(const char* name, const char* regex,
36                 const char* parentName=0);
37   cmSourceGroup(cmSourceGroup const& r);
38   ~cmSourceGroup();
39   cmSourceGroup& operator=(cmSourceGroup const&);
40
41   /**
42    * Set the regular expression for this group.
43    */
44   void SetGroupRegex(const char* regex);
45
46   /**
47    * Add a file name to the explicit list of files for this group.
48    */
49   void AddGroupFile(const char* name);
50
51   /**
52    * Add child to this sourcegroup
53    */
54   void AddChild(cmSourceGroup child);
55
56   /**
57    * Looks up child and returns it
58    */
59   cmSourceGroup *lookupChild(const char *name);
60
61   /**
62    * Get the name of this group.
63    */
64   const char* GetName() const;
65
66   /**
67    * Get the full path name for group.
68    */
69   const char* GetFullName() const;
70
71   /**
72    * Check if the given name matches this group's regex.
73    */
74   bool MatchesRegex(const char* name);
75
76   /**
77    * Check if the given name matches this group's explicit file list.
78    */
79   bool MatchesFiles(const char* name);
80
81   /**
82    * Check if the given name matches this group's explicit file list
83    * in children.
84    */
85   cmSourceGroup *MatchChildrenFiles(const char *name);
86
87   /**
88    * Check if the given name matches this group's regex in children.
89    */
90   cmSourceGroup *MatchChildrenRegex(const char *name);
91
92   /**
93    * Assign the given source file to this group.  Used only by
94    * generators.
95    */
96   void AssignSource(const cmSourceFile* sf);
97
98   /**
99    * Get the list of the source files that have been assigned to this
100    * source group.
101    */
102   const std::vector<const cmSourceFile*>& GetSourceFiles() const;
103
104   std::vector<cmSourceGroup> const& GetGroupChildren() const;
105 private:
106   /**
107    * The name of the source group.
108    */
109   std::string Name;
110   // Full path to group
111   std::string FullName;
112
113   /**
114    * The regular expression matching the files in the group.
115    */
116   cmsys::RegularExpression GroupRegex;
117
118   /**
119    * Set of file names explicitly added to this group.
120    */
121   std::set<cmStdString> GroupFiles;
122
123   /**
124    * Vector of all source files that have been assigned to
125    * this group.
126    */
127   std::vector<const cmSourceFile*> SourceFiles;
128
129   cmSourceGroupInternals* Internal;
130 };
131
132 #endif