Skip to content

Commit 124ae79

Browse files
author
gigi
committed
update
1 parent 19ed151 commit 124ae79

276 files changed

Lines changed: 9042 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

OOC-Design-Pattern/.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Object files
2+
*.o
3+
*.ko
4+
*.obj
5+
*.elf
6+
obj/
7+
8+
# Precompiled Headers
9+
*.gch
10+
*.pch
11+
12+
# Libraries
13+
*.lib
14+
*.a
15+
*.la
16+
*.lo
17+
18+
# Shared objects (inc. Windows DLLs)
19+
*.dll
20+
*.so
21+
*.so.*
22+
*.dylib
23+
24+
# Executables
25+
*.exe
26+
*.out
27+
*.app
28+
*.i*86
29+
*.x86_64
30+
*.hex
31+
bin/
32+
33+
# Debug files
34+
*.dSYM/
35+
36+
# CTags file
37+
*.tags*
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
EXECPATH = ../bin
2+
OBJPATH = ../obj/AbstractFactory
3+
INCLUDEPATH = include
4+
LIBPATH = ../lib/include
5+
SRCPATH = src
6+
CC = gcc
7+
OPTIONS = -Wall -fms-extensions
8+
9+
EXEC = $(EXECPATH)/AbstractFactory
10+
OBJS = $(OBJPATH)/linux_factory.o $(OBJPATH)/mac_factory.o $(OBJPATH)/windows_factory.o $(OBJPATH)/linux_widget.o $(OBJPATH)/mac_widget.o $(OBJPATH)/windows_widget.o $(OBJPATH)/linux_button.o $(OBJPATH)/mac_button.o $(OBJPATH)/windows_button.o $(OBJPATH)/main.o
11+
12+
all: dir build
13+
14+
dir:
15+
mkdir -p $(OBJPATH)
16+
mkdir -p $(EXECPATH)
17+
18+
build: $(OBJS) $(EXEC)
19+
20+
$(EXEC): $(OBJS)
21+
$(CC) -g -o $@ $(OBJS)
22+
23+
$(OBJPATH)/linux_factory.o: $(SRCPATH)/linux_factory.c
24+
$(CC) -g -c $< -I $(LIBPATH) -I $(INCLUDEPATH) -o $@ $(OPTIONS)
25+
26+
$(OBJPATH)/mac_factory.o: $(SRCPATH)/mac_factory.c
27+
$(CC) -g -c $< -I $(LIBPATH) -I $(INCLUDEPATH) -o $@ $(OPTIONS)
28+
29+
$(OBJPATH)/windows_factory.o: $(SRCPATH)/windows_factory.c
30+
$(CC) -g -c $< -I $(LIBPATH) -I $(INCLUDEPATH) -o $@ $(OPTIONS)
31+
32+
$(OBJPATH)/linux_widget.o: $(SRCPATH)/linux_widget.c
33+
$(CC) -g -c $< -I $(LIBPATH) -I $(INCLUDEPATH) -o $@ $(OPTIONS)
34+
35+
$(OBJPATH)/mac_widget.o: $(SRCPATH)/mac_widget.c
36+
$(CC) -g -c $< -I $(LIBPATH) -I $(INCLUDEPATH) -o $@ $(OPTIONS)
37+
38+
$(OBJPATH)/windows_widget.o: $(SRCPATH)/windows_widget.c
39+
$(CC) -g -c $< -I $(LIBPATH) -I $(INCLUDEPATH) -o $@ $(OPTIONS)
40+
41+
$(OBJPATH)/linux_button.o: $(SRCPATH)/linux_button.c
42+
$(CC) -g -c $< -I $(LIBPATH) -I $(INCLUDEPATH) -o $@ $(OPTIONS)
43+
44+
$(OBJPATH)/mac_button.o: $(SRCPATH)/mac_button.c
45+
$(CC) -g -c $< -I $(LIBPATH) -I $(INCLUDEPATH) -o $@ $(OPTIONS)
46+
47+
$(OBJPATH)/windows_button.o: $(SRCPATH)/windows_button.c
48+
$(CC) -g -c $< -I $(LIBPATH) -I $(INCLUDEPATH) -o $@ $(OPTIONS)
49+
50+
$(OBJPATH)/main.o: $(SRCPATH)/main.c
51+
$(CC) -g -c $< -I $(LIBPATH) -I $(INCLUDEPATH) -o $@ $(OPTIONS)
52+
53+
clean:
54+
-rm -rf $(EXEC) $(OBJS)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef IBUTTON_H
2+
#define IBUTTON_H
3+
4+
typedef struct _IButton IButton;
5+
6+
struct _IButton {
7+
void (*click)(IButton*);
8+
};
9+
10+
#endif
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef IFACTORY_H
2+
#define IFACTORY_H
3+
4+
#include "iwidget.h"
5+
#include "ibutton.h"
6+
7+
typedef struct _IFactory IFactory;
8+
9+
struct _IFactory {
10+
IWidget* (*createWidget)(IFactory*);
11+
IButton* (*createButton)(IFactory*);
12+
};
13+
14+
#endif
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef IWIDGET_H
2+
#define IWIDGET_H
3+
4+
typedef struct _IWidget IWidget;
5+
6+
struct _IWidget {
7+
void (*show)(IWidget*);
8+
};
9+
10+
#endif
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifndef LINUX_BUTTON_H
2+
#define LINUX_BUTTON_H
3+
4+
#include "ibutton.h"
5+
6+
typedef struct _LinuxButton LinuxButton;
7+
8+
struct _LinuxButton {
9+
union {
10+
IButton;
11+
IButton ibutton;
12+
};
13+
};
14+
15+
extern LinuxButton* LinuxButton_construct(void*);
16+
extern void LinuxButton_destruct(LinuxButton*);
17+
18+
#endif
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifndef LINUX_FACTORY_H
2+
#define LINUX_FACTORY_H
3+
4+
#include "ifactory.h"
5+
6+
typedef struct _LinuxFactory LinuxFactory;
7+
8+
struct _LinuxFactory {
9+
union {
10+
IFactory;
11+
IFactory ifactory;
12+
};
13+
};
14+
15+
extern LinuxFactory* LinuxFactory_construct(void*);
16+
extern void LinuxFactory_destruct(LinuxFactory*);
17+
18+
#endif
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifndef LINUX_WIDGET_H
2+
#define LINUX_WIDGET_H
3+
4+
#include "iwidget.h"
5+
6+
typedef struct _LinuxWidget LinuxWidget;
7+
8+
struct _LinuxWidget {
9+
union {
10+
IWidget;
11+
IWidget iwidget;
12+
};
13+
};
14+
15+
extern LinuxWidget* LinuxWidget_construct(void*);
16+
extern void LinuxWidget_destruct(LinuxWidget*);
17+
18+
#endif
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifndef MAC_BUTTON_H
2+
#define MAC_BUTTON_H
3+
4+
#include "ibutton.h"
5+
6+
typedef struct _MacButton MacButton;
7+
8+
struct _MacButton {
9+
union {
10+
IButton;
11+
IButton ibutton;
12+
};
13+
};
14+
15+
extern MacButton* MacButton_construct(void*);
16+
extern void MacButton_destruct(MacButton*);
17+
18+
#endif
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifndef MAC_FACTORY_H
2+
#define MAC_FACTORY_H
3+
4+
#include "ifactory.h"
5+
6+
typedef struct _MacFactory MacFactory;
7+
8+
struct _MacFactory {
9+
union {
10+
IFactory;
11+
IFactory ifactory;
12+
};
13+
};
14+
15+
extern MacFactory* MacFactory_construct(void*);
16+
extern void MacFactory_destruct(MacFactory*);
17+
18+
#endif

0 commit comments

Comments
 (0)