OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.61/] [tools/] [src/] [librlink/] [RlinkPort.hpp] - Blame information for rev 12

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 wfjm
// $Id: RlinkPort.hpp 380 2011-04-25 18:14:52Z mueller $
2 10 wfjm
//
3
// Copyright 2011- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
//
5
// This program is free software; you may redistribute and/or modify it under
6
// the terms of the GNU General Public License as published by the Free
7
// Software Foundation, either version 2, or at your option any later version.
8
//
9
// This program is distributed in the hope that it will be useful, but
10
// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
// for complete details.
13
// 
14
// Revision History: 
15
// Date         Rev Version  Comment
16 12 wfjm
// 2011-04-24   380   1.0.1  use boost::noncopyable (instead of private dcl's)
17 10 wfjm
// 2011-03-27   375   1.0    Initial version
18
// 2011-01-15   356   0.1    First draft
19
// ---------------------------------------------------------------------------
20
 
21
 
22
/*!
23
  \file
24 12 wfjm
  \version $Id: RlinkPort.hpp 380 2011-04-25 18:14:52Z mueller $
25 10 wfjm
  \brief   Declaration of class RlinkPort.
26
*/
27
 
28
#ifndef included_Retro_RlinkPort
29
#define included_Retro_RlinkPort 1
30
 
31
#include <string>
32
#include <map>
33
 
34 12 wfjm
#include "boost/utility.hpp"
35
 
36 10 wfjm
#include "librtools/RerrMsg.hpp"
37
#include "librtools/RlogFile.hpp"
38
#include "librtools/Rstats.hpp"
39
 
40
namespace Retro {
41
 
42 12 wfjm
  class RlinkPort : private boost::noncopyable {
43 10 wfjm
    public:
44
      typedef std::map<std::string, std::string> omap_t;
45
      typedef omap_t::iterator         omap_it_t;
46
      typedef omap_t::const_iterator   omap_cit_t;
47
      typedef omap_t::value_type       omap_val_t;
48
 
49
                    RlinkPort();
50
      virtual       ~RlinkPort();
51
 
52
      virtual bool  Open(const std::string& url, RerrMsg& emsg) = 0;
53
      virtual void  Close();
54
 
55
      virtual int   Read(uint8_t* buf, size_t size, double timeout,
56
                         RerrMsg& emsg);
57
      virtual int   Write(const uint8_t* buf, size_t size, RerrMsg& emsg);
58
      virtual bool  PollRead(double timeout);
59
 
60
      bool          IsOpen() const;
61
      const std::string&  Url() const;
62
      const std::string&  UrlScheme() const;
63
      const std::string&  UrlPath() const;
64
      const omap_t&       UrlOpts() const;
65
      bool                UrlFindOpt(const std::string& name) const;
66
      bool                UrlFindOpt(const std::string& name,
67
                                     std::string& value) const;
68
 
69
      int           FdRead() const;
70
      int           FdWrite() const;
71
 
72
      void          SetLogFile(RlogFile* log);
73
      void          SetTraceLevel(size_t level);
74
      size_t        TraceLevel() const;
75
 
76
      const Rstats& Stats() const;
77
 
78
      virtual void  Dump(std::ostream& os, int ind=0, const char* text=0) const;
79
 
80
    // some constants
81
      static const int  kEof  = 0;
82
      static const int  kTout = -1;
83
      static const int  kErr  = -2;
84
 
85
    // statistics counter indices
86
      enum stats {
87
        kStatNPortWrite = 0,
88
        kStatNPortRead,
89
        kStatNPortTxByt,
90
        kStatNPortRxByt,
91
        kDimStat
92
      };
93
 
94
    protected:
95
      bool          ParseUrl(const std::string& url, const std::string& optlist,
96
                             RerrMsg& emsg);
97
      bool          AddOpt(const std::string& key, const std::string& val,
98
                           bool hasval, const std::string& optlist,
99
                           RerrMsg& emsg);
100
 
101
    protected:
102
      bool          fIsOpen;                //!< is open flag
103
      std::string   fUrl;                   //!< full url given with open
104
      std::string   fScheme;                //!< url scheme part
105
      std::string   fPath;                  //!< url path part
106
      omap_t        fOptMap;                //!< option map
107
      int           fFdRead;                //!< fd for read
108
      int           fFdWrite;               //!< fd for write
109
      RlogFile*     fpLogFile;              //!< ptr to log file dsc
110
      size_t        fTraceLevel;            //!< trace level
111
      Rstats        fStats;                 //!< statistics
112
  };
113
 
114
} // end namespace Retro
115
 
116
#if !(defined(Retro_NoInline) || defined(Retro_RlinkPort_NoInline))
117
#include "RlinkPort.ipp"
118
#endif
119
 
120
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.