Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmSourceFileLocation.h
blob6aa875bfe4163355674de80fa0edd7067835bcf1
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmSourceFileLocation.h,v $
5 Language: C++
6 <<<<<<< cmSourceFileLocation.h
7 Date: $Date: 2007/06/18 15:59:23 $
8 Version: $Revision: 1.2 $
9 =======
10 Date: $Date: 2008-08-05 17:27:01 $
11 Version: $Revision: 1.3 $
12 >>>>>>> 1.3
14 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
15 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
17 This software is distributed WITHOUT ANY WARRANTY; without even
18 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
19 PURPOSE. See the above copyright notices for more information.
21 =========================================================================*/
22 #ifndef cmSourceFileLocation_h
23 #define cmSourceFileLocation_h
25 #include "cmStandardIncludes.h"
27 class cmMakefile;
29 /** \class cmSourceFileLocation
30 * \brief cmSourceFileLocation tracks knowledge about a source file location
32 * Source files can be referenced by a variety of names. The
33 * directory and/or extension may be omitted leading to a certain
34 * level of ambiguity about the source file location. This class is
35 * used by cmSourceFile to keep track of what is known about the
36 * source file location. Each reference may add some information
37 * about the directory or extension of the file.
39 class cmSourceFileLocation
41 public:
42 /**
43 * Construct for a source file created in a given cmMakefile
44 * instance with an initial name.
46 cmSourceFileLocation(cmMakefile* mf, const char* name);
48 /**
49 * Return whether the givne source file location could refers to the
50 * same source file as this location given the level of ambiguity in
51 * each location.
53 bool Matches(cmSourceFileLocation const& loc);
55 /**
56 * Explicity state that the source file is located in the source tree.
58 void DirectoryUseSource();
60 /**
61 * Explicity state that the source file is located in the build tree.
63 void DirectoryUseBinary();
65 /**
66 * Return whether the directory containing the source is ambiguous.
68 bool DirectoryIsAmbiguous() const { return this->AmbiguousDirectory; }
70 /**
71 * Return whether the extension of the source name is ambiguous.
73 bool ExtensionIsAmbiguous() const { return this->AmbiguousExtension; }
75 /**
76 * Get the directory containing the file as best is currently known.
77 * If DirectoryIsAmbiguous() returns false this will be a full path.
78 * Otherwise it will be a relative path (possibly empty) that is
79 * either with respect to the source or build tree.
81 const char* GetDirectory() const { return this->Directory.c_str(); }
83 /**
84 * Get the file name as best is currently known. If
85 * ExtensionIsAmbiguous() returns true this name may not be the
86 * final name (but could be). Otherwise the returned name is the
87 * final name.
89 const char* GetName() const { return this->Name.c_str(); }
91 /**
92 * Get the cmMakefile instance for which the source file was created.
94 cmMakefile* GetMakefile() const { return this->Makefile; }
95 private:
96 cmMakefile* Makefile;
97 bool AmbiguousDirectory;
98 bool AmbiguousExtension;
99 std::string Directory;
100 std::string Name;
102 bool MatchesAmbiguousExtension(cmSourceFileLocation const& loc) const;
104 // Update the location with additional knowledge.
105 void Update(cmSourceFileLocation const& loc);
106 void Update(const char* name);
107 void UpdateExtension(const char* name);
108 void UpdateDirectory(const char* name);
111 #endif