pdfobjects::PdfOperator Class Reference

#include <pdfoperatorsbase.h>

Inheritance diagram for pdfobjects::PdfOperator:
ListItem< PdfOperator > pdfobjects::CompositePdfOperator pdfobjects::SimpleGenericOperator pdfobjects::InlineImageCompositePdfOperator pdfobjects::UnknownCompositePdfOperator pdfobjects::TextSimpleOperator

List of all members.

Public Types

typedef std::deque
< boost::shared_ptr< IProperty > > 
Operands
typedef std::list
< boost::shared_ptr
< PdfOperator > > 
PdfOperators
typedef
iterator::DoubleListIterator
< PdfOperator
Iterator
typedef Iterator::ListItem ListItem
typedef libs::Rectangle BBox

Public Member Functions

virtual ~PdfOperator ()
virtual size_t getParametersCount () const =0
virtual void getParameters (Operands &container) const =0
virtual void getStringRepresentation (std::string &str) const =0
virtual void getOperatorName (std::string &first) const =0
virtual void push_back (UNUSED_PARAM const boost::shared_ptr< PdfOperator > oper, UNUSED_PARAM boost::shared_ptr< PdfOperator > _prev=boost::shared_ptr< PdfOperator >())
virtual size_t getChildrenCount () const
virtual void getChildren (PdfOperators &opers) const
virtual boost::shared_ptr
< PdfOperator
clone ()=0
void setContentStream (CContentStream &cs)
boost::shared_ptr< CContentStreamgetContentStream () const
void setBBox (const BBox &rc)
BBox getBBox () const
virtual void init_operands (boost::shared_ptr< observer::IObserver< IProperty > >, boost::weak_ptr< CPdf >, IndiRef *)=0

Static Public Member Functions

template<typename ITER >
static ITER getIterator (boost::shared_ptr< PdfOperator > op, bool forward)
template<typename ITER >
static ITER getIterator (boost::shared_ptr< PdfOperator > op)
static Iterator getIterator (boost::shared_ptr< PdfOperator > op)

Protected Member Functions

 PdfOperator ()
virtual void insert_after (const boost::shared_ptr< PdfOperator >, boost::shared_ptr< PdfOperator >)
virtual void remove (boost::shared_ptr< PdfOperator >)

Static Protected Member Functions

static void putBehind (boost::shared_ptr< PdfOperator > behindWhich, boost::shared_ptr< PdfOperator > which)

Private Attributes

CContentStream_contentstream
BBox _bbox

Friends

class iterator::DoubleListIterator< PdfOperator >
class CContentStream

Detailed Description

This class is the base class for COMPOSITE design pattern and also DECORATOR design pattern.

This is a special implementation, a hybrid between implementation of stl containers and GoF example.

Content stream consists of operators and their operands. Operators can be composites. Each operator alters graphical state in a predefined way. Operators have to be processed sequentially.

This is the building block of almost all visible objects on a page. Every operation on a text, graphics etc.. means adding/deleting/changing operators.

Operators themselves build a double linked list queue. We use iterators to iterate over them sequentially.

They also form a tree like structure and that is the reason why Composite design pattern is used here. Decorator and composite together allow a very easy way to change these operators. (e.g. changing font means wrapping the text operator to a composite, which includes also the font change operator.)

This approach allows us to represent operators in a human readable way (tree like structure) and to have the power of double linked list with iterators.

We can not simply represent these two queues in one. If we want to have all info only in interator queue, items can not be shared pointers because of the cyclic shared pointer problem (no item would get ever deallocated). If we want to have all the info in tree like queue, we would have to know the parents and it would not be easy to write an iterator. It would not be a clean straight forward solution. Another possibility is to have the queue outside (e.g. in content stream) but then we would not be able to simply create composites.

Another advantage of the composite design pattern is the single unified interface. In most cases we do not need to distinguish between a composite and a leaf.

Iterators are crucial when selecting operators.


Member Typedef Documentation

typedef libs::Rectangle pdfobjects::PdfOperator::BBox
typedef std::deque<boost::shared_ptr<IProperty> > pdfobjects::PdfOperator::Operands
typedef std::list<boost::shared_ptr<PdfOperator> > pdfobjects::PdfOperator::PdfOperators

Constructor & Destructor Documentation

pdfobjects::PdfOperator::PdfOperator (  )  [inline, protected]

Constructor.

virtual pdfobjects::PdfOperator::~PdfOperator (  )  [inline, virtual]

Destructor.


Member Function Documentation

virtual boost::shared_ptr<PdfOperator> pdfobjects::PdfOperator::clone (  )  [pure virtual]
BBox pdfobjects::PdfOperator::getBBox (  )  const [inline]

Get bounding box of this operator.

Returns:
Bounding box.

References _bbox.

virtual void pdfobjects::PdfOperator::getChildren ( PdfOperators opers  )  const [inline, virtual]

Get childrens.

Parameters:
opers Children container.

Reimplemented in pdfobjects::CompositePdfOperator.

virtual size_t pdfobjects::PdfOperator::getChildrenCount (  )  const [inline, virtual]

Get children count.

Returns:
Number of children.

Reimplemented in pdfobjects::CompositePdfOperator.

shared_ptr< CContentStream > pdfobjects::PdfOperator::getContentStream (  )  const

Get content stream.

Returns:
Content stream that this pdfoperator belongs to.

References _contentstream, and pdfobjects::CContentStream::getSmartPointer().

Referenced by pdfobjects::TextSimpleOperator::getCurrentFont().

static Iterator pdfobjects::PdfOperator::getIterator ( boost::shared_ptr< PdfOperator op  )  [inline, static]

Create simple iterator.

