stromx  0.8.0
DirectoryFileInput.h
1 /*
2 * Copyright 2012 Matthias Fuchs
3 *
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 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 
17 #ifndef STROMX_RUNTIME_DIRECTORYFILEINPUT_H
18 #define STROMX_RUNTIME_DIRECTORYFILEINPUT_H
19 
20 #include "stromx/runtime/Config.h"
21 #include "stromx/runtime/FileInput.h"
22 #include <fstream>
23 #include <sstream>
24 
25 namespace stromx
26 {
27  namespace runtime
28  {
30  class STROMX_RUNTIME_API DirectoryFileInput : public FileInput
31  {
32  public:
38  explicit DirectoryFileInput(const std::string & directory) : m_initialized(false), m_directory(directory) {}
39  virtual ~DirectoryFileInput();
40 
41  virtual void initialize(const std::string & text, const std::string & filename);
42 
43  virtual std::istream & text();
44  virtual bool hasFile() const;
45  virtual std::istream & openFile(const OpenMode mode);
46  virtual std::istream & file();
47  virtual void close();
48 
49  private:
50  static const std::string PATH_SEPARATOR;
51 
52  bool m_initialized;
53  std::string m_directory;
54  std::string m_currentFilename;
55  std::ifstream m_currentFile;
56  std::istringstream m_currentText;
57  };
58  }
59 }
60 
61 #endif // STROMX_RUNTIME_DIRECTORYFILEINPUT_H
Provides functions to initialize an input provider.
Definition: FileInput.h:27
File input which reads the input files from a common directory.
Definition: DirectoryFileInput.h:30
The stromx class library.
Definition: AdjustRgbChannels.cpp:29
OpenMode
Definition: InputProvider.h:31
DirectoryFileInput(const std::string &directory)
Definition: DirectoryFileInput.h:38