Merge pull request #403 from andybryson/rem_boost

Remove Boost Dependency - The Easy Bits
This commit is contained in:
Mark Liversedge
2012-12-27 09:51:30 -08:00
29 changed files with 106 additions and 126 deletions

View File

@@ -55,6 +55,8 @@
#include <fcntl.h>
#include <sys/types.h>
#include <stdint.h> //uint8_t
#ifdef WIN32
#include <windows.h>
#include <winbase.h>

View File

@@ -21,10 +21,10 @@
#include "GoldenCheetah.h"
#include <QtCore>
#include <boost/shared_ptr.hpp>
class CommPort;
typedef boost::shared_ptr<CommPort> CommPortPtr;
typedef QSharedPointer<CommPort> CommPortPtr;
class CommPort
{

View File

@@ -33,7 +33,7 @@
#include <algorithm> // for std::sort
#include <assert.h>
#include <boost/cstdint.hpp> // for int8_t, int16_t, etc.
#include <stdint.h> // for int8_t, int16_t, etc.
#include <iostream>
#include "math.h"

View File

@@ -38,7 +38,6 @@
#include "LTMCanvasPicker.h"
#include "TimeUtils.h"
#include <boost/scoped_ptr.hpp>
#include <algorithm> // for std::lower_bound
#define USE_T0_IN_CP_MODEL 0 // added djconnel 08Apr2009: allow 3-parameter CP model

View File

@@ -34,7 +34,6 @@
#include "RideMetadata.h"
#include "SpecialFields.h"
#include <boost/scoped_array.hpp>
#include <boost/crc.hpp>
// DB Schema Version - YOU MUST UPDATE THIS IF THE SCHEMA VERSION CHANGES!!!
@@ -133,7 +132,7 @@ computeFileCRC(QString filename)
if (!file.open(QFile::ReadOnly)) return 0;
// allocate space
boost::scoped_array<char> data(new char[file.size()]);
QScopedArrayPointer<char> data(new char[file.size()]);
// read entire file into memory
QDataStream *rawstream(new QDataStream(&file));
@@ -142,6 +141,7 @@ computeFileCRC(QString filename)
// calculate the CRC
boost::crc_optimal<16, 0x1021, 0xFFFF, 0, false, false> CRC;
CRC.process_bytes(&data[0], file.size());
return CRC.checksum();

View File

@@ -44,10 +44,10 @@ struct DeviceRideItem
QDateTime endTime; // optional, check with isValid()
unsigned work; // for progress indication
};
typedef boost::shared_ptr<DeviceRideItem> DeviceRideItemPtr;
typedef QSharedPointer<DeviceRideItem> DeviceRideItemPtr;
struct Device;
typedef boost::shared_ptr<Device> DevicePtr;
typedef QSharedPointer<Device> DevicePtr;
struct Device
{
@@ -81,7 +81,7 @@ protected:
};
struct Devices;
typedef boost::shared_ptr<Devices> DevicesPtr;
typedef QSharedPointer<Devices> DevicesPtr;
struct Devices
{

View File

@@ -26,7 +26,6 @@
#include <errno.h>
#include <QtGui>
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
DownloadRideDialog::DownloadRideDialog(MainWindow *mainWindow,
const QDir &home) :
@@ -39,7 +38,7 @@ DownloadRideDialog::DownloadRideDialog(MainWindow *mainWindow,
deviceCombo = new QComboBox(this);
QList<QString> deviceTypes = Devices::typeNames();
assert(deviceTypes.size() > 0);
BOOST_FOREACH(QString device, deviceTypes) {
Q_FOREACH(QString device, deviceTypes) {
deviceCombo->addItem(device);
}
QString defaultDevice = appsettings->value( NULL, GC_LAST_DOWNLOAD_DEVICE).toString();

View File

@@ -19,6 +19,7 @@
#include "GoldenClient.h"
#include <QMutexLocker>
#include <QSharedPointer>
bool GoldenClient::connect(QString server_hostname, quint16 server_port,
QString raceid, QString ridername, int ftp_watts,
@@ -82,7 +83,7 @@ void GoldenClient::sendTelemetry(int power_watts, int cadence_rpm,
float speed_kph) {
QMutexLocker locker(&client_lock);
boost::shared_ptr<ProtocolMessage> tm(
QSharedPointer<ProtocolMessage> tm(
new TelemetryMessage(rider_raceid, rider_id, power_watts,
cadence_rpm, distance_km, heartrate_bpm,
speed_kph) );
@@ -130,13 +131,13 @@ void GoldenClient::run() {
client_cond.wakeOne();
return;
}
boost::shared_ptr<ProtocolMessage> server_response =
QSharedPointer<ProtocolMessage> server_response =
ProtocolHandler::parseLine(server_response_text);
if (server_response->message_type == ProtocolMessage::HELLOFAIL) {
// server didn't recognize our race id, presumably. in any case,
// return out of thread after indicating failure.
boost::shared_ptr<HelloFailMessage> hfm =
boost::shared_dynamic_cast<HelloFailMessage>(server_response);
QSharedPointer<HelloFailMessage> hfm =
qSharedPointerDynamicCast<HelloFailMessage>(server_response);
server.disconnectFromHost();
running = connected = false;
client_cond.wakeOne();
@@ -144,8 +145,8 @@ void GoldenClient::run() {
} else if (server_response->message_type == ProtocolMessage::HELLOSUCCEED) {
// server completed the handshake! stash aside our riderid and
// the race distance.
boost::shared_ptr<HelloSucceedMessage> hsm =
boost::shared_dynamic_cast<HelloSucceedMessage>(server_response);
QSharedPointer<HelloSucceedMessage> hsm =
qSharedPointerDynamicCast<HelloSucceedMessage>(server_response);
rider_id = hsm->riderid;
race_distance_km = hsm->racedistance_km;
} else {
@@ -178,7 +179,7 @@ void GoldenClient::run() {
// Try non-blocking read from the network.
QString nextline;
if (read_line(locker, server, false, nextline)) {
boost::shared_ptr<ProtocolMessage> server_msg =
QSharedPointer<ProtocolMessage> server_msg =
ProtocolHandler::parseLine(nextline);
if (!handle_message(locker, server, server_msg)) {
server.disconnectFromHost();
@@ -195,7 +196,7 @@ void GoldenClient::run() {
// Do I have any data to send?
while(!write_queue.empty()) {
boost::shared_ptr<ProtocolMessage> sndmsg = write_queue.dequeue();
QSharedPointer<ProtocolMessage> sndmsg = write_queue.dequeue();
if (!write_line(locker, server,
sndmsg->toString())) {
// write failed, close up shop.
@@ -268,23 +269,23 @@ bool GoldenClient::write_line(QMutexLocker &locker, QTcpSocket &server,
}
bool GoldenClient::handle_message(QMutexLocker &locker, QTcpSocket &server,
boost::shared_ptr<ProtocolMessage> msg) {
QSharedPointer<ProtocolMessage> msg) {
if (msg->message_type == ProtocolMessage::CLIENTLIST) {
return handle_clientlist(
locker, server, boost::shared_dynamic_cast<ClientListMessage>(msg));
locker, server, qSharedPointerDynamicCast<ClientListMessage>(msg));
} else if (msg->message_type == ProtocolMessage::STANDINGS) {
return handle_standings(
locker, server, boost::shared_dynamic_cast<StandingsMessage>(msg));
locker, server, qSharedPointerDynamicCast<StandingsMessage>(msg));
} else if (msg->message_type == ProtocolMessage::RACECONCLUDED) {
return handle_raceconcluded(
locker, server, boost::shared_dynamic_cast<RaceConcludedMessage>(msg));
locker, server, qSharedPointerDynamicCast<RaceConcludedMessage>(msg));
} else {
return false;
}
}
bool GoldenClient::handle_clientlist(QMutexLocker &locker, QTcpSocket &server,
boost::shared_ptr<ClientListMessage> msg) {
QSharedPointer<ClientListMessage> msg) {
int numclients = msg->numclients;
int i;
RaceStatus new_status;
@@ -301,12 +302,12 @@ bool GoldenClient::handle_clientlist(QMutexLocker &locker, QTcpSocket &server,
printf("readline failed\n");
return false;
}
boost::shared_ptr<ProtocolMessage> next_msg =
QSharedPointer<ProtocolMessage> next_msg =
ProtocolHandler::parseLine(nextline);
if (next_msg->message_type != ProtocolMessage::CLIENT)
return false;
boost::shared_ptr<ClientMessage> client_msg =
boost::shared_dynamic_cast<ClientMessage>(next_msg);
QSharedPointer<ClientMessage> client_msg =
qSharedPointerDynamicCast<ClientMessage>(next_msg);
// initialize the rider data struct
RiderData rider_data = {
@@ -338,7 +339,7 @@ bool GoldenClient::handle_clientlist(QMutexLocker &locker, QTcpSocket &server,
return true;
}
bool GoldenClient::handle_standings(QMutexLocker &locker, QTcpSocket &server,
boost::shared_ptr<StandingsMessage> msg) {
QSharedPointer<StandingsMessage> msg) {
int numclients = msg->numclients;
int i;
RaceStatus new_status;
@@ -353,12 +354,12 @@ bool GoldenClient::handle_standings(QMutexLocker &locker, QTcpSocket &server,
if (!read_line(locker, server, true, nextline))
return false;
boost::shared_ptr<ProtocolMessage> next_msg =
QSharedPointer<ProtocolMessage> next_msg =
ProtocolHandler::parseLine(nextline);
if (next_msg->message_type != ProtocolMessage::RACER)
return false;
boost::shared_ptr<RacerMessage> racer_msg =
boost::shared_dynamic_cast<RacerMessage>(next_msg);
QSharedPointer<RacerMessage> racer_msg =
qSharedPointerDynamicCast<RacerMessage>(next_msg);
// get old rider data
if (!race_status.riders_status.contains(racer_msg->riderid)) {
@@ -389,7 +390,7 @@ bool GoldenClient::handle_standings(QMutexLocker &locker, QTcpSocket &server,
return true;
}
bool GoldenClient::handle_raceconcluded(QMutexLocker &locker, QTcpSocket &server,
boost::shared_ptr<RaceConcludedMessage> msg) {
QSharedPointer<RaceConcludedMessage> msg) {
int numclients = msg->numclients;
int i;
RaceStatus new_status;
@@ -404,12 +405,12 @@ bool GoldenClient::handle_raceconcluded(QMutexLocker &locker, QTcpSocket &server
if (!read_line(locker, server, true, nextline))
return false;
boost::shared_ptr<ProtocolMessage> next_msg =
QSharedPointer<ProtocolMessage> next_msg =
ProtocolHandler::parseLine(nextline);
if (next_msg->message_type != ProtocolMessage::RESULT)
return false;
boost::shared_ptr<ResultMessage> result_msg =
boost::shared_dynamic_cast<ResultMessage>(next_msg);
QSharedPointer<ResultMessage> result_msg =
qSharedPointerDynamicCast<ResultMessage>(next_msg);
// update old rider data with new final standings
RiderData old_data = race_status.riders_status.value(result_msg->riderid);

View File

@@ -30,8 +30,6 @@
#include <QMutex>
#include <QWaitCondition>
#include <boost/shared_ptr.hpp>
#include "ProtocolHandler.h"
typedef struct {
@@ -128,7 +126,7 @@ class GoldenClient : public QThread {
// The client can enqueue a message to be sent to the server
// on here by calling sendTelemetry().
QQueue<boost::shared_ptr<ProtocolMessage> > write_queue;
QQueue<QSharedPointer<ProtocolMessage> > write_queue;
// connect() will spawn a child thread when it successfully
// connects to a server. The child thread will enter this
@@ -151,13 +149,13 @@ class GoldenClient : public QThread {
// handle various messages from the server. returns false if things
// go wrong, in which case caller should bork out.
bool handle_message(QMutexLocker &locker, QTcpSocket &server,
boost::shared_ptr<ProtocolMessage> msg);
QSharedPointer<ProtocolMessage> msg);
bool handle_clientlist(QMutexLocker &locker, QTcpSocket &server,
boost::shared_ptr<ClientListMessage> msg);
QSharedPointer<ClientListMessage> msg);
bool handle_standings(QMutexLocker &locker, QTcpSocket &server,
boost::shared_ptr<StandingsMessage> msg);
QSharedPointer<StandingsMessage> msg);
bool handle_raceconcluded(QMutexLocker &locker, QTcpSocket &server,
boost::shared_ptr<RaceConcludedMessage> msg);
QSharedPointer<RaceConcludedMessage> msg);
};
#endif // _GC_GoldenClient_h

View File

@@ -23,7 +23,6 @@
#include <time.h>
#include <iostream>
#include <string>
#include "boost/scoped_ptr.hpp"
#include "kml/base/date_time.h"
#include "kml/base/expat_parser.h"
#include "kml/base/file.h"

View File

@@ -39,7 +39,6 @@
#include <qwt_symbol.h>
#include <math.h> // for isinf() isnan()
#include <boost/shared_ptr.hpp>
static int supported_axes[] = { QwtPlot::yLeft, QwtPlot::yRight, QwtPlot::yLeft1, QwtPlot::yRight1, QwtPlot::yLeft2, QwtPlot::yRight2, QwtPlot::yLeft3, QwtPlot::yRight3 };

View File

@@ -116,8 +116,6 @@
#include <qwt_plot_picker.h>
#include <qwt_plot_grid.h>
#include <qwt_series_data.h>
#include <boost/scoped_ptr.hpp>
#include <boost/version.hpp>
#include "Library.h"
#include "LibraryParser.h"

View File

@@ -33,7 +33,6 @@
#include "RealtimeData.h"
#include "SpecialFields.h"
#include "TimeUtils.h"
#include <boost/shared_ptr.hpp>
#ifdef Q_OS_MAC
// What versions are supported by this SDK?
@@ -356,7 +355,7 @@ class MainWindow : public QMainWindow
static QString notesFileName(QString rideFileName);
private:
boost::shared_ptr<QSettings> settings;
QSharedPointer<QSettings> settings;
IntervalItem *activeInterval; // currently active for context menu popup
RideItem *activeRide; // currently active for context menu popup
RideItem *ride; // the currently selected ride

View File

@@ -80,7 +80,7 @@ class PerformanceManagerWindow : public GcWindow
QLineEdit *PMdateRangefrom, *PMdateRangeto;
QSlider *PMleftSlider, *PMrightSlider;
QComboBox *metricCombo;
boost::shared_ptr<QSettings> settings;
QSharedPointer<QSettings> settings;
void setPMSliderDates();

View File

@@ -28,52 +28,52 @@
#include "ProtocolHandler.h"
//////// Main parser; does bulk of parsing in constructor of subclasses.
boost::shared_ptr<ProtocolMessage> ProtocolHandler::parseLine(QString line) {
QSharedPointer<ProtocolMessage> ProtocolHandler::parseLine(QString line) {
try {
if (line.startsWith("hello ") == true) {
boost::shared_ptr<ProtocolMessage> hm(new HelloMessage(line));
QSharedPointer<ProtocolMessage> hm(new HelloMessage(line));
return hm;
} else if (line.startsWith("hellofail ") == true) {
boost::shared_ptr<ProtocolMessage> hfm(new HelloFailMessage(line));
QSharedPointer<ProtocolMessage> hfm(new HelloFailMessage(line));
return hfm;
} else if (line.startsWith("hellosucceed ") == true) {
boost::shared_ptr<ProtocolMessage> hsm(new HelloSucceedMessage(line));
QSharedPointer<ProtocolMessage> hsm(new HelloSucceedMessage(line));
return hsm;
} else if (line.startsWith("clientlist ") == true) {
boost::shared_ptr<ProtocolMessage> clm(new ClientListMessage(line));
QSharedPointer<ProtocolMessage> clm(new ClientListMessage(line));
return clm;
} else if (line.startsWith("client ") == true) {
boost::shared_ptr<ProtocolMessage> cm(new ClientMessage(line));
QSharedPointer<ProtocolMessage> cm(new ClientMessage(line));
return cm;
} else if (line.startsWith("telemetry ") == true) {
boost::shared_ptr<ProtocolMessage> tm(new TelemetryMessage(line));
QSharedPointer<ProtocolMessage> tm(new TelemetryMessage(line));
return tm;
} else if (line.startsWith("standings ") == true) {
boost::shared_ptr<ProtocolMessage> sm(new StandingsMessage(line));
QSharedPointer<ProtocolMessage> sm(new StandingsMessage(line));
return sm;
} else if (line.startsWith("racer ") == true) {
boost::shared_ptr<ProtocolMessage> rm(new RacerMessage(line));
QSharedPointer<ProtocolMessage> rm(new RacerMessage(line));
return rm;
} else if (line.startsWith("raceconcluded ") == true) {
boost::shared_ptr<ProtocolMessage> rcm(new RaceConcludedMessage(line));
QSharedPointer<ProtocolMessage> rcm(new RaceConcludedMessage(line));
return rcm;
} else if (line.startsWith("result ") == true) {
boost::shared_ptr<ProtocolMessage> resm(new ResultMessage(line));
QSharedPointer<ProtocolMessage> resm(new ResultMessage(line));
return resm;
} else if (line.startsWith("goodbye ") == true) {
boost::shared_ptr<ProtocolMessage> gm(new GoodbyeMessage(line));
QSharedPointer<ProtocolMessage> gm(new GoodbyeMessage(line));
return gm;
}
} catch (std::invalid_argument& ia) {
// couldn't parse, so return an unknownmessage. pass along
// the error message embedded in the exception.
boost::shared_ptr<ProtocolMessage> um(new UnknownMessage(ia.what()));
QSharedPointer<ProtocolMessage> um(new UnknownMessage(ia.what()));
return um;
}
// couldn't figure out what kind of message this is, so return
// an UnknownMessage.
boost::shared_ptr<ProtocolMessage> um(new UnknownMessage("unknown protocol message"));
QSharedPointer<ProtocolMessage> um(new UnknownMessage("unknown protocol message"));
return um;
}
@@ -474,32 +474,32 @@ QString GoodbyeMessage::toString() {
////////////// Test code; assumes you've compiled so stdout appears at a terminal.
void ProtocolHandler::test() {
// Test "Unknown" message type
boost::shared_ptr<ProtocolMessage> msg = ProtocolHandler::parseLine("blah");
QSharedPointer<ProtocolMessage> msg = ProtocolHandler::parseLine("blah");
if (msg->message_type == ProtocolMessage::UNKNOWN) {
boost::shared_ptr<UnknownMessage> um =
boost::shared_dynamic_cast<UnknownMessage>(msg);
QSharedPointer<UnknownMessage> um =
qSharedPointerDynamicCast<UnknownMessage>(msg);
printf("UNKNOWN -- %s\n", um->toString().toAscii().constData());
} else {
printf("!! expected UNKNOWN, but didn't get it...\n");
}
// Test broken "Hello" message
boost::shared_ptr<ProtocolMessage> msg2 = ProtocolHandler::parseLine("hello there\n");
QSharedPointer<ProtocolMessage> msg2 = ProtocolHandler::parseLine("hello there\n");
if (msg2->message_type == ProtocolMessage::UNKNOWN) {
boost::shared_ptr<UnknownMessage> um =
boost::shared_dynamic_cast<UnknownMessage>(msg2);
QSharedPointer<UnknownMessage> um =
qSharedPointerDynamicCast<UnknownMessage>(msg2);
printf("broken hello --> UNKNOWN -- %s", um->toString().toAscii().constData());
} else {
printf("!! expected broken hello --> UNKNOWN, but didn't get it...\n");
}
// Test valid "Hello" message
boost::shared_ptr<ProtocolMessage> msg3 = ProtocolHandler::parseLine(
QSharedPointer<ProtocolMessage> msg3 = ProtocolHandler::parseLine(
"hello 0.1 raceid='18d1a1bcd104ee116a772310bbc61211' ridername='Steve G' ftp='213' weight='74.8'\n"
);
if (msg3->message_type == ProtocolMessage::HELLO) {
boost::shared_ptr<HelloMessage> hm =
boost::shared_dynamic_cast<HelloMessage>(msg3);
QSharedPointer<HelloMessage> hm =
qSharedPointerDynamicCast<HelloMessage>(msg3);
printf("HELLO: %s", hm->toString().toAscii().constData());
} else {
printf("!! expected hello, but didn't get it...\n");
@@ -509,120 +509,120 @@ void ProtocolHandler::test() {
printf("cons'ed up hellomessage: %s", hm2.toString().toAscii().constData());
// Test valid HelloFail message
boost::shared_ptr<ProtocolMessage> msg4 = ProtocolHandler::parseLine(
QSharedPointer<ProtocolMessage> msg4 = ProtocolHandler::parseLine(
"hellofail 0.1 nosuchrace raceid='18d1a1bcd104ee116a772310bbc61211'\n"
);
if (msg4->message_type == ProtocolMessage::HELLOFAIL) {
boost::shared_ptr<HelloFailMessage> hfm =
boost::shared_dynamic_cast<HelloFailMessage>(msg4);
QSharedPointer<HelloFailMessage> hfm =
qSharedPointerDynamicCast<HelloFailMessage>(msg4);
printf("HELLOFAIL: %s", hfm->toString().toAscii().constData());
} else {
printf("!! expected hellofail, but didn't get it...\n");
}
// Test valid HelloSucceed message
boost::shared_ptr<ProtocolMessage> msg5 = ProtocolHandler::parseLine(
QSharedPointer<ProtocolMessage> msg5 = ProtocolHandler::parseLine(
"hellosucceed 0.1 raceid='18d1a1bcd104ee116a772310bbc61211' riderid='123212321232123a' racedistance='180.0'\n"
);
if (msg5->message_type == ProtocolMessage::HELLOSUCCEED) {
boost::shared_ptr<HelloSucceedMessage> hsm =
boost::shared_dynamic_cast<HelloSucceedMessage>(msg5);
QSharedPointer<HelloSucceedMessage> hsm =
qSharedPointerDynamicCast<HelloSucceedMessage>(msg5);
printf("HELLOSUCCEED: %s", hsm->toString().toAscii().constData());
} else {
printf("!! expected hellosucceed, but didn't get it...\n");
}
// Test valid ClientList message
boost::shared_ptr<ProtocolMessage> msg6 = ProtocolHandler::parseLine(
QSharedPointer<ProtocolMessage> msg6 = ProtocolHandler::parseLine(
"clientlist raceid='18d1a1bcd104ee116a772310bbc61211' numclients='5'\n"
);
if (msg6->message_type == ProtocolMessage::CLIENTLIST) {
boost::shared_ptr<ClientListMessage> clm =
boost::shared_dynamic_cast<ClientListMessage>(msg6);
QSharedPointer<ClientListMessage> clm =
qSharedPointerDynamicCast<ClientListMessage>(msg6);
printf("CLIENTLIST: %s", clm->toString().toAscii().constData());
} else {
printf("!! expected clientlist, but didn't get it...\n");
}
// Test valid Client message
boost::shared_ptr<ProtocolMessage> msg7 = ProtocolHandler::parseLine(
QSharedPointer<ProtocolMessage> msg7 = ProtocolHandler::parseLine(
"client ridername='Steve G' riderid='123212321232123a' ftp='213' weight='75.8'"
);
if (msg7->message_type == ProtocolMessage::CLIENT) {
boost::shared_ptr<ClientMessage> cm =
boost::shared_dynamic_cast<ClientMessage>(msg7);
QSharedPointer<ClientMessage> cm =
qSharedPointerDynamicCast<ClientMessage>(msg7);
printf("CLIENT: %s", cm->toString().toAscii().constData());
} else {
printf("!! expected client, but didn't get it...\n");
}
// Test valid Telemetry message
boost::shared_ptr<ProtocolMessage> msg8 = ProtocolHandler::parseLine(
QSharedPointer<ProtocolMessage> msg8 = ProtocolHandler::parseLine(
"telemetry raceid='18d1a1bcd104ee116a772310bbc61211' riderid='123212321232123a' power='250' cadence='85' distance='5.41' heartrate='155' speed='31.5'\n"
);
if (msg8->message_type == ProtocolMessage::TELEMETRY) {
boost::shared_ptr<TelemetryMessage> tm =
boost::shared_dynamic_cast<TelemetryMessage>(msg8);
QSharedPointer<TelemetryMessage> tm =
qSharedPointerDynamicCast<TelemetryMessage>(msg8);
printf("TELEMETRY: %s", tm->toString().toAscii().constData());
} else {
printf("!! expected telemetry, but didn't get it...\n");
}
// Test valid Standings message
boost::shared_ptr<ProtocolMessage> msg9 = ProtocolHandler::parseLine(
QSharedPointer<ProtocolMessage> msg9 = ProtocolHandler::parseLine(
"standings raceid='18d1a1bcd104ee116a772310bbc61211' numclients='5'\n"
);
if (msg9->message_type == ProtocolMessage::STANDINGS) {
boost::shared_ptr<StandingsMessage> sm =
boost::shared_dynamic_cast<StandingsMessage>(msg9);
QSharedPointer<StandingsMessage> sm =
qSharedPointerDynamicCast<StandingsMessage>(msg9);
printf("STANDINGS: %s", sm->toString().toAscii().constData());
} else {
printf("!! expected standings, but didn't get it...\n");
}
// Test valid Racer message
boost::shared_ptr<ProtocolMessage> msg10 = ProtocolHandler::parseLine(
QSharedPointer<ProtocolMessage> msg10 = ProtocolHandler::parseLine(
"racer riderid='123212321232123a' power='250' cadence='85' distance='5.41' heartrate='155' speed='31.5' place='1'\n"
);
if (msg10->message_type == ProtocolMessage::RACER) {
boost::shared_ptr<RacerMessage> rm =
boost::shared_dynamic_cast<RacerMessage>(msg10);
QSharedPointer<RacerMessage> rm =
qSharedPointerDynamicCast<RacerMessage>(msg10);
printf("RACER: %s", rm->toString().toAscii().constData());
} else {
printf("!! expected racer, but didn't get it...\n");
}
// Test valid RaceConcluded message
boost::shared_ptr<ProtocolMessage> msg11 = ProtocolHandler::parseLine(
QSharedPointer<ProtocolMessage> msg11 = ProtocolHandler::parseLine(
"raceconcluded raceid='18d1a1bcd104ee116a772310bbc61211' numclients='5'\n"
);
if (msg11->message_type == ProtocolMessage::RACECONCLUDED) {
boost::shared_ptr<RaceConcludedMessage> rcm =
boost::shared_dynamic_cast<RaceConcludedMessage>(msg11);
QSharedPointer<RaceConcludedMessage> rcm =
qSharedPointerDynamicCast<RaceConcludedMessage>(msg11);
printf("RACECONCLUDED: %s", rcm->toString().toAscii().constData());
} else {
printf("!! expected raceconclded, but didn't get it...\n");
}
// Test valid Result message
boost::shared_ptr<ProtocolMessage> msg12 = ProtocolHandler::parseLine(
QSharedPointer<ProtocolMessage> msg12 = ProtocolHandler::parseLine(
"result riderid='123212321232123a' distance='5.41' place='1'\n"
);
if (msg12->message_type == ProtocolMessage::RESULT) {
boost::shared_ptr<ResultMessage> resm =
boost::shared_dynamic_cast<ResultMessage>(msg12);
QSharedPointer<ResultMessage> resm =
qSharedPointerDynamicCast<ResultMessage>(msg12);
printf("RESULT: %s", resm->toString().toAscii().constData());
} else {
printf("!! expected result, but didn't get it...\n");
}
// Test valid Goodbye message
boost::shared_ptr<ProtocolMessage> msg13 = ProtocolHandler::parseLine(
QSharedPointer<ProtocolMessage> msg13 = ProtocolHandler::parseLine(
"goodbye raceid='18d1a1bcd104ee116a772310bbc61211' riderid='123212321232123a'\n"
);
if (msg13->message_type == ProtocolMessage::GOODBYE) {
boost::shared_ptr<GoodbyeMessage> gbm =
boost::shared_dynamic_cast<GoodbyeMessage>(msg13);
QSharedPointer<GoodbyeMessage> gbm =
qSharedPointerDynamicCast<GoodbyeMessage>(msg13);
printf("GOODBYE: %s", gbm->toString().toAscii().constData());
} else {
printf("!! expected goodbye, but didn't get it...\n");

View File

@@ -24,8 +24,6 @@
#include <QString>
#include <QDebug>
#include <boost/shared_ptr.hpp>
// This abstract base class represents a protocol message. There is
// one subclass per message type.
class ProtocolMessage {
@@ -51,7 +49,7 @@ class ProtocolHandler {
ProtocolHandler() { }
~ProtocolHandler() { }
static boost::shared_ptr<ProtocolMessage> parseLine(QString line);
static QSharedPointer<ProtocolMessage> parseLine(QString line);
static void test();
};

View File

@@ -25,7 +25,6 @@
#include <QProgressBar>
#include <QList>
#include <QListIterator>
#include <boost/scoped_ptr.hpp>
#include "MainWindow.h"
// Dialog class to show filenames, import progress and to capture user input

View File

@@ -182,7 +182,6 @@
#include <QSettings>
#include <QFileInfo>
#include <boost/shared_ptr.hpp>
// wrap the standard QSettings so we can offer members
// to get global or cyclist specific settings

View File

@@ -24,7 +24,6 @@
#include <string.h>
#include <errno.h>
#include <QtGui>
#include <boost/scoped_ptr.hpp>
namespace
{
@@ -158,7 +157,7 @@ SplitRideDialog::CreateNewRideFile(const RideFile *ride, int nRecStart, int nRec
newStart = newStart.addSecs(offset);
// create the ridefile in memory
boost::scoped_ptr<RideFile> newRideFile(new RideFile(newStart, ride->recIntSecs()));
QScopedPointer<RideFile> newRideFile(new RideFile(newStart, ride->recIntSecs()));
for (int nItem = nRecStart; nItem<nRecEnd; ++nItem)
{
RideFilePoint *pPoint = ride->dataPoints().at(nItem);
@@ -189,7 +188,7 @@ SplitRideDialog::CreateNewRideFile(const RideFile *ride, int nRecStart, int nRec
// write to disk
GcFileReader f;
f.writeRideFile(mainWindow, newRideFile.get(), file);
f.writeRideFile(mainWindow, newRideFile.data(), file);
// add to the ride list
mainWindow->addRide(fileName, false);

View File

@@ -20,8 +20,6 @@
#include "SrmRideFile.h"
#include <srmio.h>
#include <QMessageBox>
#include <boost/scoped_ptr.hpp>
#include <boost/foreach.hpp>
#include <errno.h>
static bool srm5Registered =

View File

@@ -49,7 +49,7 @@ class StressCalculator:public QObject {
void calculate(int daysIndex);
void addRideData(double BS, QDateTime rideDate);
boost::shared_ptr<QSettings> settings;
QSharedPointer<QSettings> settings;
public:

View File

@@ -26,8 +26,6 @@
#include <QtCore/QCoreApplication>
#include <QtCore/QLocale>
#include <boost/scoped_array.hpp>
static QString tptypestrings[]= { "SharedFree", "CoachedFree", "SelfCoachedPremium",
"SharedSelfCoachedPremium", "CoachedPremium",
"SharedCoachedPremium"

View File

@@ -27,8 +27,6 @@
#include <QtCore/QCoreApplication>
#include <QtCore/QLocale>
#include <boost/scoped_array.hpp>
#include <zlib.h>
//

View File

@@ -241,7 +241,7 @@ class TrainTool : public GcWindow
int mode;
// everyone else wants this
QCheckBox *recordSelector;
boost::shared_ptr<QFileSystemWatcher> watcher;
QSharedPointer<QFileSystemWatcher> watcher;
bool calibrating;
};

View File

@@ -30,7 +30,6 @@
#include <QSettings>
#include <math.h> // for isinf() isnan()
#include <boost/shared_ptr.hpp>
// Treemap sorter - reversed to do descending
bool TreeMapLessThan(const TreeMap *a, const TreeMap *b) {

View File

@@ -65,7 +65,7 @@ WkoParser::WkoParser(QFile &file, QStringList &errors, QList<RideFile*>*rides)
}
bufferSize = file.size();
boost::scoped_array<WKO_UCHAR> entirefile(new WKO_UCHAR[bufferSize]);
QScopedArrayPointer<WKO_UCHAR> entirefile(new WKO_UCHAR[bufferSize]);
QDataStream *rawstream(new QDataStream(&file));
headerdata = &entirefile[0];
rawstream->readRawData(reinterpret_cast<char *>(headerdata), file.size());

View File

@@ -25,8 +25,7 @@
#include <QDataStream>
#include <string.h>
#include <math.h>
#include <boost/scoped_ptr.hpp>
#include <boost/scoped_array.hpp>
#include <memory>
#include <QtEndian>
struct WkoFileReader : public RideFileReader {

View File

@@ -298,7 +298,7 @@ void AbsWattagePage::updateMetrics()
int curSecs = 0;
// create rideFile
boost::shared_ptr<RideFile> workout(new RideFile());
QSharedPointer<RideFile> workout(new RideFile());
workout->setRecIntSecs(1);
double curMin = 0;
for(int i = 0; i < data.size() ; i++)
@@ -428,7 +428,7 @@ void RelWattagePage::updateMetrics()
int curSecs = 0;
// create rideFile
boost::shared_ptr<RideFile> workout(new RideFile());
QSharedPointer<RideFile> workout(new RideFile());
workout->setRecIntSecs(1);
for(int i = 0; i < data.size() ; i++)
{
@@ -547,7 +547,7 @@ void GradientPage::updateMetrics()
double gain = 0;
int elevation = 0;
// create rideFile
boost::shared_ptr<RideFile> workout(new RideFile());
QSharedPointer<RideFile> workout(new RideFile());
workout->setRecIntSecs(1);
for(int i = 0; i < data.size() ; i++)
{

View File

@@ -32,7 +32,6 @@
#include <QLCDNumber>
#include <QDebug>
#include <QSpinBox>
#include <boost/shared_ptr.hpp>
#include "RideFile.h"
#include "MainWindow.h"
#include "GoldenCheetah.h"