xref: /trunk/main/tools/inc/bootstrp/mkcreate.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _MK_CREATE_HXX
29 #define _MK_CREATE_HXX
30 
31 #include <tools/string.hxx>
32 //#include "bootstrp/sstring.hxx"
33 
34 DECLARE_LIST( UniStringList, UniString* )
35 
36 #include <tools/list.hxx>
37 #include "bootstrp/prj.hxx"
38 
39 class SvStream;
40 class SourceDirectoryList;
41 
42 //
43 // class SourceDirectoryDependency
44 //
45 
46 class CodedDependency : public ByteString
47 {
48 private:
49 	sal_uInt16 nOSType;							// operating systems where dependeny exists
50 
51 public:
52 	/* create a dependency instance with given coded directory name
53 	 */
54 	CodedDependency(
55 		const ByteString &rCodedIdentifier, // the coded name of the directory
56 		sal_uInt16 nOperatingSystems			// the operating systems where this dependency exists
57 	) :
58 	ByteString( rCodedIdentifier ),
59 	nOSType( nOperatingSystems )
60 	{
61 	}
62 
63 	/* returns the operating system
64 	 */
65 	sal_uInt16 GetOperatingSystem()
66 	{
67 		return nOSType;
68 	}
69 
70 	/* set operating system
71 	 */
72 	void SetOperatingSystem( sal_uInt16 nOperatingSystems )
73 	{
74 		nOSType = nOperatingSystems;
75 	}
76 
77 	/* add operating systems if same dependency
78 	 */
79 	sal_Bool TryToMerge(
80 		const ByteString &rCodedIdentifier, // the coded name of the directory
81 		sal_uInt16 nOperatingSystems			// the operating systems where this dependency exists
82 	)
83 	{
84 		if ( rCodedIdentifier != *this )
85 			return sal_False;
86 		nOSType |= nOperatingSystems;
87 		return sal_True;
88 	}
89 };
90 
91 //
92 // class Dependecy
93 //
94 
95 class Dependency : public ByteString
96 {
97 private:
98 	sal_uInt16 nOSType;							// operating systems where dependecy exists
99 
100 public:
101 	/* create a dependency instance with given directory name
102 	 */
103 	Dependency(
104 		const ByteString &rDirectoryName, 	// the coded name of the directory
105 		sal_uInt16 nOperatingSystems			// the operating systems where this dependency exists
106 	) :
107 	ByteString( rDirectoryName ),
108 	nOSType( nOperatingSystems )
109 	{
110 	}
111 
112 	/* returns the operating system
113 	 */
114 	sal_uInt16 GetOperatingSystem()
115 	{
116 		return nOSType;
117 	}
118 };
119 
120 //
121 // class SourceDirectory
122 //
123 
124 class SourceDirectory : public ByteString
125 {
126 private:
127 	SourceDirectory *pParent;				// the parent directory
128 	SourceDirectoryList *pSubDirectories;	// list of sub directories
129 	sal_uInt16 nOSType;							// operating systems where this directory is used
130 	sal_uInt16 nDepth;							// depth of directory structure (root is 0)
131 
132 	SByteStringList *pDependencies;			// dependencies on other directories in this depth
133 
134 	SByteStringList *pCodedDependencies;   	// dependencies on other directories in different depth
135 	SByteStringList *pCodedIdentifier;     	// symbolic identifier to resolve dependencies
136 
137 	/* try to resolve a single dependency
138 	 */
139 	Dependency *ResolvesDependency(
140 		CodedDependency *pCodedDependency 	// the dependency
141 	);
142 
143 	/* returns the operating systems of a coded dependency
144 	 */
145 	static sal_uInt16 GetOSType(
146 		const ByteString &sDependExt 		// the corresponding dependency extension (see also prj.hxx)
147 	);
148 
149 	/* removes this and all sub directories with all dependencies
150 	 */
151 	sal_Bool RemoveDirectoryTreeAndAllDependencies();
152 
153 public:
154 
155     /* create a directory instance with given parent and name, no parent means this is the root
156 	 * (not the file system root but the root of the source tree, e.g. o:\569)
157 	 */
158 	SourceDirectory(
159 		const ByteString &rDirectoryName, 			// name without parent
160 		sal_uInt16 nOperatingSystem,					// the operating systems where this directory is used
161 		SourceDirectory *pParentDirectory = NULL 	// parent (if not root)
162 	);
163 	~SourceDirectory();
164 
165 	/* returns the full absolute path of this directory
166 	 */
167 	ByteString GetFullPath();
168 
169 	/* returns a list of all sub directories
170 	 */
171 	SourceDirectoryList *GetSubDirectories() { return pSubDirectories; }
172 
173 	/* returns the Operating systems where this directory is used
174 	 */
175 	sal_uInt16 GetOperatingSystems() { return nOSType; }
176 
177 	/* returns the given directory
178 	 */
179 	SourceDirectory *GetDirectory(
180 		const ByteString &rDirectoryName,	// full path
181 		sal_uInt16 nOperatingSystem				// the operating systems where this directory is used
182 	);
183 
184 	/* create the directory and all mandatory parents
185 	 */
186 	SourceDirectory *InsertFull(
187 		const ByteString &rDirectoryName,	// full path
188 		sal_uInt16 nOperatingSystem				// the operating systems where this directory is used
189 	)
190 	{
191 		return GetDirectory( rDirectoryName, nOperatingSystem );
192 	}
193 
194 	/* create the directory as sub directory of this directory
195 	 */
196 	SourceDirectory *Insert(
197 		const ByteString &rDirectoryName,	// name without parent
198 		sal_uInt16 nOperatingSystem				// the operating systems where this directory is used
199 	);
200 
201 	/* get the root directory
202 	 */
203 	SourceDirectory *GetRootDirectory();
204 
205 	/* get sub directory if exists
206 	 */
207 	SourceDirectory *GetSubDirectory(
208 		const ByteString &rDirectoryPath,	// full sub path
209 		sal_uInt16 nOperatingSystem				// the operating systems where this directory is used
210 	);
211 
212 	/* add a dependency for several platforms
213 	 */
214 	CodedDependency *AddCodedDependency(
215 		const ByteString &rCodedIdentifier, // the coded name of the directory
216 		sal_uInt16 nOperatingSystems			// the operating systems where this dependency exists
217 	);
218 
219 	/* returns the dependency list
220 	 */
221 	SByteStringList *GetCodedDependencies()
222 	{
223 		return pCodedDependencies;
224 	}
225 
226 	/* add symbolic identifier to resolve dependencies (to this directory and all parents)
227 	 */
228 	CodedDependency *AddCodedIdentifier(
229 		const ByteString &rCodedIdentifier, // the coded name of the directory
230 		sal_uInt16 nOperatingSystems			// the operating systems where this dependency exists
231 	);
232 
233 	/* returns the identifier list
234 	 */
235 	SByteStringList *GetCodedIdentifier()
236 	{
237 		return pCodedIdentifier;
238 	}
239 
240 	/* create dependencies on other directory, coded dependecies are used
241 	 */
242 	void ResolveDependencies();
243 
244 	/* returns the target definition for this directory (if dependencies exist)
245 	 */
246 	ByteString GetTarget();
247 
248 	/* returns the target definition for all sub directory
249 	 */
250 	ByteString GetSubDirsTarget();
251 
252 	/* create the full directory tree (only virtual, not in file system)
253 	 */
254 	static SourceDirectory *CreateRootDirectory(
255 		const ByteString &rRoot, 	// the root directory in file system
256 		const ByteString &rVersion,	// the solar verion (r.g. SRC590, SRC591 etc.)
257 		sal_Bool bAll = sal_False			// add all directories or only buildable ones
258 	);
259 
260 	/* create the makefile.rc in file system
261 	 */
262 	sal_Bool CreateRecursiveMakefile(
263 		sal_Bool bAllChilds = sal_False 	// create rcursive for all sub directories
264 	);
265 };
266 
267 //
268 // class SourceDirectoryList
269 //
270 
271 class SourceDirectoryList : public SByteStringList
272 {
273 public:
274 	/* create a empty directory list
275 	 */
276 	SourceDirectoryList()
277 	{
278 	}
279 	~SourceDirectoryList();
280 
281 	/* search for a directory by directory name
282 	 */
283 	SourceDirectory *Search(
284 		const ByteString &rDirectoryName	// name without parent
285 	);
286 
287 	/* insert a new directory
288 	 */
289 	sal_uIntPtr InsertSorted(
290 		SourceDirectory *pDirectory 	// directory
291 	)
292 	{
293 		return PutString(( ByteString * ) pDirectory );
294 	}
295 };
296 
297 #endif
298