summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/depricatedevent.cpp41
-rw-r--r--src/depricatedevent.h19
2 files changed, 27 insertions, 33 deletions
diff --git a/src/depricatedevent.cpp b/src/depricatedevent.cpp
index ad744839c..37826ac24 100644
--- a/src/depricatedevent.cpp
+++ b/src/depricatedevent.cpp
@@ -40,71 +40,68 @@ DepricatedEvent::~DepricatedEvent()
}
void DepricatedEvent::setInt(const std::string &key, const int value)
- throw (BadDepricatedEvent)
{
if (mData.find(key) != mData.end())
- throw KEY_ALREADY_EXISTS;
+ delete mData[key];
mData[key] = new IntData(value);
}
int DepricatedEvent::getInt(const std::string &key) const
- throw (BadDepricatedEvent)
{
const VariableMap::const_iterator it = mData.find(key);
if (it == mData.end())
- throw BAD_KEY;
+ return 0;
- if (!it->second || it->second->getType() != VariableData::DATA_INT)
- throw BAD_VALUE;
+ VariableData *const data = it->second;
+ if (!data || data->getType() != VariableData::DATA_INT)
+ return 0;
- return static_cast<IntData *>(it->second)->getData();
+ return static_cast<IntData *>(data)->getData();
}
void DepricatedEvent::setString(const std::string &key,
const std::string &value)
- throw (BadDepricatedEvent)
{
if (mData.find(key) != mData.end())
- throw KEY_ALREADY_EXISTS;
+ delete mData[key];
mData[key] = new StringData(value);
}
-const std::string &DepricatedEvent::getString(const std::string &key)
- const throw (BadDepricatedEvent)
+const std::string &DepricatedEvent::getString(const std::string &key) const
{
const VariableMap::const_iterator it = mData.find(key);
if (it == mData.end())
- throw BAD_KEY;
+ return "";
- if (!it->second || it->second->getType() != VariableData::DATA_STRING)
- throw BAD_VALUE;
+ VariableData *const data = it->second;
+ if (!data || data->getType() != VariableData::DATA_STRING)
+ return "";
- return static_cast<StringData *>(it->second)->getData();
+ return static_cast<StringData *>(data)->getData();
}
void DepricatedEvent::setFloat(const std::string &key, const double value)
- throw (BadDepricatedEvent)
{
if (mData.find(key) != mData.end())
- throw KEY_ALREADY_EXISTS;
+ delete mData[key];
mData[key] = new FloatData(value);
}
double DepricatedEvent::getFloat(const std::string &key) const
- throw (BadDepricatedEvent)
{
const VariableMap::const_iterator it = mData.find(key);
if (it == mData.end())
- throw BAD_KEY;
+ return 0;
- if (!it->second || it->second->getType() != VariableData::DATA_FLOAT)
- throw BAD_VALUE;
+ VariableData *const data = it->second;
+ if (!data || data->getType() != VariableData::DATA_FLOAT)
+ return 0;
- return static_cast<FloatData *>(it->second)->getData();
+ return static_cast<FloatData *>(data)->getData();
}
void DepricatedEvent::trigger(const Channels channel,
diff --git a/src/depricatedevent.h b/src/depricatedevent.h
index 285d9f240..b7b52e671 100644
--- a/src/depricatedevent.h
+++ b/src/depricatedevent.h
@@ -133,25 +133,21 @@ class DepricatedEvent final
{ return mDepricatedEventName; }
// Sets or gets a interger with a key to identify
- void setInt(const std::string &key, int value)
- throw (BadDepricatedEvent);
+ void setInt(const std::string &key, int value);
- int getInt(const std::string &key)
- const throw (BadDepricatedEvent) A_WARN_UNUSED;
+ int getInt(const std::string &key) const A_WARN_UNUSED;
// Sets or gets a string with a key to identify
void setString(const std::string &key,
- const std::string &value)
- throw (BadDepricatedEvent);
+ const std::string &value);
const std::string &getString(const std::string &key)
- const throw (BadDepricatedEvent) A_WARN_UNUSED;
+ const A_WARN_UNUSED;
// Sets or gets a floating point number with key to identify
- void setFloat(const std::string &key, double value)
- throw (BadDepricatedEvent);
- double getFloat(const std::string &key)
- const throw (BadDepricatedEvent) A_WARN_UNUSED;
+ void setFloat(const std::string &key, double value);
+
+ double getFloat(const std::string &key) const A_WARN_UNUSED;
// Sends event to all listener on the channel
static void trigger(const Channels channel,
@@ -162,6 +158,7 @@ class DepricatedEvent final
// Adds or removes a listener to a channel.
static void bind(Listener *const listener, const Channels channel);
+
static void unbind(Listener *const listener, const Channels channel);
private: