1 ///////////////////////////////////////////////////////////
2 // Softwarebauelemente II, Aufgabe C1.2
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 {
33 // define new types for using the set
34 // typedef set<CRoom> TSetOfRooms;
35 typedef set<CRoom, MyLess<CRoom> > TSetOfRooms;
36 typedef TSetOfRooms::iterator TSetCursor;
37 typedef TSetOfRooms::const_iterator TSetConstCursor;
38
39 public:
40 // constructs a new house using its date of foundation (default: today)
41 CHouse();
42 CHouse(const CHouse& house);
43 CHouse(const CDate& dtDateOfFoundation);
44
45 // return class name
46 virtual string ClassnameOf() const { return "CHouse"; }
47
48 // display the attributes
49 virtual string Show() const;
50 // only for internal purposes !
51 virtual string ShowDebug() const;
52
53 // validate a house
54 virtual bool ClassInvariant() const;
55
56 // compare two houses
57 bool operator==(const CHouse& house) const;
58 virtual bool EqualValue(const CBasicClass* pClass) const;
59
60 // copy one house to another one
61 CHouse& operator=(const CHouse &house);
62 virtual bool Copy(const CBasicClass* pClass);
63
64 // return date of foundation
65 CDate GetDateOfFoundation() const;
66 // return number of stored rooms
67 int Card() const;
68
69 // insert a new room into the set, TRUE if successful
70 // will fail if room already exists
71 bool Insert(const CRoom& room);
72 // return first stored room, TRUE if successful
73 bool GetFirst(CRoom& room);
74 // return next room, TRUE if successful
75 bool GetNext(CRoom& room);
76 // look for a room and set cursor, TRUE if successful
77 bool Find(const CRoom& room);
78 // return the room the cursor points to, TRUE if successful
79 bool GetCurrent(CRoom& room) const;
80 // erase current room, TRUE if successful
81 bool Scratch();
82
83 private:
84 CDate m_dtDateOfFoundation;
85
86 TSetOfRooms m_Set;
87 TSetCursor m_itCursor;
88 };
89
90 #endif // !defined(AFX_HOUSE_H__A8EA7860_08E1_11D5_9BB7_A8652B9FDD20__INCLUDED_)
91