- Timestamp:
- Apr 27, 2006, 8:42:16 PM (19 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_command.cc
r7403 r7407 46 46 this->executor->setName(commandName); 47 47 48 for (unsigned int i = 0; i < this->executor->getParamCount(); i++) 49 this->completors.push_back(new CompletorDefault(&this->executor->getDefaultValue(i))); 48 50 this->alias = NULL; 49 51 … … 62 64 if (this->alias != NULL) 63 65 delete this->alias; 66 while (!this->completors.empty()) 67 { 68 delete this->completors.back(); 69 this->completors.pop_back(); 70 } 64 71 delete this->executor; 65 72 } -
trunk/src/lib/shell/shell_command.h
r7403 r7407 10 10 11 11 #include "executor/executor.h" 12 #include <stdarg.h>12 #include "shell_completion_plugin.h" 13 13 14 14 #define SHELL_COMMAND_MAX_SIZE //!< The maximum size of a Shell Command 15 16 17 15 18 16 namespace OrxShell … … 21 19 class ShellCommandClass; 22 20 class ShellCommandAlias; 21 class CompletorPlugin; 23 22 24 23 /** … … 75 74 static bool exists(const std::string& commandName, const std::string& className); 76 75 76 unsigned int getParamCount() const { return this->executor->getParamCount(); } 77 const CompletorPlugin* const getCompletorPlugin(unsigned int i) const { return this->completors[i]; }; 78 77 79 static void debug(); 78 80 … … 88 90 89 91 std::string description; //!< A description for this commnand. (initially ""). Assigned with (create)->describe("blablabla"); 92 std::vector<CompletorPlugin*> completors; //!< Completors for the Parameters 90 93 Executor* executor; //!< The Executor, that really executes the Function. 91 94 }; -
trunk/src/lib/shell/shell_command_class.cc
r7403 r7407 29 29 30 30 /** 31 * creates a new ShellCommandClass31 * @brief creates a new ShellCommandClass 32 32 * @param className the Name of the command-class to create 33 33 */ -
trunk/src/lib/shell/shell_completion_plugin.cc
r7388 r7407 27 27 namespace OrxShell 28 28 { 29 void CompletorStringArray::addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) 29 CompletorDefault::CompletorDefault(const MultiType* value) 30 :_value(value) 31 { } 32 33 void CompletorDefault::addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const 34 { 35 PRINT(0)("%s", MultiType::MultiTypeToString(this->_value->getType()).c_str()); 36 } 37 38 CompletorPlugin* CompletorDefault::clone() const 39 { 40 return new CompletorDefault(this->_value); 41 } 42 43 44 45 46 47 void CompletorStringArray::addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const 30 48 { 31 49 unsigned int inputLen = completionBegin.size(); … … 35 53 } 36 54 55 CompletorPlugin* CompletorStringArray::clone() const 56 { 57 return new CompletorStringArray(this->_stringArray, this->_size); 58 } 37 59 38 60 … … 42 64 } 43 65 44 void CompletorList::addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) 66 void CompletorList::addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const 45 67 { 46 68 unsigned int inputLen = completionBegin.size(); … … 51 73 } 52 74 75 CompletorPlugin* CompletorList::clone() const 76 { 77 return new CompletorList(this->_list); 78 } 53 79 54 80 … … 60 86 61 87 62 void CompletorFileSystem::addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) 88 void CompletorFileSystem::addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const 63 89 { 64 90 if (completionBegin.empty()) // if we do not yet have the beginning of the line, start with the chosen startDir. … … 68 94 } 69 95 } 96 CompletorPlugin* CompletorFileSystem::clone() const 97 { 98 return new CompletorFileSystem(this->_fileExtension, this->_startDir, this->_subDir); 99 } 100 70 101 71 102 } -
trunk/src/lib/shell/shell_completion_plugin.h
r7406 r7407 10 10 #include <vector> 11 11 #include <string> 12 #include "multi_type.h" 12 13 13 14 namespace OrxShell 14 15 { 15 16 //! The Base of All Completors 16 class Completor 17 class CompletorPlugin 17 18 { 18 public: 19 virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) = 0; 20 virtual ~Completor() { }; 21 protected: 22 Completor(); 19 public: 20 virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const = 0; 21 virtual ~CompletorPlugin() { }; 22 23 virtual CompletorPlugin* clone() const = 0; 24 protected: 25 CompletorPlugin() {}; 26 }; 27 28 class CompletorDefault : public CompletorPlugin 29 { 30 public: 31 CompletorDefault(const MultiType* value); 32 virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const; 33 34 virtual CompletorPlugin* clone() const; 35 private: 36 const MultiType* _value; 23 37 }; 24 38 25 39 40 //! Completor that completes static Arrays of Strings. 41 class CompletorStringArray : public CompletorPlugin 42 { 43 public: 44 CompletorStringArray(const std::string* stringArray, unsigned int size) 45 : _stringArray(stringArray), _size(size) {}; 46 virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const; 26 47 27 28 //! Completor that completes static Arrays of Strings. 29 class CompletorStringArray : public Completor 30 { 31 public: 32 CompletorStringArray(const std::string* stringArray, unsigned int size) 33 : _stringArray(stringArray), _size(size) {}; 34 virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin); 35 36 private: 37 const std::string* _stringArray; 38 unsigned int _size; 48 virtual CompletorPlugin* clone() const; 49 private: 50 const std::string* _stringArray; 51 unsigned int _size; 39 52 }; 40 53 41 54 42 class CompletorList : public Completor 55 class CompletorList : public CompletorPlugin 43 56 { 44 public: 45 CompletorList(const std::list<std::string>* list); 46 virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin); 47 private: 48 const std::list<std::string>* _list; 57 public: 58 CompletorList(const std::list<std::string>* list); 59 virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const; 60 virtual CompletorPlugin* clone() const; 61 62 private: 63 const std::list<std::string>* _list; 49 64 }; 50 65 … … 52 67 53 68 //! Completor that completes FileSystem Entries. 54 class CompletorFileSystem : public Completor 69 class CompletorFileSystem : public CompletorPlugin 55 70 { 56 57 public: 58 // Where to search if the completionString is empty. 59 typedef enum 60 { 61 StartAtRoot, 62 StartAtHome, 63 StartAtDataDir, 71 public: 72 // Where to search if the completionString is empty. 73 typedef enum 74 { 75 StartAtRoot, 76 StartAtHome, 77 StartAtDataDir, 64 78 } StartDirectory; 65 79 66 CompletorFileSystem(const std::string& fileExtension = "", 67 StartDirectory startDir = StartAtDataDir, 68 const std::string& subDir = ""); 69 virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin); 80 CompletorFileSystem(const std::string& fileExtension = "", 81 StartDirectory startDir = StartAtDataDir, 82 const std::string& subDir = ""); 83 virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const; 84 virtual CompletorPlugin* clone() const; 70 85 71 72 73 74 86 private: 87 std::string _fileExtension; 88 std::string _subDir; 89 StartDirectory _startDir; 75 90 }; 76 91 … … 79 94 80 95 //! A Templated Completor 81 template<typename CLASS> class CompletorTList : public Completor 96 template<typename CLASS> class CompletorTList : public CompletorPlugin 82 97 { 83 public: 84 CompletorTList(const std::list<CLASS*>& completionList); 85 virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) 86 {}; 98 public: 99 CompletorTList(const std::list<CLASS*>& completionList); 100 virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) 101 {}; 102 virtual CompletorPlugin* clone() const; 87 103 }; 88 104 -
trunk/src/lib/util/executor/executor.h
r7331 r7407 47 47 const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL, 48 48 const MultiType& value4 = MT_NULL); 49 /** @param i the i'th defaultValue, @returns reference to the MultiType */ 50 inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; }; 49 51 50 52 // EXECUTE
Note: See TracChangeset
for help on using the changeset viewer.