use boost stuff

This commit is contained in:
Eduardo Bart 2011-04-11 18:22:01 -03:00
parent 08b6563fd5
commit 83b166e91e
21 changed files with 40 additions and 37 deletions

View File

@ -82,6 +82,6 @@ private:
Size m_cornersSize; Size m_cornersSize;
}; };
typedef std::shared_ptr<BorderedImage> BorderedImagePtr; typedef boost::shared_ptr<BorderedImage> BorderedImagePtr;
#endif // BORDEREDIMAGE_H #endif // BORDEREDIMAGE_H

View File

@ -92,6 +92,6 @@ private:
Size m_glyphsSize[256]; Size m_glyphsSize[256];
}; };
typedef std::shared_ptr<Font> FontPtr; typedef boost::shared_ptr<Font> FontPtr;
#endif // FONT_H #endif // FONT_H

View File

@ -44,6 +44,6 @@ protected:
Rect m_textureCoords; Rect m_textureCoords;
}; };
typedef std::shared_ptr<Image> ImagePtr; typedef boost::shared_ptr<Image> ImagePtr;
#endif // IMAGE_H #endif // IMAGE_H

View File

@ -52,6 +52,6 @@ private:
Size m_size; Size m_size;
}; };
typedef std::shared_ptr<Texture> TexturePtr; typedef boost::shared_ptr<Texture> TexturePtr;
#endif // TEXTURE_H #endif // TEXTURE_H

View File

@ -28,7 +28,7 @@
#include "prerequisites.h" #include "prerequisites.h"
#include "texture.h" #include "texture.h"
typedef std::weak_ptr<Texture> TextureWeakPtr; typedef boost::weak_ptr<Texture> TextureWeakPtr;
class Textures class Textures
{ {

View File

@ -33,15 +33,16 @@
class TestState; class TestState;
class Protocol; class Protocol;
class Connections; class Connections;
class Connection;
class Connection : public std::enable_shared_from_this<Connection> class Connection : public boost::enable_shared_from_this<Connection>
{ {
public: public:
typedef std::function<void()> ConnectionCallback; typedef boost::function<void()> ConnectionCallback;
typedef std::function<void(NetworkMessagePtr)> RecvCallback; typedef boost::function<void(NetworkMessagePtr)> RecvCallback;
typedef std::function<void(const boost::system::error_code&, const std::string&)> ErrorCallback; typedef boost::function<void(const boost::system::error_code&, const std::string&)> ErrorCallback;
typedef std::shared_ptr<Connection> ConnectionPtr; typedef boost::shared_ptr<Connection> ConnectionPtr;
private: private:
Connection(boost::asio::io_service& ioService); Connection(boost::asio::io_service& ioService);
@ -94,6 +95,6 @@ private:
friend class Connections; friend class Connections;
}; };
typedef std::shared_ptr<Connection> ConnectionPtr; typedef boost::shared_ptr<Connection> ConnectionPtr;
#endif //CONNECTION_h #endif //CONNECTION_h

View File

@ -92,6 +92,6 @@ protected:
uint8 m_msgBuf[NETWORKMESSAGE_MAXSIZE]; uint8 m_msgBuf[NETWORKMESSAGE_MAXSIZE];
}; };
typedef std::shared_ptr<NetworkMessage> NetworkMessagePtr; typedef boost::shared_ptr<NetworkMessage> NetworkMessagePtr;
#endif //NETWORKMESSAGE_H #endif //NETWORKMESSAGE_H

View File

@ -58,16 +58,18 @@ typedef int8_t int8;
#include <map> #include <map>
#include <string> #include <string>
#include <list> #include <list>
#include <memory>
// boost utilities // boost utilities
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#define foreach BOOST_FOREACH #define foreach BOOST_FOREACH
typedef std::function<void()> Callback; typedef boost::function<void()> Callback;
// yaml // yaml
#include <yaml-cpp/yaml.h> #include <yaml-cpp/yaml.h>

View File

@ -51,6 +51,6 @@ private:
Callback m_buttonClickCallback; Callback m_buttonClickCallback;
}; };
typedef std::shared_ptr<UIButton> UIButtonPtr; typedef boost::shared_ptr<UIButton> UIButtonPtr;
#endif // UIBUTTON_H #endif // UIBUTTON_H

View File

@ -48,7 +48,7 @@ public:
virtual UI::EElementType getElementType() const { return UI::Container; } virtual UI::EElementType getElementType() const { return UI::Container; }
UIContainerPtr asUIContainer() { return std::static_pointer_cast<UIContainer>(shared_from_this()); } UIContainerPtr asUIContainer() { return boost::static_pointer_cast<UIContainer>(shared_from_this()); }
static UIContainerPtr& getRootContainer(); static UIContainerPtr& getRootContainer();

View File

@ -33,12 +33,12 @@
class UIElementSkin; class UIElementSkin;
class UIContainer; class UIContainer;
typedef std::shared_ptr<UIContainer> UIContainerPtr; typedef boost::shared_ptr<UIContainer> UIContainerPtr;
typedef std::weak_ptr<UIContainer> UIContainerWeakPtr; typedef boost::weak_ptr<UIContainer> UIContainerWeakPtr;
class UIElement; class UIElement;
typedef std::shared_ptr<UIElement> UIElementPtr; typedef boost::shared_ptr<UIElement> UIElementPtr;
typedef std::weak_ptr<UIElement> UIElementWeakPtr; typedef boost::weak_ptr<UIElement> UIElementWeakPtr;
class UIElement : public UILayout class UIElement : public UILayout
{ {
@ -72,7 +72,7 @@ public:
UI::EElementType getElementType() const { return m_type; } UI::EElementType getElementType() const { return m_type; }
UIElementPtr asUIElement() { return std::static_pointer_cast<UIElement>(shared_from_this()); } UIElementPtr asUIElement() { return boost::static_pointer_cast<UIElement>(shared_from_this()); }
virtual UIContainerPtr asUIContainer() { return UIContainerPtr(); } virtual UIContainerPtr asUIContainer() { return UIContainerPtr(); }
friend class UIContainer; friend class UIContainer;

View File

@ -43,6 +43,6 @@ private:
std::string m_text; std::string m_text;
}; };
typedef std::shared_ptr<UILabel> UILabelPtr; typedef boost::shared_ptr<UILabel> UILabelPtr;
#endif // UILABEL_H #endif // UILABEL_H

View File

@ -39,8 +39,8 @@ enum EAnchorType {
}; };
class UILayout; class UILayout;
typedef std::shared_ptr<UILayout> UILayoutPtr; typedef boost::shared_ptr<UILayout> UILayoutPtr;
typedef std::weak_ptr<UILayout> UILayoutWeakPtr; typedef boost::weak_ptr<UILayout> UILayoutWeakPtr;
class AnchorLine class AnchorLine
{ {
@ -62,7 +62,7 @@ private:
EAnchorType m_anchorType; EAnchorType m_anchorType;
}; };
class UILayout : public std::enable_shared_from_this<UILayout> class UILayout : public boost::enable_shared_from_this<UILayout>
{ {
public: public:
UILayout() : UILayout() :

View File

@ -194,17 +194,17 @@ void UILoader::loadElement(const UIElementPtr& element, const YAML::Node& node)
// load specific element type // load specific element type
if(element->getElementType() == UI::Button) { if(element->getElementType() == UI::Button) {
UIButtonPtr button = std::static_pointer_cast<UIButton>(element); UIButtonPtr button = boost::static_pointer_cast<UIButton>(element);
node["text"] >> tmp; node["text"] >> tmp;
button->setText(tmp); button->setText(tmp);
} }
else if(element->getElementType() == UI::Window) { else if(element->getElementType() == UI::Window) {
UIWindowPtr window = std::static_pointer_cast<UIWindow>(element); UIWindowPtr window = boost::static_pointer_cast<UIWindow>(element);
node["title"] >> tmp; node["title"] >> tmp;
window->setTitle(tmp); window->setTitle(tmp);
} }
else if(element->getElementType() == UI::Label) { else if(element->getElementType() == UI::Label) {
UILabelPtr label = std::static_pointer_cast<UILabel>(element); UILabelPtr label = boost::static_pointer_cast<UILabel>(element);
node["text"] >> tmp; node["text"] >> tmp;
label->setText(tmp); label->setText(tmp);
} }

View File

@ -35,6 +35,6 @@ public:
UIPanel() : UIContainer(UI::Panel) { } UIPanel() : UIContainer(UI::Panel) { }
}; };
typedef std::shared_ptr<UIPanel> UIPanelPtr; typedef boost::shared_ptr<UIPanel> UIPanelPtr;
#endif // UIPANEL_H #endif // UIPANEL_H

