ctkCmdLineModuleDefaultPathBuilder.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) University College London
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =============================================================================*/
  14. #ifndef __ctkCmdLineModuleDefaultPathBuilder_h
  15. #define __ctkCmdLineModuleDefaultPathBuilder_h
  16. #include "ctkCommandLineModulesCoreExport.h"
  17. #include <QStringList>
  18. #include <QScopedPointer>
  19. struct ctkCmdLineModuleDefaultPathBuilderPrivate;
  20. /**
  21. * \class ctkCmdLineModuleDefaultPathBuilder
  22. * \brief Builds up a list of directory paths to search for command
  23. * line modules.
  24. * \ingroup CommandLineModulesCore
  25. * \author m.clarkson@ucl.ac.uk
  26. *
  27. * Implements the following basic strategy, depending on which boolean
  28. * flags are on: By default they are all off, as directory scanning is
  29. * often time consuming.
  30. *
  31. * <pre>
  32. * 1. CTK_MODULE_LOAD_PATH environment variable
  33. * 2. Home directory
  34. * 3. Home directory / cli-modules
  35. * 4. Current working directory
  36. * 5. Current working directory / cli-modules
  37. * 6. Application directory
  38. * 7. Application directory / cli-modules
  39. * </pre>
  40. */
  41. class CTK_CMDLINEMODULECORE_EXPORT ctkCmdLineModuleDefaultPathBuilder
  42. {
  43. public:
  44. ctkCmdLineModuleDefaultPathBuilder();
  45. ~ctkCmdLineModuleDefaultPathBuilder();
  46. /**
  47. * @brief Instruct the builder to include the users
  48. * home directory and sub-folder cli-modules.
  49. */
  50. virtual void setLoadFromHomeDir(bool doLoad);
  51. /**
  52. * @brief Instruct the builder to include the current
  53. * running directory and sub-folder cli-modules.
  54. */
  55. virtual void setLoadFromCurrentDir(bool doLoad);
  56. /**
  57. * @brief Instruct the builder to include the application
  58. * installation directory and sub-folder cli-modules.
  59. */
  60. virtual void setLoadFromApplicationDir(bool doLoad);
  61. /**
  62. * @brief Instruct the builder to include the path denoted
  63. * by the environment variable CTK_MODULE_LOAD_PATH.
  64. */
  65. virtual void setLoadFromCtkModuleLoadPath(bool doLoad);
  66. /**
  67. * @brief Builds the list of paths to search and returns them
  68. * as QStringList
  69. * @return a QStringList of directory path names
  70. */
  71. virtual QStringList build() const;
  72. private:
  73. QScopedPointer<ctkCmdLineModuleDefaultPathBuilderPrivate> d;
  74. Q_DISABLE_COPY(ctkCmdLineModuleDefaultPathBuilder)
  75. };
  76. #endif