Create a custom library which uses Arduino Extended Database Library

Hi,

I’m writing because I am having a hard time to create and use a class library that should abstract an EDB database, and I am seeking your guidance and help :confused: .

The general project architecture is based on an INO sketch that instantiates a Runner class object which uses many other custom classes and libraries.

Among the classes used by the Runner is a class that is an abstraction (and make use) of Arduino Extended Database (EDB.h) library, to perform raw db operations while implementing high level business rules.
And it is at the very heart of my (C++) problem. >:(

The wanted workflow is: At every (sketch) loop, the runner object instance performs various tasks, for example it checks for serial port incoming bytes, and stores (write in flash file) some things with the EDB abstraction object.

I searched and found one example of similar request:Q&A_1 and Q&A_2

But after reading the given answers and trying different codes from Q&A1 and Q&A2 I still can’t compile and have questions such as:
-Where in my case should I put the read and write functions ? in the Runner.h ?
-Since there is only one class and instance using the EDB.h should I write the code to manage the instance ?

Despite all my efforts and searches and try, I’m now stuck: it doesn’t compile and my C++ knowledge is not enough.
I appreciate your help. Thank you.

Here is what I did (and doesn’t work):
The Sketch:

#include "Arduino.h"
#include <EDB.h>
#include "Runner.h"
#include "DBabstraction.h"

#define UsbSerial Serial
Runner myRunner;

void setup(){
    myRunner.run();
    UsbSerial.begin(115200);
    UsbSerial.printf("[SETUP] start\n");
    
}

void loop() {delay(1000);UsbSerial.printf("[LOOP] run\n");}

The Runner.h:

#include "Arduino.h"
#include "DBabstraction.h"

class Runner {
public:
    Runner();
    void run();
    static DBabstraction *globalDB;
    void globalConfigWriter( unsigned long address, byte data ) {
        globalDB->tdbWriter(address, data);
    }
    byte globalConfigReader( unsigned long address ) {
        return globalDB->tdbReader(address);
    }
private:
    
};

Runner.cpp

Runner::Runner(){
    globalDB = new DBabstraction();
    globalDB->begin();
}

void Runner::run(){
    Serial.printf("ok\n");
}

DBabstraction.h

#include "Arduino.h"
#include <EDB.h>
//Use SPIFFS FS as data storage
#include "LStorage.h"
#include "LFlash.h"

#define Drv LFlash          // use Internal 10M Flash
#define TABLE_SIZE 8192

// EDB records to create at begin()
#define RECORDS_TO_CREATE 10

// Arbitrary record definition for this table.
// This should be modified to reflect your record needs.
struct DataStruct {
    int id;
    int temperature;
}
dataStruct;
//
class DBabstraction {
public:
    DBabstraction();
    EDB myDB = new EDB(DBabstraction::dbWriter, DBabstraction::dbReader);
    void begin();
    static LFile myFile;
    static void dbWriter( unsigned long address, byte data );
    static byte dbReader( unsigned long address );
    
private:
    static DBabstraction * pInstance;
};

DBabstraction.cpp

#include "DBabstraction.h"
//constructor
DBabstraction::DBabstraction(){
    pInstance = this;
}
//public functions
static void DBabstraction::dbWriter(unsigned long address, byte data ){
    /* nothing for now but planned SD implementation */
    
}

static byte DBabstraction::dbReader( unsigned long address){
    /* nothing for now but planned SD implementation */
    
}

Again thx.

-Where in my case should I put the read and write functions ? in the Runner.h ?

That depends on what you mean by "put the functions". The header file defines what functions exist within the class, so you need to declare them there.

The source file implements the functions, so you need to implement them there.

The functions that you currently implement in the header file really do not belong there.

Using globalDB in any function, without making sure that globalDB is not a NULL pointer, is not a good idea.

You NEVER call new from a header file. That code belongs in a method in the source file.

Why does each runner need a separate database? The whole idea behind databases is to collect data.

Here is what I did (and doesn't work):

What did not work? Did the code compile? I have my doubts, which means that talking about the code working, or not, is unreasonable.

Warning: In Runner::run() you are sending output to Serial but in setup() you call myRunner.run() before calling Serial.begin().

Hi PaulS, JohnWasser,

PaulS:
That depends on what you mean by "put the functions".
The header file defines what functions exist within the class, so you need to declare them there.

The source file implements the functions, so you need to implement them there.

The functions that you currently implement in the header file really do not belong there.

I'd like to write a single self contained class to handle the high level and raw crud operations.
Could it be the write/read functions to be declared in the DBabstraction class ?

PaulS:
Using globalDB in any function, without making sure that globalDB is not a NULL pointer, is not a good idea.

I understand, by how can I check it ?

PaulS:
You NEVER call new from a header file. That code belongs in a method in the source file.

I edited my code and edited the original question above accordingly, thx.
I restored the original code so comments can apply.

PaulS:
Why does each runner need a separate database? The whole idea behind databases is to collect data.

Because I want a flexible component to abstract high level treatments. Thanks again PaulS

johnwasser:
Warning: In Runner::run() you are sending output to Serial but in setup() you call myRunner.run() before calling Serial.begin().

Right, thanks Jhnwasser, original post edited then restored.

Could it be the write/read functions to be declared in the DBabstraction class ?

I would think so.

I understand, by how can I check it ?

if(globalDB)
   globalDB->someMethod();

I edited my code and edited the original question above accordingly

So, you make me look like an idiot, questioning code that no longer has the problem. Thanks.

I'm done.

PaulS:
What did not work? Did the code compile? I have my doubts, which means that talking about the code working, or not, is unreasonable.

No it doesn't compile, and I am looking for guidance so to fix it. thx.

PaulS:
I would think so.

if(globalDB)

globalDB->someMethod();



So, you make me look like an idiot, questioning code that no longer has the problem. Thanks.
I'm done.

Don’t take it like this: that is absolutely not my intention.
If you want, I can still edit the original post and with the original code, and add replies with the corrected code. I just wanted to ease.

Edit: I restored the original post so all your comments can apply (and humbly apologize for any trouble my edit may have cause).
Thanks

Where would I find the LStorage.h and LFlash.h librarties?!?

As I thought it doesn't impact my project, I wrongfully omitted to tell it to you. I'am sorry.
Moreover, I won't update the original code anymore. Its better like this.

I am using Xcode (and embedxcode) on Macos.
I am compiling for a Mediatek Linkit One HDK (see description here) which comes with custom libraries made to be compatible with Arduino's environnement.
You can find the doc here.

As to my understanding, as for now, it's a pure C++ pattern implementation problem. I may be wrong.
Thanks again.

The LFlash is the 10M internal flash memory.
LFile is a file object provided by opening a file path with the LFlash.
LFile object can be byte written and read.
So the implementation of the dbWriter and dbReader in DBabstraction.cpp shall use these.

As to my understanding, as for now, it's a pure C++ pattern implementation problem.

How about you explain what the current problem is. Does the code compile? If not, post the error messages. If it does, explain what the problem(s) is/are.

Thanks PaulS,

I am not sure but it may have something to do with the scope of the write/read functions.
No it doesn't compile.
In DBabstraction.h:

static void DBabstraction::dbWriter(unsigned long address, byte data ){
/* nothing */
}
->Cannot declare member function 'static void DBabstraction::dbWriter(long unsigned int, byte)' to have static linkage

Same for dbReader

PS. In the INO sketch, I realize that I should have write myRunner.run() in the loop(). I corrected this already.

The declaration of the method, in the header file, would have the static keyword, not the implementation in the source file.

Here is where I get lost: So, if I understand well, there should be a "static" in the .h of DBabstraction, but not in the .cpp ? Am I right ?
Thanks

TiboFR:
Here is where I get lost: So, if I understand well, there should be a "static" in the .h of DBabstraction, but not in the .cpp ? Am I right ?
Thanks

That's what I said, so it must be right. It would, of course, have been faster to test the theory than to post the question.

PaulS:
That's what I said, so it must be right. It would, of course, have been faster to test the theory than to post the question.

Thanks PaulS, I did but couldn't update you before.
Meanwhile I switched to Arduino 1.8.5 IDE so to get the full same reading from compilation result as I didn't with Xcode.

So I removed the static keyword in front of the source code implementation and the result the previous error disappeared and there is new errors at compilation, related to undefined reference to globalDB, and multiple definition of `dataStruct':

DBabstraction.cpp.o: In function `DBabstraction::begin()': DBabstraction.cpp:11: multiple definition of `dataStruct'
first defined in INO sketch loop()
Runner.cpp.o: In function `Runner::run()': Runner.cpp:8: multiple definition of `dataStruct'
DBabstraction.cpp.o: In function `DBabstraction::DBabstraction()': DBabstraction.cpp:(...): warning: undefined reference to `DBabstraction::pInstance'
Runner.cpp.o: In function `Runner::Runner()': Runner.cpp:(...): warning: undefined reference to `Runner::globalDB'

Looks like my globalDB object doesn't persist (pInstance is initialized?), and a new globalDB is recreated every time, and dataStruct is therefore redefined, is it ?

How should I fix this ? Thank you PaulS

How should I fix this ?

With a text editor.

My crystal ball is at the cleaners. I can't see your current code, so I can't tell you how to fix it.

Here it is. Sorry and thank you.

INO:

#include "Arduino.h"
#include <EDB.h>
#include "Runner.h"
#include "DBabstraction.h"

// Define structures and classes

// Define variables and constants
#define UsbSerial Serial // rename Serial ports

// Variables
Runner myRunner;

// Add setup code
void setup()
{
    UsbSerial.begin(115200);
    UsbSerial.print("[SETUP] [Start]\n");
}

// Add loop code
void loop()
{
    myRunner.run();
    delay(1000);
}

DBabstraction.h

#ifndef DBabstraction_h
#define DBabstraction_h

#include "Arduino.h"
#include <EDB.h>
//Use SPIFFS FS as data storage
#include "LStorage.h"
#include "LFlash.h"

#define Drv LFlash          // use Internal 10M Flash
#define TABLE_SIZE 8192

// The number of demo records that should be created.  This should be less
// than (TABLE_SIZE - sizeof(EDB_Header)) / sizeof(LogEvent).  If it is higher,
// operations will return EDB_OUT_OF_RANGE for all records outside the usable range.
#define RECORDS_TO_CREATE 10

// Arbitrary record definition for this table.
// This should be modified to reflect your record needs.
struct Data_Struct {
    int id;
    int temperature;
}
data_struct;
//
class DBabstraction {
public:
    DBabstraction();
    EDB *myDB = new EDB(DBabstraction::dbWriter, DBabstraction::dbReader); //
    void begin();
    static LFile myFile;
    static void dbWriter( unsigned long address, byte data );
    static byte dbReader( unsigned long address );
    
private:
    static DBabstraction * pInstance;
};

#endif // DBabstraction_h

DBabstraction.cpp:

// Library header
#include "DBabstraction.h"
//constructor
DBabstraction::DBabstraction(){
    pInstance = this;
}
//public functions
void DBabstraction::dbWriter(unsigned long address, byte data ){
    /* nothing */
    
}

byte DBabstraction::dbReader( unsigned long address){
    /* nothing */
    
}

//public functions
void DBabstraction::begin(){
    /* nothing */
    
}
// Code DBabstraction.cpp

Runner.h:

#ifndef Runner_h
#define Runner_h

#include "Arduino.h"
#include "DBabstraction.h"

class Runner {
public:
    Runner();
    void run();
    //DBabstraction myAbstraction = new DBabstraction(); // ???
    static DBabstraction *globalDB;
    void globalConfigWriter( unsigned long address, byte data ) {
        globalDB->dbWriter(address, data);
    }
    byte globalConfigReader( unsigned long address ) {
        return globalDB->dbReader(address);
    }
private:
    
};

#endif // Runner_h

Runner.cpp:

// Library header
#include "Runner.h"

// Code
/**************************************************/
// public functions

Runner::Runner(){
    globalDB = new DBabstraction();
    if(globalDB)
        globalDB->begin();
}

void Runner::run(){
    Serial.printf("ok\n");
}

Compilation:

/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.cpp.o: In function `DBabstraction::begin()':
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.cpp:11: multiple definition of `data_struct'
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/CPPTEST.ino.cpp.o:/Users/Thibault/Desktop/CPPtest/CPPTEST.ino:24: first defined here
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/Runner.cpp.o: In function `Runner::run()':
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/Runner.cpp:8: multiple definition of `data_struct'
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/CPPTEST.ino.cpp.o:/Users/Thibault/Desktop/CPPtest/CPPTEST.ino:24: first defined here
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.cpp.o: In function `DBabstraction::DBabstraction()':
DBabstraction.cpp:(.text._ZN13DBabstractionC2Ev+0x38): warning: undefined reference to `DBabstraction::pInstance'
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/Runner.cpp.o: In function `Runner::Runner()':
Runner.cpp:(.text._ZN6RunnerC2Ev+0x30): warning: undefined reference to `Runner::globalDB'
collect2: error: ld returned 1 exit status
Using library EDB at version 1.0.4 in folder: /Users/Thibault/Documents/Arduino/libraries/EDB 
Using library LStorage in folder: /Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/libraries/LStorage (legacy)
exit status 1
Error compiling for board LinkIt ONE.

compilation warnings:
In file included from /Users/Thibault/Desktop/CPPtest/CPPTEST.ino:3:0:
/Users/Thibault/Documents/Arduino/libraries/EDB/EDB.h:24:25: warning: 'typedef' was ignored in this declaration [enabled by default]
};

^
In file included from /var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/Runner.h:5:0,
from /Users/Thibault/Desktop/CPPtest/CPPTEST.ino:4:
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.h:30:73: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]
EDB *myDB = new EDB(DBabstraction::dbWriter, DBabstraction::dbReader); //
^
"/Users/Thibault/Library/Arduino15/packages/LinkIt/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -O2 -MMD -ffunction-sections -fdata-sections -fvisibility=hidden -fpic -mthumb -mlittle-endian -nostdlib -fno-non-call-exceptions -fno-rtti -fno-exceptions -Dprintf=iprintf "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/system/libmtk" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/system/libmtk/include" -mcpu=arm7tdmi-s -DF_CPU=84000000L -DARDUINO=10805 -DARDUINO_MTK_ONE -DARDUINO_ARCH_ARM -D__COMPILER_GCC__ -D__LINKIT_ONE__ -D__LINKIT_ONE_RELEASE__ -mthumb -DUSB_VID=0x0E8D -DUSB_PID=0x0023 -DUSBCON '-DUSB_MANUFACTURER="Unknown"' '-DUSB_PRODUCT="LinkIt ONE"' "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/system/libmtk" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/system/libmtk/include" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/cores/arduino" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/variants/linkit_one" "-I/Users/Thibault/Documents/Arduino/libraries/EDB" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/libraries/LStorage" "/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.cpp" -o "/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.cpp.o"
In file included from /var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.h:5:0,
from /var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.cpp:2:
/Users/Thibault/Documents/Arduino/libraries/EDB/EDB.h:24:25: warning: 'typedef' was ignored in this declaration [enabled by default]
};

