1 ///////////////////////////////////////////////////////////
2 // Softwarebauelemente II, Aufgabe C1.1
3 //
4 // author: Stephan Brumme
5 // last changes: July 3, 2001
6
7 #if !defined(AFX_HOUSE_H__A8EA7860_08E1_11D5_9BB7_A8652B9FDD20__INCLUDED_)
8 #define AFX_HOUSE_H__A8EA7860_08E1_11D5_9BB7_A8652B9FDD20__INCLUDED_
9
10
11 #if _MSC_VER > 1000
12 #pragma once
13 #endif // _MSC_VER > 1000
14
15
16 // STL's list container
17 #include <set>
18
19 // CRoom used as member variable
20 #include "Room.h"
21 // CDate used as member variable
22 #include "Date.h"
23 // template used to compare two objects
24 #include "MyLess.tli"
25
26
27 // disable compiler warning (too long names)
28 #pragma warning (disable: 4786)
29
30
31 class CHouse : public CBasicClass
{
32 // define new types for using the set
33 // typedef set<CRoom> TSetOfRooms;
34 typedef set<CRoom, MyLess<CRoom> > TSetOfRooms;
35 typedef TSetOfRooms::iterator TSetCursor;
36 typedef TSetOfRooms::const_iterator TSetConstCursor;
37
38 // my own iterator
39 typedef void (*TIteratorFunc) (CRoom*);
40
41 public:
42 // constructs a new house using its date of foundation (default: today)
43 CHouse();
44 CHouse(const CHouse& house);
45 CHouse(const CDate& dtDateOfFoundation);
46
47 // return class name
48 virtual string ClassnameOf() const { return "CHouse"; }
49
50 // display the attributes
51 virtual string Show() const;
52 // only for internal purposes !
53 virtual string ShowDebug() const;
54
55 // validate a house
56 virtual bool ClassInvariant() const;
57
58 // compare two houses
59 bool operator==(const CHouse& house) const;
60 virtual bool EqualValue(const CBasicClass* pClass) const;
61
62 // copy one house to another one
63 CHouse& operator=(const CHouse &house);
64 virtual bool Copy(const CBasicClass* pClass);
65
66 // return date of foundation
67 CDate GetDateOfFoundation() const;
68 // return number of stored rooms
69 int Card() const;
70
71 // insert a new room into the set, TRUE if successful
72 // will fail if room already exists
73 bool Insert(const CRoom& room);
74 // return first stored room, TRUE if successful
75 bool GetFirst(CRoom& room);
76 // return next room, TRUE if successful
77 bool GetNext(CRoom& room);
78 // look for a room and set cursor, TRUE if successful
79 bool Find(const CRoom& room);
80 // return the room the cursor points to, TRUE if successful
81 bool GetCurrent(CRoom& room) const;
82 // erase current room, TRUE if successful
83 bool Scratch();
84
85 // iterate through the set
86 void ForEachDo(const TIteratorFunc iterator);
87 // show elements by calling ForEachDo
88 string ShowUsingForEachDo() const;
89
90 private:
91 CDate m_dtDateOfFoundation;
92
93 TSetOfRooms m_Set;
94 TSetCursor m_itCursor;
95 };
96
97 #endif // !defined(AFX_HOUSE_H__A8EA7860_08E1_11D5_9BB7_A8652B9FDD20__INCLUDED_)
98
99