Skip to content

Commit dfe4196

Browse files
committed
Aggiungere i file di progetto.
1 parent e0cefce commit dfe4196

25 files changed

+2263
-0
lines changed

Makefile

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
CC = g++
2+
3+
#CFLAGS = -O4 -DNDEBUG -funroll-loops
4+
CFLAGS = -g
5+
6+
LIBFLAG = -lm
7+
8+
EXTHDRS = /usr/include/assert.h \
9+
/usr/include/floatingpoint.h \
10+
/usr/include/math.h \
11+
/usr/include/stdio.h \
12+
/usr/include/sys/ieeefp.h
13+
14+
HDRS = global.h \
15+
queue.h \
16+
rand.h \
17+
simulator.h \
18+
calendar.h \
19+
packet.h \
20+
event.h \
21+
easyio.h \
22+
stat.h \
23+
buffer.h
24+
25+
MAKEFILE = Makefile
26+
27+
OBJS = main.o \
28+
queue.o \
29+
rand.o \
30+
simulator.o \
31+
calendar.o \
32+
packet.o \
33+
event.o \
34+
easyio.o \
35+
stat.o \
36+
buffer.o
37+
38+
PROGRAM = queue
39+
40+
41+
SRCS = main.c \
42+
queue.c \
43+
rand.c \
44+
simulator.c \
45+
calendar.c \
46+
packet.c \
47+
event.c \
48+
easyio.c \
49+
stat.c \
50+
buffer.c
51+
52+
all: $(PROGRAM)
53+
54+
$(PROGRAM): $(OBJS) $(LIBS)
55+
@echo -n "Loading $(PROGRAM) ... "
56+
@$(CC) $(CFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM) $(LIBFLAG)
57+
@echo "done"
58+
59+
clean:; @rm -f $(OBJS)
60+
61+
depend:; @mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM)
62+
63+
index:; @ctags -wx $(HDRS) $(SRCS)
64+
65+
tags: $(HDRS) $(SRCS); @ctags $(HDRS) $(SRCS)
66+
67+
###
68+
main.o: global.h simulator.h queue.h
69+
queue.o: global.h simulator.h queue.h event.h
70+
rand.o: global.h rand.h
71+
simulator.o: global.h
72+
calendar.o: calendar.h global.h
73+
packet.o: packet.h global.h
74+
buffer.o: buffer.h global.h
75+
event.o: global.h event.h
76+
# DO NOT DELETE

Makefile.bak

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
CC = g++
2+
3+
#CFLAGS = -O4 -DNDEBUG -funroll-loops
4+
CFLAGS = -g
5+
6+
LIBFLAG = -lm
7+
8+
EXTHDRS = /usr/include/assert.h \
9+
/usr/include/floatingpoint.h \
10+
/usr/include/math.h \
11+
/usr/include/stdio.h \
12+
/usr/include/sys/ieeefp.h
13+
14+
HDRS = global.h \
15+
queue.h \
16+
rand.h \
17+
simulator.h \
18+
calendar.h \
19+
packet.h \
20+
event.h \
21+
easyio.h \
22+
stat.h \
23+
buffer.h
24+
25+
MAKEFILE = Makefile
26+
27+
OBJS = main.o \
28+
queue.o \
29+
rand.o \
30+
simulator.o \
31+
calendar.o \
32+
packet.o \
33+
event.o \
34+
easyio.o \
35+
stat.o \
36+
buffer.o
37+
38+
PROGRAM = queue
39+
40+
41+
SRCS = main.c \
42+
queue.c \
43+
rand.c \
44+
simulator.c \
45+
calendar.c \
46+
packet.c \
47+
event.c \
48+
easyio.c \
49+
stat.c \
50+
buffer.c
51+
52+
all: $(PROGRAM)
53+
54+
$(PROGRAM): $(OBJS) $(LIBS)
55+
@echo -n "Loading $(PROGRAM) ... "
56+
@$(CC) $(CFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM) $(LIBFLAG)
57+
@echo "done"
58+
59+
clean:; @rm -f $(OBJS)
60+
61+
depend:; @mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM)
62+
63+
index:; @ctags -wx $(HDRS) $(SRCS)
64+
65+
tags: $(HDRS) $(SRCS); @ctags $(HDRS) $(SRCS)
66+
67+
###
68+
main.o: global.h simulator.h queue.h
69+
queue.o: global.h simulator.h queue.h event.h
70+
rand.o: global.h rand.h
71+
simulator.o: global.h
72+
calendar.o: calendar.h global.h
73+
packet.o: packet.h global.h
74+
buffer.o: buffer.h global.h
75+
event.o: global.h event.h
76+
# DO NOT DELETE

