///////////////////////////////////////////////////////////////// // GraphReaderDemo.cpp - Project #2 Experiment reading graphs // // // // Jim Fawcett, CSE687 - Object Oriented Design, Spring 2010 // ///////////////////////////////////////////////////////////////// #include #include /////////////////////////////////////////////////////////// // graph class // Just enough definition to test type decisions for // graph reading template class graph {}; /////////////////////////////////////////////////////////// // global function uses RTTI template bool isTypeOf(T t) { return typeid(S) == typeid(T); } /////////////////////////////////////////////////////////// // GraphReader class - just an incomplete prototype class GraphReader { public: template static bool Read(graph& g); }; template bool GraphReader::Read(graph& g) { std::string testStr; if(isTypeOf(testStr) && isTypeOf(testStr)) { std::cout << "\n will build graph"; // Attempt to read graph from XML file. // If you can't find one, then return false, else read and return true; } if(isTypeOf(testStr) && isTypeOf(3.5)) { std::cout << "\n will build graph"; // Attempt to read graph from XML file. // If you can't find one, then return false, else read and return true; } std::cout << "\n can't read a graph of this type"; return false; // simulates graph of unsupported types } /////////////////////////////////////////////////////////// // Test Stub void main() { graph gss; GraphReader::Read(gss); graph gsd; GraphReader::Read(gsd); graph gds; GraphReader::Read(gds); std::cout << "\n\n"; }