mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-26 16:09:35 -05:00
switched serviceinfo items to new serialization
This commit is contained in:
parent
c33c34b175
commit
2d19783296
@ -25,6 +25,7 @@
|
||||
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
#include "serialiser/rsserviceinfoitems.h"
|
||||
#include "serialization/rstypeserializer.h"
|
||||
|
||||
/***
|
||||
#define RSSERIAL_DEBUG 1
|
||||
@ -35,8 +36,7 @@
|
||||
/*************************************************************************/
|
||||
/***** RsServiceInfo ****/
|
||||
|
||||
template<>
|
||||
std::ostream &RsTlvParamRef<RsServiceInfo>::print(std::ostream &out, uint16_t /*indent*/) const
|
||||
template<> std::ostream& RsTlvParamRef<RsServiceInfo>::print(std::ostream &out, uint16_t /*indent*/) const
|
||||
{
|
||||
out << "RsServiceInfo: " << mParam.mServiceType << " name " << mParam.mServiceName;
|
||||
out << std::endl;
|
||||
@ -138,38 +138,19 @@ template class RsTlvParamRef<RsServiceInfo>;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
RsServiceInfoListItem::~RsServiceInfoListItem()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void RsServiceInfoListItem::clear()
|
||||
{
|
||||
mServiceInfo.clear();
|
||||
}
|
||||
|
||||
std::ostream &RsServiceInfoListItem::print(std::ostream &out, uint16_t indent)
|
||||
void RsServiceInfoListItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
printRsItemBase(out, "RsServiceInfoListItem", indent);
|
||||
uint16_t int_Indent = indent + 2;
|
||||
RsTlvServiceInfoMapRef map(mServiceInfo);
|
||||
map.print(out, int_Indent);
|
||||
out << std::endl;
|
||||
|
||||
printRsItemEnd(out, "RsServiceInfoListItem", indent);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
uint32_t RsServiceInfoSerialiser::sizeInfo(RsServiceInfoListItem *item)
|
||||
{
|
||||
uint32_t s = 8; /* header */
|
||||
RsTlvServiceInfoMapRef map(item->mServiceInfo);
|
||||
s += map.TlvSize();
|
||||
|
||||
return s;
|
||||
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,map,"map") ;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
/* serialise the data to the buffer */
|
||||
bool RsServiceInfoSerialiser::serialiseInfo(RsServiceInfoListItem *item, void *data, uint32_t *pktsize)
|
||||
{
|
||||
@ -291,7 +272,14 @@ uint32_t RsServiceInfoSerialiser::sizePermissions(RsServiceInfoPermissionsIte
|
||||
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
void RsServiceInfoPermissionsItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,allowedBw,"allowedBw") ;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
/* serialise the data to the buffer */
|
||||
bool RsServiceInfoSerialiser::serialisePermissions(RsServiceInfoPermissionsItem *item, void *data, uint32_t *pktsize)
|
||||
{
|
||||
@ -440,6 +428,21 @@ RsItem *RsServiceInfoSerialiser::deserialise(void *data, uint32_t *pktsize)
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
#endif
|
||||
|
||||
RsItem *RsServiceInfoSerialiser::create_item(uint16_t service, uint8_t item_sub_id) const
|
||||
{
|
||||
if(service != RS_SERVICE_TYPE_SERVICEINFO)
|
||||
return NULL ;
|
||||
|
||||
switch(item_sub_id)
|
||||
{
|
||||
case RS_PKT_SUBTYPE_SERVICELIST_ITEM: return new RsServiceInfoListItem() ;
|
||||
case RS_PKT_SUBTYPE_SERVICEPERMISSIONS_ITEM: return new RsServiceInfoPermissionsItem() ;
|
||||
default:
|
||||
return NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -34,8 +34,6 @@
|
||||
#include "rsitems/rsitem.h"
|
||||
#include "rsitems/itempriorities.h"
|
||||
|
||||
#include "serialiser/rsserial.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
#include "serialiser/rstlvgenericmap.h"
|
||||
#include "retroshare/rsservicecontrol.h"
|
||||
|
||||
@ -63,72 +61,47 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class RsServiceInfoListItem: public RsItem
|
||||
{
|
||||
public:
|
||||
RsServiceInfoListItem()
|
||||
:RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_SERVICEINFO,
|
||||
RS_PKT_SUBTYPE_SERVICELIST_ITEM)
|
||||
RsServiceInfoListItem() :RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_SERVICEINFO, RS_PKT_SUBTYPE_SERVICELIST_ITEM)
|
||||
{
|
||||
setPriorityLevel(QOS_PRIORITY_RS_SERVICE_INFO_ITEM);
|
||||
return;
|
||||
}
|
||||
|
||||
virtual ~RsServiceInfoListItem();
|
||||
virtual void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
virtual ~RsServiceInfoListItem(){}
|
||||
virtual void clear();
|
||||
|
||||
std::map<uint32_t, RsServiceInfo> mServiceInfo;
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
std::map<uint32_t, RsServiceInfo> mServiceInfo;
|
||||
};
|
||||
|
||||
|
||||
class RsServiceInfoPermissionsItem: public RsItem
|
||||
{
|
||||
public:
|
||||
RsServiceInfoPermissionsItem()
|
||||
:RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_SERVICEINFO,
|
||||
RS_PKT_SUBTYPE_SERVICEPERMISSIONS_ITEM)
|
||||
RsServiceInfoPermissionsItem() :RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_SERVICEINFO, RS_PKT_SUBTYPE_SERVICEPERMISSIONS_ITEM)
|
||||
{
|
||||
setPriorityLevel(QOS_PRIORITY_RS_SERVICE_INFO_ITEM);
|
||||
return;
|
||||
}
|
||||
|
||||
virtual ~RsServiceInfoPermissionsItem();
|
||||
virtual void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
virtual ~RsServiceInfoPermissionsItem(){}
|
||||
virtual void clear(){}
|
||||
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
uint32_t allowedBw; // Units are bytes/sec => 4Gb/s;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class RsServiceInfoSerialiser: public RsSerialType
|
||||
class RsServiceInfoSerialiser: public RsServiceSerializer
|
||||
{
|
||||
public:
|
||||
RsServiceInfoSerialiser()
|
||||
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_SERVICEINFO)
|
||||
{ return; }
|
||||
virtual ~RsServiceInfoSerialiser()
|
||||
{ return; }
|
||||
RsServiceInfoSerialiser() :RsServiceSerializer(RS_SERVICE_TYPE_SERVICEINFO) {}
|
||||
virtual ~RsServiceInfoSerialiser() {}
|
||||
|
||||
virtual uint32_t size(RsItem *);
|
||||
virtual bool serialise (RsItem *item, void *data, uint32_t *size);
|
||||
virtual RsItem * deserialise(void *data, uint32_t *size);
|
||||
|
||||
private:
|
||||
|
||||
virtual uint32_t sizeInfo(RsServiceInfoListItem *);
|
||||
virtual bool serialiseInfo(RsServiceInfoListItem *item, void *data, uint32_t *size);
|
||||
virtual RsServiceInfoListItem *deserialiseInfo(void *data, uint32_t *size);
|
||||
|
||||
|
||||
virtual uint32_t sizePermissions(RsServiceInfoPermissionsItem *);
|
||||
virtual bool serialisePermissions(RsServiceInfoPermissionsItem *item, void *data, uint32_t *size);
|
||||
virtual RsServiceInfoPermissionsItem *deserialisePermissions(void *data, uint32_t *size);
|
||||
|
||||
|
||||
virtual RsItem *create_item(uint16_t /* service */, uint8_t /* item_sub_id */) const;
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
@ -24,6 +24,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "serialiser/rstlvbase.h"
|
||||
|
||||
// Must be different - as this is inline in headers.
|
||||
//#define TLV_GENERICMAP_DEBUG 1
|
||||
|
Loading…
Reference in New Issue
Block a user