1 ///###////////////////////////////////////////////////////////////////////////
2 //
3 // Burton Computer Corporation
4 // http://www.burton-computer.com
5 // http://www.cooldevtools.com
6 // $Id: HdlStatement.h 272 2007-01-06 19:37:27Z brian $
7 //
8 // Copyright (C) 2007 Burton Computer Corporation
9 // ALL RIGHTS RESERVED
10 //
11 // This program is open source software; you can redistribute it
12 // and/or modify it under the terms of the Q Public License (QPL)
13 // version 1.0. Use of this software in whole or in part, including
14 // linking it (modified or unmodified) into other programs is
15 // subject to the terms of the QPL.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 // Q Public License for more details.
21 //
22 // You should have received a copy of the Q Public License
23 // along with this program; see the file LICENSE.txt.  If not, visit
24 // the Burton Computer Corporation or CoolDevTools web site
25 // QPL pages at:
26 //
27 //    http://www.burton-computer.com/qpl.html
28 //    http://www.cooldevtools.com/qpl.html
29 //
30 
31 #ifndef _HdlStatement_h
32 #define _HdlStatement_h
33 
34 #include <vector>
35 #include "util.h"
36 
37 class HdlToken;
38 
39 class HdlStatement
40 {
41 public:
42   HdlStatement(const Ref<HdlToken> &name,
43                bool is_block);
44   ~HdlStatement();
45 
isBlock()46   bool isBlock() const
47   {
48     return m_isBlock;
49   }
50 
name()51   const CRef<HdlToken> &name() const
52   {
53     return m_name;
54   }
55 
numArguments()56   int numArguments() const
57   {
58     return (int)m_arguments.size();
59   }
60 
argument(int index)61   const CRef<HdlToken> &argument(int index) const
62   {
63     assert(index >= 0);
64     assert(index < numArguments());
65     return m_arguments[index];
66   }
67 
addArgument(const Ref<HdlToken> & arg)68   void addArgument(const Ref<HdlToken> &arg)
69   {
70     assert(arg.isNotNull());
71     m_arguments.push_back(arg);
72   }
73 
numChildren()74   int numChildren() const
75   {
76     return (int)m_children.size();
77   }
78 
child(int index)79   const CRef<HdlStatement> &child(int index) const
80   {
81     assert(index >= 0);
82     assert(index < numChildren());
83     return m_children[index];
84   }
85 
86   const CRef<HdlStatement> child(const CRef<HdlToken> &token) const;
87   const CRef<HdlStatement> child(const string &name) const;
88 
addChild(const Ref<HdlStatement> & stmt)89   void addChild(const Ref<HdlStatement> &stmt)
90   {
91     assert(stmt.isNotNull());
92     m_children.push_back(stmt);
93   }
94 
95 private:
96   /// Not implemented.
97   HdlStatement(const HdlStatement &);
98 
99   /// Not implemented.
100   HdlStatement& operator=(const HdlStatement &);
101 
102 private:
103   typedef vector<Ref<HdlToken> > ArgVector;
104   typedef vector<Ref<HdlStatement> > ChildVector;
105 
106   Ref<HdlToken> m_name;
107   bool m_isBlock;
108   ArgVector m_arguments;
109   ChildVector m_children;
110 };
111 
112 #endif // _HdlStatement_h
113