aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2012-09-17 01:03:35 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-13 22:41:06 +0100
commitb05920748f2eb83839c7925f3c83530b733331f1 (patch)
tree122f00948216df036b159df9630fed645da1585a
parent6bfb5f6d2c9b78c1439f9dfcc44005e6dc8056e4 (diff)
downloadusdx-b05920748f2eb83839c7925f3c83530b733331f1.tar.gz
usdx-b05920748f2eb83839c7925f3c83530b733331f1.tar.xz
usdx-b05920748f2eb83839c7925f3c83530b733331f1.zip
add const where applicable
-rw-r--r--src/menu/control.cpp10
-rw-r--r--src/menu/control.hpp16
-rw-r--r--src/utils/image.cpp4
-rw-r--r--src/utils/image.hpp6
4 files changed, 22 insertions, 14 deletions
diff --git a/src/menu/control.cpp b/src/menu/control.cpp
index 5a19682d..6ca59e8e 100644
--- a/src/menu/control.cpp
+++ b/src/menu/control.cpp
@@ -39,8 +39,8 @@ namespace usdx
// you need the next iterator to be able to produce the next value after
// removing it (each control, will be issue a request to remove it self
// from the list)
- for (std::list<Control*>::iterator next = slaves.begin(), it = next++;
- it != slaves.end(); it = next++) {
+ for (std::list<const Control*>::iterator next = slaves.begin(),
+ it = next++; it != slaves.end(); it = next++) {
delete *it;
}
@@ -65,17 +65,17 @@ namespace usdx
}
}
- Control* Control::get_owner(void) const
+ const Control* Control::get_owner(void) const
{
return owner;
}
- void Control::add_slave(Control *new_slave)
+ void Control::add_slave(const Control *new_slave)
{
slaves.push_back(new_slave);
}
- void Control::remove_slave(Control *slave)
+ void Control::remove_slave(const Control *slave)
{
slaves.remove(slave);
}
diff --git a/src/menu/control.hpp b/src/menu/control.hpp
index b821e79b..a4314579 100644
--- a/src/menu/control.hpp
+++ b/src/menu/control.hpp
@@ -43,10 +43,14 @@ namespace usdx
Control* owner;
protected:
- std::list<Control*> slaves;
+ /**
+ * All slaves the control owns. All these controls should be deleted
+ * during decontruction of this control.
+ */
+ std::list<const Control*> slaves;
- void add_slave(Control*);
- void remove_slave(Control*);
+ void add_slave(const Control*);
+ void remove_slave(const Control*);
public:
Control(Control*);
@@ -58,7 +62,11 @@ namespace usdx
* withthe new owner.
*/
void set_owner(Control*);
- Control* get_owner(void) const;
+
+ /**
+ * Returns the current owner of this control.
+ */
+ const Control* get_owner(void) const;
};
};
diff --git a/src/utils/image.cpp b/src/utils/image.cpp
index 4146e0e4..93808f2e 100644
--- a/src/utils/image.cpp
+++ b/src/utils/image.cpp
@@ -58,7 +58,7 @@ namespace usdx
}
}
- void Image::load(void)
+ void Image::load(void) const
{
BinaryFile file(filename);
@@ -73,7 +73,7 @@ namespace usdx
}
}
- SDL_Surface* Image::get_surface(void)
+ const SDL_Surface* Image::get_surface(void) const
{
if (surface == NULL) {
load();
diff --git a/src/utils/image.hpp b/src/utils/image.hpp
index e27dc49d..b968652c 100644
--- a/src/utils/image.hpp
+++ b/src/utils/image.hpp
@@ -51,15 +51,15 @@ namespace usdx
static log4cpp::Category& log;
boost::filesystem::wpath filename;
- SDL_Surface* surface;
+ mutable SDL_Surface* surface;
- void load(void);
+ void load(void) const;
public:
Image(boost::filesystem::wpath filename);
virtual ~Image();
- SDL_Surface* get_surface(void);
+ const SDL_Surface* get_surface(void) const;
};
};