source: to-imperative/trunk/runtime/rf_channel.ih @ 840

Last change on this file since 840 was 840, checked in by pooh, 18 years ago
  • Implemented missing StdIO::Print* and StdIO::Write* functions.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.2 KB
Line 
1#ifndef __rf_channel_ih__
2#define __rf_channel_ih__
3
4#include "rf_channel.hh"
5#include "rf_object.ih"
6#include "rf_expr.ih"
7
8#include <typeinfo>
9
10namespace rftype
11{
12
13inline Channel::Channel (FILE* _fp /* = null */) :
14  fp (_fp)
15{}
16
17inline Channel::Channel (Channel const& _channel) :
18  Object (),
19  fp (_channel.fp)
20{}
21
22inline Channel::~Channel ()
23{
24  close();
25}
26
27inline Channel& Channel::operator = (Channel const& _channel)
28{
29  if (this != &_channel) {
30    this->~Channel();
31    new(this) Channel(_channel);
32  }
33  return self;
34}
35
36inline unsigned Channel::get_type () const
37{
38  return reg.get_type();
39}
40
41//
42// FIXME: Return proper hash value
43inline uint32_t Channel::hash () const
44{
45  return 0;
46}
47
48inline bool Channel::operator == (Object const& _obj) const
49{
50  try {
51    Channel const& ch = dynamic_cast<Channel const&>(_obj);
52    return fp == ch.fp;
53  } catch (std::bad_cast&) {
54    return false;
55  }
56}
57
58inline bool Channel::open (char const* _fname, char const* _mode)
59{
60  if (fp != 0) fclose(fp);
61  fp = fopen(_fname, _mode);
62  return fp != null ? true : false;
63}
64
65inline void Channel::close ()
66{
67  if (fp != 0) fclose(fp);
68}
69
70inline FILE* Channel::get_fp () const
71{
72  return fp;
73}
74
75}
76
77#endif // __rf_channel_ih__
Note: See TracBrowser for help on using the repository browser.