Support custom default extension for FileNameOption
[alexxy/gromacs.git] / src / gromacs / options / filenameoptionstorage.h
index d7a5973a1804ac66ce329c9e3a3976e9787840ab..84a0f8fc21bca37caf331aab38e6d283b33ba722 100644 (file)
@@ -1,10 +1,10 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012, by the GROMACS development team, led by
- * David van der Spoel, Berk Hess, Erik Lindahl, and including many
- * others, as listed in the AUTHORS file in the top-level source
- * directory and at http://www.gromacs.org.
+ * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
  *
  * GROMACS is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -43,6 +43,7 @@
 #define GMX_OPTIONS_FILENAMEOPTIONSTORAGE_H
 
 #include <string>
+#include <vector>
 
 #include "filenameoption.h"
 #include "optionfiletype.h"
@@ -52,6 +53,7 @@ namespace gmx
 {
 
 class FileNameOption;
+class FileNameOptionManager;
 
 /*! \internal \brief
  * Converts, validates, and stores file names.
@@ -59,11 +61,18 @@ class FileNameOption;
 class FileNameOptionStorage : public OptionStorageTemplate<std::string>
 {
     public:
-        //! \copydoc StringOptionStorage::StringOptionStorage()
-        explicit FileNameOptionStorage(const FileNameOption &settings);
+        /*! \brief
+         * Initializes the storage from option settings.
+         *
+         * \param[in] settings   Storage settings.
+         * \param     manager    Manager for this object (can be NULL).
+         */
+        FileNameOptionStorage(const FileNameOption  &settings,
+                              FileNameOptionManager *manager);
 
         virtual OptionInfo &optionInfo() { return info_; }
-        virtual const char *typeString() const { return "file"; }
+        virtual std::string typeString() const;
+        virtual std::string formatExtraDescription() const;
         virtual std::string formatSingleValue(const std::string &value) const;
 
         //! \copydoc FileNameOptionInfo::isInputFile()
@@ -75,11 +84,27 @@ class FileNameOptionStorage : public OptionStorageTemplate<std::string>
         //! \copydoc FileNameOptionInfo::isLibraryFile()
         bool isLibraryFile() const { return bLibrary_; }
 
+        //! \copydoc FileNameOptionInfo::isDirectoryOption()
+        bool isDirectoryOption() const;
+        //! \copydoc FileNameOptionInfo::isTrajectoryOption()
+        bool isTrajectoryOption() const;
+        //! \copydoc FileNameOptionInfo::defaultExtension()
+        const char *defaultExtension() const;
+        //! \copydoc FileNameOptionInfo::extensions()
+        std::vector<const char *> extensions() const;
+        //! \copydoc FileNameOptionInfo::isValidType()
+        bool isValidType(int fileType) const;
+        //! \copydoc FileNameOptionInfo::fileTypes()
+        ConstArrayRef<int> fileTypes() const;
+
     private:
         virtual void convertValue(const std::string &value);
+        virtual void processAll();
 
         FileNameOptionInfo      info_;
-        OptionFileType          filetype_;
+        FileNameOptionManager  *manager_;
+        int                     fileType_;
+        const char             *defaultExtension_;
         bool                    bRead_;
         bool                    bWrite_;
         bool                    bLibrary_;