summaryrefslogtreecommitdiff
path: root/libvtv/testsuite/template-list-iostream.cc
blob: a35fd308382dfced51b8b91f1cd42ef29ce76b5a (plain)
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
111
112
113
114
115
116
117
118
#include <assert.h>
#include <iostream>
#include <fstream>

using std::ofstream;
using std::ifstream;
using std::ios;

extern "C" int printf(const char *, ...);

class Subscriptor
{
  public:

  Subscriptor() : counter(1) {}

  virtual ~Subscriptor()
  {
    counter--;
    assert(counter == 0);
  }

  private:
    mutable int counter;
};

template <int dim> struct Function
{
  Function(int i): value(dim + i) {}
  int value;
};

template <int dim> struct Triangulation
{

};

template <int dim> struct Exercise_2_3
{
  enum { DIM = dim };
};

  template <int dim>
  struct SetUpBase : public Subscriptor
  {
      virtual
      const Function<dim> get_boundary_values () const = 0;

      virtual
      const Function<dim> get_right_hand_side () const = 0;

    //      virtual
    //      void create_coarse_grid (Triangulation<dim> &coarse_grid) const = 0;
  };

  template <class Traits, int dim>
  struct SetUp : public SetUpBase<dim>
  {
      SetUp () {};

      virtual
      const Function<dim>  get_boundary_values () const
    { return Function<dim>(Traits::DIM); }

      virtual
      const Function<dim>  get_right_hand_side () const
    { return Function<dim>(Traits::DIM); }

    //      virtual
    //      void create_coarse_grid (Triangulation<dim> &coarse_grid) const;

    //      static const typename Traits::BoundaryValues boundary_values;
    //      static const typename Traits::RightHandSide  right_hand_side;
  };


void myread(std::istream * in)
{
  char input_str[50] = "\0";
  if (in->good())
    (*in) >> input_str;
  std::cout << input_str << std::endl;
  delete in;
}



int main()
{
  /*

  SetUp<Exercise_2_3<1000>, 2> s1a;
  SetUp<Exercise_2_3<2000>, 1> s2;
  SetUp<Exercise_2_3<2000>, 2> s2a;
  return s1->get_boundary_values().value + s1a.get_boundary_values().value +
      s2.get_boundary_values().value + s2a.get_boundary_values().value +
      s1->get_right_hand_side().value + s1a.get_right_hand_side().value +
      s2.get_right_hand_side().value + s2a.get_right_hand_side().value;
  */

  SetUp<Exercise_2_3<1000>, 1> * s1 =  new  SetUp<Exercise_2_3<1000>, 1>();

  printf("%d\n", s1->get_boundary_values().value);

  ifstream * infile = new ifstream("./template-list-iostream.cc");

  myread(infile);

  ofstream * outfile = new ofstream("/tmp/xxx.txt");

  if (outfile->good())
    (*outfile) << "hello there" << std::endl;
  std::cerr << "Reached End" << std::endl;

  delete outfile;

  return 0;
}