{
myTooltip = tooltip;
}
+
+const std::string& Config_FeatureMessage::pluginLibrary() const
+{
+ return myPluginLibrary;
+}
+
+void Config_FeatureMessage::setPluginLibrary(const std::string& myPluginLibrary)
+{
+ this->myPluginLibrary = myPluginLibrary;
+}
#include <Event_Message.hxx>\r
#include <string>\r
\r
+/*\r
+ * Class to pass a feature entry extracted from xml file.\r
+ * Example of the feature entry:\r
+ * <feature id="new_part" text="Part" tooltip="Creates a new part" icon=":pictures/part_ico.png"/>\r
+ */\r
class CONFIG_EXPORT Config_FeatureMessage: public Event_Message\r
{\r
+ std::string myId; //Feature unique id\r
+ std::string myText; //Represents action's text\r
+ std::string myTooltip; //Represents action's tooltip\r
+ std::string myIcon; //Represents action's icon\r
+ std::string myKeysequence; //Represents action's key sequence\r
\r
- std::string myId;\r
- std::string myText;\r
- std::string myTooltip;\r
- std::string myIcon;\r
- std::string myKeysequence;\r
-\r
- std::string myGroupId;\r
- std::string myWorkbenchId;\r
+ std::string myGroupId; //Id of feature's group\r
+ std::string myWorkbenchId; //Id of feature's workbench\r
+ std::string myPluginLibrary; //Name of feature's library\r
\r
public:\r
//const Event_ID theID, const void* theSender = 0\r
\r
const std::string& groupId() const;\r
const std::string& workbenchId() const;\r
+ const std::string& pluginLibrary() const;\r
\r
void setIcon(const std::string& icon);\r
void setId(const std::string& id);\r
\r
void setGroupId(const std::string& groupId);\r
void setWorkbenchId(const std::string& workbenchId);\r
+ void setPluginLibrary(const std::string& thePluginLibrary);\r
};\r
\r
#endif // CONFIG_MESSAGE_H\r
\ No newline at end of file
const static char* FEATURE_KEYSEQUENCE = "keysequence";
Config_FeatureReader::Config_FeatureReader(const std::string& theXmlFile)
- : Config_XMLReader(theXmlFile), m_fetchWidgetCfg(false)
+ : Config_XMLReader(theXmlFile),
+ myFetchWidgetCfg(false)
{
+ myLibraryName = "";
+
#ifdef _DEBUG
- if(!Event_Loop::Loop()) {
+ if (!Event_Loop::Loop()) {
std::cout << "Config_FeatureReader::importWorkbench: "
- << "No event loop registered" << std::endl;
+ << "No event loop registered" << std::endl;
+ }
+#endif
+}
+
+Config_FeatureReader::Config_FeatureReader(const std::string& theXmlFile,
+ const std::string& theLibraryName)
+ : Config_XMLReader(theXmlFile),
+ myLibraryName(theLibraryName),
+ myFetchWidgetCfg(false)
+{
+#ifdef _DEBUG
+ if (!Event_Loop::Loop()) {
+ std::cout << "Config_FeatureReader::importWorkbench: "
+ << "No event loop registered" << std::endl;
}
#endif
}
std::string Config_FeatureReader::featureWidgetCfg(std::string theFeatureName)
{
- m_fetchWidgetCfg = true;
+ myFetchWidgetCfg = true;
readAll();
- m_fetchWidgetCfg = false;
- return m_widgetCfg;
+ myFetchWidgetCfg = false;
+ return myWidgetCfg;
}
void Config_FeatureReader::processNode(xmlNodePtr theNode)
{
if (isNode(theNode, NODE_FEATURE, NULL)) {
- if (m_fetchWidgetCfg) {
+ if (myFetchWidgetCfg) {
xmlBufferPtr buffer = xmlBufferCreate();
int size = xmlNodeDump(buffer, theNode->doc, theNode, 0, 1);
- m_widgetCfg = std::string((char*) buffer->content);
+ myWidgetCfg = std::string((char*) buffer->content);
} else {
Event_Loop* aEvLoop = Event_Loop::Loop();
Config_FeatureMessage aMessage(aEvLoop->EventByName("menu_item"), this);
}
//The m_last* variables always defined before fillFeature() call. XML is a tree.
if (isNode(theNode, NODE_GROUP, NULL)) {
- m_lastGroup = getProperty(theNode, _ID);
+ myLastGroup = getProperty(theNode, _ID);
}
if (isNode(theNode, NODE_WORKBENCH, NULL)) {
- m_lastWorkbench = getProperty(theNode, _ID);
+ myLastWorkbench = getProperty(theNode, _ID);
}
}
outFtMessage.setTooltip(getProperty(theRoot, FEATURE_TOOLTIP));
outFtMessage.setIcon(getProperty(theRoot, FEATURE_ICON));
outFtMessage.setKeysequence(getProperty(theRoot, FEATURE_KEYSEQUENCE));
- outFtMessage.setGroupId(m_lastGroup);
- outFtMessage.setWorkbenchId(m_lastWorkbench);
-
+ outFtMessage.setGroupId(myLastGroup);
+ outFtMessage.setWorkbenchId(myLastWorkbench);
+ outFtMessage.setPluginLibrary(myLibraryName);
}
{
public:
Config_FeatureReader(const std::string& theXmlFile);
+ Config_FeatureReader(const std::string& theXmlFile,
+ const std::string& theLibraryName);
virtual ~Config_FeatureReader();
std::string featureWidgetCfg(std::string theFeatureName);
void fillFeature(xmlNodePtr theRoot, Config_FeatureMessage& outFeatureMessage);
- std::string m_lastWorkbench;
- std::string m_lastGroup;
+ std::string myLastWorkbench;
+ std::string myLastGroup;
+ std::string myLibraryName;
- bool m_fetchWidgetCfg;
- std::string m_widgetCfg;
+ bool myFetchWidgetCfg;
+ std::string myWidgetCfg;
};
#endif /* CONFIG_FEATUREREADER_H_ */
const static char* PLUGIN_LIBRARY = "library";
Config_ModuleReader::Config_ModuleReader()
- : Config_XMLReader("plugins.xml"), m_isAutoImport(false)
+ : Config_XMLReader("plugins.xml"), myIsAutoImport(false)
{
}
void Config_ModuleReader::processNode(xmlNodePtr theNode)
{
if (isNode(theNode, NODE_PLUGIN, NULL)) {
- std::string aPluginName = getProperty(theNode, PLUGIN_CONFIG);
- if (m_isAutoImport)
- importPlugin(aPluginName);
- m_pluginsList.push_back(aPluginName);
+ std::string aPluginConf = getProperty(theNode, PLUGIN_CONFIG);
+ std::string aPluginLibrary = getProperty(theNode, PLUGIN_LIBRARY);
+ if (myIsAutoImport)
+ importPlugin(aPluginConf, aPluginLibrary);
+ myPluginsMap[aPluginLibrary] = aPluginConf;
}
}
return isNode(theNode, NODE_PLUGINS, NULL);
}
-void Config_ModuleReader::importPlugin(const std::string& thePluginName)
+void Config_ModuleReader::importPlugin(const std::string& thePluginName,
+ const std::string& thePluginLibrary)
{
- Config_FeatureReader aReader(thePluginName);
- aReader.readAll();
+ Config_FeatureReader* aReader;
+ if(thePluginLibrary.empty()) {
+ aReader = new Config_FeatureReader(thePluginName);
+ } else {
+ aReader = new Config_FeatureReader(thePluginName, thePluginLibrary);
+ }
+ aReader->readAll();
}
-void Config_ModuleReader::setAutoImport(bool enabled)
+void Config_ModuleReader::setAutoImport(bool theEnabled)
{
- m_isAutoImport = enabled;
+ myIsAutoImport = theEnabled;
}
-const std::list<std::string>& Config_ModuleReader::pluginsList() const
+const std::map<std::string, std::string>& Config_ModuleReader::plugins() const
{
- return m_pluginsList;
+ return myPluginsMap;
}
#include <Config_XMLReader.h>
-#include <list>
+#include <map>
class CONFIG_EXPORT Config_ModuleReader: public Config_XMLReader
{
virtual ~Config_ModuleReader();
void setAutoImport(bool enabled);
- const std::list<std::string>& pluginsList() const;
+ const std::map<std::string, std::string>& plugins() const;
std::string getModuleName();
void processNode(xmlNodePtr aNode);
bool processChildren(xmlNodePtr aNode);
- void importPlugin(const std::string& thePluginName);
+ void importPlugin(const std::string& thePluginName,
+ const std::string& thePluginLibrary = "");
private:
- bool m_isAutoImport;
- std::list<std::string> m_pluginsList;
+ bool myIsAutoImport;
+ std::map<std::string, std::string> myPluginsMap;
+
};
prefix = "../plugins/";
#endif
- m_DocumentPath = prefix + theXmlFileName;
+ myDocumentPath = prefix + theXmlFileName;
}
Config_XMLReader::~Config_XMLReader()
xmlNodePtr Config_XMLReader::findRoot()
{
xmlDocPtr aDoc;
- aDoc = xmlParseFile(m_DocumentPath.c_str());
+ aDoc = xmlParseFile(myDocumentPath.c_str());
if (aDoc == NULL) {
#ifdef _DEBUG
- std::cout << "Config_XMLReader::import: " << "Document " << m_DocumentPath
+ std::cout << "Config_XMLReader::import: " << "Document " << myDocumentPath
<< " is not parsed successfully." << std::endl;
#endif
return NULL;
bool isNode(xmlNodePtr theNode, const char* name, ...);
private:
- std::string m_DocumentPath;
+ std::string myDocumentPath;
};
#endif /* CONFIG_XMLREADER_H_ */
{
Config_ModuleReader aModuleReader = Config_ModuleReader();
aModuleReader.readAll();
- std::string aPluginName = aModuleReader.pluginsList().front();
- Config_FeatureReader* aReader = new Config_FeatureReader(aPluginName);
- XGUI_Command* aCmd = dynamic_cast<XGUI_Command*>(sender());
- std::string aXMLWidgetCfg = aReader->featureWidgetCfg(aCmd->getId().toStdString());
- delete aReader;
+// std::string aPluginName = aModuleReader.plugins().front();
+// Config_FeatureReader* aReader = new Config_FeatureReader(aPluginName);
+// XGUI_Command* aCmd = dynamic_cast<XGUI_Command*>(sender());
+// std::string aXMLWidgetCfg = aReader->featureWidgetCfg(aCmd->getId().toStdString());
+// delete aReader;
}