View File

@ -57,6 +57,6 @@ private:
std::string m_text; std::string m_text;
}; };
typedef std::shared_ptr<UITextEdit> UITextEditPtr; typedef boost::shared_ptr<UITextEdit> UITextEditPtr;
#endif // UITEXTEDIT_H #endif // UITEXTEDIT_H

View File

@ -41,6 +41,6 @@ private:
std::string m_title; std::string m_title;
}; };
typedef std::shared_ptr<UIWindow> UIWindowPtr; typedef boost::shared_ptr<UIWindow> UIWindowPtr;
#endif // UIWINDOW_H #endif // UIWINDOW_H

View File

@ -43,6 +43,6 @@ protected:
mpz_t m_p, m_q, m_u, m_d, m_dp, m_dq, m_mod; mpz_t m_p, m_q, m_u, m_d, m_dp, m_dq, m_mod;
}; };
typedef std::shared_ptr<Rsa> RsaPtr; typedef boost::shared_ptr<Rsa> RsaPtr;
#endif //RSA_H #endif //RSA_H

View File

@ -113,8 +113,8 @@ int main(int argc, const char *argv[])
// state scope // state scope
{ {
std::shared_ptr<MenuState> initialState(new MenuState); boost::shared_ptr<MenuState> initialState(new MenuState);
//std::shared_ptr<TestState> initialState(new TestState); //boost::shared_ptr<TestState> initialState(new TestState);
g_dispatcher.addTask(boost::bind(&Engine::changeState, &g_engine, initialState.get())); g_dispatcher.addTask(boost::bind(&Engine::changeState, &g_engine, initialState.get()));
Platform::showWindow(); Platform::showWindow();

View File

@ -41,10 +41,10 @@ void MenuState::onEnter()
UIContainerPtr mainMenuPanel = UILoader::loadFile("ui/mainMenu.yml")->asUIContainer(); UIContainerPtr mainMenuPanel = UILoader::loadFile("ui/mainMenu.yml")->asUIContainer();
UIButtonPtr button = std::static_pointer_cast<UIButton>(mainMenuPanel->getChildById("exitGameButton")); UIButtonPtr button = boost::static_pointer_cast<UIButton>(mainMenuPanel->getChildById("exitGameButton"));
button->setOnClick(boost::bind(&MenuState::onClose, this)); button->setOnClick(boost::bind(&MenuState::onClose, this));
button = std::static_pointer_cast<UIButton>(mainMenuPanel->getChildById("enterGameButton")); button = boost::static_pointer_cast<UIButton>(mainMenuPanel->getChildById("enterGameButton"));
button->setOnClick(boost::bind(&MenuState::enterGameButton_clicked, this)); button->setOnClick(boost::bind(&MenuState::enterGameButton_clicked, this));
} }

View File

@ -50,6 +50,6 @@ private:
static const char* rsa; static const char* rsa;
}; };
typedef std::shared_ptr<ProtocolTibia87> ProtocolTibia87Ptr; typedef boost::shared_ptr<ProtocolTibia87> ProtocolTibia87Ptr;
#endif //PROTOCOLTIBIA87_H #endif //PROTOCOLTIBIA87_H