1 /*!
2  * \file   mfront/include/MFront/CMaterialPropertyInterfaceBase.hxx
3  * \brief  This file declares the CMaterialPropertyInterfaceBase class
4  * \author Thomas Helfer
5  * \date   06 mai 2008
6  * \copyright Copyright (C) 2006-2018 CEA/DEN, EDF R&D. All rights
7  * reserved.
8  * This project is publicly released under either the GNU GPL Licence
9  * or the CECILL-A licence. A copy of thoses licences are delivered
10  * with the sources of TFEL. CEA or EDF may also distribute this
11  * project under specific licensing conditions.
12  */
13 
14 #ifndef LIB_MFRONTCLAWINTERFACEBASE_HXX
15 #define LIB_MFRONTCLAWINTERFACEBASE_HXX
16 
17 #include<string>
18 #include<fstream>
19 
20 #include"MFront/LawFunction.hxx"
21 #include"MFront/VariableDescription.hxx"
22 #include"MFront/VariableBoundsDescription.hxx"
23 #include"MFront/AbstractMaterialPropertyInterface.hxx"
24 
25 namespace mfront{
26 
27   /*!
28    * \brief Base class for a set of material properties interface.
29    */
30   struct CMaterialPropertyInterfaceBase
31     : public AbstractMaterialPropertyInterface
32   {
33     /*!
34      * \return the position of the variable in the inputs plus one.
35      * \param[in] mpd: material property description
36      * \param[in] n:   variable name
37      */
38     static VariableDescriptionContainer::size_type
39     getVariableNumber(const MaterialPropertyDescription&,
40 		      const std::string&);
41     //! constructor
42     CMaterialPropertyInterfaceBase();
43     /*!
44      * \brief generate the output files
45      * \param[in] mpd : material property description
46      * \param[in] fd  : mfront file description
47      */
48     void writeOutputFiles(const MaterialPropertyDescription&,
49 			  const FileDescription&) const override;
50     //! destructor
51     ~CMaterialPropertyInterfaceBase() override;
52 
53   protected:
54 
55     virtual void
56     writeParameterList(std::ostream&,
57 		       const VariableDescriptionContainer&) const;
58     /*!
59      * \param[out] os:  output file stream
60      */
61     virtual void
62     writeInterfaceSpecificVariables(std::ostream&,
63 				    const VariableDescriptionContainer&) const;
64     /*!
65      * \param[out] os:  output file stream
66      */
67     virtual void writeBeginHeaderNamespace(std::ostream&) const = 0;
68     /*!
69      * \param[out] os:  output file stream
70      */
71     virtual void writeEndHeaderNamespace(std::ostream&) const = 0;
72     /*!
73      * \param[out] os:  output file stream
74      * \param[in]  mpd: material property description
75      */
76     virtual void writeEntryPointSymbol(std::ostream&,
77 				       const MaterialPropertyDescription&) const;
78     /*!
79      * \param[out] os:  output file stream
80      * \param[in]  mpd: material property description
81      */
82     virtual void writeTFELVersionSymbol(std::ostream&,
83 					const MaterialPropertyDescription&) const;
84     /*!
85      * \param[out] os:  output file stream
86      * \param[in]  mpd: material property description
87      */
88     virtual void writeMaterialSymbol(std::ostream&,
89 				     const MaterialPropertyDescription&) const;
90     /*!
91      * \param[out] os:  output file stream
92      * \param[in]  mpd: material property description
93      */
94     virtual void writeInterfaceSymbol(std::ostream&,
95 				      const MaterialPropertyDescription&) const = 0;
96     /*!
97      * \param[out] os:  output file stream
98      * \param[in]  mpd: material property description
99      */
100     virtual void writeMaterialKnowledgeTypeSymbol(std::ostream&,
101 						  const MaterialPropertyDescription&) const;
102     /*!
103      * \param[out] os:  output file stream
104      * \param[in]  name: name of the generated material property
105      * \param[in]  mpd: material property description
106      */
107     virtual void writeVariablesNamesSymbol(std::ostream&,
108 					   const std::string&,
109 					   const MaterialPropertyDescription&) const;
110     /*!
111      * \param[out] os:  output file stream
112      * \param[in]  name: name of the generated material property
113      * \param[in]  mpd: material property description
114      */
115     virtual void writeVariablesBoundsSymbols(std::ostream&,
116 					     const std::string&,
117 					     const MaterialPropertyDescription&) const;
118     /*!
119      * \param[out] os:  output file stream
120      */
121     virtual void writeBeginSrcNamespace(std::ostream&) const = 0;
122     /*!
123      * \param[out] os:  output file stream
124      */
125     virtual void writeEndSrcNamespace(std::ostream&) const = 0;
126     /*!
127      * \param[out] os:  output file stream
128      * \param[in]  mpd: material property description
129      */
130     virtual void
131     writeHeaderPreprocessorDirectives(std::ostream&,
132 				      const MaterialPropertyDescription&) const;
133     /*!
134      * \param[out] os:  output file stream
135      * \param[in]  mpd: material property description
136      */
137     virtual void
138     writeSrcPreprocessorDirectives(std::ostream&,
139 				   const MaterialPropertyDescription&) const;
140     /*!
141      * \param[out] os:  output file stream
142      * \param[in]  mpd: material property description
143      */
144     virtual void
145     writeCErrorTreatment(std::ostream&,
146 			 const MaterialPropertyDescription&) const;
147 
148     virtual std::string getCallingConvention() const;
149 
150     virtual bool requiresCheckBoundsFunction() const = 0;
151     /*!
152      * \param[in] mpd: material property description
153      */
154     virtual std::string
155     getFunctionName(const MaterialPropertyDescription&) const = 0;
156     /*!
157      * \param[in] mpd: material property description
158      */
159     virtual std::string
160     getCheckBoundsFunctionName(const MaterialPropertyDescription&) const = 0;
161 
162     /*!
163      * \param const std::string&, name of the material
164      * \param const std::string&, name of the class
165      */
166     virtual std::string
167     getHeaderFileName(const std::string&,
168 		      const std::string&) const = 0;
169 
170     /*!
171      * \param const std::string&, name of the material
172      * \param const std::string&, name of the class
173      */
174     virtual std::string
175     getSrcFileName(const std::string&,
176 		   const std::string&) const = 0;
177 
178     /*!
179      * \brief : write the source file. The headerFile member has been
180      * opened appropriately and will be closed after the call.
181      * \param[in] mpd : material property description
182      * \param[in] fd  : file description
183      */
184     virtual void
185     writeHeaderFile(const MaterialPropertyDescription&,
186 		    const FileDescription&) const;
187     /*!
188      * \brief : write the source file. The srcFile member has been
189      * opened appropriately and will be closed after the call.
190      * \param[in] mpd : material property description
191      * \param[in] fd  : file description
192      */
193     virtual void
194     writeSrcFile(const MaterialPropertyDescription&,
195 		 const FileDescription&) const;
196 
197   }; // end of MfrontCMaterialPropertyInterfaceBase
198 
199 } // end of namespace mfront
200 
201 #endif /* LIB_MFRONTCLAWINTERFACEBASE_HXX */
202 
203