00001 #ifndef hpp_RendererAllocator_hpp
00002 #define hpp_RendererAllocator_hpp
00003
00004
00005
00006 namespace HTML
00007 {
00008 namespace Renderer
00009 {
00010
00011 class Box;
00012
00013 class Mapper;
00014
00015
00022 namespace Allocators
00023 {
00025 class BaseAllocator
00026 {
00027 protected:
00029 BaseAllocator() {}
00030
00031 public:
00033 virtual HTML::Renderer::BoxHierarchy * getNewBoxHierarchy(const HTML::GenericElement::ElementID tagID, const HTML::Renderer::BoxHierarchy::String & ID, const HTML::Renderer::BoxHierarchy::String & Class) const volatile = 0;
00035 virtual void returnBoxHierarchy(const HTML::Renderer::BoxHierarchy *) const volatile = 0;
00037 virtual CSS::Length * getNewAbsoluteLength(const float value, const CSS::AbsoluteLength::AbsoluteUnit & relUnit) const volatile = 0;
00039 virtual CSS::Length * getNewRelativeLength(const float value, const CSS::RelativeLength::RelativeUnit & relUnit, CSS::Length * relativeTo) const volatile = 0;
00041 virtual CSS::Length * getNewAutoLength() const volatile = 0;
00043 virtual void returnLength(CSS::Length *) const volatile = 0;
00045 virtual HTML::Renderer::Box * getNewBox(Mapper &, const BoxHierarchy *, const CSS::StyleImplement & style, const uint32 ct = 0, const Strings::FastString & text = "") const volatile = 0;
00047 virtual void returnBox(HTML::Renderer::Box *) const volatile = 0;
00048 };
00049
00051 class SimpleHeap : public BaseAllocator
00052 {
00053 public:
00055 SimpleHeap() {}
00056
00057 public:
00059 virtual HTML::Renderer::BoxHierarchy * getNewBoxHierarchy(const HTML::GenericElement::ElementID tagID, const HTML::Renderer::BoxHierarchy::String & ID, const HTML::Renderer::BoxHierarchy::String & Class) const volatile
00060 {
00061 return new HTML::Renderer::BoxHierarchy(tagID, ID, Class);
00062 }
00064 virtual void returnBoxHierarchy(const HTML::Renderer::BoxHierarchy * box) const volatile
00065 {
00066 delete box;
00067 }
00068
00070 virtual CSS::Length * getNewAbsoluteLength(const float value, const CSS::AbsoluteLength::AbsoluteUnit & relUnit) const volatile
00071 {
00072 return new CSS::AbsoluteLength(value, relUnit);
00073 }
00075 virtual CSS::Length * getNewRelativeLength(const float value, const CSS::RelativeLength::RelativeUnit & relUnit, CSS::Length * relativeTo) const volatile
00076 {
00077 if (!relativeTo) return 0;
00078 return new CSS::RelativeLength(value, relUnit, *relativeTo);
00079 }
00081 virtual CSS::Length * getNewAutoLength() const volatile
00082 {
00083 return new CSS::AutoLength();
00084 }
00086 virtual void returnLength(CSS::Length * length) const volatile
00087 {
00088 delete length;
00089 }
00091 virtual HTML::Renderer::Box * getNewBox(Mapper &, const BoxHierarchy *, const CSS::StyleImplement & style, const uint32 ct = 0, const Strings::FastString & text = "") const volatile;
00093 virtual void returnBox(HTML::Renderer::Box *) const volatile;
00094 };
00095 }
00096 }
00097 }
00098
00099 #endif