Commit bd841c01 authored by Andrea Bulgarelli's avatar Andrea Bulgarelli
Browse files

added (1) decoding only section (bool onlySections), (2)...

added (1) decoding only section (bool onlySections), (2) PartOfPacket::decode() only on demand (3) ByteStream(ByteStreamPtr b0, dword start, dword end, bool memory_sharing)
parent 34eebebc
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -50,6 +50,10 @@ public:
    /// The mamory of byte* is allocated.
    /// The mamory of byte* is allocated.
    ByteStream(ByteStreamPtr b0, ByteStreamPtr b1, ByteStreamPtr b2);
    ByteStream(ByteStreamPtr b0, ByteStreamPtr b1, ByteStreamPtr b2);
	
	
	/// Creates a new ByteStream from start to end
	/// If end=-1 use the end of the b0
    ByteStream(ByteStreamPtr b0, dword start, dword end=-1, bool memory_sharing=true);

    ~ByteStream();
    ~ByteStream();


    byte* getStream();
    byte* getStream();
+4 −4
Original line number Original line Diff line number Diff line
@@ -70,14 +70,14 @@ public:
    /// \param packetHeader This is the header of the packet
    /// \param packetHeader This is the header of the packet
    /// \param packetDataField This is the data field of the packet
    /// \param packetDataField This is the data field of the packet
    /// \post If return is true all the fields are set with the correct value.
    /// \post If return is true all the fields are set with the correct value.
    virtual bool setPacketValue(ByteStreamPtr prefix, ByteStreamPtr packetHeader, ByteStreamPtr packetDataField);
    virtual bool setPacketValue(ByteStreamPtr prefix, ByteStreamPtr packetHeader, ByteStreamPtr packetDataField, bool onlySections = false);


    /// Sets all the fields of the packet with correct value contained into the input ByteStream.
    /// Sets all the fields of the packet with correct value contained into the input ByteStream.
    ///	\pre The structure of the stream must be loaded.
    ///	\pre The structure of the stream must be loaded.
    /// \param prefix This is the prefix of the packet
    /// \param prefix This is the prefix of the packet
    /// \param packet This is the packet
    /// \param packet This is the packet
    /// \post If return is true all the fields are set with the correct value.
    /// \post If return is true all the fields are set with the correct value.
    virtual bool setPacketValue(ByteStreamPtr prefix, ByteStreamPtr packet);
    virtual bool setPacketValue(ByteStreamPtr prefix, ByteStreamPtr packet, bool onlySections = false);


    /// Verifies if within the ByteStream passed with arguments it's present a correct packet.
    /// Verifies if within the ByteStream passed with arguments it's present a correct packet.
    ///	\pre The structure of the stream must be loaded.
    ///	\pre The structure of the stream must be loaded.
@@ -92,7 +92,7 @@ public:


    /// Sets all the fields of the packet with correct value contained into the input ByteStream.
    /// Sets all the fields of the packet with correct value contained into the input ByteStream.
    /// \param stream A pointer to the stream of byte, with prefix and packet
    /// \param stream A pointer to the stream of byte, with prefix and packet
    bool setPacketValue(byte* stream);
    bool setPacketValue(byte* stream, bool onlySections = false);


    /// Verifies if within the ByteStream passed with arguments it's present a correct packet.
    /// Verifies if within the ByteStream passed with arguments it's present a correct packet.
    ///	\pre The structure of the stream must be loaded.
    ///	\pre The structure of the stream must be loaded.
@@ -248,7 +248,7 @@ protected:


    bool setPacketValueDataFieldHeader(ByteStreamPtr packetDataField);
    bool setPacketValueDataFieldHeader(ByteStreamPtr packetDataField);


    bool setPacketValueSourceDataField(ByteStreamPtr packetDataField);
    bool setPacketValueSourceDataField(ByteStreamPtr packetDataField, bool onlySections = false);


    bool setPacketValueHeader(ByteStreamPtr header);
    bool setPacketValueHeader(ByteStreamPtr header);


+6 −0
Original line number Original line Diff line number Diff line
@@ -74,6 +74,7 @@ public:
    /// \param index Represent the index in the list.
    /// \param index Represent the index in the list.
    virtual  inline  Field* getFields(word index)
    virtual  inline  Field* getFields(word index)
    {
    {
		decode();
        if(index < numberOfFields)
        if(index < numberOfFields)
            return fields[index];
            return fields[index];
        else
        else
@@ -84,6 +85,7 @@ public:
    /// \param index Represent the index in the list.
    /// \param index Represent the index in the list.
    virtual  inline word getFieldValue(word index)
    virtual  inline word getFieldValue(word index)
    {
    {
		decode();
        if(index < numberOfFields)
        if(index < numberOfFields)
            return fields[index]->value;
            return fields[index]->value;
        else
        else
@@ -305,6 +307,10 @@ public:


protected:
protected:


	bool decode();
	
	bool decoded;
	
    /// Represent current stream reads from input.
    /// Represent current stream reads from input.
    ByteStreamPtr stream;
    ByteStreamPtr stream;


+1 −1
Original line number Original line Diff line number Diff line
@@ -150,7 +150,7 @@ public:


    virtual ByteStreamPtr generateStream(bool bigendian);
    virtual ByteStreamPtr generateStream(bool bigendian);


    virtual bool setByteStream(ByteStreamPtr s);
    virtual bool setByteStream(ByteStreamPtr s, bool onlySections = false);


    virtual ByteStreamPtr getByteStream()
    virtual ByteStreamPtr getByteStream()
    {
    {
+11 −2
Original line number Original line Diff line number Diff line
@@ -34,6 +34,8 @@ public:


    virtual ~SDFRBlock();
    virtual ~SDFRBlock();
	
	


    virtual bool loadFields(InputText& fp) throw(PacketException*);
    virtual bool loadFields(InputText& fp) throw(PacketException*);


     /// Get a block of number nblock of the group of blocks of the rblock
     /// Get a block of number nblock of the group of blocks of the rblock
@@ -42,6 +44,11 @@ public:
    /// \param rBlockIndex the number of the rblock
    /// \param rBlockIndex the number of the rblock
    virtual SDFRBBlock* getBlock(word nblock, word rBlockIndex);
    virtual SDFRBBlock* getBlock(word nblock, word rBlockIndex);
	
	
	///Get the fixed part of the source data field
	virtual ByteStreamPtr getFixedPart() { return block[0].fixed.getByteStream(); };
	
	///Get the variable part of the source data field
	//virtual ByteStreamPtr getVariablePart();
    
    
    /// Returns a pointer of a field in the fixed part of this source data field.
    /// Returns a pointer of a field in the fixed part of this source data field.
    /// \param index Represent the index in the list.
    /// \param index Represent the index in the list.
@@ -66,7 +73,9 @@ public:


    virtual dword getDimension();
    virtual dword getDimension();
	
	
    virtual bool setByteStream(ByteStreamPtr s);
	virtual dword getDimensionFixedPart();

    virtual bool setByteStream(ByteStreamPtr s, bool onlySections = false);


    virtual bool setOutputStream(ByteStreamPtr os, dword first);
    virtual bool setOutputStream(ByteStreamPtr os, dword first);


Loading