--- trunk/src/io/basic_teebuf.hpp 2005/02/24 20:55:07 376 +++ trunk/src/io/basic_teebuf.hpp 2010/05/10 17:28:26 1442 @@ -1,4 +1,4 @@ - /* +/* * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. * * The University of Notre Dame grants you ("Licensee") a @@ -6,19 +6,10 @@ * redistribute this software in source and binary code form, provided * that the following conditions are met: * - * 1. Acknowledgement of the program authors must be made in any - * publication of scientific results based in part on use of the - * program. An acceptable form of acknowledgement is citation of - * the article in which the program was described (Matthew - * A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher - * J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented - * Parallel Simulation Engine for Molecular Dynamics," - * J. Comput. Chem. 26, pp. 252-271 (2005)) - * - * 2. Redistributions of source code must retain the above copyright + * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - * 3. Redistributions in binary form must reproduce the above copyright + * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. @@ -37,83 +28,92 @@ * arising out of the use of or inability to use software, even if the * University of Notre Dame has been advised of the possibility of * such damages. + * + * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your + * research, please cite the appropriate papers when you publish your + * work. Good starting points are: + * + * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). + * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). + * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). + * [4] Vardeman & Gezelter, in progress (2009). */ #ifndef UTILS_MULTISTREAMBUF_HPP #define UTILS_MULTISTREAMBUF_HPP #include #include -namespace oopse { +namespace OpenMD { -/** - * @class basic_teebuf basic_teebuf.hpp "utils/basic_teebuf.hpp" - * @brief As a subclass of basic_streambuf, basic_teebuf can operate on multiple stream simultaneously. - * @code - * std::ofstream file1("file1"); - * std::ofstream file2("file22"); - * std::vector buffers; - * buffers.push_back(file1.rdbuf()); - * buffers.push_back(file2.rdbuf()); - * teebuf tmp(buffers.begin(), buffers.end()); - * std::ostream myOs(&tmp); - * myOs << "hello world"; - * @endcode - */ + /** + * @class basic_teebuf basic_teebuf.hpp "utils/basic_teebuf.hpp" + * @brief As a subclass of basic_streambuf, basic_teebuf can operate on multiple stream simultaneously. + * @code + * std::ofstream file1("file1"); + * std::ofstream file2("file22"); + * std::vector buffers; + * buffers.push_back(file1.rdbuf()); + * buffers.push_back(file2.rdbuf()); + * teebuf tmp(buffers.begin(), buffers.end()); + * std::ostream myOs(&tmp); + * myOs << "hello world"; + * @endcode + */ -template > -class basic_teebuf: public std::basic_streambuf { - public: - typedef std::basic_streambuf streambuf_type; - typedef Traits traits_type; - typedef CharT char_type; - typedef typename traits_type::int_type int_type; + template > + class basic_teebuf: public std::basic_streambuf { + public: + typedef std::basic_streambuf streambuf_type; + typedef Traits traits_type; + typedef CharT char_type; + typedef typename traits_type::int_type int_type; - template - basic_teebuf(ForwardIterator begin, ForwardIterator end) : buffers_(begin, end){ + template + basic_teebuf(ForwardIterator begin, ForwardIterator end) : buffers_(begin, end){ - } + } - protected: - int_type overflow(int_type c = traits_type::eof()) { + protected: + int_type overflow(int_type c = traits_type::eof()) { - //avoid writing eof to stream - if (c == traits_type::eof()) { - return traits_type::eof(); - } + //avoid writing eof to stream + if (c == traits_type::eof()) { + return traits_type::eof(); + } - typename std::vector::iterator iter; //typename is needed since it's a dependant name - for (iter = buffers_.begin(); iter != buffers_.end(); ++iter) { - if ((*iter)->sputc(c) == traits_type::eof()) { - return traits_type::eof(); - } - } + typename std::vector::iterator iter; //typename is needed since it's a dependant name + for (iter = buffers_.begin(); iter != buffers_.end(); ++iter) { + if ((*iter)->sputc(c) == traits_type::eof()) { + return traits_type::eof(); + } + } - return traits_type::not_eof(c); - } + return traits_type::not_eof(c); + } - int sync() { + int sync() { - //flush buffer, checking return for eof. - if (traits_type::eq_int_type(overflow(traits_type::eof()), traits_type::eof())) { - return -1; - } + //flush buffer, checking return for eof. + if (traits_type::eq_int_type(overflow(traits_type::eof()), traits_type::eof())) { + return -1; + } - //flush streams - typename std::vector::iterator iter; - for (iter = buffers_.begin(); iter != buffers_.end(); ++iter) { - if ((*iter)->pubsync() == -1) { - return -1; - } - } + //flush streams + typename std::vector::iterator iter; + for (iter = buffers_.begin(); iter != buffers_.end(); ++iter) { + if ((*iter)->pubsync() == -1) { + return -1; + } + } - return 0; - } + return 0; + } - private: - std::vector buffers_; -}; + private: + std::vector buffers_; + }; -typedef basic_teebuf TeeBuf; + typedef basic_teebuf TeeBuf; } #endif