Created
December 29, 2019 14:52
-
-
Save gsrunion/70b7f10b42246f5c2b9adcc4c97fdc9c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Bus.h" | |
#include <memory.h> | |
typedef struct SubscriptionList { | |
Subscription subscriptions[MAX_SUBSCRIBERS_PER_TOPIC]; | |
} SubscriptionList; | |
typedef struct Topic { | |
char* topicString; | |
SubscriptionList subscriptions; | |
} Topic; | |
static Topic topics[MAX_TOPICS]; | |
void Bus_Init(void) { | |
memset(&topics, 0, sizeof(topics)); | |
} | |
BusStatus Bus_Publish(const char* const topic, void* data, size_t size) { | |
} | |
BusStatus Bus_Subscribe(const char* const topic, Subscription subscription) { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef UNTITLED5_BUS_H | |
#define UNTITLED5_BUS_H | |
#include <stdlib.h> | |
#define MAX_TOPICS 5 | |
#define MAX_SUBSCRIBERS_PER_TOPIC 5 | |
typedef enum BusStatus { | |
PUBLISHED, | |
SUBSCRIBED, | |
ERROR, | |
} BusStatus; | |
typedef int (*Subscription)(void* data, size_t size); | |
void Bus_Init(void); | |
BusStatus Bus_Publish(const char* const topic, void* data, size_t size); | |
BusStatus Bus_Subscribe(const char* const topic, Subscription subscription); | |
#endif //UNTITLED5_BUS_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Bus.h" | |
#include <memory.h> | |
typedef struct SubscriptionList { | |
Subscription subscriptions[MAX_SUBSCRIBERS_PER_TOPIC]; | |
} SubscriptionList; | |
typedef struct Topic { | |
char* topicString; | |
SubscriptionList subscriptions; | |
} Topic; | |
static Topic topics[MAX_TOPICS]; | |
void Bus_Init(void) { | |
memset(&topics, 0, sizeof(topics)); | |
} | |
BusStatus Bus_Publish(const char* const topic, void* data, size_t size) { | |
} | |
BusStatus Bus_Subscribe(const char* const topic, Subscription subscription) { | |
} | |
#ifndef UNTITLED5_BUS_H | |
#define UNTITLED5_BUS_H | |
#include <stdlib.h> | |
#define MAX_TOPICS 5 | |
#define MAX_SUBSCRIBERS_PER_TOPIC 5 | |
typedef enum BusStatus { | |
PUBLISHED, | |
SUBSCRIBED, | |
ERROR, | |
} BusStatus; | |
typedef int (*Subscription)(void* data, size_t size); | |
void Bus_Init(void); | |
BusStatus Bus_Publish(const char* const topic, void* data, size_t size); | |
BusStatus Bus_Subscribe(const char* const topic, Subscription subscription); | |
#endif //UNTITLED5_BUS_H |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment