Bonjour à tous,
Je suis face à un problème plus que basique mais où je sèche...
J'ai une classe avec une méthode me servant à procéder à un traitement suite à la réception de data.
Le code suivant fonctionne sans problème :
Cependant le code suivant non
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 //---------------------------------- bool MCU::handleApplicationRequests(std::shared_ptr<Action> &action, std::shared_ptr<Channel> channel, const bool &hasToLock) //---------------------------------- { const std::string &actionCode = action->getDataAsString("actionCode"); const std::string &method = action->getMethod(); if (method == "dump") { Utils::log(Logger::LEVEL::DEBUG, "Method: [%s]", method.c_str()); this->_channels->dump(); this->_conferences->dump(); } else if (method == "X") this->handleXMessage(action); ... return true; }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 //---------------------------------- bool MCU::handleApplicationRequests(std::shared_ptr<Action> &action, std::shared_ptr<Channel> channel, const bool &hasToLock) //---------------------------------- { boost::asio::post(this->_threadPool, [action, channel, hasToLock, this] () { const std::string &actionCode = action->getDataAsString("actionCode"); const std::string &method = action->getMethod(); if (method != "ActionHeartbeatMcuDTO") action->dump(); if (method == "dump") { Utils::log(Logger::LEVEL::DEBUG, "Method: [%s]", method.c_str()); this->_channels->dump(); this->_conferences->dump(); } else if (method == "X") this->handleXMessage(action); ... }); return true; }
Le message d'erreur est le suivant
J'ai trouvé un workaround qui est le suivant:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 [root@std1-viapika-archiv3-dev MCU]# make g++ -I./includes -I/usr/include/pika -I/usr/local/includes -I/usr/include -I/usr/local/apr/include/apr-1 -I/usr/local/unimrcp/include -Wall -ansi -pedantic -std=gnu++1z -DGP_USE_CALLINFO_EX -DASR_TELISMA -DRESOURCES_DEBUG -g -ggdb -c mcu.cpp -o mcu.o mcu.cpp: In lambda function: mcu.cpp:164:74: error: binding reference of type std::shared_ptr<Action>& to const std::shared_ptr<Action> discards qualifiers else if (method == "X") this->handleXMessage(action);
Est-ce que qqun arriverait à m'expliquer où est le problème et surtout pourquoi je dois passer par une variable intermédiaire?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 //---------------------------------- bool MCU::handleApplicationRequests(std::shared_ptr<Action> &action, std::shared_ptr<Channel> channel, const bool &hasToLock) //---------------------------------- { boost::asio::post(this->_threadPool, [action2 = action, channel, hasToLock, this] () { std::shared_ptr<Action> action = action2; const std::string &actionCode = action->getDataAsString("actionCode"); const std::string &method = action->getMethod(); if (method != "ActionHeartbeatMcuDTO") action->dump(); if (method == "dump") { Utils::log(Logger::LEVEL::DEBUG, "Method: [%s]", method.c_str()); this->_channels->dump(); this->_conferences->dump(); } else if (method == "X") this->handleXMessage(action);
Bonne journée
Partager