From 83b166e91e338c9b00a63cd9c3b7910a549bfeab Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Mon, 11 Apr 2011 18:22:01 -0300 Subject: [PATCH] use boost stuff --- src/framework/graphics/borderedimage.h | 2 +- src/framework/graphics/font.h | 2 +- src/framework/graphics/image.h | 2 +- src/framework/graphics/texture.h | 2 +- src/framework/graphics/textures.h | 2 +- src/framework/net/connection.h | 13 +++++++------ src/framework/net/networkmessage.h | 2 +- src/framework/prerequisites.h | 6 ++++-- src/framework/ui/uibutton.h | 2 +- src/framework/ui/uicontainer.h | 2 +- src/framework/ui/uielement.h | 10 +++++----- src/framework/ui/uilabel.h | 2 +- src/framework/ui/uilayout.h | 6 +++--- src/framework/ui/uiloader.cpp | 6 +++--- src/framework/ui/uipanel.h | 2 +- src/framework/ui/uitextedit.h | 2 +- src/framework/ui/uiwindow.h | 2 +- src/framework/util/rsa.h | 2 +- src/main.cpp | 4 ++-- src/menustate.cpp | 4 ++-- src/net/protocoltibia87.h | 2 +- 21 files changed, 40 insertions(+), 37 deletions(-) diff --git a/src/framework/graphics/borderedimage.h b/src/framework/graphics/borderedimage.h index dfb6ea31..5ec3c380 100644 --- a/src/framework/graphics/borderedimage.h +++ b/src/framework/graphics/borderedimage.h @@ -82,6 +82,6 @@ private: Size m_cornersSize; }; -typedef std::shared_ptr BorderedImagePtr; +typedef boost::shared_ptr BorderedImagePtr; #endif // BORDEREDIMAGE_H diff --git a/src/framework/graphics/font.h b/src/framework/graphics/font.h index 10827d4c..4e691d46 100644 --- a/src/framework/graphics/font.h +++ b/src/framework/graphics/font.h @@ -92,6 +92,6 @@ private: Size m_glyphsSize[256]; }; -typedef std::shared_ptr FontPtr; +typedef boost::shared_ptr FontPtr; #endif // FONT_H diff --git a/src/framework/graphics/image.h b/src/framework/graphics/image.h index 62b98fa8..2d31f2a4 100644 --- a/src/framework/graphics/image.h +++ b/src/framework/graphics/image.h @@ -44,6 +44,6 @@ protected: Rect m_textureCoords; }; -typedef std::shared_ptr ImagePtr; +typedef boost::shared_ptr ImagePtr; #endif // IMAGE_H diff --git a/src/framework/graphics/texture.h b/src/framework/graphics/texture.h index eafdb835..6ecdf034 100644 --- a/src/framework/graphics/texture.h +++ b/src/framework/graphics/texture.h @@ -52,6 +52,6 @@ private: Size m_size; }; -typedef std::shared_ptr TexturePtr; +typedef boost::shared_ptr TexturePtr; #endif // TEXTURE_H diff --git a/src/framework/graphics/textures.h b/src/framework/graphics/textures.h index 161a11e2..eabaefe6 100644 --- a/src/framework/graphics/textures.h +++ b/src/framework/graphics/textures.h @@ -28,7 +28,7 @@ #include "prerequisites.h" #include "texture.h" -typedef std::weak_ptr TextureWeakPtr; +typedef boost::weak_ptr TextureWeakPtr; class Textures { diff --git a/src/framework/net/connection.h b/src/framework/net/connection.h index 50301074..eab21c40 100644 --- a/src/framework/net/connection.h +++ b/src/framework/net/connection.h @@ -33,15 +33,16 @@ class TestState; class Protocol; class Connections; +class Connection; -class Connection : public std::enable_shared_from_this +class Connection : public boost::enable_shared_from_this { public: - typedef std::function ConnectionCallback; - typedef std::function RecvCallback; - typedef std::function ErrorCallback; + typedef boost::function ConnectionCallback; + typedef boost::function RecvCallback; + typedef boost::function ErrorCallback; - typedef std::shared_ptr ConnectionPtr; + typedef boost::shared_ptr ConnectionPtr; private: Connection(boost::asio::io_service& ioService); @@ -94,6 +95,6 @@ private: friend class Connections; }; -typedef std::shared_ptr ConnectionPtr; +typedef boost::shared_ptr ConnectionPtr; #endif //CONNECTION_h diff --git a/src/framework/net/networkmessage.h b/src/framework/net/networkmessage.h index 5365ab55..c3edce6e 100644 --- a/src/framework/net/networkmessage.h +++ b/src/framework/net/networkmessage.h @@ -92,6 +92,6 @@ protected: uint8 m_msgBuf[NETWORKMESSAGE_MAXSIZE]; }; -typedef std::shared_ptr NetworkMessagePtr; +typedef boost::shared_ptr NetworkMessagePtr; #endif //NETWORKMESSAGE_H \ No newline at end of file diff --git a/src/framework/prerequisites.h b/src/framework/prerequisites.h index b68b4197..f69fff0f 100644 --- a/src/framework/prerequisites.h +++ b/src/framework/prerequisites.h @@ -58,16 +58,18 @@ typedef int8_t int8; #include #include #include -#include // boost utilities #include #include #include #include +#include +#include +#include #define foreach BOOST_FOREACH -typedef std::function Callback; +typedef boost::function Callback; // yaml #include diff --git a/src/framework/ui/uibutton.h b/src/framework/ui/uibutton.h index c21cd4c0..712f8974 100644 --- a/src/framework/ui/uibutton.h +++ b/src/framework/ui/uibutton.h @@ -51,6 +51,6 @@ private: Callback m_buttonClickCallback; }; -typedef std::shared_ptr UIButtonPtr; +typedef boost::shared_ptr UIButtonPtr; #endif // UIBUTTON_H diff --git a/src/framework/ui/uicontainer.h b/src/framework/ui/uicontainer.h index b9b6413e..f64bf514 100644 --- a/src/framework/ui/uicontainer.h +++ b/src/framework/ui/uicontainer.h @@ -48,7 +48,7 @@ public: virtual UI::EElementType getElementType() const { return UI::Container; } - UIContainerPtr asUIContainer() { return std::static_pointer_cast(shared_from_this()); } + UIContainerPtr asUIContainer() { return boost::static_pointer_cast(shared_from_this()); } static UIContainerPtr& getRootContainer(); diff --git a/src/framework/ui/uielement.h b/src/framework/ui/uielement.h index a6474e43..9f415868 100644 --- a/src/framework/ui/uielement.h +++ b/src/framework/ui/uielement.h @@ -33,12 +33,12 @@ class UIElementSkin; class UIContainer; -typedef std::shared_ptr UIContainerPtr; -typedef std::weak_ptr UIContainerWeakPtr; +typedef boost::shared_ptr UIContainerPtr; +typedef boost::weak_ptr UIContainerWeakPtr; class UIElement; -typedef std::shared_ptr UIElementPtr; -typedef std::weak_ptr UIElementWeakPtr; +typedef boost::shared_ptr UIElementPtr; +typedef boost::weak_ptr UIElementWeakPtr; class UIElement : public UILayout { @@ -72,7 +72,7 @@ public: UI::EElementType getElementType() const { return m_type; } - UIElementPtr asUIElement() { return std::static_pointer_cast(shared_from_this()); } + UIElementPtr asUIElement() { return boost::static_pointer_cast(shared_from_this()); } virtual UIContainerPtr asUIContainer() { return UIContainerPtr(); } friend class UIContainer; diff --git a/src/framework/ui/uilabel.h b/src/framework/ui/uilabel.h index 3a7f8e13..7a24be0f 100644 --- a/src/framework/ui/uilabel.h +++ b/src/framework/ui/uilabel.h @@ -43,6 +43,6 @@ private: std::string m_text; }; -typedef std::shared_ptr UILabelPtr; +typedef boost::shared_ptr UILabelPtr; #endif // UILABEL_H diff --git a/src/framework/ui/uilayout.h b/src/framework/ui/uilayout.h index f62b3fe1..de5fff7c 100644 --- a/src/framework/ui/uilayout.h +++ b/src/framework/ui/uilayout.h @@ -39,8 +39,8 @@ enum EAnchorType { }; class UILayout; -typedef std::shared_ptr UILayoutPtr; -typedef std::weak_ptr UILayoutWeakPtr; +typedef boost::shared_ptr UILayoutPtr; +typedef boost::weak_ptr UILayoutWeakPtr; class AnchorLine { @@ -62,7 +62,7 @@ private: EAnchorType m_anchorType; }; -class UILayout : public std::enable_shared_from_this +class UILayout : public boost::enable_shared_from_this { public: UILayout() : diff --git a/src/framework/ui/uiloader.cpp b/src/framework/ui/uiloader.cpp index c4b6c26b..891aed8b 100644 --- a/src/framework/ui/uiloader.cpp +++ b/src/framework/ui/uiloader.cpp @@ -194,17 +194,17 @@ void UILoader::loadElement(const UIElementPtr& element, const YAML::Node& node) // load specific element type if(element->getElementType() == UI::Button) { - UIButtonPtr button = std::static_pointer_cast(element); + UIButtonPtr button = boost::static_pointer_cast(element); node["text"] >> tmp; button->setText(tmp); } else if(element->getElementType() == UI::Window) { - UIWindowPtr window = std::static_pointer_cast(element); + UIWindowPtr window = boost::static_pointer_cast(element); node["title"] >> tmp; window->setTitle(tmp); } else if(element->getElementType() == UI::Label) { - UILabelPtr label = std::static_pointer_cast(element); + UILabelPtr label = boost::static_pointer_cast(element); node["text"] >> tmp; label->setText(tmp); } diff --git a/src/framework/ui/uipanel.h b/src/framework/ui/uipanel.h index c78bcb66..d69a20fb 100644 --- a/src/framework/ui/uipanel.h +++ b/src/framework/ui/uipanel.h @@ -35,6 +35,6 @@ public: UIPanel() : UIContainer(UI::Panel) { } }; -typedef std::shared_ptr UIPanelPtr; +typedef boost::shared_ptr UIPanelPtr; #endif // UIPANEL_H diff --git a/src/framework/ui/uitextedit.h b/src/framework/ui/uitextedit.h index 2dd7a269..45c504f1 100644 --- a/src/framework/ui/uitextedit.h +++ b/src/framework/ui/uitextedit.h @@ -57,6 +57,6 @@ private: std::string m_text; }; -typedef std::shared_ptr UITextEditPtr; +typedef boost::shared_ptr UITextEditPtr; #endif // UITEXTEDIT_H diff --git a/src/framework/ui/uiwindow.h b/src/framework/ui/uiwindow.h index 572bb8bf..6fe5b0e4 100644 --- a/src/framework/ui/uiwindow.h +++ b/src/framework/ui/uiwindow.h @@ -41,6 +41,6 @@ private: std::string m_title; }; -typedef std::shared_ptr UIWindowPtr; +typedef boost::shared_ptr UIWindowPtr; #endif // UIWINDOW_H diff --git a/src/framework/util/rsa.h b/src/framework/util/rsa.h index 6f8f401f..2773d527 100644 --- a/src/framework/util/rsa.h +++ b/src/framework/util/rsa.h @@ -43,6 +43,6 @@ protected: mpz_t m_p, m_q, m_u, m_d, m_dp, m_dq, m_mod; }; -typedef std::shared_ptr RsaPtr; +typedef boost::shared_ptr RsaPtr; #endif //RSA_H \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 91a78949..9d3e989f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -113,8 +113,8 @@ int main(int argc, const char *argv[]) // state scope { - std::shared_ptr initialState(new MenuState); - //std::shared_ptr initialState(new TestState); + boost::shared_ptr initialState(new MenuState); + //boost::shared_ptr initialState(new TestState); g_dispatcher.addTask(boost::bind(&Engine::changeState, &g_engine, initialState.get())); Platform::showWindow(); diff --git a/src/menustate.cpp b/src/menustate.cpp index 56aeda96..5dcbc48e 100644 --- a/src/menustate.cpp +++ b/src/menustate.cpp @@ -41,10 +41,10 @@ void MenuState::onEnter() UIContainerPtr mainMenuPanel = UILoader::loadFile("ui/mainMenu.yml")->asUIContainer(); - UIButtonPtr button = std::static_pointer_cast(mainMenuPanel->getChildById("exitGameButton")); + UIButtonPtr button = boost::static_pointer_cast(mainMenuPanel->getChildById("exitGameButton")); button->setOnClick(boost::bind(&MenuState::onClose, this)); - button = std::static_pointer_cast(mainMenuPanel->getChildById("enterGameButton")); + button = boost::static_pointer_cast(mainMenuPanel->getChildById("enterGameButton")); button->setOnClick(boost::bind(&MenuState::enterGameButton_clicked, this)); } diff --git a/src/net/protocoltibia87.h b/src/net/protocoltibia87.h index 358aef84..8e9d5a8a 100644 --- a/src/net/protocoltibia87.h +++ b/src/net/protocoltibia87.h @@ -50,6 +50,6 @@ private: static const char* rsa; }; -typedef std::shared_ptr ProtocolTibia87Ptr; +typedef boost::shared_ptr ProtocolTibia87Ptr; #endif //PROTOCOLTIBIA87_H \ No newline at end of file