^
In file included from /var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.cpp:2:0:
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.h:30:73: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]
EDB *myDB = new EDB(DBabstraction::dbWriter, DBabstraction::dbReader); //
^
"/Users/Thibault/Library/Arduino15/packages/LinkIt/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -O2 -MMD -ffunction-sections -fdata-sections -fvisibility=hidden -fpic -mthumb -mlittle-endian -nostdlib -fno-non-call-exceptions -fno-rtti -fno-exceptions -Dprintf=iprintf "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/system/libmtk" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/system/libmtk/include" -mcpu=arm7tdmi-s -DF_CPU=84000000L -DARDUINO=10805 -DARDUINO_MTK_ONE -DARDUINO_ARCH_ARM -D__COMPILER_GCC__ -D__LINKIT_ONE__ -D__LINKIT_ONE_RELEASE__ -mthumb -DUSB_VID=0x0E8D -DUSB_PID=0x0023 -DUSBCON '-DUSB_MANUFACTURER="Unknown"' '-DUSB_PRODUCT="LinkIt ONE"' "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/system/libmtk" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/system/libmtk/include" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/cores/arduino" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/variants/linkit_one" "-I/Users/Thibault/Documents/Arduino/libraries/EDB" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/libraries/LStorage" "/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/Runner.cpp" -o "/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/Runner.cpp.o"
In file included from /var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.h:5:0,
from /var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/Runner.h:5,
from /var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/Runner.cpp:2:
/Users/Thibault/Documents/Arduino/libraries/EDB/EDB.h:24:25: warning: 'typedef' was ignored in this declaration [enabled by default]
};

