OpenWalnut  1.5.0dev
WDataModuleInputFile.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WDATAMODULEINPUTFILE_H
26 #define WDATAMODULEINPUTFILE_H
27 
28 #include <memory>
29 #include <ostream>
30 #include <string>
31 
32 #include <boost/filesystem/path.hpp>
33 
34 #include "WDataModuleInput.h"
35 
36 /**
37  * Implements a file based input for the \ref WDataModule.
38  */
40 {
41 public:
42  /**
43  * Convenience typedef for a std::shared_ptr< WDataModuleInputFile >.
44  */
45  typedef std::shared_ptr< WDataModuleInputFile > SPtr;
46 
47  /**
48  * Convenience typedef for a std::shared_ptr< const WDataModuleInputFile >.
49  */
50  typedef std::shared_ptr< const WDataModuleInputFile > ConstSPtr;
51 
52  /**
53  * Default constructor.
54  *
55  * \param fname the filename to use.
56  */
57  explicit WDataModuleInputFile( boost::filesystem::path fname );
58 
59  /**
60  * Default constructor.
61  *
62  * \param fname the filename to use.
63  */
64  explicit WDataModuleInputFile( std::string fname );
65 
66  /**
67  * Destructor.
68  */
69  virtual ~WDataModuleInputFile();
70 
71  /**
72  * Get the filename to load.
73  *
74  * \return the filename
75  */
76  boost::filesystem::path getFilename() const;
77 
78  /**
79  * Return a unique name for this input type. This is used to identify a certain input later.
80  *
81  * \return the name.
82  */
83  virtual std::string getName() const;
84 
85  /**
86  * The file input as human readable string.
87  *
88  * \return the readable form.
89  */
90  virtual std::string asString() const;
91 
92  /**
93  * Return some extend information for the input, like complete path, server data (username, subject name, ...). It is up to you.
94  *
95  * \return some extended information as string.
96  */
97  virtual std::string getExtendedInfo() const;
98 
99  /**
100  * Write a machine-readable string which allows to restore your specific input later. No line-breaks, no ":" and it must not be empty.
101  *
102  * \param out the stream to serialize to
103  *
104  * \return the stream
105  */
106  virtual std::ostream& serialize( std::ostream& out ) const; // NOLINT: yes, it is an intended non-const ref
107 protected:
108 private:
109  /**
110  * The filename to load.
111  */
112  boost::filesystem::path m_filename;
113 };
114 
115 #endif // WDATAMODULEINPUTFILE_H
116 
Implements a file based input for the WDataModule.
virtual std::ostream & serialize(std::ostream &out) const
Write a machine-readable string which allows to restore your specific input later.
virtual ~WDataModuleInputFile()
Destructor.
boost::filesystem::path getFilename() const
Get the filename to load.
WDataModuleInputFile(boost::filesystem::path fname)
Default constructor.
virtual std::string getName() const
Return a unique name for this input type.
std::shared_ptr< WDataModuleInputFile > SPtr
Convenience typedef for a std::shared_ptr< WDataModuleInputFile >.
virtual std::string getExtendedInfo() const
Return some extend information for the input, like complete path, server data (username,...
boost::filesystem::path m_filename
The filename to load.
std::shared_ptr< const WDataModuleInputFile > ConstSPtr
Convenience typedef for a std::shared_ptr< const WDataModuleInputFile >.
virtual std::string asString() const
The file input as human readable string.
This class is the abstract interface to all the possible inputs a WDataModule might handle.