xref: /aoo4110/main/idlc/inc/idlc/astdeclaration.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _IDLC_ASTDECLARATION_HXX_
24 #define _IDLC_ASTDECLARATION_HXX_
25 
26 #include <idlc/idlc.hxx>
27 #include <registry/registry.hxx>
28 
29 class AstScope;
30 
31 // Enum defining the different kinds of Ast nodes
32 enum NodeType
33 {
34 	NT_object,				// Denotes an object
35 	NT_service,				// Denotes an servcie
36 	NT_interface_member,	// Denotes an interface which is exported from object
37 	NT_service_member,		// Denotes an service which is exported from object
38 	NT_observes,			// Denotes an observed interface
39 	NT_needs,				// Denotes an needed service
40 	NT_module,				// Denotes a module
41 	NT_root,				// Denotes the root of AST
42 	NT_interface,			// Denotes an interface
43 	NT_constants,		 	// Denotes a constant group
44 	NT_const,				// Denotes a constant
45 	NT_exception,			// Denotes an exception
46 	NT_attribute,			// Denotes an attribute
47 	NT_property,			// Denotes an property
48 	NT_operation,			// Denotes an operation
49 	NT_parameter,			// Denotes an op. parameter
50 	NT_union,				// Denotes a union
51 	NT_union_branch,		// Denotes a union branch
52 	NT_struct,              // Denotes either a plain struct type, or a
53                             // polymorphic struct type template
54     NT_type_parameter,      // Denotes a type parameter of a polymorphic struct
55                             // type template
56     NT_instantiated_struct, // Denotes an instantiated polymorphic struct type
57 	NT_member,				// Denotes a member in structure, exception
58 	NT_enum,				// Denotes an enumeration
59 	NT_enum_val,			// Denotes an enum. value
60 	NT_array,				// Denotes an IDL array
61 	NT_sequence,			// Denotes an IDL sequence
62 	NT_typedef,				// Denotes a typedef
63 	NT_predefined,			// Denotes a predefined type
64 	NT_singleton			// Denotes a singleton
65 };
66 
67 class AstDeclaration
68 {
69 public:
70 	// Constructors
71 	AstDeclaration(NodeType type, const ::rtl::OString& name, AstScope* pScope);
72 	virtual ~AstDeclaration();
73 
74 	// Data access
75 	void setName(const ::rtl::OString& name);
getLocalName() const76 	const ::rtl::OString& getLocalName() const
77 		{ return m_localName; }
getScopedName() const78 	const ::rtl::OString&	getScopedName() const
79 		{ return m_scopedName; }
getFullName()80 	const ::rtl::OString&	getFullName()
81 		{ return m_fullName; }
getRelativName() const82 	virtual const sal_Char*	getRelativName() const
83 		{ return m_fullName.getStr()+1; }
getScope()84 	AstScope* getScope()
85 		{ return m_pScope; }
setScope(AstScope * pSc)86 	void setScope(AstScope* pSc)
87 		{ m_pScope = pSc; }
getNodeType() const88     NodeType getNodeType() const
89 		{ return m_nodeType; }
isInMainfile() const90 	sal_Bool isInMainfile() const
91 		{ return m_bInMainFile; }
setInMainfile(sal_Bool bInMainfile)92 	void setInMainfile(sal_Bool bInMainfile)
93 		{ m_bInMainFile = bInMainfile; }
isImported() const94 	sal_Bool isImported() const
95 		{ return m_bImported; }
setImported(sal_Bool bImported)96 	void setImported(sal_Bool bImported)
97 		{ m_bImported = bImported; }
getLineNumber() const98 	sal_Int32 getLineNumber() const
99 		{ return m_lineNumber; }
setLineNumber(sal_Int32 lineNumber)100 	void setLineNumber(sal_Int32 lineNumber)
101 		{ m_lineNumber = lineNumber; }
getFileName() const102 	const ::rtl::OString& getFileName() const
103 		{ return m_fileName; }
setFileName(const::rtl::OString & rFileName)104 	void setFileName(const ::rtl::OString& rFileName)
105 		{ m_fileName = rFileName; }
getDocumentation() const106 	const ::rtl::OUString& getDocumentation() const
107 		{ return m_documentation; }
setDocumentation(const::rtl::OUString & rDocumentation)108 	void setDocumentation(const ::rtl::OUString& rDocumentation)
109 		{ m_documentation = rDocumentation; }
isAdded()110 	sal_Bool isAdded()
111 		{ return m_bIsAdded; }
markAsAdded()112 	void markAsAdded()
113 		{ m_bIsAdded = sal_True; }
114 
115     virtual bool isType() const;
116 
117 	sal_Bool hasAncestor(AstDeclaration* pDecl);
118 
setPublished()119     void setPublished() { m_bPublished = true; }
isPublished() const120     bool isPublished() const { return m_bPublished; }
121 
122 	virtual sal_Bool dump(RegistryKey& rKey);
123 
isPredefined()124     bool isPredefined() { return m_bPredefined; }
125     void setPredefined(bool bPredefined);
126 
127 protected:
128     ::rtl::OString		m_localName;
129 	::rtl::OString		m_scopedName; 		// full qualified name
130 	::rtl::OString		m_fullName;			// full qualified name with '/' as seperator
131 	AstScope*			m_pScope;
132 	NodeType            m_nodeType;
133 	sal_Bool			m_bImported;		// imported ?
134 	sal_Bool			m_bIsAdded;			// mark declaration as added in scope
135 	sal_Bool			m_bInMainFile;		// defined in main file
136     bool                m_bPublished;
137     bool                m_bPredefined;
138 	sal_Int32			m_lineNumber;		// line number defined in
139 	::rtl::OString		m_fileName;			// fileName	defined in
140 	::rtl::OUString		m_documentation; 	// fileName	defined in
141 };
142 
143 #endif // _IDLC_ASTDECLARATION_HXX_
144 
145