//=========================================================================== // $Name: $ // $Id: Arts.hh,v 1.1.1.1 2000/03/29 22:53:56 kkeys Exp $ //=========================================================================== // CAIDA Copyright Notice // // By accessing this software, arts++, you are duly informed // of and agree to be bound by the conditions described below in this // notice: // // This software product, arts++, is developed by Daniel W. McRobb, and // copyrighted(C) 1998 by the University of California, San Diego // (UCSD), with all rights reserved. UCSD administers the CAIDA grant, // NCR-9711092, under which part of this code was developed. // // There is no charge for arts++ software. You can redistribute it // and/or modify it under the terms of the GNU General Public License, // v. 2 dated June 1991 which is incorporated by reference herein. // arts++ is distributed WITHOUT ANY WARRANTY, IMPLIED OR EXPRESS, OF // MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE or that the use // of it will not infringe on any third party's intellectual property // rights. // // You should have received a copy of the GNU GPL along with arts++. // Copies can also be obtained from: // // http://www.gnu.org/copyleft/gpl.html // // or by writing to: // // University of California, San Diego // // SDSC/CAIDA // 9500 Gilman Dr., MS-0505 // La Jolla, CA 92093 - 0505 USA // // Or contact: // // info@caida.org //=========================================================================== #include #include "ArtsHeader.hh" #include "ArtsAttribute.hh" #include "ArtsIpPathData.hh" #include "ArtsAsMatrixData.hh" #include "ArtsNetMatrixData.hh" #include "ArtsPortTableData.hh" #include "ArtsPortMatrixData.hh" #include "ArtsProtocolTableData.hh" #include "ArtsSelectedPortTableData.hh" #ifndef _ARTS_HH_ #define _ARTS_HH_ //--------------------------------------------------------------------------- // class Arts //--------------------------------------------------------------------------- // Top-level Arts class. The most frequent instantiation of this class: // an application needs to deal with an Arts object whose type is not // known until runtime. For example, reading a file containing ARTS // objects of arbitrary type or order. // // In cases where an application knows what type of Arts object it // needs, it should instantiate the derived class and not this class. //--------------------------------------------------------------------------- class Arts { public: //------------------------------------------------------------------------- // Arts() //......................................................................... // constructor //------------------------------------------------------------------------- Arts(); //------------------------------------------------------------------------- // ~Arts() //......................................................................... // destructor //------------------------------------------------------------------------- ~Arts(); //------------------------------------------------------------------------- // void AddHostAttribute(ipv4addr_t hostAddr) //......................................................................... // Adds a host attribute with an IP address of hostAddr. //------------------------------------------------------------------------- void AddHostAttribute(ipv4addr_t hostAddr); //------------------------------------------------------------------------- // void AddCreationAttribute(uint32_t creationTime); //......................................................................... // Adds a creation time attribute. //------------------------------------------------------------------------- void AddCreationAttribute(uint32_t creationTime); //------------------------------------------------------------------------- // void AddPeriodAttribute(uint32_t startTime, uint32_t endTime) //......................................................................... // Adds a period attribute (startTime to endTime). //------------------------------------------------------------------------- void AddPeriodAttribute(uint32_t startTime, uint32_t endTime); //------------------------------------------------------------------------- // void AddIfIndexAttribute(uint16_t ifIndex) //......................................................................... // Adds an interface index attribute using ifIndex as value. //------------------------------------------------------------------------- void AddIfIndexAttribute(uint16_t ifIndex); //------------------------------------------------------------------------- // inline ArtsHeader & Header() const //......................................................................... // Returns a reference to the header data. //------------------------------------------------------------------------- inline ArtsHeader & Header() const { return(this->_header); } //------------------------------------------------------------------------- // inline vector & Attributes() const //......................................................................... // Returns a reference to the vector of attributes. //------------------------------------------------------------------------- inline vector & Attributes() const { return(this->_attributes); } //------------------------------------------------------------------------- // vector::iterator FindCreationAttribute() const //......................................................................... // Returns an iterator for the first creation attribute in the object. // If a creation attribute is not found, returns this->Attributes().end() //------------------------------------------------------------------------- vector::iterator FindCreationAttribute() const; //------------------------------------------------------------------------- // vector::const_iterator FindPeriodAttribute() const //......................................................................... // Returns an iterator for the first period attribute in the object. // If a period attribute is not found, returns this->Attributes().end() //------------------------------------------------------------------------- vector::const_iterator FindPeriodAttribute() const; //------------------------------------------------------------------------- // vector::const_iterator FindHostAttribute() const //......................................................................... // Returns an iterator for the first host attribute in the object. // If a host attribute is not found, returns this->Attributes().end() //------------------------------------------------------------------------- vector::const_iterator FindHostAttribute() const; //------------------------------------------------------------------------- // vector::const_iterator FindIfIndexAttribute() const //......................................................................... // returns an iterator for the first interface index attribute in // the object. If an interface index attribute is not found, returns // this->Attributes().end() //------------------------------------------------------------------------- vector::const_iterator FindIfIndexAttribute() const; //------------------------------------------------------------------------- // inline ArtsIpPathData* IpPathData() const //......................................................................... // Returns a pointer to the IP path data in an object containing // ArtsIpPathData. If the object is not holding ArtsIpPathData, // returns NULL. //------------------------------------------------------------------------- inline ArtsIpPathData* IpPathData() const { return(this->_data._ipPath); } //------------------------------------------------------------------------- // inline ArtsAsMatrixData* AsMatrixData() const //......................................................................... // Returns a pointer to the AS matrix data in an object. Returns NULL // if there is no AS matrix data in the object. //------------------------------------------------------------------------- inline ArtsAsMatrixData* AsMatrixData() const { return(this->_data._asMatrix); } //------------------------------------------------------------------------- // inline ArtsNetMatrixData* NetMatrixData() const //......................................................................... // Returns a pointer to the AS matrix data in an object. Returns NULL // if there is no AS matrix data in the object. //------------------------------------------------------------------------- inline ArtsNetMatrixData* NetMatrixData() const { return(this->_data._netMatrix); } //------------------------------------------------------------------------- // inline ArtsPortTableData* PortTableData() const //......................................................................... // Returns a pointer to the port table in the object. Returns NULL if // there is no port table in the object. //------------------------------------------------------------------------- inline ArtsPortTableData* PortTableData() const { return(this->_data._portTable); } //------------------------------------------------------------------------- // inline ArtsSelectedPortTableData* SelectedPortTableData() const //......................................................................... // Returns a pointer to the selected port table in the object. // Returns NULL if there is no selected port table in the object. //------------------------------------------------------------------------- inline ArtsSelectedPortTableData* SelectedPortTableData() const { return(this->_data._selectedPortTable); } //------------------------------------------------------------------------- // inline ArtsPortMatrixData* PortMatrixData() const //......................................................................... // Returns a pointer to the port matrix in the object. Returns NULL // if there is no port matrix in the object. //------------------------------------------------------------------------- inline ArtsPortMatrixData* PortMatrixData() const { return(this->_data._portMatrix); } //------------------------------------------------------------------------- // inline ArtsProtocolTableData* ProtocolTableData() const //......................................................................... // Returns a pointer to the protocol table in the object. Returns // NULL if there is no protocol table in the object. //------------------------------------------------------------------------- inline ArtsProtocolTableData* ProtocolTableData() const { return(this->_data._protocolTable); } //------------------------------------------------------------------------- // istream& read(istream& is) //......................................................................... // Loads the data from an istream into the Arts object. Returns a // reference to the istream. //------------------------------------------------------------------------- istream & read(istream & is); //------------------------------------------------------------------------- // int read(int fd) //......................................................................... // Loads the data from a file descriptor into the Arts object. // Returns the number of bytes read on success, -1 on failure. //------------------------------------------------------------------------- int read(int fd); //------------------------------------------------------------------------- // ostream& write(ostream& os) //......................................................................... // Writes an Arts object to an ostream. Returns a reference to the // ostream. //------------------------------------------------------------------------- ostream& write(ostream& os); //------------------------------------------------------------------------- // int write(int fd) //......................................................................... // Writes an Arts object to a file descriptor. Returns the number // of bytes written on success, -1 on failure. //------------------------------------------------------------------------- int write(int fd); //------------------------------------------------------------------------- // Arts & operator = (const Arts & arts) //......................................................................... // Overloaded '=' operator to deep-copy an ARTS object. //------------------------------------------------------------------------- Arts & operator = (const Arts & arts); //------------------------------------------------------------------------- // friend ostream& operator << (ostream& os, // const Arts & arts) //......................................................................... // Overloaded ostream '<<' operator to dump the contents of an Arts // object to an ostream in a human-readable form. Returns the // ostream. //------------------------------------------------------------------------- friend ostream& operator << (ostream& os, const Arts & arts); protected: struct { ArtsIpPathData* _ipPath; ArtsAsMatrixData* _asMatrix; ArtsPortTableData* _portTable; ArtsProtocolTableData* _protocolTable; ArtsNetMatrixData* _netMatrix; ArtsPortMatrixData* _portMatrix; ArtsSelectedPortTableData *_selectedPortTable; } _data; mutable ArtsHeader _header; mutable vector _attributes; }; #endif /* _ARTS_HH_ */