Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/CDiaInst.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations) (download) (as text)
Sun Aug 15 01:53:13 2010 UTC (13 years, 9 months ago) by okadu
File MIME type: text/x-chdr
File size: 4600 byte(s)


1 #ifndef CDIAINST_H_INCLUDED
2 #define CDIAINST_H_INCLUDED
3
4 class CListElement;
5 class CListView;
6 class CTrainGroup;
7
8 /*
9 * ダイヤ要素基本クラス
10 */
11 class CDiaElementBase{
12 friend class CDiaDialogBase;
13 friend class CDiaListBase;
14 protected:
15 CListElement *m_ListElement; // リスト要素
16 public:
17 CDiaElementBase();
18 virtual ~CDiaElementBase(){}
19 void UpdateCaption();
20 virtual string GetListCaption() = 0;
21 virtual char *Label() = 0;
22 virtual char *Read(char *) = 0;
23 virtual void Save(FILE *, char *) = 0;
24 };
25
26 // 反復子
27 typedef list<CDiaElementBase *>::iterator IPDiaElementBase;
28
29 /*
30 * ダイヤリスト基本クラス
31 */
32 class CDiaListBase{
33 friend class CDiaDialogBase;
34 friend class CDiaInstBase;
35 protected:
36 bool m_UseDefault; // デフォルト設定を使用
37 list<CDiaElementBase *> m_DiaList; // ダイヤリスト
38 public:
39 CDiaListBase();
40 virtual ~CDiaListBase(){}
41 void Free();
42 int Size(){ return m_DiaList.size(); }
43 void ListElement(CListView *, int);
44 int AddElement(CDiaElementBase *);
45 int DeleteElement(CDiaElementBase *);
46 void RotateElement(bool);
47 CDiaElementBase *DequeueBase(bool);
48 virtual CDiaElementBase *NewEntry() = 0;
49 virtual char *Label() = 0;
50 char *Read(char *, CTrainGroup **);
51 void Save(FILE *, char *, CTrainGroup *);
52 };
53
54 // 反復子
55 typedef map<CTrainGroup *, CDiaListBase *>::iterator IPDiaListBase;
56
57 /*
58 * ダイヤ関連インスタンス基本クラス
59 */
60 class CDiaInstBase{
61 friend class CDiaDialogBase;
62 protected:
63 string m_Name; // 名称
64 map<CTrainGroup *, CDiaListBase *> m_DiaMap; // ダイヤマップ
65 public:
66 virtual ~CDiaInstBase();
67 bool IsInside(CTrainGroup *group){ return !!m_DiaMap.count(group); }
68 bool IsDefault(CTrainGroup *group){
69 return m_DiaMap.count(group) ? m_DiaMap[group]->m_UseDefault : true;
70 }
71 CDiaListBase *Search(CTrainGroup *);
72 CDiaListBase *SearchEffectBase(CTrainGroup *);
73 CDiaElementBase *DequeueBase(CTrainGroup *g){ return SearchEffectBase(g)->DequeueBase(true); }
74 void DeleteGroup(CTrainGroup *g){ m_DiaMap.erase(g); }
75 virtual CDiaListBase *NewEntry() = 0;
76 virtual char *Label() = 0;
77 void RestoreAddress();
78 char *Read(char *);
79 void Save(FILE *, char *);
80 };
81
82 #define CDIAINSTBASE_CASTFUNC(el, li) \
83 li *SearchEffect(CTrainGroup *g){ return (li *)SearchEffectBase(g); } \
84 el *Dequeue(CTrainGroup *g){ return (el *)DequeueBase(g); }
85
86 ////////////////////////////////////////////////////////////////////////////////
87 ////////////////////////////////////////////////////////////////////////////////
88
89 /*
90 * ポイント切替要素
91 */
92 class CPointElement: public CDiaElementBase{
93 friend class CPointDialog;
94 private:
95 int m_PointSwitch;
96 public:
97 CPointElement();
98 string GetListCaption();
99 int GetValue(){ return m_PointSwitch; }
100 void SetValue(int p){ m_PointSwitch = p; }
101 int CalcPoint();
102 char *Label(){ return "PointElement"; }
103 char *Read(char *);
104 void Save(FILE *, char *);
105 };
106
107 /*
108 * ポイント切替要素リスト
109 */
110 class CPointList: public CDiaListBase{
111 private:
112 public:
113 virtual CDiaElementBase *NewEntry(){ return new CPointElement; }
114 char *Label(){ return "PointList"; }
115 };
116
117 /*
118 * ポイント切替マップ
119 */
120 class CPointInst: public CDiaInstBase{
121 private:
122 public:
123 virtual CDiaListBase *NewEntry(){ return new CPointList; }
124 char *Label(){ return "PointInst"; }
125 CDIAINSTBASE_CASTFUNC(CPointElement, CPointList);
126 };
127
128 ////////////////////////////////////////////////////////////////////////////////
129 ////////////////////////////////////////////////////////////////////////////////
130
131 /*
132 * ダイヤ設定要素
133 */
134 class CDiaElement: public CDiaElementBase{
135 friend class CDiaDialog;
136 friend class CTrainGroup;
137 private:
138 int m_Action; // 動作
139 int m_TimeType; // 時間設定
140 int m_Hour; // 時
141 int m_Minute; // 分
142 int m_Second; // 秒
143 // int m_Joint; // 連結を受け入れる
144 float m_Offset; // 停車位置
145 public:
146 CDiaElement();
147 string GetListCaption();
148 double GetTime(){ return (m_Hour+(m_Minute+m_Second/60.0)/60.0)/24.0; }
149 char *Label(){ return "DiaElement"; }
150 char *Read(char *);
151 void Save(FILE *, char *);
152 };
153
154 /*
155 * ダイヤ設定要素リスト
156 */
157 class CDiaList: public CDiaListBase{
158 private:
159 public:
160 virtual CDiaElementBase *NewEntry(){ return new CDiaElement; }
161 char *Label(){ return "DiaList"; }
162 };
163
164 /*
165 * ダイヤ設定マップ
166 */
167 class CDiaInst: public CDiaInstBase{
168 private:
169 public:
170 virtual CDiaListBase *NewEntry(){ return new CDiaList; }
171 char *Label(){ return "DiaInst"; }
172 CDIAINSTBASE_CASTFUNC(CDiaElement, CDiaList);
173 };
174
175 // 外部グローバル
176 extern char *g_DiaDefaultString[];
177
178 #endif

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26