Scroom 0.14-49-gb7ae7a6d
Loading...
Searching...
No Matches
Scroom::Pnm::Source Class Reference

#include <pnmsource.hh>

Inheritance diagram for Scroom::Pnm::Source:
Inheritance graph
Collaboration diagram for Scroom::Pnm::Source:
Collaboration graph

Public Types

using Ptr = std::shared_ptr< Source >
 
- Public Types inherited from SourcePresentation
using Ptr = std::shared_ptr< SourcePresentation >
 

Public Member Functions

bool resetPresentation ()
 
void done () override
 
std::string getName () override
 
- Public Member Functions inherited from SourcePresentation
virtual void fillTiles (int startLine, int lineCount, int tileWidth, int firstTile, std::vector< Tile::Ptr > &tiles)=0
 

Protected Member Functions

 Source (std::string fileName, std::ifstream pnm, BitmapMetaData bmd)
 

Protected Attributes

std::string m_fileName
 
std::ifstream m_preOpenedPnm
 
std::ifstream m_pnm
 
BitmapMetaData m_bmd
 
Scroom::Logger m_logger
 

Member Typedef Documentation

◆ Ptr

using Scroom::Pnm::Source::Ptr = std::shared_ptr<Source>

Constructor & Destructor Documentation

◆ Source()

Scroom::Pnm::Source::Source ( std::string  fileName,
std::ifstream  pnm,
BitmapMetaData  bmd 
)
protected
151 : m_fileName(std::move(fileName))
152 , m_preOpenedPnm(std::move(pnm))
153 , m_bmd(std::move(bmd))
154 {
155 }
std::ifstream m_preOpenedPnm
Definition pnmsource.hh:40
BitmapMetaData m_bmd
Definition pnmsource.hh:42
std::string m_fileName
Definition pnmsource.hh:39

Member Function Documentation

◆ done()

void Scroom::Pnm::Source::done ( )
overridevirtual

Done reading bitmap data

Any open files can be closed now

Implements SourcePresentation.

185{ m_pnm.close(); }
std::ifstream m_pnm
Definition pnmsource.hh:41

◆ getName()

std::string Scroom::Pnm::Source::getName ( )
inlineoverridevirtual

Implements SourcePresentation.

50{ return m_fileName; }

◆ resetPresentation()

bool Scroom::Pnm::Source::resetPresentation ( )
158 {
159 m_pnm = std::move(m_preOpenedPnm);
160
161 if(!m_pnm)
162 {
164 if(r && approx(std::get<0>(*r), m_bmd))
165 {
166 m_pnm = std::move(std::get<1>(*r));
167 }
168 else
169 {
170 if(r)
171 {
172 m_logger->error("Can't reload. Bitmap changed too much");
173 m_logger->info("Previously: {}", to_string(m_bmd));
174 m_logger->info("Now: {}", to_string(std::get<0>(*r)));
175 }
176 // if (!r) then the error has already been reported by open()
177 return false;
178 }
179 }
180 ensure(m_pnm);
181
182 return true;
183 }
#define ensure(expr)
Definition assertions.hh:35
Scroom::Logger m_logger
Definition pnmsource.hh:43
boost::optional< std::tuple< Scroom::TiledBitmap::BitmapMetaData, std::ifstream, SourceType > > open(const Scroom::Logger &logger, const std::string &fileName)
Definition pnmsource.cc:55
std::string to_string(const BitmapMetaData &bmd)
Definition layerspecforbitmap.cc:28
bool approx(const BitmapMetaData &left, const BitmapMetaData &right)
Definition pnmsource.cc:21
Scroom::Utils::Rectangle< double > const r
Definition transformpresentation_test.cc:65
Here is the call graph for this function:

Member Data Documentation

◆ m_bmd

◆ m_fileName

std::string Scroom::Pnm::Source::m_fileName
protected

Referenced by getName(), and resetPresentation().

◆ m_logger

Scroom::Logger Scroom::Pnm::Source::m_logger
protected

Referenced by resetPresentation().

◆ m_pnm

◆ m_preOpenedPnm

std::ifstream Scroom::Pnm::Source::m_preOpenedPnm
protected

Referenced by resetPresentation().


The documentation for this class was generated from the following files: