00001 /*---------------------------------------------------------*- c++ -*---\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | Copyright (C) SuSE Linux AG | 00011 \----------------------------------------------------------------------/ 00012 00013 File: Import.h 00014 00015 Author: Klaus Kaempf <kkaempf@suse.de> 00016 Maintainer: Klaus Kaempf <kkaempf@suse.de> 00017 00018 /-*/ 00019 // -*- c++ -*- 00020 00021 #ifndef Import_h 00022 #define Import_h 00023 00024 #include <string> 00025 #include <stack> 00026 using std::string; 00027 00028 #include "ycp/YCode.h" 00029 #include "ycp/SymbolTable.h" 00030 #include "ycp/YSymbolEntry.h" 00031 00032 class SymbolEntry; 00033 class Y2Namespace; 00034 00036 class Import { 00037 // track tables of nested imports, no need to track their usage 00038 00039 static int m_disable_tracking; 00040 static std::stack <std::pair <string, SymbolTable *> > m_table_stack; 00041 public: 00042 static void disableTracking (); 00043 static void enableTracking (); 00044 00045 public: 00046 // module block pointer, pointer to constructor 00047 // map of name : module_entry 00048 typedef std::map<std::string, Y2Namespace *> module_map; 00049 00050 00051 protected: 00052 static module_map m_active_modules; 00053 00054 Ustring m_name; 00055 00056 // iterator to share the module state on multiple imports 00057 module_map::iterator m_module; 00058 00059 public: 00060 Import (); 00061 00062 // load module by name. If block != 0, it's already loaded 00063 // name_space is non-const since it might get evaluated 00064 Import (const string &name, Y2Namespace *name_space = 0); 00065 ~Import (); 00066 00067 int import (const string &name, Y2Namespace *preloaded_namespace = 0); // delayed import, use in case default constructor was used 00068 00069 string name () const; 00070 Y2Namespace *nameSpace () const; // return NULL on failure 00071 }; 00072 00073 #endif // Import_h