1 /*!
2  * \file   mfront/include/MFront/AbstractDSL.hxx
3  * \brief
4  *
5  * \author Thomas Helfer
6  * \date   09 nov 2006
7  * \copyright Copyright (C) 2006-2018 CEA/DEN, EDF R&D. All rights
8  * reserved.
9  * This project is publicly released under either the GNU GPL Licence
10  * or the CECILL-A licence. A copy of thoses licences are delivered
11  * with the sources of TFEL. CEA or EDF may also distribute this
12  * project under specific licensing conditions.
13  */
14 
15 #ifndef LIB_MFRONT_ABSTRACTDSL_HXX
16 #define LIB_MFRONT_ABSTRACTDSL_HXX
17 
18 #include <map>
19 #include <set>
20 #include <vector>
21 #include <string>
22 
23 #include "MFront/MFrontConfig.hxx"
24 
25 namespace mfront {
26 
27   // forward declaration
28   struct FileDescription;
29   // forward declaration
30   struct TargetsDescription;
31   // forward declaration
32   struct MaterialPropertyDescription;
33 
34   /*!
35    * Interface class for all domain specific languages.
36    */
37   struct MFRONT_VISIBILITY_EXPORT AbstractDSL {
38     //! list of dsl targets
39     enum DSLTarget {
40       MATERIALPROPERTYDSL,
41       BEHAVIOURDSL,
42       MODELDSL
43     };  // end of DSLTarget
44     //! \return the target of the dsl
45     virtual DSLTarget getTargetType() const = 0;
46     //! \return the file description associated with the treated file
47     virtual const FileDescription& getFileDescription() const = 0;
48     /*!
49      * \return the identifier (material property name, behaviour name, model
50      * name) of the treated file
51      */
52     virtual std::string getMaterialKnowledgeIdentifier() const = 0;
53     //! \return the material described by the treated file
54     virtual std::string getMaterialName() const = 0;
55     /*!
56      * \return the variable name associated with the given external name
57      * \param[in] n: external name of the quantity overridable by a parameter
58      *
59      * Depending on the DSL's, a parameter may override a parameter, but also a
60      * material property for example.
61      */
62     virtual std::string getOverridableVariableNameByExternalName(
63         const std::string&) const = 0;
64     /*!
65      * \brief analyse a file
66      * \param[in] f     : file name
67      * \param[in] ecmds : additionnal commands inserted treated before
68      * the input file commands (those commands are given through the
69      * `--@??` option of the command line
70      * \param[in] s : substitutions patterns inserted (those
71      * substitutions are given through command-line options such as
72      * `--@YYY@=XXX`)
73      */
74     virtual void analyseFile(const std::string&,
75                              const std::vector<std::string>&,
76                              const std::map<std::string, std::string>&) = 0;
77     /*!
78      * \brief analyse the specified string.
79      * \param[in] s : analysed a string
80      */
81     virtual void analyseString(const std::string&) = 0;
82     /*!
83      * \brief import a file
84      * \param[in] f     : file name
85      * \param[in] ecmds : additionnal commands inserted treated before
86      * the input file commands
87      * \param[in] s : substitutions patterns inserted (those
88      * substitutions are given through command-line options such as
89      * `--@YYY@=XXX`)
90      */
91     virtual void importFile(const std::string&,
92                             const std::vector<std::string>&,
93                             const std::map<std::string, std::string>&) = 0;
94     /*!
95      * \brief method called at the end of the input file processing.
96      * \note This method shall be called *after* the `analyseFile` or
97      * `analyseString` methods.
98      */
99     virtual void endsInputFileProcessing() = 0;
100     /*!
101      * \return the target description
102      * \note This method shall be called *after* the `analyseFile` or
103      * `analyseString` methods.
104      */
105     virtual const TargetsDescription& getTargetsDescription() const = 0;
106     /*!
107      * \brief treat the specified file.
108      * \note This method shall be called *after* the analyseFile method
109      */
110     virtual void generateOutputFiles() = 0;
111     /*!
112      * \brief set list of interfaces
113      * \param[in] inames : list of interfaces
114      */
115     virtual void setInterfaces(const std::set<std::string>&) = 0;
116     /*!
117      * \brief return the list of keywords usable with this parser
118      * \param[out] k : the list of keywords registred for this parser
119      */
120     virtual void getKeywordsList(std::vector<std::string>&) const = 0;
121     //! destructor
122     virtual ~AbstractDSL();
123   };
124 
125 }  // end of namespace mfront
126 
127 #endif /* LIB_MFRONT_ABSTRACTDSL_HXX */
128