Going on with structure
Added observer/observable for RTC git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@251 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Class.h (c) 2013 Micro-Key bv
|
||||
* -----------------------------------------------------------------------------
|
||||
* Micro-Key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* -----------------------------------------------------------------------------
|
||||
* Description: Macro utilities to hide or protect struct members
|
||||
* -----------------------------------------------------------------------------
|
||||
* $Id$
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _CLASS_H_
|
||||
#define _CLASS_H_
|
||||
|
||||
#ifndef CLASS_INTERNAL_INCLUDE
|
||||
|
||||
#define PRIVATE(member) DONOTUSE ## member
|
||||
#undef CLASS_INTERNAL_INCLUDE
|
||||
|
||||
#else
|
||||
|
||||
#define PRIVATE(member) member
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -82,6 +82,7 @@
|
||||
Logger_logISR(a, "", "", 0, LOGTYPE_PRINT, ##__VA_ARGS__)
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
#include "Class.h"
|
||||
#include "Observer.h"
|
||||
|
||||
/* -------------------------------*
|
||||
@@ -37,17 +36,14 @@
|
||||
/**
|
||||
* Maximal number of Observers for one Observable.
|
||||
*/
|
||||
#define OBSERVABLE_MAX_OBSERVERS (32)
|
||||
#define OBSERVABLE_MAX_OBSERVERS (10)
|
||||
|
||||
/**
|
||||
* Static initializer for the Observable class.
|
||||
* Typical usage: struct Observable observable = OBSERVABLE_INITIALIZER;
|
||||
*/
|
||||
#ifdef CLASS_INTERNAL_INCLUDE
|
||||
#define OBSERVABLE_INITIALIZER { .nrOfObservers = 0, .observers = { 0, } }
|
||||
#else
|
||||
#define OBSERVABLE_INITIALIZER { .DONOTUSEnrOfObservers = 0, .DONOTUSEobservers = { 0, } }
|
||||
#endif
|
||||
#define OBSERVABLE_INITIALIZER { .nrOfObservers = 0, .observers = { 0, } }
|
||||
|
||||
|
||||
/* ------------------*
|
||||
* Type definitions. *
|
||||
@@ -59,8 +55,8 @@
|
||||
*/
|
||||
struct Observable
|
||||
{
|
||||
int PRIVATE(nrOfObservers);
|
||||
Observer PRIVATE(observers)[OBSERVABLE_MAX_OBSERVERS];
|
||||
int nrOfObservers;
|
||||
Observer observers[OBSERVABLE_MAX_OBSERVERS];
|
||||
};
|
||||
|
||||
/* ----------------------*
|
||||
@@ -74,14 +70,14 @@ struct Observable
|
||||
* @param self: address of the Observable struct.
|
||||
* @retval none.
|
||||
*/
|
||||
void Observable_initialize(struct Observable* self);
|
||||
void Observable_construct(struct Observable* self);
|
||||
|
||||
/**
|
||||
* Terminates the Observable class. All Observers are removed.
|
||||
* @param self: address of the Observable struct.
|
||||
* @retval none.
|
||||
*/
|
||||
void Observable_terminate(struct Observable* self);
|
||||
void Observable_destruct(struct Observable* self);
|
||||
|
||||
/**
|
||||
* Adds one Observer to the Observable.
|
||||
|
||||
Reference in New Issue
Block a user