File: _s__.i

package info (click to toggle)
gnucap-python 0.0.2-1.2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 2,668 kB
  • sloc: python: 7,873; sh: 4,384; cpp: 1,786; makefile: 249
file content (110 lines) | stat: -rw-r--r-- 3,193 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* Copyright (C) 2018 Felix Salfelder
 * Author: Felix Salfelder <felix@salfelder.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 *------------------------------------------------------------------
 */
%module(directors="0", allprotected="1") s__
%feature(director);

%{
#include <s__.h>
%}

%include _u_sim_data.i
%include _c_comand.i
%include _ap.i

#if 0
// does not work. some protected types confuse SWIG.
%include "s__.h"
#else
class SIM : public CMD {
protected:
  SIM();
public:
  ~SIM();
protected: // swig needs to know about these, apparently
  virtual void	setup(CS&)	= 0;
  virtual void	sweep()		= 0;
protected:
  virtual void	outdata(double, int);
  virtual void	head(double,double,const std::string&);
  virtual void	print_results(double);
  virtual void	alarm();
  virtual void	store_results(double);
protected:				/* s__solve.cc */
  void	advance_time();
};
#endif

%extend SIM {
  inline SIM_DATA& sim_(){
    return *self->_sim;
  }
}

// SIM_ is needed since Swig doesn't handle private virtual methods
// or protected enums.
// All non-status methods that are inherited from SIM should also be copied
// here or you will get segmentation faults (really?)
%inline %{
class SIM_ : public SIM {
protected:
  enum TRACE { // how much diagnostics to show
    tNONE      = 0,	/* no extended diagnostics			*/
    tUNDER     = 1,	/* show underlying analysis, important pts only	*/
    tALLTIME   = 2,	/* show every time step, including hidden 	*/
    tREJECTED  = 3,	/* show rejected time steps			*/
    tITERATION = 4,	/* show every iteration, including nonconverged	*/
    tVERBOSE   = 5	/* show extended diagnostics			*/
  };
protected:
  explicit SIM_() : SIM() { }
  ~SIM_() { }
public:
  virtual void  setup(CS&)=0;
  virtual void  sweep()=0;
  virtual void  do_it(CS&, CARD_LIST*){ incomplete(); };
public: // huh?
  virtual void	outdata(double d, int i){ return SIM::outdata(d, i);}
  virtual void	head(double a,double b, const std::string& s){
  return SIM::head(a,b,s);
  }
//  virtual void	print_results(double);
//  virtual void	alarm();
//  virtual void	store_results(double);
protected:
  bool solve(OPT::ITL a, unsigned b){
        return SIM::solve(a, SIM::TRACE(b));
  }
  bool solve_with_homotopy(OPT::ITL a, unsigned b){
        return SIM::solve_with_homotopy(a, SIM::TRACE(b));
  }
public:
  OMSTREAM&   hackout(){return _out;}
};

%}

%extend SIM_ {
  inline OMSTREAM& out_(){
    return self->hackout();
  }
  inline OMSTREAM& out_assign(OMSTREAM& o){
    return self->hackout() = o;
  }
}