ArtsPortChoice


[ libArts | Source | Keywords | Summary | Ancestors | All Members | Descendants ]

Quick Index

DESCRIPTION

Class Summary

class ArtsPortChoice

{

public:
typedef pair<uint16_t,uint16_t> value_type;
const uint8_t k_isRangeMask = 0x01;
const uint8_t k_firstPortLengthMask = 0x02;
const uint8_t k_lastPortLengthMask = 0x04;
ArtsPortChoice();
ArtsPortChoice(uint16_t port);
ArtsPortChoice(uint16_t firstPort, uint16_t lastPort);
bool IsRange() const ;
bool IsRange(bool isRange) ;
const value_type & Value() const;
uint16_t Value(uint16_t port);
const value_type & Value(uint16_t firstPort, uint16_t lastPort);
bool Matches(uint16_t port) const;
uint32_t Length() const;
int read(int fd);
istream & read(istream & is);
int write(int fd) const;
ostream & write(ostream & os) const;
bool operator == (const ArtsPortChoice & portChoice) const;
bool operator < (const ArtsPortChoice & portChoice) const;
friend ostream & operator << (ostream& os, const ArtsPortChoice & portChoice);
protected:
}; // ArtsPortChoice

Back to the top of ArtsPortChoice


DESCRIPTION


---------------------------------------------------------------------------
class ArtsPortChoice
---------------------------------------------------------------------------
This class abstracts a port choice. A port choice can be a single port number or a range of ports ([a,b] inclusive). Typically this class is used only inside the ArtsPortChooser class.
---------------------------------------------------------------------------

Back to the top of ArtsPortChoice


typedef pair<uint16_t,uint16_t> value_type;


-------------------------------------------------------------------------
The value we will hold is a [firstPort,lastPort], stored in a pair<uint16_t,uint16_t>. When the port choice is a range, first will be set to firstPort and second will be set to lastPort. When the port choice is a single port, only the first value of the pair is valid.
-------------------------------------------------------------------------

  typedef  pair<uint16_t,uint16_t>  value_type;

Back to the top of ArtsPortChoice


const uint8_t k_isRangeMask = 0x01;


-------------------------------------------------------------------------
We use a single bit in _flags for a few settings:

- whether or not the value is a range or a single port - the length of the first port number - the length of the second port number if the value is a range

This isn't really relevant to the class user, since _flags is private. But I document the use here anyway.
-------------------------------------------------------------------------

-------------------------------------------------------------------------
If the value is a range, (_flags & k_isRangeMask) == 1
-------------------------------------------------------------------------

  const uint8_t  k_isRangeMask         = 0x01;

Back to the top of ArtsPortChoice


const uint8_t k_firstPortLengthMask = 0x02;


-------------------------------------------------------------------------
If the first port number is two bytes, (_flags & k_firstPortLengthMask) == 0x02 else (_flags & k_firstPortLengthMask) == 0
-------------------------------------------------------------------------

  const uint8_t  k_firstPortLengthMask = 0x02;

Back to the top of ArtsPortChoice


const uint8_t k_lastPortLengthMask = 0x04;


-------------------------------------------------------------------------
If the value is a range, there will be a second port number. If the second port number is two bytes, (_flags & k_lastPortLengthMask) == 0x04 else (_flags & k_firstPortLengthMask) == 0
-------------------------------------------------------------------------

  const uint8_t  k_lastPortLengthMask  = 0x04;

Back to the top of ArtsPortChoice


ArtsPortChoice();


-------------------------------------------------------------------------
ArtsPortChoice()
.........................................................................
constructor
-------------------------------------------------------------------------

  ArtsPortChoice();

Back to the top of ArtsPortChoice


ArtsPortChoice(uint16_t port);


-------------------------------------------------------------------------
ArtsPortChoice(uint16_t port)
.........................................................................
Constructor for a singple port number choice.
-------------------------------------------------------------------------

  ArtsPortChoice(uint16_t port);

Back to the top of ArtsPortChoice


ArtsPortChoice(uint16_t firstPort, uint16_t lastPort);


-------------------------------------------------------------------------
ArtsPortChoice(uint16_t firstPort, uint16_t lastPort)
.........................................................................
Constructor for a port range choice. firstPort must be less than or equal to lastPort. The range is inclusive.
-------------------------------------------------------------------------

  ArtsPortChoice(uint16_t firstPort, uint16_t lastPort);

Back to the top of ArtsPortChoice


bool IsRange() const ;


-------------------------------------------------------------------------
bool IsRange() const
.........................................................................
Returns true if the port choice is a range, else returns false.
-------------------------------------------------------------------------

  inline bool IsRange() const
                                                                                    
;

Function is currently defined inline.


Back to the top of ArtsPortChoice


bool IsRange(bool isRange) ;


-------------------------------------------------------------------------
inline bool IsRange(bool isRange)
.........................................................................
If isRange is true, sets the port choice to a range, else sets the port choice to a single port.
-------------------------------------------------------------------------

  inline bool IsRange(bool isRange)
                                                                                                                                    
;

Function is currently defined inline.


Back to the top of ArtsPortChoice


const value_type & Value() const;


