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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.7/] [tools/] [src/] [librtcltools/] [RtclProxyBase.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: RtclProxyBase.hpp 401 2011-07-31 21:02:33Z 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-07-31   401   1.2    add ctor(type,interp,name) for direct usage
17
// 2011-04-23   380   1.1    use boost/function instead of RmethDsc
18
//                           use boost::noncopyable (instead of private dcl's)
19 10 wfjm
// 2011-02-20   363   1.0    Initial version
20
// 2011-02-11   360   0.1    First draft
21
// ---------------------------------------------------------------------------
22
 
23
/*!
24
  \file
25 12 wfjm
  \version $Id: RtclProxyBase.hpp 401 2011-07-31 21:02:33Z mueller $
26 10 wfjm
  \brief   Declaration of class RtclProxyBase.
27
*/
28
 
29
#ifndef included_Retro_RtclProxyBase
30
#define included_Retro_RtclProxyBase 1
31
 
32
#include "tcl.h"
33
 
34
#include <string>
35
#include <map>
36
 
37 12 wfjm
#include "boost/utility.hpp"
38
#include "boost/function.hpp"
39
 
40 10 wfjm
#include "RtclArgs.hpp"
41
 
42
namespace Retro {
43
 
44 12 wfjm
  class RtclProxyBase : private boost::noncopyable {
45 10 wfjm
    public:
46
      static const int kOK  = TCL_OK;
47
      static const int kERR = TCL_ERROR;
48
 
49 12 wfjm
      typedef boost::function<int(RtclArgs&)> methfo_t;
50
 
51
      typedef std::map<std::string, methfo_t> mmap_t;
52 10 wfjm
      typedef mmap_t::iterator         mmap_it_t;
53
      typedef mmap_t::const_iterator   mmap_cit_t;
54
      typedef mmap_t::value_type       mmap_val_t;
55
 
56
      explicit      RtclProxyBase(const std::string& type = std::string());
57 12 wfjm
                    RtclProxyBase(const std::string& type, Tcl_Interp* interp,
58
                                  const char* name);
59 10 wfjm
      virtual       ~RtclProxyBase();
60
 
61
      virtual int   ClassCmdConfig(Tcl_Interp* interp, int objc,
62
                                   Tcl_Obj* const objv[]);
63
 
64
      const std::string& Type() const;
65
      Tcl_Command        Token() const;
66
 
67
    protected:
68
      void          SetType(const std::string& type);
69
 
70 12 wfjm
      void          AddMeth(const std::string& name, const methfo_t& methfo);
71
 
72 10 wfjm
      void          CreateObjectCmd(Tcl_Interp* interp, const char* name);
73
 
74
      int           TclObjectCmd(Tcl_Interp* interp, int objc,
75
                                 Tcl_Obj* const objv[]);
76
 
77
      static int    ThunkTclObjectCmd(ClientData cdata, Tcl_Interp* interp,
78
                                      int objc, Tcl_Obj* const objv[]);
79
      static void   ThunkTclCmdDeleteProc(ClientData cdata);
80
      static void   ThunkTclExitProc(ClientData cdata);
81
 
82
    protected:
83
      std::string   fType;                  //!< proxied type name
84
      mmap_t        fMapMeth;               //!< map for named methods
85
      Tcl_Interp*   fInterp;                //!< tcl interpreter
86
      Tcl_Command   fCmdToken;              //!< cmd token for object command
87
  };
88
 
89
} // end namespace Retro
90
 
91
#if !(defined(Retro_NoInline) || defined(Retro_RtclProxyBase_NoInline))
92
#include "RtclProxyBase.ipp"
93
#endif
94
 
95
#endif

powered by: WebSVN 2.1.0

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