1*dd7bc091SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*dd7bc091SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*dd7bc091SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*dd7bc091SAndrew Rist * distributed with this work for additional information 6*dd7bc091SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*dd7bc091SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*dd7bc091SAndrew Rist * "License"); you may not use this file except in compliance 9*dd7bc091SAndrew Rist * with the License. You may obtain a copy of the License at 10*dd7bc091SAndrew Rist * 11*dd7bc091SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*dd7bc091SAndrew Rist * 13*dd7bc091SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*dd7bc091SAndrew Rist * software distributed under the License is distributed on an 15*dd7bc091SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*dd7bc091SAndrew Rist * KIND, either express or implied. See the License for the 17*dd7bc091SAndrew Rist * specific language governing permissions and limitations 18*dd7bc091SAndrew Rist * under the License. 19*dd7bc091SAndrew Rist * 20*dd7bc091SAndrew Rist *************************************************************/ 21*dd7bc091SAndrew Rist 22*dd7bc091SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef X2C_DEPENDY_HXX 25cdf0e10cSrcweir #define X2C_DEPENDY_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <vector> 29cdf0e10cSrcweir #include <map> 30cdf0e10cSrcweir #include <set> 31cdf0e10cSrcweir #include <../support/sistr.hxx> 32cdf0e10cSrcweir 33cdf0e10cSrcweir class Service; 34cdf0e10cSrcweir class ServiceInfo; 35cdf0e10cSrcweir 36cdf0e10cSrcweir typedef std::vector< Simstr> StringVector; 37cdf0e10cSrcweir typedef std::vector< ServiceInfo* > List_Implementations; 38cdf0e10cSrcweir typedef std::map< Simstr, Service* > Map_Services; 39cdf0e10cSrcweir 40cdf0e10cSrcweir class Service 41cdf0e10cSrcweir { 42cdf0e10cSrcweir public: 43cdf0e10cSrcweir Service( 44cdf0e10cSrcweir const char * i_sName ); 45cdf0e10cSrcweir 46cdf0e10cSrcweir ServiceInfo & AddImplementation( 47cdf0e10cSrcweir const char * i_sLibrary ); /// That is: module-name. 48cdf0e10cSrcweir Name() const49cdf0e10cSrcweir const Simstr & Name() const { return sName; } FirstImplementation() const50cdf0e10cSrcweir const ServiceInfo & FirstImplementation() const 51cdf0e10cSrcweir { return *aImplementations[0]; } 52cdf0e10cSrcweir 53cdf0e10cSrcweir private: 54cdf0e10cSrcweir Simstr sName; 55cdf0e10cSrcweir List_Implementations 56cdf0e10cSrcweir aImplementations; 57cdf0e10cSrcweir }; 58cdf0e10cSrcweir 59cdf0e10cSrcweir class ServiceInfo 60cdf0e10cSrcweir { 61cdf0e10cSrcweir public: 62cdf0e10cSrcweir typedef StringVector List_NeededServices; 63cdf0e10cSrcweir 64cdf0e10cSrcweir ServiceInfo( 65cdf0e10cSrcweir const char * i_sLibrary ); 66cdf0e10cSrcweir 67cdf0e10cSrcweir void AddDependency( 68cdf0e10cSrcweir const char * i_sNeededService ); 69cdf0e10cSrcweir Library() const70cdf0e10cSrcweir const Simstr & Library() const { return sImplementingLibrary; } 71cdf0e10cSrcweir const List_NeededServices & NeededServices() const72cdf0e10cSrcweir NeededServices() const { return aNeededServices; } 73cdf0e10cSrcweir 74cdf0e10cSrcweir 75cdf0e10cSrcweir private: 76cdf0e10cSrcweir Simstr sImplementingLibrary; 77cdf0e10cSrcweir List_NeededServices aNeededServices; 78cdf0e10cSrcweir }; 79cdf0e10cSrcweir 80cdf0e10cSrcweir 81cdf0e10cSrcweir class DependencyFinder 82cdf0e10cSrcweir { 83cdf0e10cSrcweir public: 84cdf0e10cSrcweir DependencyFinder(); 85cdf0e10cSrcweir ~DependencyFinder(); 86cdf0e10cSrcweir 87cdf0e10cSrcweir void GatherData( 88cdf0e10cSrcweir const char * i_sSearchDirectory ); 89cdf0e10cSrcweir 90cdf0e10cSrcweir void FindNeededServices( 91cdf0e10cSrcweir StringVector & o_rLibraries, 92cdf0e10cSrcweir StringVector & o_rServices, 93cdf0e10cSrcweir const Simstr & i_rService ); 94cdf0e10cSrcweir private: 95cdf0e10cSrcweir void ReadFile( 96cdf0e10cSrcweir const char * i_sFilename ); 97cdf0e10cSrcweir void Add2Result( 98cdf0e10cSrcweir const Service & i_rService ); 99cdf0e10cSrcweir 100cdf0e10cSrcweir // Data 101cdf0e10cSrcweir Map_Services aServices; 102cdf0e10cSrcweir 103cdf0e10cSrcweir // Temporary data 104cdf0e10cSrcweir std::set< Simstr > aResult_Libraries; 105cdf0e10cSrcweir std::set< Simstr > aResult_Services; 106cdf0e10cSrcweir }; 107cdf0e10cSrcweir 108cdf0e10cSrcweir 109cdf0e10cSrcweir 110cdf0e10cSrcweir #endif 111cdf0e10cSrcweir 112cdf0e10cSrcweir 113