Download | Plain Text | No Line Numbers


  1. /**
  2.  * @module cdatset
  3.  * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348)
  4.  * @brief Datatype template and datatype definition for CCPU and CMem
  5.  * @date 26.05.2009
  6.  */
  7.  
  8. #ifndef CDATSET_H
  9. #define CDATSET_H 1
  10.  
  11. #include <iostream>
  12. #include "cdat.h"
  13.  
  14. /**
  15.  * @class CDatSet
  16.  *
  17.  * Datatype template for CCPU and CMem.
  18.  */
  19. class CDatSet
  20. : public CDat<int>, public boost::operators<CDatSet>
  21. {
  22. public:
  23. /**
  24.   * @method CDatSet
  25.   * @brief Default ctor
  26.   * @param -
  27.   * @return -
  28.   * @globalvars none
  29.   * @exception bad_alloc
  30.   * @pre none
  31.   * @post none
  32.   */
  33. CDatSet()
  34. {}
  35.  
  36. /**
  37.   * @method CDatSet
  38.   * @brief Copy constructor for int
  39.   * @param newval new value for CDatSet
  40.   * @return -
  41.   * @globalvars none
  42.   * @exception none
  43.   * @pre none
  44.   * @post none
  45.   */
  46. CDatSet(const int newval)
  47. : CDat<int>(newval)
  48. {}
  49.  
  50. /**
  51.   * @method operator>>
  52.   * @brief Shift/read operator for inputstream
  53.   * @param stream reference to inputstream
  54.   * @param cdat reference to object which will be read from stream
  55.   * @return reference to inputstream
  56.   * @globalvars none
  57.   * @exception none
  58.   * @pre stream != null
  59.   * @post cdat.m_value = count of char 'o'
  60.   */
  61. friend std::istream& operator>>(std::istream & stream, CDatSet& cdat)
  62. {
  63. unsigned count = 0;
  64. while(stream.good() && !stream.eof())
  65. {
  66. int val = stream.get();
  67. if (val != 'o')
  68. break;
  69. ++count;
  70. }
  71. stream.clear();
  72. cdat.m_value = count;
  73. return stream;
  74. }
  75. };
  76.  
  77. #endif
  78.  
  79. /* vim: set et sw=2 ts=2: */
  80.