^
In file included from /var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/Runner.h:5:0,
from /var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/Runner.cpp:2:
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.h:30:73: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]
EDB *myDB = new EDB(DBabstraction::dbWriter, DBabstraction::dbReader); //
^
Compiling libraries...
(...)
Linking everything together...

/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.cpp.o: In function DBabstraction::begin()': /var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.cpp:11: multiple definition of data_struct'
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/CPPTEST.ino.cpp.o:/Users/Thibault/Desktop/CPPtest/CPPTEST.ino:24: first defined here
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/Runner.cpp.o: In function Runner::run()': /var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/Runner.cpp:8: multiple definition of data_struct'
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/CPPTEST.ino.cpp.o:/Users/Thibault/Desktop/CPPtest/CPPTEST.ino:24: first defined here
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.cpp.o: In function DBabstraction::DBabstraction()': DBabstraction.cpp:(.text._ZN13DBabstractionC2Ev+0x38): warning: undefined reference to DBabstraction::pInstance'
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/Runner.cpp.o: In function Runner::Runner()': Runner.cpp:(.text._ZN6RunnerC2Ev+0x30): warning: undefined reference to Runner::globalDB'
collect2: error: ld returned 1 exit status
Using library EDB at version 1.0.4 in folder: /Users/Thibault/Documents/Arduino/libraries/EDB
Using library LStorage in folder: /Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/libraries/LStorage (legacy)
exit status 1
Error compiling for board LinkIt ONE.

