Name | Modified | Size | Downloads / Week |
---|---|---|---|
html | 2019-01-28 | ||
obj | 2019-01-28 | ||
libs | 2019-01-28 | ||
bin | 2019-01-28 | ||
README.md | 2019-02-12 | 3.6 kB | |
guidefs.hh | 2019-01-28 | 1.6 kB | |
guidisplay.cc | 2019-01-28 | 1.5 kB | |
guidisplay.hh | 2019-01-28 | 767 Bytes | |
Makefile | 2019-01-28 | 1.9 kB | |
moc_netmngr.cc | 2019-01-28 | 3.2 kB | |
netmngr.cc | 2019-01-28 | 3.0 kB | |
netmngr.hh | 2019-01-28 | 1.6 kB | |
Patterns.mk | 2019-01-28 | 404 Bytes | |
Targets.mk | 2019-01-28 | 385 Bytes | |
usIRSatellite.cc | 2019-01-28 | 2.8 kB | |
usIRSatellite.hh | 2019-01-28 | 936 Bytes | |
usRadar.cc | 2019-01-28 | 2.6 kB | |
usRadar.hh | 2019-01-28 | 860 Bytes | |
wxpc_web.cc | 2019-01-28 | 1.1 kB | |
wxweb.zip | 2019-01-28 | 1.1 MB | |
Totals: 20 Items | 1.1 MB | 0 |
Qt Based Network Manager {#mainpage}
The Qt based Network Manager is a simple network services module which can be expanded upon and customized as needed by the developer. The heart of the manager is the NetMngr class implemented on top of the Qt based QNetworkAccessManager class. The primary function of the added layering is to provide a means whereby the NetMngr class can provide network services without special regard to who or how many users are making web requests.
Although the network manager is built on top of QtNetworkAccessManager, the implementation does not use the slot/signal connection mechanism used by Qt. An explanation of the mechanism is given below in the second to last paragraph.
The Qt based Network Manager is written in C++ and compiles and runs under either Qt4 or Qt5. There are no dependencies on operating system, compiler, or linker. A sample application with code and Makefile is provided. This code is provided as is and may be freely used by anyone without any restriction.
Given that the class NetMngr is instantiated as a globally visible object, the NetMngr class is used as follows:
- The user (ie, the requesting object of network services) must first register with the network manager-
mMyID = pNetMngr->registerRequestor(this);
where mMyID is data member of the requesting object, this.
- The requesting object dynamically assigns mMyID as a property of its base inherited class, RequestingObject-
this->RequestingObject::setProperty(SIGEMIT, QVariant(mMyID));
It is required that the requesting object inherit from the RequestingObject class which is defined in netmngr.hh.
- The requesting object must contain a public member function as follows:
void replyReceived(QNetworkReply *);
replyReceived() is effectively a signal handling slot, however, it is not declared as such and not 'connected' as such to the network manager's reply received slot.
- The requesting object may now issue web requests to the network manager. For example-
pNetMngr->requestInitiate(&netRequest, this);
where\par QNetworkRequest netRequest;\par this - pointer to requesting object
- The requesting object's replyReceived member function is called by the network manager when the network reply is received by the network manager.
Behind the scenes the network manager is handling multiple requests from multiple objects. The following describes how this is managed.
The mMyID is a random number generated by the network manager and handed back to the requesting object. mMyID serves as a unique identifier of the requesting object. The requesting object also passes it's this pointer to the network manager when registering. The network manager takes both the mMyID and this and adds them as a pair to a STL based map object, mMyID being the key and this being the value. The network manager also adds the mMyID as a dynamic property to the network reply. Upon receiving the network reply, the network manager extracts the mMyID key from the reply, looks up the corresponding this pointer to the requesting object, and calls the requesting object's replyReceived() member function. Since mMyID is unique, the proper requesting object will be called irregardless of the order in which replies are received.
The prospective user may wish to peruse the sample application code provided to clarify details and inner workings. For example, see usIRSatellite.cc/hh and usRadar.cc/hh which are examples of requesting objects.