template<typename ITER >
static ITER pdfobjects::PdfOperator::getIterator ( boost::shared_ptr< PdfOperator op  )  [inline, static]

Get iterator.REMARK: We can't simply make getIterator a method, because we have to know the smart pointer behind the object. Member variable "this" is not sufficient.

Parameters:
op Operator from which we want the iterator.
forward Direction of traversing when looking for the first valid item.
Returns:
Iterator.
.

template<typename ITER >
static ITER pdfobjects::PdfOperator::getIterator ( boost::shared_ptr< PdfOperator op,
bool  forward 
) [inline, static]

Get iterator.

REMARK: We can't simply make getIterator a method, because we have to know the smart pointer behind the object. Member variable "this" is not sufficient.

Parameters:
op Operator from which we want the iterator.
forward Direction of traversing when looking for the first valid item.
Returns:
Iterator.

Referenced by pdfobjects::CContentStream::CContentStream(), pdfobjects::CPageContents::convert(), pdfobjects::CContentStream::deleteOperator(), pdfobjects::CContentStream::insertOperator(), pdfobjects::CPageContents::parse(), gui::QSPdfOperatorIterator::QSPdfOperatorIterator(), pdfobjects::CContentStream::reparse(), and pdfobjects::CContentStream::replaceOperator().

virtual void pdfobjects::PdfOperator::getOperatorName ( std::string &  first  )  const [pure virtual]

Get the string operator name.

Parameters:
first String that will hold operator name.

Implemented in pdfobjects::SimpleGenericOperator, pdfobjects::UnknownCompositePdfOperator, pdfobjects::InlineImageCompositePdfOperator, and pdfobjects::CompositePdfOperator.

Referenced by pdfobjects::isPdfOp().

virtual void pdfobjects::PdfOperator::getParameters ( Operands container  )  const [pure virtual]

Get the parameters used with this operator.

Parameters:
container Will be used to store parameters.

Implemented in pdfobjects::SimpleGenericOperator, pdfobjects::InlineImageCompositePdfOperator, and pdfobjects::CompositePdfOperator.

virtual size_t pdfobjects::PdfOperator::getParametersCount (  )  const [pure virtual]

Return the number of parameters.

Returns:
Number of parameters.

Implemented in pdfobjects::SimpleGenericOperator, pdfobjects::InlineImageCompositePdfOperator, and pdfobjects::CompositePdfOperator.

virtual void pdfobjects::PdfOperator::getStringRepresentation ( std::string &  str  )  const [pure virtual]

Get the string representation of this operator.

Parameters:
str String that will hold the representation of this operator.

Implemented in pdfobjects::SimpleGenericOperator, pdfobjects::UnknownCompositePdfOperator, pdfobjects::InlineImageCompositePdfOperator, and pdfobjects::CompositePdfOperator.

virtual void pdfobjects::PdfOperator::init_operands ( boost::shared_ptr< observer::IObserver< IProperty > >  ,
boost::weak_ptr< CPdf ,
IndiRef  
) [pure virtual]

Init operands and store observer for later unregistering.

Implemented in pdfobjects::SimpleGenericOperator, and pdfobjects::CompositePdfOperator.

virtual void pdfobjects::PdfOperator::insert_after ( const boost::shared_ptr< PdfOperator ,
boost::shared_ptr< PdfOperator  
) [inline, protected, virtual]

Insert an operator after an item.

Parameters:
oper Operator after which an oper will be inserted.
newOper Operator to be inserted.

Reimplemented in pdfobjects::CompositePdfOperator.

virtual void pdfobjects::PdfOperator::push_back ( UNUSED_PARAM const boost::shared_ptr< PdfOperator oper,
UNUSED_PARAM boost::shared_ptr< PdfOperator _prev = boost::shared_ptr<PdfOperator> () 
) [inline, virtual]

Add an operator to the end of composite. One problem is when the composite is empty, we have to specify prev variable because we can not get shared pointer from this.

Parameters:
oper Operator to be added.
prev Operator, after which we should place the added one in iterator list. If not specified, it is assumed that children are not empty and that the last item is not a composite.
static void pdfobjects::PdfOperator::putBehind ( boost::shared_ptr< PdfOperator behindWhich,
boost::shared_ptr< PdfOperator which 
) [static, protected]

Put behind.

REMARK: We can't simply make putBehind a method, because we have to know the smart pointer behind the object. Member variable "this" is not sufficient.

Parameters:
behindWhich Behind which elemnt.
which Which element.
virtual void pdfobjects::PdfOperator::remove ( boost::shared_ptr< PdfOperator  )  [inline, protected, virtual]

Remove an operator from the composite interface.

REMARK: This will not remove it from the Iterator list.

Parameters:
op to be erased.

Reimplemented in pdfobjects::CompositePdfOperator.

void pdfobjects::PdfOperator::setBBox ( const BBox rc  )  [inline]

Set bounding box.

Parameters:
rc Bounding box.

References _bbox.

void pdfobjects::PdfOperator::setContentStream ( CContentStream cs  )  [inline]

Set content stream.

Every pdf operator needs to know into which content stream it belongs. This is due to the fact, that some functions just return container of pdfoperators, and if we want to work with them, we have to know the contentstream.

We can find out the CStream but there is no mapping between CStream and content stream.

Parameters:
cs Content stream.

References _contentstream.


Friends And Related Function Documentation

friend class CContentStream [friend]
friend class iterator::DoubleListIterator< PdfOperator > [friend]

Member Data Documentation

Bounding box of this operator.

Referenced by getBBox(), and setBBox().

This enables mapping between pdfoperator and contentstream.

Referenced by getContentStream(), and setContentStream().


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