#include <vector> //#include "Node.h" #include "Lan.h" #include "Workstation.h" #include "PrintServer.h" #include "Packet.h" #include "PacketFactory.h" int main() { //Testing lan class // uso la classe definita singleton PacketFactory* pf = PacketFactory::instance(); vector< Node * > vectorNodes; Node *n1 = new Workstation( "workstation1", pf ); Node *n2 = new Workstation( "workstation2", pf ); Node *n3 = new Workstation( "workstation3", pf ); Node *n4 = new Workstation( "workstation4", pf ); Node *n5 = new Workstation( "workstation5", pf ); Node *n6 = new PrintServer( "printserver1", pf, "PostScript"); Node *n7 = new PrintServer( "printserver2", pf); vectorNodes.push_back( n1 ); vectorNodes.push_back( n2 ); vectorNodes.push_back( n3 ); vectorNodes.push_back( n4 ); vectorNodes.push_back( n5 ); vectorNodes.push_back( n6 ); vectorNodes.push_back( n7 ); //cout << "Dimensione " << vectorNodes.size() << endl; Lan *mylan = new Lan( 10, vectorNodes ); Node *n8 = new PrintServer( "hewlett packard", pf, "ASCII"); mylan->addNode( n8 ); //Packet *tpacket = vectorNodes[1]->send(); //cout << "o: " << tpacket->getOriginator() << " d: " << tpacket->getDestination() << endl; //Packet *tpacket2 = vectorNodes[2]->send(); //cout << "o: " << tpacket2->getOriginator() << " d: " << tpacket2->getDestination() << endl; //mylan->enqueue( tpacket ); //mylan->enqueue( tpacket2 ); //cout << "mylan: Banda disponibile " << mylan->bandWidth() << "pps" << endl; for (int i=0; i < 100; i++) mylan->doWork(); cout << "mylan: Banda disponibile " << mylan->bandWidth() << "pps" << endl; delete mylan; return 0; }