stromx  0.8.0
DirectoryFileOutput.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_DIRECTORYFILEOUTPUT_H
18 #define STROMX_RUNTIME_DIRECTORYFILEOUTPUT_H
19 
20 #include "stromx/runtime/Config.h"
21 #include "stromx/runtime/FileOutput.h"
22 #include <fstream>
23 #include <sstream>
24 
25 namespace stromx
26 {
27  namespace runtime
28  {
30  class STROMX_RUNTIME_API DirectoryFileOutput : public FileOutput
31  {
32  public:
38  explicit DirectoryFileOutput(const std::string & directory) : m_initialized(false), m_directory(directory) {}
39  virtual ~DirectoryFileOutput();
40 
41  virtual void initialize(const std::string & filename);
42  virtual const std::string & getFilename() const;
43  virtual const std::string getText() const;
44 
45  virtual std::ostream & text();
46  virtual std::ostream & openFile(const std::string & ext, const OpenMode mode);
47  virtual std::ostream & file();
48  virtual void close();
49 
50  private:
51  static const std::string PATH_SEPARATOR;
52 
53  bool m_initialized;
54  std::string m_directory;
55  std::string m_currentBasename;
56  std::string m_currentFilename;
57  std::ofstream m_currentFile;
58  std::ostringstream m_currentText;
59  };
60  }
61 }
62 
63 #endif // STROMX_RUNTIME_DIRECTORYFILEOUTPUT_H
OpenMode
Definition: OutputProvider.h:31
The stromx class library.
Definition: AdjustRgbChannels.cpp:29
File output which stores the output data in single files in a common directory.
Definition: DirectoryFileOutput.h:30
DirectoryFileOutput(const std::string &directory)
Definition: DirectoryFileOutput.h:38
Provides functions to initialize an output provider.
Definition: FileOutput.h:27