summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2014-02-14 18:49:04 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2014-02-14 18:49:04 +0100
commitc1da0ac7cca49e0b96dbb359ee48000cb04df15b (patch)
treec6041007cfa28ea80e5dc5df2f1944faf714ab32
parentd6d8d67b1c921d8fca7257291c15c07bdea8d14a (diff)
downloaddabmux-c1da0ac7cca49e0b96dbb359ee48000cb04df15b.tar.gz
dabmux-c1da0ac7cca49e0b96dbb359ee48000cb04df15b.tar.bz2
dabmux-c1da0ac7cca49e0b96dbb359ee48000cb04df15b.zip
improve RC constness
-rw-r--r--src/MuxElements.cpp10
-rw-r--r--src/MuxElements.h10
-rw-r--r--src/RemoteControl.h14
-rw-r--r--src/dabInputZmq.cpp5
-rw-r--r--src/dabInputZmq.h5
5 files changed, 26 insertions, 18 deletions
diff --git a/src/MuxElements.cpp b/src/MuxElements.cpp
index 1e3f5b2..11eb4bf 100644
--- a/src/MuxElements.cpp
+++ b/src/MuxElements.cpp
@@ -218,7 +218,8 @@ bool DabComponent::isPacketComponent(vector<dabSubchannel*>& subchannels)
return true;
}
-void DabComponent::set_parameter(string parameter, string value)
+void DabComponent::set_parameter(const string& parameter,
+ const string& value)
{
stringstream ss(value);
ss.exceptions ( stringstream::failbit | stringstream::badbit );
@@ -266,7 +267,7 @@ void DabComponent::set_parameter(string parameter, string value)
}
}
-string DabComponent::get_parameter(string parameter)
+const string DabComponent::get_parameter(const string& parameter) const
{
stringstream ss;
if (parameter == "label") {
@@ -315,7 +316,8 @@ unsigned char DabService::nbComponent(vector<DabComponent*>& components)
return nb;
}
-void DabService::set_parameter(string parameter, string value)
+void DabService::set_parameter(const string& parameter,
+ const string& value)
{
stringstream ss(value);
ss.exceptions ( stringstream::failbit | stringstream::badbit );
@@ -363,7 +365,7 @@ void DabService::set_parameter(string parameter, string value)
}
}
-string DabService::get_parameter(string parameter)
+const string DabService::get_parameter(const string& parameter) const
{
stringstream ss;
if (parameter == "label") {
diff --git a/src/MuxElements.h b/src/MuxElements.h
index 711f3cf..c416314 100644
--- a/src/MuxElements.h
+++ b/src/MuxElements.h
@@ -188,10 +188,11 @@ class DabComponent : public RemoteControllable
bool isPacketComponent(vector<dabSubchannel*>& subchannels);
/* Remote control */
- virtual void set_parameter(string parameter, string value);
+ virtual void set_parameter(const string& parameter,
+ const string& value);
/* Getting a parameter always returns a string. */
- virtual string get_parameter(string parameter);
+ virtual const string get_parameter(const string& parameter) const;
private:
@@ -221,10 +222,11 @@ class DabService : public RemoteControllable
DabLabel label;
/* Remote control */
- virtual void set_parameter(string parameter, string value);
+ virtual void set_parameter(const string& parameter,
+ const string& value);
/* Getting a parameter always returns a string. */
- virtual string get_parameter(string parameter);
+ virtual const string get_parameter(const string& parameter) const;
private:
const DabService& operator=(const DabService& other);
diff --git a/src/RemoteControl.h b/src/RemoteControl.h
index a39af09..e76ba68 100644
--- a/src/RemoteControl.h
+++ b/src/RemoteControl.h
@@ -84,7 +84,7 @@ class RemoteControllable {
* It might be used in the commands the user has to type, so keep
* it short
*/
- virtual std::string get_rc_name() { return m_name; }
+ virtual std::string get_rc_name() const { return m_name; }
/* Tell the controllable to enrol at the given controller */
virtual void enrol_at(BaseRemoteController& controller) {
@@ -92,9 +92,9 @@ class RemoteControllable {
}
/* Return a list of possible parameters that can be set */
- virtual list<string> get_supported_parameters() {
+ virtual list<string> get_supported_parameters() const {
list<string> parameterlist;
- for (list< vector<string> >::iterator it = m_parameters.begin();
+ for (list< vector<string> >::const_iterator it = m_parameters.begin();
it != m_parameters.end(); ++it) {
parameterlist.push_back((*it)[0]);
}
@@ -102,15 +102,17 @@ class RemoteControllable {
}
/* Return a mapping of the descriptions of all parameters */
- virtual std::list< std::vector<std::string> > get_parameter_descriptions() {
+ virtual std::list< std::vector<std::string> >
+ get_parameter_descriptions() const {
return m_parameters;
}
/* Base function to set parameters. */
- virtual void set_parameter(string parameter, string value) = 0;
+ virtual void set_parameter(const string& parameter,
+ const string& value) = 0;
/* Getting a parameter always returns a string. */
- virtual string get_parameter(string parameter) = 0;
+ virtual const string get_parameter(const string& parameter) const = 0;
protected:
std::string m_name;
diff --git a/src/dabInputZmq.cpp b/src/dabInputZmq.cpp
index 387c8cc..de0a4fe 100644
--- a/src/dabInputZmq.cpp
+++ b/src/dabInputZmq.cpp
@@ -311,7 +311,8 @@ int DabInputZmqAAC::readFromSocket(int framesize)
/********* REMOTE CONTROL ***********/
-void DabInputZmqBase::set_parameter(string parameter, string value)
+void DabInputZmqBase::set_parameter(const string& parameter,
+ const string& value)
{
stringstream ss(value);
ss.exceptions ( stringstream::failbit | stringstream::badbit );
@@ -349,7 +350,7 @@ void DabInputZmqBase::set_parameter(string parameter, string value)
}
}
-string DabInputZmqBase::get_parameter(string parameter)
+const string DabInputZmqBase::get_parameter(const string& parameter) const
{
stringstream ss;
if (parameter == "buffer") {
diff --git a/src/dabInputZmq.h b/src/dabInputZmq.h
index cb7fdd4..5c88316 100644
--- a/src/dabInputZmq.h
+++ b/src/dabInputZmq.h
@@ -90,10 +90,11 @@ class DabInputZmqBase : public DabInputBase, public RemoteControllable {
virtual int close();
/* Remote control */
- virtual void set_parameter(string parameter, string value);
+ virtual void set_parameter(const string& parameter,
+ const string& value);
/* Getting a parameter always returns a string. */
- virtual string get_parameter(string parameter);
+ virtual const string get_parameter(const string& parameter) const;
protected:
virtual int readFromSocket(int framesize) = 0;