output.hh revision 5402
11388SN/A/* 21388SN/A * Copyright (c) 2005 The Regents of The University of Michigan 31388SN/A * All rights reserved. 41388SN/A * 51388SN/A * Redistribution and use in source and binary forms, with or without 61388SN/A * modification, are permitted provided that the following conditions are 71388SN/A * met: redistributions of source code must retain the above copyright 81388SN/A * notice, this list of conditions and the following disclaimer; 91388SN/A * redistributions in binary form must reproduce the above copyright 101388SN/A * notice, this list of conditions and the following disclaimer in the 111388SN/A * documentation and/or other materials provided with the distribution; 121388SN/A * neither the name of the copyright holders nor the names of its 131388SN/A * contributors may be used to endorse or promote products derived from 141388SN/A * this software without specific prior written permission. 151388SN/A * 161388SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 171388SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 181388SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 191388SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 201388SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 211388SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 221388SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 231388SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 241388SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 251388SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 261388SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Nathan Binkert 291388SN/A */ 301388SN/A 311388SN/A#ifndef __BASE_OUTPUT_HH__ 321388SN/A#define __BASE_OUTPUT_HH__ 331388SN/A 341388SN/A#include <iosfwd> 351388SN/A#include <map> 361388SN/A#include <string> 371388SN/A 381388SN/Aclass OutputDirectory 391388SN/A{ 401388SN/A private: 411388SN/A typedef std::map<std::string, std::ostream *> map_t; 421388SN/A 431388SN/A map_t files; 441388SN/A std::string dir; 451388SN/A 465402Ssaidi@eecs.umich.edu std::string resolve(const std::string &name); 475402Ssaidi@eecs.umich.edu 481388SN/A public: 491388SN/A OutputDirectory(); 501388SN/A ~OutputDirectory(); 511388SN/A 521388SN/A void setDirectory(const std::string &dir); 531388SN/A const std::string &directory(); 541388SN/A 554840Ssaidi@eecs.umich.edu std::ostream *create(const std::string &name, bool binary = false); 561388SN/A std::ostream *find(const std::string &name); 571388SN/A 581388SN/A static bool isFile(const std::ostream *os); 591388SN/A static inline bool isFile(const std::ostream &os) { return isFile(&os); } 601388SN/A}; 611388SN/A 621388SN/Aextern OutputDirectory simout; 631388SN/A 641388SN/A#endif // __BASE_OUTPUT_HH__ 65