1 /*
2 
3     This file is part of the Maude 2 interpreter.
4 
5     Copyright 1997-2003 SRI International, Menlo Park, CA 94025, USA.
6 
7     This program is free software; you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation; either version 2 of the License, or
10     (at your option) any later version.
11 
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16 
17     You should have received a copy of the GNU General Public License
18     along with this program; if not, write to the Free Software
19     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
20 
21 */
22 
23 //
24 //      Abstract base class for module descriptions that can produce actual modules.
25 //
26 #ifndef _preModule_hh_
27 #define _preModule_hh_
28 #include "namedEntity.hh"
29 #include "mixfixModule.hh"
30 #include "moduleDatabase.hh"
31 
32 class PreModule
33   : public NamedEntity,
34     public Entity::User
35 {
36   NO_COPYING(PreModule);
37 
38 public:
39   PreModule(int moduleName, Interpreter* owner);
40   virtual ~PreModule();
41 
42   Interpreter* getOwner() const;
43   void setModuleType(MixfixModule::ModuleType type);
44   MixfixModule::ModuleType getModuleType() const;
45 
46 
47   virtual int getNrParameters() const = 0;
48   virtual int getParameterName(int index) const = 0;
49   virtual const ModuleExpression* getParameter(int index) const = 0;
50 
51   virtual const ModuleDatabase::ImportMap& getAutoImports() const = 0;
52   virtual int getNrImports() const = 0;
53   virtual int getImportMode(int index) const = 0;
54   virtual const ModuleExpression* getImport(int index) const = 0;
55 
56   virtual VisibleModule* getFlatSignature() = 0;
57   virtual VisibleModule* getFlatModule() = 0;
58 
59 private:
60   Interpreter* const owner;
61   MixfixModule::ModuleType moduleType;
62 };
63 
64 inline Interpreter*
getOwner() const65 PreModule::getOwner() const
66 {
67   return owner;
68 }
69 
70 inline void
setModuleType(MixfixModule::ModuleType type)71 PreModule::setModuleType(MixfixModule::ModuleType type)
72 {
73   moduleType = type;
74 }
75 
76 inline MixfixModule::ModuleType
getModuleType() const77 PreModule::getModuleType() const
78 {
79   return moduleType;
80 }
81 
82 #ifndef NO_ASSERT
83 inline ostream&
operator <<(ostream & s,const PreModule * p)84 operator<<(ostream& s, const PreModule* p)
85 {
86   //
87   //	Needed to avoid overload ambiguity between NamedEntity and Entity::User.
88   //
89   s << static_cast<const NamedEntity*>(p);
90   return s;
91 }
92 #endif
93 
94 #endif
95