text.cc (5570:13592d41f290) | text.cc (5581:5e1863e9afa2) |
---|---|
1/* 2 * Copyright (c) 2004-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 93 unchanged lines hidden (view full) --- 102void 103Text::open(std::ostream &_stream) 104{ 105 if (stream) 106 panic("stream already set!"); 107 108 mystream = false; 109 stream = &_stream; | 1/* 2 * Copyright (c) 2004-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 93 unchanged lines hidden (view full) --- 102void 103Text::open(std::ostream &_stream) 104{ 105 if (stream) 106 panic("stream already set!"); 107 108 mystream = false; 109 stream = &_stream; |
110 assert(valid()); | 110 if (!valid()) 111 fatal("Unable to open output stream for writing\n"); |
111} 112 113void 114Text::open(const std::string &file) 115{ 116 if (stream) 117 panic("stream already set!"); 118 119 mystream = true; 120 stream = new ofstream(file.c_str(), ios::trunc); | 112} 113 114void 115Text::open(const std::string &file) 116{ 117 if (stream) 118 panic("stream already set!"); 119 120 mystream = true; 121 stream = new ofstream(file.c_str(), ios::trunc); |
121 assert(valid()); | 122 if (!valid()) 123 fatal("Unable to open statistics file for writing\n"); |
122} 123 124bool 125Text::valid() const 126{ | 124} 125 126bool 127Text::valid() const 128{ |
127 return stream != NULL; | 129 return stream != NULL && stream->good(); |
128} 129 130void 131Text::output() 132{ 133 using namespace Database; 134 135 ccprintf(*stream, "\n---------- Begin Simulation Statistics ----------\n"); --- 615 unchanged lines hidden --- | 130} 131 132void 133Text::output() 134{ 135 using namespace Database; 136 137 ccprintf(*stream, "\n---------- Begin Simulation Statistics ----------\n"); --- 615 unchanged lines hidden --- |