Changeset 15452
- Timestamp:
- 2013-03-04T00:41:45+01:00 (11 years ago)
- Location:
- branches/OMEdit/OMEditGUI
- Files:
-
- 2 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OMEdit/OMEditGUI/OMC/OMCProxy.cpp
r15451 r15452 42 42 #include "OMCProxy.h" 43 43 #include "../../../Compiler/runtime/config.h" 44 45 /*! 46 \class OMCCommandsCache 47 \brief Stores the list of cached OMC classes. 48 */ 49 /*! 50 \param pParent - pointer to QObject 51 */ 52 OMCCommandsCache::OMCCommandsCache(QObject *pParent) 53 : QObject(pParent) 54 { 55 56 } 57 58 /*! 59 Returns the cached OMC command from the hash. 60 \param className - the name of the class to search for. 61 \param command - the command to search for. 62 \return the OMC command 63 */ 64 OMCCommand OMCCommandsCache::getOMCCommand(QString className, QString command) 65 { 66 if (mOMCCommandsHash.contains(className)) 67 { 68 QList<OMCCommand> commandsList = mOMCCommandsHash.value(className); 69 foreach (OMCCommand omcCommand, commandsList) 70 { 71 if (omcCommand.mOMCCommand.compare(command) == 0) 72 return omcCommand; 73 } 74 } 75 return OMCCommand(); 76 } 77 78 /*! 79 Adds the OMC class name to the hash of cached classes. 80 \param className - the name of the class. 81 \param command - the command. 82 \param commandResult - the command result 83 */ 84 void OMCCommandsCache::addOMCCommand(QString className, QString command, QString commandResult) 85 { 86 /* if the className is already in commands hash */ 87 if (mOMCCommandsHash.contains(className)) 88 { 89 QList<OMCCommand> commandsList = mOMCCommandsHash.value(className); 90 /* if the commands list doesn't contain the command then add it */ 91 bool found = false; 92 foreach (OMCCommand omcCommand, commandsList) 93 { 94 if (omcCommand.mOMCCommand.compare(command) == 0) 95 { 96 found = true; 97 break; 98 } 99 } 100 if (!found) 101 { 102 OMCCommand omcCommand; 103 omcCommand.mOMCCommand = command; 104 omcCommand.mOMCCommandResult = commandResult; 105 commandsList.append(omcCommand); 106 mOMCCommandsHash.insert(className, commandsList); 107 } 108 } 109 else 110 { 111 QList<OMCCommand> commandsList; 112 OMCCommand omcCommand; 113 omcCommand.mOMCCommand = command; 114 omcCommand.mOMCCommandResult = commandResult; 115 commandsList.append(omcCommand); 116 mOMCCommandsHash.insert(className, commandsList); 117 } 118 } 44 119 45 120 /*! … … 333 408 } 334 409 /* if OMC command is find in the cached OMC commands then use it and return. */ 335 OMCCommand *pOMCCommand = mpOMCCommandsCache->getOMCCommand(className, expression);336 if ( pOMCCommand)337 { 338 setResult(pOMCCommand ->getOMCCommandResult());410 OMCCommand pOMCCommand = mpOMCCommandsCache->getOMCCommand(className, expression); 411 if (!pOMCCommand.mOMCCommandResult.isEmpty()) 412 { 413 setResult(pOMCCommand.mOMCCommandResult); 339 414 // write command to the commands log. 340 415 QTime commandTime; -
branches/OMEdit/OMEditGUI/OMC/OMCProxy.h
r15451 r15452 51 51 class StringHandler; 52 52 class OMCCommandsCache; 53 54 struct OMCCommand 55 { 56 QString mOMCCommand; 57 QString mOMCCommandResult; 58 }; 59 60 class OMCCommandsCache : public QObject 61 { 62 Q_OBJECT 63 public: 64 OMCCommandsCache(QObject *pParent); 65 OMCCommand getOMCCommand(QString className, QString command); 66 void addOMCCommand(QString className, QString command, QString commandResult); 67 private: 68 QHash<QString, QList<OMCCommand> > mOMCCommandsHash; 69 }; 53 70 54 71 class OMCProxy : public QObject -
branches/OMEdit/OMEditGUI/OMEditGUI.pro
r15449 r15452 61 61 omc_communication.cc \ 62 62 OMC/OMCProxy.cpp \ 63 OMC/OMCCommandsCache.cpp \64 63 Util/StringHandler.cpp \ 65 64 GUI/Widgets/MessagesWidget.cpp \ … … 92 91 omc_communication.h \ 93 92 OMC/OMCProxy.h \ 94 OMC/OMCCommandsCache.h \95 93 Util/StringHandler.h \ 96 94 GUI/Widgets/MessagesWidget.h \
Note: See TracChangeset
for help on using the changeset viewer.