You need to define the struct in a header file, with include guards, and only include that file where you need the struct.

You REALLY need to understand what goes in a header file and what goes in a source file, and quit trying to put stuff in the header file that belongs in the source file. You declare variables in a header file. You do NOT initialize them in the header file. You do not implement functions in the header file.

Following your comment I stripped ‘myDB’ initialization code from DBabstraction header, only leaving the pointer variable declaration. The initialization now takes place in the DBabstraction’s constructor source:

// Library header
#include "DBabstraction.h"
//constructor
DBabstraction::DBabstraction(){
    pInstance = this;
    myDB = new EDB(DBabstraction::dbWriter, DBabstraction::dbReader); //
}
//public functions
void DBabstraction::dbWriter(unsigned long address, byte data ){
    /* nothing */
    
}

byte DBabstraction::dbReader( unsigned long address){
    /* nothing */
    
}

//public functions
void DBabstraction::begin(){
    /* nothing */
    
}
// Code DBabstraction.cpp

Then I removed the struct from DBabstraction header, and created a new file called DBrecord.h:

#ifndef DBabstraction_h
#define DBabstraction_h

#include "Arduino.h"
#include <EDB.h>
//Use SPIFFS FS as data storage
#include "LStorage.h"
#include "LFlash.h"


#define Drv LFlash          // use Internal 10M Flash
#define TABLE_SIZE 8192
#define FILE_PATH "tdb.txt"

