summaryrefslogtreecommitdiffstats
path: root/ue4/mycpu/cdatset.h
blob: 56a0630c7dab6bbda313ebd93a4b96487eff3322 (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
/**
 * @module cdatset
 * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348)
 * @brief  Datatype template and datatype definition for CCPU and CMem
 * @date   26.05.2009
 */

#ifndef CDATSET_H
#define CDATSET_H 1

#include <iostream>
#include "cdat.h"

/**
 * @class CDatSet
 *
 * Datatype template for CCPU and CMem.
 */
class CDatSet
  : public CDat<int>, public boost::operators<CDatSet>
{
  public:
    /**
     * @method CDatSet
     * @brief  Default ctor
     * @param  -
     * @return -
     * @globalvars none
     * @exception  bad_alloc
     * @pre  none
     * @post none
     */
    CDatSet()
    {}

    /**
     * @method CDatSet
     * @brief  Copy constructor for int
     * @param  newval  new value for CDatSet
     * @return -
     * @globalvars none
     * @exception  none
     * @pre  none
     * @post none
     */
    CDatSet(const int newval)
      : CDat<int>(newval)
    {}

    /**
     * @method operator>>
     * @brief  Shift/read operator for inputstream
     * @param  stream  reference to inputstream
     * @param  cdat    reference to object which will be read from stream
     * @return reference to inputstream
     * @globalvars none
     * @exception  none
     * @pre  none
     * @post none
     */
    friend std::istream& operator>>(std::istream & stream, CDatSet& cdat)
    {
      unsigned count = 0;
      while(stream.good() && !stream.eof())
      {
        int val = stream.get();
        if (val != 'o')
          break;
        ++count;
      }
      stream.clear();
      cdat.m_value = count;
      return stream;
    }
};

#endif

/* vim: set et sw=2 ts=2: */