Version: 8.3.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
portParsers.hxx
Go to the documentation of this file.
1
// Copyright (C) 2006-2016 CEA/DEN, EDF R&D
2
//
3
// This library is free software; you can redistribute it and/or
4
// modify it under the terms of the GNU Lesser General Public
5
// License as published by the Free Software Foundation; either
6
// version 2.1 of the License, or (at your option) any later version.
7
//
8
// This library is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
// Lesser General Public License for more details.
12
//
13
// You should have received a copy of the GNU Lesser General Public
14
// License along with this library; if not, write to the Free Software
15
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
//
17
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18
//
19
20
#ifndef _PORTPARSERS_HXX_
21
#define _PORTPARSERS_HXX_
22
23
#include "
parserBase.hxx
"
24
#include "
propertyParsers.hxx
"
25
26
#include "
factory.hxx
"
27
28
namespace
YACS
29
{
30
47
template
<
class
T=myinport>
48
struct
inporttypeParser
:
parser
49
{
50
static
inporttypeParser<T>
inportParser
;
51
virtual
void
onStart
(
const
XML_Char
* el,
const
XML_Char
** attr);
52
virtual
void
onEnd
(
const
char
*el,
parser
* child);
53
virtual
void
buildAttr
(
const
XML_Char
** attr);
54
virtual
void
pre
();
55
virtual
void
name
(
const
std::string&
name
);
56
virtual
void
type
(
const
std::string&
type
);
57
virtual
void
property
(
const
myprop
& prop);
58
virtual
T&
post
();
59
protected
:
60
T
_port
;
61
};
62
68
template
<
class
T=myoutport>
69
struct
outporttypeParser
:
public
inporttypeParser
<T>
70
{
71
static
outporttypeParser<T>
outportParser
;
72
};
73
74
template
<
class
T>
inporttypeParser<T>
inporttypeParser<T>::inportParser
;
75
template
<
class
T>
outporttypeParser<T>
outporttypeParser<T>::outportParser
;
76
77
template
<
class
T>
78
void
inporttypeParser<T>::onStart
(
const
XML_Char
* el,
const
XML_Char
** attr)
79
{
80
std::string element(el);
81
parser
* pp=&
parser::main_parser
;
82
if
(element ==
"property"
)pp=&
propertytypeParser::propertyParser
;
83
this->SetUserDataAndPush(pp);
84
pp->
init
();
85
pp->
pre
();
86
pp->
buildAttr
(attr);
87
}
88
template
<
class
T>
89
void
inporttypeParser<T>::onEnd
(
const
char
*el,
parser
* child)
90
{
91
std::string element(el);
92
if
(element ==
"property"
)property(((
propertytypeParser
*)child)->post());
93
}
94
template
<
class
T>
95
void
inporttypeParser<T>::buildAttr
(
const
XML_Char
** attr)
96
{
97
if
(!attr)
98
return
;
99
required(
"name"
,attr);
100
required(
"type"
,attr);
101
for
(
int
i
= 0; attr[
i
];
i
+= 2)
102
{
103
if
(std::string(attr[
i
]) ==
"name"
)name(attr[i+1]);
104
if
(std::string(attr[i]) ==
"type"
)type(attr[i+1]);
105
}
106
}
107
template
<
class
T>
108
void
inporttypeParser<T>::pre
()
109
{
110
_port._name=
""
;
111
_port._type=
""
;
112
_port.clear();
113
}
114
template
<
class
T>
115
void
inporttypeParser<T>::name
(
const
std::string& name)
116
{
117
_port._name=name;
118
}
119
template
<
class
T>
120
void
inporttypeParser<T>::type
(
const
std::string& type)
121
{
122
_port._type=type;
123
}
124
template
<
class
T>
125
void
inporttypeParser<T>::property
(
const
myprop
& prop)
126
{
127
DEBTRACE
(
"property_set: "
<< prop.
_name
<< prop.
_value
)
128
_port.setProperty(prop.
_name
,prop.
_value
);
129
}
130
template
<
class
T>
131
T&
inporttypeParser<T>::post
()
132
{
133
return
_port;
134
}
135
136
}
137
138
#endif
src
yacsloader
portParsers.hxx
Copyright © 2006-2017 CEA/DEN, EDF R&D