| 1 | /* This file is part of the FaCT++ DL reasoner |
| 2 | Copyright (C) 2005-2015 Dmitry Tsarkov and The University of Manchester |
| 3 | Copyright (C) 2015-2017 Dmitry Tsarkov |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with this library; if not, write to the Free Software |
| 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #ifndef TDATATYPE_H |
| 21 | #define TDATATYPE_H |
| 22 | |
| 23 | #include "tDataEntry.h" |
| 24 | #include "tNECollection.h" |
| 25 | |
| 26 | /// class for representing general data type |
| 27 | class TDataType: public TNECollection<TDataEntry> |
| 28 | { |
| 29 | protected: // members |
| 30 | /// data type |
| 31 | TDataEntry* Type; |
| 32 | /// data type |
| 33 | std::vector<TDataEntry*> Expr; |
| 34 | |
| 35 | protected: // methods |
| 36 | /// register data value in the datatype |
| 37 | void registerNew ( TDataEntry* p ) override { p->setHostType(Type); } |
| 38 | |
| 39 | public: // interface |
| 40 | /// c'tor: create the TYPE entry |
| 41 | explicit TDataType ( const std::string& name ) |
| 42 | : TNECollection<TDataEntry>(name) |
| 43 | { Type = new TDataEntry(name); } |
| 44 | /// no copy c'tor |
| 45 | TDataType ( const TDataType& ) = delete; |
| 46 | /// no assignment |
| 47 | TDataType& operator = ( const TDataType& ) = delete; |
| 48 | /// d'tor: delete data type entry and all the expressions |
| 49 | ~TDataType() override |
| 50 | { |
| 51 | for ( auto& p: Expr ) |
| 52 | delete p; |
| 53 | delete Type; |
| 54 | } |
| 55 | |
| 56 | // access to the type |
| 57 | |
| 58 | /// get RW access to the type entry (useful for relevance etc) |
| 59 | TDataEntry* getType ( void ) { return Type; } |
| 60 | /// get RO access to the type entry |
| 61 | const TDataEntry* getType ( void ) const { return Type; } |
| 62 | |
| 63 | /// create new expression of the type |
| 64 | TDataEntry* getExpr ( void ) |
| 65 | { |
| 66 | TDataEntry* ret = registerElem(new TDataEntry("expr")); |
| 67 | Expr.push_back(ret); |
| 68 | return ret; |
| 69 | } |
| 70 | }; // TDataType |
| 71 | |
| 72 | #endif |