6 #include "fwIO/IWriter.hpp" 8 #include <fwCom/Slots.hpp> 9 #include <fwCom/Slots.hxx> 11 #include <fwCore/base.hpp> 13 #include <fwServices/macros.hpp> 19 const ::fwCom::Slots::SlotKeyType IWriter::s_SET_FILE_FOLDER =
"setFileFolder";
22 static const ::fwCom::Slots::SlotKeyType s_CONFIGURE_WITH_IHM =
"configureWithIHM";
26 IWriter::IWriter() noexcept
34 IWriter::~IWriter() noexcept
43 FW_RAISE_IF(
"Exactly one file must be define in location", m_locations.size() != 1);
44 return m_locations.front();
53 m_locations.push_back(file);
61 FW_RAISE_IF(
"At least one file must be define in location", m_locations.empty() );
78 FW_RAISE_IF(
"Exactly one folder must be define in location", m_locations.size() != 1 );
79 return m_locations.front();
88 m_locations.push_back(folder);
95 FW_RAISE_IF(
"This reader doesn't manage file or files",
98 for(
auto& file : m_locations)
100 file = file.filename();
101 file = folder / file;
109 FW_RAISE_IF(
"At least one path must be define in location", m_locations.empty() );
124 SLM_ASSERT(
"Generic configuring method is only available for io service that uses paths.",
127 SLM_ASSERT(
"This writer does not manage folders and a folder path is given in the configuration",
131 SLM_ASSERT(
"This writer does not manages files and a file path is given in the configuration",
135 ::fwRuntime::ConfigurationElement::sptr titleConfig =
m_configuration->findConfigurationElement(
"windowTitle");
141 std::vector< ::fwRuntime::ConfigurationElement::sptr > config =
m_configuration->find(
"file");
142 FW_RAISE_IF(
"No more than one file must be defined in the configuration", config.size() > 1 );
143 if (config.size() == 1)
145 std::string file = config.at(0)->getValue();
146 this->
setFile(::boost::filesystem::path(file));
153 std::vector< ::fwRuntime::ConfigurationElement::sptr > config =
m_configuration->find(
"file");
155 for(::fwRuntime::ConfigurationElement::sptr elt : config)
157 std::string location = elt->getValue();
158 locations.push_back(::boost::filesystem::path(location));
165 std::vector< ::fwRuntime::ConfigurationElement::sptr > config =
m_configuration->find(
"folder");
166 FW_RAISE_IF(
"No more than one folder must be defined in configuration", config.size() > 1 );
167 if (config.size() == 1)
169 std::string folder = config.at(0)->getValue();
170 this->
setFolder(::boost::filesystem::path(folder));
179 return ::fwIO::TYPE_NOT_DEFINED;
186 return m_locations.size() > 0;
FWIO_API void setFiles(const ::fwIO::LocationsType &files)
Sets file paths.
virtual FWIO_API void configureWithIHM()=0
Configure the image path (by default does nothing).
FWIO_API void setFile(const ::boost::filesystem::path &file)
Sets file path.
virtual FWIO_API void configuring() override
This method proposes to parse xml configuration to retrieve file/files/folder paths.
FWIO_APIconst::boost::filesystem::path & getFile() const
Returns the file path set by the user or set during service configuration.
FWIO_API void clearLocations()
Clear any location set by the setFile/setFiles/setFolder setter.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
FWIO_API void setFileFolder(::boost::filesystem::path folder)
Slot: Sets the folder when a path is configured in FILE or FILES mode This is ignored if a path is no...
FWIO_APIconst::boost::filesystem::path & getFolder() const
Returns folder path set by the user or set during service configuration.
::fwRuntime::ConfigurationElement::sptr m_configuration
Configuration element used to configure service internal state using a generic XML like structure TOD...
FWIO_APIconst::fwIO::LocationsType & getFiles() const
Returns file paths set by the user or set during service configuration.
IOPathType
IOPathType defines different type of paths used by service readers/writers.
The namespace fwIO contains the base interface for reader and writer services.
FWIO_APIconst::fwIO::LocationsType & getLocations() const
Returns file/files/folder paths set by the user or set during service configuration.
FWIO_API void setFolder(const ::boost::filesystem::path &folder)
Sets folder path.
std::vector< ::boost::filesystem::path > LocationsType
List of paths managed by io services.
FWIO_API bool hasLocationDefined() const
Returns if a location has been defined ( by the configuration process or directly by user ) ...
virtual FWIO_API::fwIO::IOPathType getIOPathType() const
This method must be implemented by concrete service writers that use path file system to write data...
std::string m_windowTitle
Title of the window that will open when the configureWithIHM slot is called.