00001 // Torc - Copyright 2011 University of Southern California. All Rights Reserved. 00002 // $HeadURL: https://torc-isi.svn.sourceforge.net/svnroot/torc-isi/branches/staging/0.9/src/torc/examples/PhysicalExample.cpp $ 00003 // $Id: PhysicalExample.cpp 10 2011-10-12 18:40:16Z nsteiner $ 00004 00005 // This program is free software: you can redistribute it and/or modify it under the terms of the 00006 // GNU General Public License as published by the Free Software Foundation, either version 3 of the 00007 // License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 00010 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 00011 // the GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License along with this program. If 00014 // not, see <http://www.gnu.org/licenses/>. 00015 00016 /// \file 00017 /// \brief Example program to read in an XDL file, do something with it, and write it back out. 00018 00019 #include "torc/Physical.hpp" 00020 #include <fstream> 00021 00022 /// \brief Standard main() function. 00023 int main(int argc, char* argv[]) { 00024 00025 // import the XDL design 00026 if(argc < 2) return 0; 00027 std::string inFileName(argv[1]); 00028 std::fstream fileStream(inFileName.c_str()); 00029 if(!fileStream.good()) return -1; 00030 torc::physical::XdlImporter importer; 00031 importer(fileStream, inFileName); 00032 00033 // look up the design (and do something with it ...) 00034 torc::physical::DesignSharedPtr designPtr = importer.getDesignPtr(); 00035 00036 // export the XDL design 00037 std::string outFileName = boost::filesystem::path(inFileName).replace_extension().string() 00038 + ".mod.xdl"; 00039 std::fstream xdlExport(outFileName.c_str(), std::ios_base::out); 00040 torc::physical::XdlExporter fileExporter(xdlExport); 00041 fileExporter(designPtr); 00042 00043 return 0; 00044 }