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

Subversion Repositories w11

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

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

Line No. Rev Author Line
1 10 wfjm
// $Id: RlinkPort.hpp 375 2011-04-02 07:56:47Z mueller $
2
//
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
// 2011-03-27   375   1.0    Initial version
17
// 2011-01-15   356   0.1    First draft
18
// ---------------------------------------------------------------------------
19
 
20
 
21
/*!
22
  \file
23
  \version $Id: RlinkPort.hpp 375 2011-04-02 07:56:47Z mueller $
24
  \brief   Declaration of class RlinkPort.
25
*/
26
 
27
#ifndef included_Retro_RlinkPort
28
#define included_Retro_RlinkPort 1
29
 
30
#include <string>
31
#include <map>
32
 
33
#include "librtools/RerrMsg.hpp"
34
#include "librtools/RlogFile.hpp"
35
#include "librtools/Rstats.hpp"
36
 
37
namespace Retro {
38
 
39
  class RlinkPort {
40
    public:
41
      typedef std::map<std::string, std::string> omap_t;
42
      typedef omap_t::iterator         omap_it_t;
43
      typedef omap_t::const_iterator   omap_cit_t;
44
      typedef omap_t::value_type       omap_val_t;
45
 
46
                    RlinkPort();
47
      virtual       ~RlinkPort();
48
 
49
      virtual bool  Open(const std::string& url, RerrMsg& emsg) = 0;
50
      virtual void  Close();
51
 
52
      virtual int   Read(uint8_t* buf, size_t size, double timeout,
53
                         RerrMsg& emsg);
54
      virtual int   Write(const uint8_t* buf, size_t size, RerrMsg& emsg);
55
      virtual bool  PollRead(double timeout);
56
 
57
      bool          IsOpen() const;
58
      const std::string&  Url() const;
59
      const std::string&  UrlScheme() const;
60
      const std::string&  UrlPath() const;
61
      const omap_t&       UrlOpts() const;
62
      bool                UrlFindOpt(const std::string& name) const;
63
      bool                UrlFindOpt(const std::string& name,
64
                                     std::string& value) const;
65
 
66
      int           FdRead() const;
67
      int           FdWrite() const;
68
 
69
      void          SetLogFile(RlogFile* log);
70
      void          SetTraceLevel(size_t level);
71
      size_t        TraceLevel() const;
72
 
73
      const Rstats& Stats() const;
74
 
75
      virtual void  Dump(std::ostream& os, int ind=0, const char* text=0) const;
76
 
77
    // some constants
78
      static const int  kEof  = 0;
79
      static const int  kTout = -1;
80
      static const int  kErr  = -2;
81
 
82
    // statistics counter indices
83
      enum stats {
84
        kStatNPortWrite = 0,
85
        kStatNPortRead,
86
        kStatNPortTxByt,
87
        kStatNPortRxByt,
88
        kDimStat
89
      };
90
 
91
    protected:
92
      bool          ParseUrl(const std::string& url, const std::string& optlist,
93
                             RerrMsg& emsg);
94
      bool          AddOpt(const std::string& key, const std::string& val,
95
                           bool hasval, const std::string& optlist,
96
                           RerrMsg& emsg);
97
 
98
    protected:
99
      bool          fIsOpen;                //!< is open flag
100
      std::string   fUrl;                   //!< full url given with open
101
      std::string   fScheme;                //!< url scheme part
102
      std::string   fPath;                  //!< url path part
103
      omap_t        fOptMap;                //!< option map
104
      int           fFdRead;                //!< fd for read
105
      int           fFdWrite;               //!< fd for write
106
      RlogFile*     fpLogFile;              //!< ptr to log file dsc
107
      size_t        fTraceLevel;            //!< trace level
108
      Rstats        fStats;                 //!< statistics
109
 
110
    // RlinkPort is not copyable and assignable
111
    private:
112
                    RlinkPort(const RlinkPort& rhs);
113
      RlinkPort&    operator=(const RlinkPort& rhs);
114
 
115
  };
116
 
117
} // end namespace Retro
118
 
119
#if !(defined(Retro_NoInline) || defined(Retro_RlinkPort_NoInline))
120
#include "RlinkPort.ipp"
121
#endif
122
 
123
#endif

powered by: WebSVN 2.1.0

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