-------------------------------------------------------------------------
const value_type & Value() const
.........................................................................
Returns a constant reference to the value in the port choice.
-------------------------------------------------------------------------

  const value_type & Value() const;

Back to the top of ArtsPortChoice


uint16_t Value(uint16_t port);


-------------------------------------------------------------------------
uint16_t Value(uint16_t port)
.........................................................................
Sets the port choice to a single port with value 'port'. Returns the single port value.
-------------------------------------------------------------------------

  uint16_t Value(uint16_t port);

Back to the top of ArtsPortChoice


const value_type & Value(uint16_t firstPort, uint16_t lastPort);


-------------------------------------------------------------------------
const value_type & Value(uint16_t firstPort, uint16_t lastPort)
.........................................................................
Sets the port choice to a port range [firstPort,lastPort] inclusive. Returns a refernece to the range value.
-------------------------------------------------------------------------

  const value_type & Value(uint16_t firstPort, uint16_t lastPort);

Back to the top of ArtsPortChoice


bool Matches(uint16_t port) const;


-------------------------------------------------------------------------
bool Matches(uint16_t port) const
.........................................................................
Returns true if port matches our value (is equal to our first port number if we're a single port value, or is within the range specified by our [first,second] port pair if we're a port range). Returns false otherwise.
-------------------------------------------------------------------------

  bool Matches(uint16_t port) const;

Back to the top of ArtsPortChoice


uint32_t Length() const;


-------------------------------------------------------------------------
uint32_t Length() const
.........................................................................
Returns the length (in bytes) of space required to store the port choice on disk.
-------------------------------------------------------------------------

  uint32_t Length() const;

Back to the top of ArtsPortChoice


int read(int fd);


-------------------------------------------------------------------------
int read(int fd)
.........................................................................
Reads the port choice from a file descriptor. Returns the number of bytes read on successs, -1 on failure.
-------------------------------------------------------------------------

  int read(int fd);

Back to the top of ArtsPortChoice


istream & read(istream & is);


-------------------------------------------------------------------------
istream & read(istream & is)
.........................................................................
Reads the port choice from an istream. Returns the istream.
-------------------------------------------------------------------------

  istream & read(istream & is);

Back to the top of ArtsPortChoice


int write(int fd) const;


-------------------------------------------------------------------------
int write(int fd) const
.........................................................................
Writes the port choice to a file descriptor. Returns the number of bytes written on success, -1 on failure.
-------------------------------------------------------------------------

  int write(int fd) const;

Back to the top of ArtsPortChoice


ostream & write(ostream & os) const;


-------------------------------------------------------------------------
ostream & write(ostream & os) const
.........................................................................
Writes the port choice to an ostream. Returns the ostream.
-------------------------------------------------------------------------

  ostream & write(ostream & os) const;

Back to the top of ArtsPortChoice


bool operator == (const ArtsPortChoice & portChoice) const;


-------------------------------------------------------------------------
bool operator == (const ArtsPortChoice & portChoice) const
.........................................................................
Overloaded '==' operator.
-------------------------------------------------------------------------

  bool operator == (const ArtsPortChoice & portChoice) const;

Back to the top of ArtsPortChoice


bool operator < (const ArtsPortChoice & portChoice) const;


-------------------------------------------------------------------------
bool operator < (const ArtsPortChoice & portChoice) const
.........................................................................
Overloaded '<' operator, used for sorting a vector of ArtsPortChoice objects so that 2 vectors of ArtsPortChoice objects may be compared.
-------------------------------------------------------------------------

  bool operator < (const ArtsPortChoice & portChoice) const;

Back to the top of ArtsPortChoice


friend ostream & operator << (ostream& os, const ArtsPortChoice & portChoice);


-------------------------------------------------------------------------
friend ostream & operator << (ostream& os, const ArtsPortChoice & portChoice)
.........................................................................
Overloaded ostream << operator to dump an ArtsPortChoice to an ostream in a human-readable form.
-------------------------------------------------------------------------

  friend ostream & operator << (ostream& os,
                                const ArtsPortChoice & portChoice);

Back to the top of ArtsPortChoice


All Members

public:
typedef pair<uint16_t,uint16_t> value_type;
const uint8_t k_isRangeMask = 0x01;
const uint8_t k_firstPortLengthMask = 0x02;
const uint8_t k_lastPortLengthMask = 0x04;
bool IsRange() const ;
bool IsRange(bool isRange) ;
const value_type & Value() const;
uint16_t Value(uint16_t port);
const value_type & Value(uint16_t firstPort, uint16_t lastPort);
bool Matches(uint16_t port) const;
uint32_t Length() const;
int read(int fd);
istream & read(istream & is);
int write(int fd) const;
ostream & write(ostream & os) const;
bool operator == (const ArtsPortChoice & portChoice) const;
bool operator < (const ArtsPortChoice & portChoice) const;
friend ostream & operator << (ostream& os, const ArtsPortChoice & portChoice);
protected:

Back to the top of ArtsPortChoice


Ancestors

Class does not inherit from any other class.

Back to the top of ArtsPortChoice


Descendants

Class is not inherited by any others.

Back to the top of ArtsPortChoice


Generated from source by the Cocoon utilities on Sat Oct 17 14:39:59 1998 .

Report problems to jkotula@unimax.com