Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/shell/shell_completion_plugin.h @ 7422

Last change on this file since 7422 was 7422, checked in by bensch, 18 years ago

orxonox/trunk: completing file-system entries

File size: 2.8 KB
Line 
1/*!
2 * @file shell_completion_plugin.h
3 * @brief The Shell Completion Plugin
4 */
5
6#ifndef _SHELL_COMPLETION_PLUGIN_H
7#define _SHELL_COMPLETION_PLUGIN_H
8
9#include <list>
10#include <vector>
11#include <string>
12#include "multi_type.h"
13
14namespace OrxShell
15{
16  //! The Base of All Completors
17  class CompletorPlugin
18  {
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;
37  };
38
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;
47
48    virtual CompletorPlugin* clone() const;
49  private:
50    const std::string*   _stringArray;
51    unsigned int         _size;
52  };
53
54
55  class CompletorList : public CompletorPlugin
56  {
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;
64  };
65
66
67
68  //! Completor that completes FileSystem Entries.
69  class CompletorFileSystem : public CompletorPlugin
70  {
71  public:
72    // Where to search if the completionString is empty.
73    typedef enum
74    {
75      StartAtRoot,
76      StartAtHome,
77      StartAtDataDir,
78    } StartDirectory;
79
80    CompletorFileSystem(const std::string& fileExtension = "",
81                        const std::string& subDir = "",
82                        StartDirectory startDir = StartAtDataDir);
83    virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const;
84    virtual CompletorPlugin* clone() const;
85
86  private:
87    std::string             _fileExtension;
88    std::string             _subDir;
89    StartDirectory          _startDir;
90  };
91
92
93
94
95  //! A Templated Completor
96  template<typename CLASS> class CompletorTList : public CompletorPlugin
97  {
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;
103  };
104
105}
106#endif /* _SHELL_COMPLETION_PLUGIN_H */
Note: See TracBrowser for help on using the repository browser.