forked from organicmaps/organicmaps
Removed type of message from base message class
This commit is contained in:
parent
1d5ca3b937
commit
2ebcafc4fc
5 changed files with 45 additions and 74 deletions
|
@ -12,7 +12,6 @@ SOURCES += \
|
|||
engine_context.cpp \
|
||||
memory_feature_index.cpp \
|
||||
message_queue.cpp \
|
||||
message.cpp \
|
||||
threads_commutator.cpp \
|
||||
message_acceptor.cpp \
|
||||
backend_renderer.cpp \
|
||||
|
|
|
@ -26,9 +26,9 @@ class MapShapeReadedMessage : public Message
|
|||
public:
|
||||
MapShapeReadedMessage(TileKey const & key, dp::TransferPointer<MapShape> shape)
|
||||
: m_key(key), m_shape(shape)
|
||||
{
|
||||
SetType(MapShapeReaded);
|
||||
}
|
||||
{}
|
||||
|
||||
Type GetType() const override { return Message::MapShapeReaded; }
|
||||
|
||||
~MapShapeReadedMessage()
|
||||
{
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
#include "drape_frontend/message.hpp"
|
||||
|
||||
#include "base/assert.hpp"
|
||||
|
||||
namespace df
|
||||
{
|
||||
|
||||
Message::Message()
|
||||
: m_type(Unknown) {}
|
||||
|
||||
Message::Type Message::GetType() const
|
||||
{
|
||||
ASSERT(m_type != Unknown, ());
|
||||
return m_type;
|
||||
}
|
||||
|
||||
void Message::SetType(Type t)
|
||||
{
|
||||
m_type = t;
|
||||
}
|
||||
|
||||
} // namespace df
|
|
@ -8,8 +8,6 @@ class Message
|
|||
public:
|
||||
enum Type
|
||||
{
|
||||
// in perfect world GetType never return this type
|
||||
// for this you need call SetType on subclass constructor
|
||||
Unknown,
|
||||
TileReadStarted,
|
||||
TileReadEnded,
|
||||
|
@ -26,15 +24,8 @@ public:
|
|||
GuiLayerRecached
|
||||
};
|
||||
|
||||
Message();
|
||||
virtual ~Message() {}
|
||||
Type GetType() const;
|
||||
|
||||
protected:
|
||||
void SetType(Type t);
|
||||
|
||||
private:
|
||||
Type m_type;
|
||||
virtual Type GetType() const { return Unknown; }
|
||||
};
|
||||
|
||||
} // namespace df
|
||||
|
|
|
@ -24,11 +24,8 @@ namespace df
|
|||
class BaseTileMessage : public Message
|
||||
{
|
||||
public:
|
||||
BaseTileMessage(TileKey const & key, Message::Type type)
|
||||
: m_tileKey(key)
|
||||
{
|
||||
SetType(type);
|
||||
}
|
||||
BaseTileMessage(TileKey const & key)
|
||||
: m_tileKey(key) {}
|
||||
|
||||
TileKey const & GetKey() const { return m_tileKey; }
|
||||
|
||||
|
@ -40,31 +37,36 @@ class TileReadStartMessage : public BaseTileMessage
|
|||
{
|
||||
public:
|
||||
TileReadStartMessage(TileKey const & key)
|
||||
: BaseTileMessage(key, Message::TileReadStarted) {}
|
||||
: BaseTileMessage(key) {}
|
||||
|
||||
Type GetType() const override { return Message::TileReadStarted; }
|
||||
};
|
||||
|
||||
class TileReadEndMessage : public BaseTileMessage
|
||||
{
|
||||
public:
|
||||
TileReadEndMessage(TileKey const & key)
|
||||
: BaseTileMessage(key, Message::TileReadEnded) {}
|
||||
: BaseTileMessage(key) {}
|
||||
|
||||
Type GetType() const override { return Message::TileReadEnded; }
|
||||
};
|
||||
|
||||
class FlushRenderBucketMessage : public BaseTileMessage
|
||||
{
|
||||
public:
|
||||
FlushRenderBucketMessage(TileKey const & key, dp::GLState const & state, dp::TransferPointer<dp::RenderBucket> buffer)
|
||||
: BaseTileMessage(key, Message::FlushTile)
|
||||
: BaseTileMessage(key)
|
||||
, m_state(state)
|
||||
, m_buffer(buffer)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
~FlushRenderBucketMessage()
|
||||
{
|
||||
m_buffer.Destroy();
|
||||
}
|
||||
|
||||
Type GetType() const override { return Message::FlushTile; }
|
||||
|
||||
dp::GLState const & GetState() const { return m_state; }
|
||||
dp::MasterPointer<dp::RenderBucket> AcceptBuffer() { return dp::MasterPointer<dp::RenderBucket>(m_buffer); }
|
||||
|
||||
|
@ -76,10 +78,10 @@ private:
|
|||
class ResizeMessage : public Message
|
||||
{
|
||||
public:
|
||||
ResizeMessage(Viewport const & viewport) : m_viewport(viewport)
|
||||
{
|
||||
SetType(Resize);
|
||||
}
|
||||
ResizeMessage(Viewport const & viewport)
|
||||
: m_viewport(viewport) {}
|
||||
|
||||
Type GetType() const override { return Message::Resize; }
|
||||
|
||||
Viewport const & GetViewport() const { return m_viewport; }
|
||||
|
||||
|
@ -91,10 +93,9 @@ class UpdateModelViewMessage : public Message
|
|||
{
|
||||
public:
|
||||
UpdateModelViewMessage(ScreenBase const & screen)
|
||||
: m_screen(screen)
|
||||
{
|
||||
SetType(UpdateModelView);
|
||||
}
|
||||
: m_screen(screen) {}
|
||||
|
||||
Type GetType() const override { return Message::UpdateModelView; }
|
||||
|
||||
ScreenBase const & GetScreen() const { return m_screen; }
|
||||
|
||||
|
@ -106,10 +107,9 @@ class InvalidateRectMessage : public Message
|
|||
{
|
||||
public:
|
||||
InvalidateRectMessage(m2::RectD const & rect)
|
||||
: m_rect(rect)
|
||||
{
|
||||
SetType(InvalidateRect);
|
||||
}
|
||||
: m_rect(rect) {}
|
||||
|
||||
Type GetType() const override { return Message::InvalidateRect; }
|
||||
|
||||
m2::RectD const & GetRect() const { return m_rect; }
|
||||
|
||||
|
@ -122,10 +122,9 @@ class UpdateReadManagerMessage : public UpdateModelViewMessage
|
|||
public:
|
||||
UpdateReadManagerMessage(ScreenBase const & screen, set<TileKey> const & tiles)
|
||||
: UpdateModelViewMessage(screen)
|
||||
, m_tiles(tiles)
|
||||
{
|
||||
SetType(UpdateReadManager);
|
||||
}
|
||||
, m_tiles(tiles) {}
|
||||
|
||||
Type GetType() const override { return Message::UpdateReadManager; }
|
||||
|
||||
set<TileKey> const & GetTiles() const { return m_tiles; }
|
||||
|
||||
|
@ -137,10 +136,9 @@ class InvalidateReadManagerRectMessage : public Message
|
|||
{
|
||||
public:
|
||||
InvalidateReadManagerRectMessage(set<TileKey> const & tiles)
|
||||
: m_tiles(tiles)
|
||||
{
|
||||
SetType(InvalidateReadManagerRect);
|
||||
}
|
||||
: m_tiles(tiles) {}
|
||||
|
||||
Type GetType() const override { return Message::InvalidateReadManagerRect; }
|
||||
|
||||
set<TileKey> const & GetTilesForInvalidate() const { return m_tiles; }
|
||||
|
||||
|
@ -158,17 +156,21 @@ class ClearUserMarkLayerMessage : public BaseTileMessage
|
|||
{
|
||||
public:
|
||||
ClearUserMarkLayerMessage(TileKey const & tileKey)
|
||||
: BaseTileMessage(tileKey, Message::ClearUserMarkLayer) {}
|
||||
: BaseTileMessage(tileKey) {}
|
||||
|
||||
Type GetType() const override { return Message::ClearUserMarkLayer; }
|
||||
};
|
||||
|
||||
class ChangeUserMarkLayerVisibilityMessage : public BaseTileMessage
|
||||
{
|
||||
public:
|
||||
ChangeUserMarkLayerVisibilityMessage(TileKey const & tileKey, bool isVisible)
|
||||
: BaseTileMessage(tileKey, Message::ChangeUserMarkLayerVisibility)
|
||||
: BaseTileMessage(tileKey)
|
||||
, m_isVisible(isVisible) {}
|
||||
|
||||
bool IsVisible() const { return m_isVisible; }
|
||||
Type GetType() const override { return Message::ChangeUserMarkLayerVisibility; }
|
||||
|
||||
bool IsVisible() const { return m_isVisible; }
|
||||
|
||||
private:
|
||||
bool m_isVisible;
|
||||
|
@ -178,7 +180,7 @@ class UpdateUserMarkLayerMessage : public BaseTileMessage
|
|||
{
|
||||
public:
|
||||
UpdateUserMarkLayerMessage(TileKey const & tileKey, UserMarksProvider * provider)
|
||||
: BaseTileMessage(tileKey, Message::UpdateUserMarkLayer)
|
||||
: BaseTileMessage(tileKey)
|
||||
, m_provider(provider)
|
||||
{
|
||||
m_provider->IncrementCounter();
|
||||
|
@ -192,6 +194,8 @@ public:
|
|||
delete m_provider;
|
||||
}
|
||||
|
||||
Type GetType() const override { return Message::UpdateUserMarkLayer; }
|
||||
|
||||
UserMarksProvider const * StartProcess()
|
||||
{
|
||||
m_provider->BeginRead();
|
||||
|
@ -220,10 +224,9 @@ class GuiLayerRecachedMessage : public Message
|
|||
{
|
||||
public:
|
||||
GuiLayerRecachedMessage(dp::TransferPointer<gui::LayerRenderer> renderer)
|
||||
: m_renderer(move(renderer))
|
||||
{
|
||||
SetType(GuiLayerRecached);
|
||||
}
|
||||
: m_renderer(renderer) {}
|
||||
|
||||
Type GetType() const override { return Message::GuiLayerRecached; }
|
||||
|
||||
dp::MasterPointer<gui::LayerRenderer> AcceptRenderer()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue