src/share/vm/utilities/ostream.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 






  25 // Output streams for printing
  26 //
  27 // Printing guidelines:
  28 // Where possible, please use tty->print() and tty->print_cr().
  29 // For product mode VM warnings use warning() which internally uses tty.
  30 // In places where tty is not initialized yet or too much overhead,
  31 // we may use jio_printf:
  32 //     jio_fprintf(defaultStream::output_stream(), "Message");
  33 // This allows for redirection via -XX:+DisplayVMOutputToStdout and
  34 // -XX:+DisplayVMOutputToStderr
  35 class outputStream : public ResourceObj {
  36  protected:
  37    int _indentation; // current indentation
  38    int _width;       // width of the page
  39    int _position;    // position on the current line
  40    int _newlines;    // number of '\n' output so far
  41    julong _precount; // number of chars output, less _position
  42    TimeStamp _stamp; // for time stamps
  43 
  44    void update_position(const char* s, size_t len);


 228 
 229 #ifndef PRODUCT
 230 
 231 class networkStream : public bufferedStream {
 232 
 233   private:
 234     int _socket;
 235 
 236   public:
 237     networkStream();
 238     ~networkStream();
 239 
 240     bool connect(const char *host, short port);
 241     bool is_open() const { return _socket != -1; }
 242     int read(char *buf, size_t len);
 243     void close();
 244     virtual void flush();
 245 };
 246 
 247 #endif


   1 /*
   2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_UTILITIES_OSTREAM_HPP
  26 #define SHARE_VM_UTILITIES_OSTREAM_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "runtime/timer.hpp"
  30 
  31 // Output streams for printing
  32 //
  33 // Printing guidelines:
  34 // Where possible, please use tty->print() and tty->print_cr().
  35 // For product mode VM warnings use warning() which internally uses tty.
  36 // In places where tty is not initialized yet or too much overhead,
  37 // we may use jio_printf:
  38 //     jio_fprintf(defaultStream::output_stream(), "Message");
  39 // This allows for redirection via -XX:+DisplayVMOutputToStdout and
  40 // -XX:+DisplayVMOutputToStderr
  41 class outputStream : public ResourceObj {
  42  protected:
  43    int _indentation; // current indentation
  44    int _width;       // width of the page
  45    int _position;    // position on the current line
  46    int _newlines;    // number of '\n' output so far
  47    julong _precount; // number of chars output, less _position
  48    TimeStamp _stamp; // for time stamps
  49 
  50    void update_position(const char* s, size_t len);


 234 
 235 #ifndef PRODUCT
 236 
 237 class networkStream : public bufferedStream {
 238 
 239   private:
 240     int _socket;
 241 
 242   public:
 243     networkStream();
 244     ~networkStream();
 245 
 246     bool connect(const char *host, short port);
 247     bool is_open() const { return _socket != -1; }
 248     int read(char *buf, size_t len);
 249     void close();
 250     virtual void flush();
 251 };
 252 
 253 #endif
 254 
 255 #endif // SHARE_VM_UTILITIES_OSTREAM_HPP