-
Notifications
You must be signed in to change notification settings - Fork 0
/
PortTypeMapping.c
157 lines (131 loc) · 3.92 KB
/
PortTypeMapping.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "Port.h"
#include "Visitor.h"
#include "tools.h"
#include "PortTypeMapping.h"
#define DEBUG 0
#if DEBUG
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
#endif
PortTypeMapping* new_PortTypeMapping()
{
PortTypeMapping* pObj;
/* Allocating memory */
pObj = (PortTypeMapping*)malloc(sizeof(PortTypeMapping));
if (pObj == NULL)
{
return NULL;
}
/* pointing to itself as we are creating base class object*/
pObj->pDerivedObj = pObj;
memset(&pObj->generated_KMF_ID[0], 0, sizeof(pObj->generated_KMF_ID));
rand_str(pObj->generated_KMF_ID, 8);
pObj->beanMethodName = NULL;
pObj->serviceMethodName = NULL;
pObj->paramTypes = NULL;
pObj->eContainer = NULL;
pObj->internalGetKey = PortTypeMapping_internalGetKey;
pObj->metaClassName = PortTypeMapping_metaClassName;
pObj->Delete = delete_PortTypeMapping;
pObj->VisitAttributes = PortTypeMapping_VisitAttributes;
pObj->VisitPathAttributes = PortTypeMapping_VisitPathAttributes;
pObj->FindByPath = PortTypeMapping_FindByPath;
return pObj;
}
char* PortTypeMapping_metaClassName(void * const this)
{
char *name;
name = malloc(sizeof(char) * (strlen("PortTypeMapping")) + 1);
if(name != NULL)
strcpy(name, "PortTypeMapping");
else
return NULL;
return name;
}
char* PortTypeMapping_internalGetKey(void * const this)
{
PortTypeMapping *pObj = (PortTypeMapping*)this;
return pObj->generated_KMF_ID;
}
void delete_PortTypeMapping(void * const this)
{
/* destroy data memebers */
if(this != NULL)
{
PortTypeMapping *pObj = (PortTypeMapping*)this;
free(pObj->beanMethodName);
free(pObj->serviceMethodName);
free(pObj->paramTypes);
free(pObj->eContainer);
free(pObj);
/*this = NULL;*/
}
}
void PortTypeMapping_VisitAttributes(void* const this, char* parent, Visitor* visitor, bool recursive)
{
char path[256];
char* cClass = NULL;
memset(&path[0], 0, sizeof(path));
sprintf(path,"%s\\cClass", parent);
cClass = ((PortTypeMapping*)this)->metaClassName((PortTypeMapping*)this);
visitor->action(path, STRING, cClass);
/*free(cClass);*/
free(cClass);
sprintf(path,"%s\\ID",parent);
visitor->action(path, STRING, ((PortTypeMapping*)(this))->generated_KMF_ID);
sprintf(path,"%s\\beanMethodName",parent);
visitor->action(path, STRING, ((PortTypeMapping*)(this))->beanMethodName);
sprintf(path,"%s\\serviceMethodName",parent);
visitor->action(path, STRING, ((PortTypeMapping*)(this))->serviceMethodName);
sprintf(path,"%s\\paramTypes",parent);
visitor->action(path, STRING, ((PortTypeMapping*)(this))->paramTypes);
}
void PortTypeMapping_VisitPathAttributes(void *const this, char *parent, Visitor *visitor, bool recursive)
{
char path[256];
char* cClass = NULL;
memset(&path[0], 0, sizeof(path));
/*sprintf(path,"%s\\cClass", parent);
cClass = ((PortTypeMapping*)this)->metaClassName((PortTypeMapping*)this);
visitor->action(path, STRING, cClass);
free(cClass);*/
sprintf(path,"%s\\ID",parent);
visitor->action(path, STRING, ((PortTypeMapping*)(this))->generated_KMF_ID);
sprintf(path,"%s\\beanMethodName",parent);
visitor->action(path, STRING, ((PortTypeMapping*)(this))->beanMethodName);
sprintf(path,"%s\\serviceMethodName",parent);
visitor->action(path, STRING, ((PortTypeMapping*)(this))->serviceMethodName);
sprintf(path,"%s\\paramTypes",parent);
visitor->action(path, STRING, ((PortTypeMapping*)(this))->paramTypes);
}
void* PortTypeMapping_FindByPath(char* attribute, void * const this)
{
PortTypeMapping *pObj = (PortTypeMapping*)this;
/* Local attributes */
if(!strcmp("beanMethodName", attribute))
{
return pObj->beanMethodName;
}
else if(!strcmp("serviceMethodName", attribute))
{
return pObj->serviceMethodName;
}
else if(!strcmp("paramTypes", attribute))
{
return pObj->paramTypes;
}
else if(!strcmp("generated_KMF_ID", attribute))
{
return pObj->generated_KMF_ID;
}
/* There is no local references */
else
{
PRINTF("Wrong path\n");
return NULL;
}
}