// The number of demo records that should be created.  This should be less
// than (TABLE_SIZE - sizeof(EDB_Header)) / sizeof(LogEvent).  If it is higher,
// operations will return EDB_OUT_OF_RANGE for all records outside the usable range.
#define RECORDS_TO_CREATE 10


//
class DBabstraction {
public:
    DBabstraction();
    EDB *myDB;
    void begin();
    static LFile myFile;
    static void dbWriter( unsigned long address, byte data );
    static byte dbReader( unsigned long address );
    
private:
    static DBabstraction * pInstance;
};

#endif // DBabstraction_h

DBrecord.h file:

#ifndef DBrecord_h
#define DBrecord_h
// Arbitrary record definition for this table.
// This should be modified to reflect your record needs.
struct Data_Struct {
    int id;
    int temperature;
}
data_struct;
#endif // DBrecord_h

Now it does compile but with theses warnings:

"/Users/Thibault/Library/Arduino15/packages/LinkIt/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -O2 -MMD -ffunction-sections -fdata-sections -fvisibility=hidden -fpic -mthumb -mlittle-endian -nostdlib -fno-non-call-exceptions -fno-rtti -fno-exceptions -Dprintf=iprintf "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/system/libmtk" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/system/libmtk/include" -mcpu=arm7tdmi-s -DF_CPU=84000000L -DARDUINO=10805 -DARDUINO_MTK_ONE -DARDUINO_ARCH_ARM -D__COMPILER_GCC__ -D__LINKIT_ONE__ -D__LINKIT_ONE_RELEASE__ -mthumb -DUSB_VID=0x0E8D -DUSB_PID=0x0023 -DUSBCON '-DUSB_MANUFACTURER="Unknown"' '-DUSB_PRODUCT="LinkIt ONE"' "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/system/libmtk" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/system/libmtk/include" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/cores/arduino" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/variants/linkit_one" "-I/Users/Thibault/Documents/Arduino/libraries/EDB" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/libraries/LStorage" "/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/CPPTEST.ino.cpp" -o "/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/CPPTEST.ino.cpp.o"
In file included from /Users/Thibault/Desktop/CPPtest/CPPTEST.ino:3:0:
/Users/Thibault/Documents/Arduino/libraries/EDB/EDB.h:24:25: warning: 'typedef' was ignored in this declaration [enabled by default]
                         };

                         ^
"/Users/Thibault/Library/Arduino15/packages/LinkIt/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -O2 -MMD -ffunction-sections -fdata-sections -fvisibility=hidden -fpic -mthumb -mlittle-endian -nostdlib -fno-non-call-exceptions -fno-rtti -fno-exceptions -Dprintf=iprintf "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/system/libmtk" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/system/libmtk/include" -mcpu=arm7tdmi-s -DF_CPU=84000000L -DARDUINO=10805 -DARDUINO_MTK_ONE -DARDUINO_ARCH_ARM -D__COMPILER_GCC__ -D__LINKIT_ONE__ -D__LINKIT_ONE_RELEASE__ -mthumb -DUSB_VID=0x0E8D -DUSB_PID=0x0023 -DUSBCON '-DUSB_MANUFACTURER="Unknown"' '-DUSB_PRODUCT="LinkIt ONE"' "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/system/libmtk" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/system/libmtk/include" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/cores/arduino" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/variants/linkit_one" "-I/Users/Thibault/Documents/Arduino/libraries/EDB" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/libraries/LStorage" "/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.cpp" -o "/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.cpp.o"
In file included from /var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.h:5:0,
                 from /var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.cpp:2:
/Users/Thibault/Documents/Arduino/libraries/EDB/EDB.h:24:25: warning: 'typedef' was ignored in this declaration [enabled by default]
                         };

                         ^
"/Users/Thibault/Library/Arduino15/packages/LinkIt/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -O2 -MMD -ffunction-sections -fdata-sections -fvisibility=hidden -fpic -mthumb -mlittle-endian -nostdlib -fno-non-call-exceptions -fno-rtti -fno-exceptions -Dprintf=iprintf "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/system/libmtk" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/system/libmtk/include" -mcpu=arm7tdmi-s -DF_CPU=84000000L -DARDUINO=10805 -DARDUINO_MTK_ONE -DARDUINO_ARCH_ARM -D__COMPILER_GCC__ -D__LINKIT_ONE__ -D__LINKIT_ONE_RELEASE__ -mthumb -DUSB_VID=0x0E8D -DUSB_PID=0x0023 -DUSBCON '-DUSB_MANUFACTURER="Unknown"' '-DUSB_PRODUCT="LinkIt ONE"' "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/system/libmtk" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/system/libmtk/include" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/cores/arduino" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/variants/linkit_one" "-I/Users/Thibault/Documents/Arduino/libraries/EDB" "-I/Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/libraries/LStorage" "/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/Runner.cpp" -o "/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/Runner.cpp.o"
In file included from /var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.h:5:0,
                 from /var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/Runner.h:5,
                 from /var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/Runner.cpp:2:
/Users/Thibault/Documents/Arduino/libraries/EDB/EDB.h:24:25: warning: 'typedef' was ignored in this declaration [enabled by default]
                         };

                         ^
DBabstraction.cpp.o: In function `DBabstraction::DBabstraction()': DBabstraction.cpp:6: warning: undefined reference to `DBabstraction::pInstance'
Runner.cpp.o: In function `Runner::Runner()':Runner.cpp:12: warning: undefined reference to `Runner::globalDB'

pInstance and globalDB seems to not exist.

thanks again PaulS.