buffer.cpp

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/***************************************************************************
2+
BUFFER.C
3+
***************************************************************************/
4+
5+
#include "buffer.h"
6+
7+
buffer::buffer(){
8+
head=NULL;
9+
last=NULL;
10+
status=0;
11+
tot_delay=0.0;
12+
tot_packs=0.0;
13+
}
14+
15+
void buffer::insert(packet* pack){
16+
if(head==NULL){
17+
head=pack;
18+
last=pack;
19+
last->next=head;
20+
}
21+
else {
22+
last->next=pack;
23+
last=pack;
24+
last->next=head;
25+
}
26+
}
27+
28+
packet* buffer::get(){
29+
30+
packet* pack;
31+
if(head==NULL)
32+
return NULL;
33+
if(last==head){
34+
pack=head;
35+
last=NULL;
36+
head=NULL;
37+
}
38+
else {
39+
pack=head;
40+
head=head->next;
41+
last->next=head;
42+
}
43+
return pack;
44+
}
45+

buffer.h

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/***************************************************************************
2+
BUFFER.H
3+
***************************************************************************/
4+
5+
#ifndef BUFFER_H
6+
#define BUFFER_H
7+
8+
#include "packet.h"
9+
10+
class buffer {
11+
12+
packet* head;
13+
packet* last;
14+
public:
15+
int status;
16+
17+
public:
18+
buffer();
19+
~buffer(){}
20+
void insert(packet* pack);
21+
packet* get();
22+
packet* full(){return head;}
23+
double tot_delay;
24+
double tot_packs;
25+
};
26+
27+
#endif

calendar.cpp

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/* -*- C++ -*- */
2+
/*******************************************************
3+
CALENDAR C
4+
*******************************************************/
5+
6+
#include "global.h"
7+
#include "calendar.h"
8+
9+
10+
event* calendar::get(){
11+
12+
if(head==NULL)
13+
return NULL;
14+
event* ev;
15+
if(head==last){
16+
ev=head;
17+
head=NULL;
18+
last=NULL;
19+
return ev;
20+
}
21+
ev=head;
22+
head=head->next;
23+
last->next=head;
24+
return ev;
25+
}
26+
27+
void calendar::put(event* New){
28+
event* temp=head;
29+
event* pippo;
30+
pippo=New;
31+
if(head==NULL){
32+
head=New;
33+
head->next=New;
34+
last=New;
35+
}
36+
else if (New->time<head->time){
37+
New->next=head;
38+
head=New;
39+
last->next=head;
40+
}
41+
else if (last==head){
42+
if(New->time<head->time){
43+
head=New;
44+
head->next=last;
45+
last->next=head;
46+
}
47+
else {
48+
last=New;
49+
head->next=last;
50+
last->next=head;
51+
}
52+
}
53+
else if (last->time<New->time){
54+
last->next=New;
55+
last=New;
56+
last->next=head;
57+
}
58+
else {
59+
while(temp->next->time < New->time)
60+
temp=temp->next;
61+
New->next=temp->next;
62+
temp->next=New;
63+
}
64+
}
65+

calendar.h

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*******************************************************
2+
CALENDAR H
3+
*******************************************************/
4+
5+
6+
#ifndef _CALENDAR_H
7+
#define _CALENDAR_H
8+
9+
#include "simulator.h"
10+
#include "event.h"
11+
12+
class calendar{
13+
14+
event* head;
15+
event* last;
16+
17+
public:
18+
19+
calendar();
20+
~calendar();
21+
event* get();
22+
void put(event* New_event);
23+
};
24+
25+
26+
inline calendar::calendar(){
27+
head=NULL;
28+
last=NULL;
29+
}
30+
inline calendar::~calendar(){
31+
event* temp=head;
32+
last->next=NULL;
33+
while(temp!=NULL){
34+
temp=temp->next;
35+
delete head;
36+
head=temp;
37+
}
38+
}
39+
40+
#endif
41+

0 commit comments

Comments
 (0)