Commit 72bf391d authored by Andrea Bulgarelli's avatar Andrea Bulgarelli
Browse files

Changed Field management, dimension of a packet (dword), InputTextFile with MemoryBuffer management

parent d8788298
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -41,12 +41,12 @@ class ByteStream
        //##ModelId=3EADC12501CA
        //##Documentation
        //## The memory of byte* is allocated
        ByteStream(long size, bool bigendian);
        ByteStream(dword size, bool bigendian);

        //##ModelId=3EADC125023B
        //##Documentation
        //## The memory of byte* is not allocated
        ByteStream(byte* stream, long dim, bool bigendian, bool memory_sharing = true);
        ByteStream(byte* stream, dword dim, bool bigendian, bool memory_sharing = true);

        //##ModelId=3EADC125031B
        //##Documentation
@@ -79,56 +79,56 @@ class ByteStream
        //## Returns a subset of the current stream. If there is problemas return NULL
        //## \remarks This method don't allocate a new stream structure in memory,
        //## but create only a new ByteStream object that points in the same memory area.
        ByteStream* getSubByteStream(word first, word last);
        ByteStream* getSubByteStream(dword first, dword last);

        //##ModelId=3EADC126003A
        //##Documentation
        //## Returns a subset of the current stream. If there is problemas return NULL
        //## \remarks This method allocate a new stream structure in memory.
        ByteStream* getSubByteStreamCopy(word first, word last);
        ByteStream* getSubByteStreamCopy(dword first, dword last);

        //##ModelId=3C87744001F6
        //##Documentation
        //## Sets the stream from arguments.
        bool setStream(byte* b, unsigned dim, bool bigendian, bool memory_sharing = true);
        bool setStream(byte* b, dword dim, bool bigendian, bool memory_sharing = true);

        //##ModelId=3EADC1260157
        //##Documentation
        //## Get the stream from another object of the same type. Don't allocate new memory
        bool setStream(ByteStream* b, word first, word last);
        bool setStream(ByteStream* b, dword first, dword last);

        //##ModelId=3EADC1260244
        //##Documentation
        //## Copy the stream in argument of dimension dim.
        //## \remarks This method delete old stream and creates a new stream in memory
        void setStreamCopy(byte* b, unsigned dim);
        void setStreamCopy(byte* b, dword dim);

        //##ModelId=3EADC12602F1
        //##Documentation
        //## Sets a word of the stream with the value of parameter.
        bool setWord(unsigned start, word value);
        bool setWord(dword start, word value);

        //##ModelId=3EADC12603A5
        //##Documentation
        //## Sets a byte of the stream with the value of parameter.
        void setByte(unsigned start, word value);
        void setByte(dword start, word value);

        //##ModelId=3C0F6BDB0041
        //##Documentation
        //## This method return a byte of the stram in the position byteNumber
        byte getByte( unsigned byteNumber );
        byte getByte( dword byteNumber );

        //##ModelId=3C18775001BB
        //##Documentation
        //## Get the value in the stream starting from position start and of dim dimension
        //## \param start Start position in the stream of byte
        //## \param dim number of byte (1 oe 2)
        long getValue(unsigned start, unsigned dim);
        long getValue(dword start, dword dim);

        //##ModelId=3C87744001D8
        //##Documentation
        //## Gets the dimension of the stream
        unsigned getDimension();
        dword getDimension();

        //##ModelId=3C87744001EC
        char* printStreamInHexadecimal();
@@ -183,7 +183,7 @@ class ByteStream
	//##ModelId=3EADC1250121
        //##Documentation
        //## This attribute specifes the number of byte in the stream
        word byteInTheStream;
        dword byteInTheStream;

        //##ModelId=3C877440014B
        //##Documentation
+45 −17
Original line number Diff line number Diff line
@@ -21,34 +21,62 @@

namespace PacketLib {

//A single field of a telemtry packet

class FieldType {

	public:
	
		FieldType();
	
		//Dimension of field in bit.
        word dimension;

        //It indicates that there's a predefined value for this field.
        bool thereIsPredefinedValue;

        //Predefined value of field (for the generation of packet).
        int predefinedValue;
	
        //Name of the field.
        char* name;	
};



//A single field of a telemetry packet
class Field
{
    public:

        //## Constructor of class.
        //Constructor of class.
        Field(char* name, char* dimension, char* predefinedValue, int progressiv);

        //## Destructor of class.
        //Destructor of class.
        ~Field();

        //## Dimension of field in bit.
        word dimension;
        //Value reads from stream of byte (from packet).
        word value;
        
        //## It indicates that there's a predefined value for this field.
        bool thereIsPredefinedValue;
        //Dimension of field in bit.
        inline dword getDimension() { return type->dimension; };

        //## Predefined value of field (for the generation of packet).
        int predefinedValue;
        //It indicates that there's a predefined value for this field.
        inline bool thereIsPredefinedValue() { return type->thereIsPredefinedValue; };

        //## Index of packet in the list of packet.
        int progressiv;
        //Predefined value of field (for the generation of packet).
        inline int getPredefinedValue() { return type->predefinedValue; };
	
        //## Name of the field.
        char* name;
        //Name of the field.
        inline char* getName() { return type->name; };	
        
        //## Value reads from stream of byte (from packet).
        word value;
        inline int getProgressiv() { return progressiv; };
        
    protected:
        
        //Index of packet in the list of packet.
        int progressiv;
        
        FieldType * type;

};

+4 −0
Original line number Diff line number Diff line
@@ -40,6 +40,10 @@ class InputText

        virtual char* getInputTextName() = 0;
        
        virtual long getpos() = 0;
        
        virtual long setpos(long offset) throw(PacketExceptionIO*) = 0;

        virtual bool isClosed();

        virtual bool isEOF();
+3 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#define MEMORYBUFFER_H
#include "PacketLibDefinition.h"
#include "PacketExceptionIO.h"
#include "PacketException.h"

namespace PacketLib {

@@ -41,10 +42,10 @@ class MemoryBuffer
        //##ModelId=3EADC12A00B8
        //##Documentation
        //## Write property of char** buffer.
        void setbuffer( char* _newVal);
        void setbuffer( char* _newVal) throw(PacketException*);;

        //##ModelId=3EADC12A00BF
        void setbuffer( char* _newVal, dword index);
        void setbuffer( char* _newVal, dword index) throw(PacketException*);

        //##ModelId=3EADC12A00CB
        //##Documentation
+2 −2
Original line number Diff line number Diff line
@@ -164,12 +164,12 @@ class Packet
        //##ModelId=3EADC131018A
        //##Documentation
        //## Gets the dimension in byte of the current packet.
        word getDimension();
        dword getDimension();

        //##ModelId=3EADC13101E9
        //##Documentation
        //## Gets the max dimension in byte of the packet.
        word getMaxDimension();
        dword getMaxDimension();
        
        //##Documentation
        //## Gets the ByteStream received as input
Loading