xref: /trunk/main/xml2cmp/source/finder/dependy.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 X2C_DEPENDY_HXX
29 #define X2C_DEPENDY_HXX
30 
31 
32 #include <vector>
33 #include <map>
34 #include <set>
35 #include <../support/sistr.hxx>
36 
37 class Service;
38 class ServiceInfo;
39 
40 typedef std::vector< Simstr> 			StringVector;
41 typedef std::vector< ServiceInfo* > 	List_Implementations;
42 typedef std::map< Simstr, Service* >	Map_Services;
43 
44 class Service
45 {
46   public:
47 						Service(
48 							const char *		i_sName );
49 
50 	ServiceInfo &		AddImplementation(
51 							const char *		i_sLibrary );	/// That is: module-name.
52 
53 	const Simstr &		Name() const			{ return sName; }
54 	const ServiceInfo &	FirstImplementation() const
55 												{ return *aImplementations[0]; }
56 
57   private:
58 	Simstr				sName;
59 	List_Implementations
60 						aImplementations;
61 };
62 
63 class ServiceInfo
64 {
65   public:
66 	typedef StringVector List_NeededServices;
67 
68 						ServiceInfo(
69 							const char *		i_sLibrary );
70 
71 	void				AddDependency(
72 							const char *		i_sNeededService );
73 
74 	const Simstr &		Library() const			{ return sImplementingLibrary; }
75 	const List_NeededServices &
76 						NeededServices() const	{ return aNeededServices; }
77 
78 
79   private:
80 	Simstr				sImplementingLibrary;
81 	List_NeededServices	aNeededServices;
82 };
83 
84 
85 class DependencyFinder
86 {
87   public:
88 						DependencyFinder();
89 						~DependencyFinder();
90 
91 	void				GatherData(
92 							const char *		i_sSearchDirectory );
93 
94 	void				FindNeededServices(
95 							StringVector &		o_rLibraries,
96 							StringVector &		o_rServices,
97 							const Simstr &		i_rService );
98   private:
99 	void				ReadFile(
100 							const char * 		i_sFilename );
101 	void               	Add2Result(
102 							const Service &		i_rService );
103 
104 	// Data
105 	Map_Services		aServices;
106 
107 	// Temporary data
108 	std::set< Simstr >	aResult_Libraries;
109 	std::set< Simstr >	aResult_Services;
110 };
111 
112 
113 
114 #endif
115 
116 
117