Skip to content
This repository was archived by the owner on Oct 15, 2019. It is now read-only.

Commit

Permalink
Add docs, getting started C++
Browse files Browse the repository at this point in the history
  • Loading branch information
gladhorn committed Jun 3, 2013
1 parent 242775b commit 52b5e58
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 5 deletions.
2 changes: 2 additions & 0 deletions doc/enginio-qt.qdocconf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ sourcedirs += ../src/enginio_plugin
headerdirs += ../src/enginio_client
headerdirs += ../src/enginio_plugin

imagedirs += images

outputdir = ./html
outputformats = HTML

Binary file added doc/images/object_browser_first_city_object.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 55 additions & 4 deletions src/enginio_client/enginio.qdoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ Enginio works from both, C++ and Qt Quick.
\brief Introduction to using Enginio using Qt Quick

You use the QML version of \l EnginioClient and things like \l EnginioModel.


*/


Expand All @@ -57,7 +55,60 @@ You use the QML version of \l EnginioClient and things like \l EnginioModel.
\title Getting Started with Enginio using C++
\brief Introduction to using Enginio using C++

The most important class is \l EnginioClient.

\section1 Setup Qt application project

You need to link to Enginio. For QMake based projects simply add
\code
QT += enginio
\endcode
to your \c .pro file.

\section1 Initialize Enginio Client

