2 * Copyright (C) 2003-2006 Gabest
3 * http://www.gabest.org
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
25 #include "StringMap.h"
32 enum NodePriority
{PLow
, PNormal
, PHigh
};
41 CAtlList
<Node
*> m_nodes
;
42 StringMapW
<Node
*> m_name2node
;
43 CStringW m_type
, m_name
;
44 NodePriority m_priority
;
47 Node(NodeFactory
* pnf
, CStringW name
);
52 bool IsType(CStringW type
);
54 virtual void AddTail(Node
* pNode
);
55 virtual void GetChildDefs(CAtlList
<Definition
*>& l
, LPCWSTR type
= NULL
, bool fFirst
= true);
56 virtual void Dump(OutputStream
& s
, int level
= 0, bool fLast
= false) = 0;
59 class Reference
: public Node
62 Reference(NodeFactory
* pnf
, CStringW name
);
65 void GetChildDefs(CAtlList
<Definition
*>& l
, LPCWSTR type
= NULL
, bool fFirst
= true);
66 void Dump(OutputStream
& s
, int level
= 0, bool fLast
= false);
69 class Definition
: public Node
72 template<typename T
> struct Number
{T value
; int sign
; CStringW unit
;};
73 struct Time
{Number
<float> start
, stop
;};
75 enum status_t
{node
, string
, number
, boolean
, block
};
80 CStringW m_value
, m_unit
;
82 CStringW m_num_string
;
84 StringMapW
<Definition
*> m_type2def
;
85 void RemoveFromCache(LPCWSTR type
= NULL
);
88 void GetAsNumber(Number
<T
>& n
, StringMapW
<T
>* n2n
= NULL
);
91 Definition(NodeFactory
* pnf
, CStringW name
);
92 virtual ~Definition();
94 bool IsVisible(Definition
* pDef
);
96 void AddTail(Node
* pNode
);
97 void Dump(OutputStream
& s
, int level
= 0, bool fLast
= false);
99 Definition
& operator[] (LPCWSTR type
);
101 bool IsValue(status_t s
= (status_t
)0);
103 void SetAsValue(status_t s
, CStringW v
, CStringW u
= L
"");
104 void SetAsNumber(CStringW v
, CStringW u
= L
"");
106 void GetAsString(CStringW
& str
);
107 void GetAsNumber(Number
<int>& n
, StringMapW
<int>* n2n
= NULL
);
108 void GetAsNumber(Number
<DWORD
>& n
, StringMapW
<DWORD
>* n2n
= NULL
);
109 void GetAsNumber(Number
<float>& n
, StringMapW
<float>* n2n
= NULL
);
111 void GetAsNumber(T
& t
, StringMapW
<T
>* n2n
= NULL
) {Number
<T
> n
; GetAsNumber(n
, n2n
); t
= n
.value
;}
112 void GetAsBoolean(bool& b
);
113 bool GetAsTime(Time
& t
, StringMapW
<float>& offset
, StringMapW
<float>* n2n
= NULL
, int default_id
= 0);
119 Definition
* SetChildAsValue(CStringW path
, status_t s
, CStringW v
, CStringW u
= L
"");
120 Definition
* SetChildAsNumber(CStringW path
, CStringW v
, CStringW u
= L
"");