KPN IoT / senml

Fork of kpn_senml by KPN IoT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers senml_base_parser.h Source File

senml_base_parser.h

00001 /*  _  __  ____    _   _ 
00002  * | |/ / |  _ \  | \ | |
00003  * | ' /  | |_) | |  \| |
00004  * | . \  |  __/  | |\  |
00005  * |_|\_\ |_|     |_| \_|
00006  * 
00007  * (c) 2018 KPN
00008  * License: MIT License.
00009  * Author: Jan Bogaerts
00010  * 
00011  * base class for all parsers header
00012  */
00013 
00014 
00015 
00016 #ifndef SENMLBASEPARSER
00017 #define SENMLBASEPARSER
00018 
00019 #include <senml_pack.h>
00020 #include <senml_record.h>
00021 
00022 /**
00023  * base class for json and cbor parsers. Provides functionality to connect to 
00024  * and search in senml packs and recrods. 
00025 */
00026 class SenMLBaseParser {
00027 
00028   public:
00029     SenMLBaseParser(SenMLPack* root): root(root), curPack(root) {};
00030 
00031 
00032   private:
00033     
00034 
00035   protected:
00036     SenMLPack* root;                    //the root document for which we are parsing. Used to search the up all the actuators.
00037     SenMLRecord* curRec;
00038     SenMLPack* curPack;                 //used while searching, to store the current pack to use. init to root pack by default. Make it protected, so child parsers can easily access it without too much fuzz
00039     String curRecName;                  //keeps a ref of the record name, for raising events for unknown records
00040     String curPackName;                 //name of hte current pack to send the actuator to.
00041 
00042     //looks up the pack object that has to contain the next field. This is in order
00043     //to support multiple packs (gateway functionality)
00044     void setCurrentPack(String& name);
00045 
00046 
00047     //check if base units match, if not, show error message
00048     void checkBaseUnit(String& name);
00049 
00050     //look up a record with the spedified name in the current pack 
00051     void setCurrentRecord(String& name);
00052 };
00053 
00054 #endif // SENMLBASEPARSER
00055 
00056 
00057 
00058 
00059 
00060 
00061