1 /*
2  *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  *  Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
4  *
5  * Copyright (C) 2012 - 2016 - Scilab Enterprises
6  *
7  * This file is hereby licensed under the terms of the GNU GPL v2.0,
8  * pursuant to article 5.3.4 of the CeCILL v.2.1.
9  * This file was originally licensed under the terms of the CeCILL v2.1,
10  * and continues to be available under such terms.
11  * For more information, see the COPYING file which you should have received
12  * along with this program.
13  *
14  */
15 
16 #ifndef __LIBRARY_HXX__
17 #define __LIBRARY_HXX__
18 
19 #include <list>
20 #include <unordered_map>
21 
22 #include "typesdecl.hxx"
23 
24 namespace types
25 {
26 class EXTERN_AST Library : public GenericType
27 {
28 public :
29     Library(const std::wstring& _wstPath);
30     ~Library();
31 
isLibrary(void)32     bool isLibrary(void)
33     {
34         return true;
35     }
36 
37     /* return type as string ( double, int, cell, list, ... )*/
getTypeStr() const38     virtual std::wstring getTypeStr() const
39     {
40         return L"library";
41     }
42     /* return type as short string ( s, i, ce, l, ... )*/
getShortTypeStr() const43     virtual std::wstring getShortTypeStr() const
44     {
45         return L"f";
46     }
47 
getType(void)48     inline ScilabType getType(void)
49     {
50         return ScilabLibrary;
51     }
getId(void)52     inline ScilabId getId(void)
53     {
54         return IdLibrary;
55     }
56 
57     bool toString(std::wostringstream& ostr);
58     Library* clone();
isAssignable()59     bool isAssignable()
60     {
61         return true;
62     }
63 
64     bool extract(const std::wstring& name, InternalType *& out);
65 
66     void add(const std::wstring& _wstName, MacroFile* _macro);
67     MacroFile* get(const std::wstring& _wstName);
68     int getMacrosName(std::list<std::wstring>& lst);
69     std::wstring getPath();
70     bool getMemory(long long* _piSize, long long* _piSizePlusType);
71 private:
72     std::wstring m_wstPath;
73     typedef std::unordered_map<std::wstring, MacroFile*> MacroMap;
74     MacroMap m_macros;
75 };
76 }
77 
78 #endif /* __LIBRARY_HXX__ */
79