To use Enginio Qt library in your code, you have to include relevant library headers.
\code
#include <Enginio/Enginio>
\endcode
Before making any calls to the Enginio API, the \l EnginioClient needs to be instantiated.
The constructor requires the \l{EnginioClient::backendId}{Backend ID} and \l{EnginioClient::backendSecret}{Backend Secret}.
They can be copied from the Dashboard.
Go to the \l{https://dashboard.engin.io/}{Enginio Dashboard} and select a backend.
Copy the Backend Id and Backend Secret values.

\code
QString backendId("YOUR_OWN_BACKEND_ID");
QString backendSecret("YOUR_OWN_BACKEND_SECRET");
EnginioClient *client = new EnginioClient(backendId, backendSecret);
\endcode
For testing purposes it is easiest to hardcode the backend ID and backend secret directly into application code. But this might not be always the best choice and sometimes it might be beneficial to put backend configuration in separate configuration file.
\section1 Store your first Object

Create an object in JSON format and fill in the data:
\code
QJsonObject city;
city.insert("objectType", QString("objects.city")); // an object type is required for all objects in Enginio
city.insert("name", QString("Oslo")); // other properties can be chosen freely
city.insert("population", 624000);
\endcode

Create the object in the Enginio database by calling \l{EnginioClient::create}:
\code
client->create(city);
connect(client, SIGNAL(finished(EnginioReply*)), this, SLOT(uploadFinished(EnginioReply*)));
\endcode
Note that execute() method performs the actual asynchronous network communication.
You need to wait for its completion by connecting to the \l{EnginioClient::finished}{finished} and \l{EnginioClient::error}{error} signals.

\section1 Checking stored objects in the Dashboard

When you have successfully stored objects with Qt C++ or QML code, go to your \l{https://dashboard.engin.io/}{Enginio Dashboard}
and check the status there.

\list
\li Select the ’Objects’ view from top navigation bar.
\li Make sure that objects.city is selected in the type drop-down.
\li The list should now show a row for the object which was just uploaded.
\endlist
\image object_browser_first_city_object.png
*/

39 changes: 38 additions & 1 deletion src/enginio_client/enginioclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ void EnginioClient::unregisterObjectFactory(int factoryId)
}

/*!
\internal
* Create new object of specified \a type and optionally with \a id.
* Note that types of user-defined objects have "objects." prefix.
*/
Expand Down Expand Up @@ -394,6 +395,12 @@ void EnginioClient::ignoreSslErrors(QNetworkReply* reply,
reply->ignoreSslErrors(errors);
}

/*!
* \brief Search.
*
* \return EnginioReply containing the status and the result once it is finished.
* \sa EnginioReply, create(), query(), update(), remove()
*/
EnginioReply *EnginioClient::search(const QJsonObject &query)
{
Q_D(EnginioClient);
Expand All @@ -404,6 +411,12 @@ EnginioReply *EnginioClient::search(const QJsonObject &query)
return ereply;
}

/*!
* \brief Query the database.
*
* \return EnginioReply containing the status and the result once it is finished.
* \sa EnginioReply, create(), update(), remove()
*/
EnginioReply* EnginioClient::query(const QJsonObject &query, const Operation operation)
{
Q_D(EnginioClient);
Expand All @@ -414,6 +427,14 @@ EnginioReply* EnginioClient::query(const QJsonObject &query, const Operation ope
return ereply;
}

/*!
* \brief Insert a new \a object into the database.
*
* The \a operation is the area in which the object gets created. It defaults to \l ObjectOperation
* to create new objects by default.
* \return EnginioReply containing the status of the query and the data once it is finished.
* \sa EnginioReply, query(), update(), remove()
*/
EnginioReply* EnginioClient::create(const QJsonObject &object, const Operation operation)
{
Q_D(EnginioClient);
Expand All @@ -428,6 +449,14 @@ EnginioReply* EnginioClient::create(const QJsonObject &object, const Operation o
return ereply;
}

/*!
* \brief Update an existing \a object in the database.
*
* The \a operation is the area in which the object gets created. It defaults to \l ObjectOperation
* to create new objects by default.
* \return EnginioReply containing the status of the query and the data once it is finished.
* \sa EnginioReply, create(), query(), remove()
*/
EnginioReply* EnginioClient::update(const QJsonObject &object, const Operation operation)
{
Q_D(EnginioClient);
Expand All @@ -442,6 +471,14 @@ EnginioReply* EnginioClient::update(const QJsonObject &object, const Operation o
return ereply;
}

/*!
* \brief Remove an existing \a object from the database.
*
* The \a operation is the area in which the object gets created. It defaults to \l ObjectOperation
* to create new objects by default.
* \return EnginioReply containing the status of the query and the data once it is finished.
* \sa EnginioReply, create(), query(), update()
*/
EnginioReply* EnginioClient::remove(const QJsonObject &object, const Operation operation)
{
Q_D(EnginioClient);
Expand Down Expand Up @@ -477,7 +514,7 @@ void EnginioClient::setIdentity(EnginioIdentity *identity)

/*!
* \brief EnginioClient::uploadFile uploads a file
* \param associatedObject an existing object on the server
* \param object an existing object on the server
* \param file the file to upload
* \return
*
Expand Down
1 change: 1 addition & 0 deletions src/enginio_client/enginioerror.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ EnginioError::EnginioError(ErrorType error,

/*!
* Constructor used in inheriting classes.
* \internal
*/
EnginioError::EnginioError(ErrorType error,
QString errorString,
Expand Down
22 changes: 22 additions & 0 deletions src/enginio_client/enginioreply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,42 @@
#include "enginioclient_p.h"
#include "enginioobjectadaptor_p.h"

/*!
\class EnginioReply
\brief The EnginioReply class contains the data from a request to the Enginio database.
\inmodule enginio-client
The finished signal is emitted when the query is done.
\sa EnginioClient
*/

/*!
\internal
*/
EnginioReply::EnginioReply(EnginioClientPrivate *p, QNetworkReply *reply)
: QObject(p->q_ptr)
, d(new EnginioReplyPrivate(reply))
{
p->registerReply(reply, this);
}

/*!
\internal
*/
EnginioReply::EnginioReply(EnginioClientPrivate *parent, QNetworkReply *reply, EnginioReplyPrivate *priv)
: QObject(parent->q_ptr)
, d(priv)
{
parent->registerReply(reply, this);
}


/*!
\brief Destroys the EnginioReply.
The reply needs to be deleted after the finished signal is emitted.
*/
EnginioReply::~EnginioReply()
{
}
Expand Down

0 comments on commit 52b5e58

Please sign in to comment.