fork of ReportDB customized and renamed as a trivial support personnel database

Fork of ReportDB by Doug Anson

Files at this revision

API Documentation at this revision

Comitter:
ansond
Date:
Thu Oct 09 04:03:14 2014 +0000
Parent:
3:ea6ac7464011
Commit message:
updates including name change to support personnel

Changed in this revision

ReportDB.cpp Show diff for this revision Revisions of this file
ReportDB.h Show diff for this revision Revisions of this file
SupportPersonnelDB.cpp Show annotated file Show diff for this revision Revisions of this file
SupportPersonnelDB.h Show annotated file Show diff for this revision Revisions of this file
diff -r ea6ac7464011 -r 90df92778e77 ReportDB.cpp
--- a/ReportDB.cpp	Wed Sep 24 18:52:53 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-/* Copyright C2014 ARM, MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
- * and associated documentation files the "Software", to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
- 
- #include "ReportDB.h"
- 
- // min function
- extern "C" int min(int val1,int val2) {
-     if (val1 < val2) return val1;
-     return val2;
- }
- 
- // constructor
- ReportDB::ReportDB() {
-     this->initDB();
- }
- 
- // destructor
- ReportDB::~ReportDB() {
- }
- 
- // lookup and return a report
- ReportEntry *ReportDB::lookup(int rfid) {
-     ReportEntry *entry = NULL;
-     bool         found = false;
-     
-     // linear search through the list until we end or find something...
-     for(int i=0;i<DB_MAX_NUM_REPORTS &&!found;++i) {
-         if (this->m_db[i].rfid == rfid) {
-             found = true;
-             entry = &(this->m_db[i]);
-         }
-     }
-     
-     return entry;
- }
- 
- // lookup a report and return its name
- char *ReportDB::lookupReportName(int rfid) {
-     ReportEntry *entry = this->lookup(rfid);
-     if (entry != NULL) return entry->name;
-     return NULL;
- }
- 
-  // lookup a report and return its description
- char *ReportDB::lookupReportDescription(int rfid) {
-     ReportEntry *entry = this->lookup(rfid);
-     if (entry != NULL) return entry->description;
-     return NULL;
- }
-     
- // lookup a report and return its condition
- char *ReportDB::lookupReportCondition(int rfid) {
-     ReportEntry *entry = this->lookup(rfid);
-     if (entry != NULL) return entry->condition;
-     return NULL;
- }
- 
- // lookup a report and return its latitude
- char *ReportDB::lookupReportLatitude(int rfid) {
-     ReportEntry *entry = this->lookup(rfid);
-     if (entry != NULL) return entry->latitude;
-     return NULL;
- }
- 
- // lookup a report and return its longitude
- char *ReportDB::lookupReportLongitude(int rfid) {
-     ReportEntry *entry = this->lookup(rfid);
-     if (entry != NULL) return entry->longitude;
-     return NULL;
- }
- 
- // initialize the simple report DB
- void ReportDB::initDB() {
-     // First Report
-     memset((void *)&(this->m_db[FIRST_REPORT]),0,sizeof(ReportEntry));
-     this->m_db[FIRST_REPORT].rfid = FIRST_REPORT_RFID;
-     strncpy(this->m_db[FIRST_REPORT].name,FIRST_REPORT_NAME,min(strlen(FIRST_REPORT_NAME),DB_MAX_NAME_LENGTH));
-     strncpy(this->m_db[FIRST_REPORT].description,FIRST_REPORT_DESCRIPTION,min(strlen(FIRST_REPORT_DESCRIPTION),DB_MAX_DESCRIPTION_LENGTH));
-     strncpy(this->m_db[FIRST_REPORT].condition,FIRST_REPORT_CONDITION,min(strlen(FIRST_REPORT_CONDITION),DB_MAX_CONDITION_LENGTH));
-     strncpy(this->m_db[FIRST_REPORT].latitude,FIRST_REPORT_LATITUDE,min(strlen(FIRST_REPORT_LATITUDE),DB_MAX_LATLONG_LENGTH));
-     strncpy(this->m_db[FIRST_REPORT].longitude,FIRST_REPORT_LONGITUDE,min(strlen(FIRST_REPORT_LONGITUDE),DB_MAX_LATLONG_LENGTH));
-     
-     // Second Report
-     memset((void *)&(this->m_db[SECOND_REPORT]),0,sizeof(ReportEntry));
-     this->m_db[SECOND_REPORT].rfid = SECOND_REPORT_RFID;
-     strncpy(this->m_db[SECOND_REPORT].name,SECOND_REPORT_NAME,min(strlen(SECOND_REPORT_NAME),DB_MAX_NAME_LENGTH));
-     strncpy(this->m_db[SECOND_REPORT].description,SECOND_REPORT_DESCRIPTION,min(strlen(SECOND_REPORT_DESCRIPTION),DB_MAX_DESCRIPTION_LENGTH));
-     strncpy(this->m_db[SECOND_REPORT].condition,SECOND_REPORT_CONDITION,min(strlen(SECOND_REPORT_CONDITION),DB_MAX_CONDITION_LENGTH));
-     strncpy(this->m_db[SECOND_REPORT].latitude,SECOND_REPORT_LATITUDE,min(strlen(SECOND_REPORT_LATITUDE),DB_MAX_LATLONG_LENGTH));
-     strncpy(this->m_db[SECOND_REPORT].longitude,SECOND_REPORT_LONGITUDE,min(strlen(SECOND_REPORT_LONGITUDE),DB_MAX_LATLONG_LENGTH));
-     
-     // Third Report
-     memset((void *)&(this->m_db[THIRD_REPORT]),0,sizeof(ReportEntry));
-     this->m_db[THIRD_REPORT].rfid = THIRD_REPORT_RFID;
-     strncpy(this->m_db[THIRD_REPORT].name,THIRD_REPORT_NAME,min(strlen(THIRD_REPORT_NAME),DB_MAX_NAME_LENGTH));
-     strncpy(this->m_db[THIRD_REPORT].description,THIRD_REPORT_DESCRIPTION,min(strlen(THIRD_REPORT_DESCRIPTION),DB_MAX_DESCRIPTION_LENGTH));
-     strncpy(this->m_db[THIRD_REPORT].condition,THIRD_REPORT_CONDITION,min(strlen(THIRD_REPORT_CONDITION),DB_MAX_CONDITION_LENGTH));
-     strncpy(this->m_db[THIRD_REPORT].latitude,THIRD_REPORT_LATITUDE,min(strlen(THIRD_REPORT_LATITUDE),DB_MAX_LATLONG_LENGTH));
-     strncpy(this->m_db[THIRD_REPORT].longitude,THIRD_REPORT_LONGITUDE,min(strlen(THIRD_REPORT_LONGITUDE),DB_MAX_LATLONG_LENGTH));
- }
\ No newline at end of file
diff -r ea6ac7464011 -r 90df92778e77 ReportDB.h
--- a/ReportDB.h	Wed Sep 24 18:52:53 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/* Copyright C2014 ARM, MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
- * and associated documentation files the "Software", to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
- 
- #ifndef _REPORT_DB_H_
- #define _REPORT_DB_H_
- 
- #include "Definitions.h"
- 
- // trivial widget db entry...
- typedef struct {
-     int  rfid;
-     char name[DB_MAX_NAME_LENGTH+1];
-     char description[DB_MAX_DESCRIPTION_LENGTH+1];
-     char condition[DB_MAX_CONDITION_LENGTH+1];
-     char latitude[DB_MAX_LATLONG_LENGTH+1];
-     char longitude[DB_MAX_LATLONG_LENGTH+1];
-     
- } ReportEntry;
- 
- // trivial database of reports to generate cases with ...    
- class ReportDB {
-     private:
-        ReportEntry m_db[DB_MAX_NUM_REPORTS];
-     
-     public:
-        ReportDB();
-        virtual ~ReportDB();
-        
-        char *lookupReportName(int rfid);
-        char *lookupReportDescription(int rfid);
-        char *lookupReportCondition(int rfid);
-        char *lookupReportLatitude(int rfid);
-        char *lookupReportLongitude(int rfid);
-        
-     private:
-        void initDB();
-        ReportEntry *lookup(int rfid);
- };
- 
- #endif // _REPORT_DB_H_
\ No newline at end of file
diff -r ea6ac7464011 -r 90df92778e77 SupportPersonnelDB.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SupportPersonnelDB.cpp	Thu Oct 09 04:03:14 2014 +0000
@@ -0,0 +1,115 @@
+/* Copyright C2014 ARM, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files the "Software", to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+ 
+ #include "SupportPersonnelDB.h"
+ 
+ // min function
+ extern "C" int min(int val1,int val2) {
+     if (val1 < val2) return val1;
+     return val2;
+ }
+ 
+ // constructor
+ SupportPersonnelDB::SupportPersonnelDB() {
+     this->initDB();
+ }
+ 
+ // destructor
+ SupportPersonnelDB::~SupportPersonnelDB() {
+ }
+ 
+ // lookup and return a support person
+ SupportPersonEntry *SupportPersonnelDB::lookup(int rfid) {
+     SupportPersonEntry *entry = NULL;
+     bool         found = false;
+     
+     // linear search through the list until we end or find something...
+     for(int i=0;i<DB_MAX_NUM_SUPPORT_PERSONS &&!found;++i) {
+         if (this->m_db[i].rfid == rfid) {
+             found = true;
+             entry = &(this->m_db[i]);
+         }
+     }
+     
+     return entry;
+ }
+ 
+ // lookup a support person and return the name
+ char *SupportPersonnelDB::lookupName(int rfid) {
+     SupportPersonEntry *entry = this->lookup(rfid);
+     if (entry != NULL) return entry->name;
+     return NULL;
+ }
+ 
+  // lookup a support person and return the description
+ char *SupportPersonnelDB::lookupDescription(int rfid) {
+     SupportPersonEntry *entry = this->lookup(rfid);
+     if (entry != NULL) return entry->description;
+     return NULL;
+ }
+     
+ // lookup a support person and return the current status
+ char *SupportPersonnelDB::lookupStatus(int rfid) {
+     SupportPersonEntry *entry = this->lookup(rfid);
+     if (entry != NULL) return entry->status;
+     return NULL;
+ }
+ 
+ // lookup a support person and return the current location(latitude)
+ char *SupportPersonnelDB::lookupLocationLatitude(int rfid) {
+     SupportPersonEntry *entry = this->lookup(rfid);
+     if (entry != NULL) return entry->latitude;
+     return NULL;
+ }
+ 
+ // lookup a support person and return the current location(longitude)
+ char *SupportPersonnelDB::lookupLocationLongitude(int rfid) {
+     SupportPersonEntry *entry = this->lookup(rfid);
+     if (entry != NULL) return entry->longitude;
+     return NULL;
+ }
+ 
+ // initialize the simple support personnel DB
+ void SupportPersonnelDB::initDB() {
+     // First Support Person
+     memset((void *)&(this->m_db[FIRST_SUPPORT_PERSON]),0,sizeof(SupportPersonEntry));
+     this->m_db[FIRST_SUPPORT_PERSON].rfid = FIRST_SUPPORT_PERSON_RFID;
+     strncpy(this->m_db[FIRST_SUPPORT_PERSON].name,FIRST_SUPPORT_PERSON_NAME,min(strlen(FIRST_SUPPORT_PERSON_NAME),DB_MAX_NAME_LENGTH));
+     strncpy(this->m_db[FIRST_SUPPORT_PERSON].description,FIRST_SUPPORT_PERSON_DESCRIPTION,min(strlen(FIRST_SUPPORT_PERSON_DESCRIPTION),DB_MAX_DESCRIPTION_LENGTH));
+     strncpy(this->m_db[FIRST_SUPPORT_PERSON].status,FIRST_SUPPORT_PERSON_STATUS,min(strlen(FIRST_SUPPORT_PERSON_STATUS),DB_MAX_STATUS_LENGTH));
+     strncpy(this->m_db[FIRST_SUPPORT_PERSON].latitude,FIRST_SUPPORT_PERSON_LATITUDE,min(strlen(FIRST_SUPPORT_PERSON_LATITUDE),DB_MAX_LATLONG_LENGTH));
+     strncpy(this->m_db[FIRST_SUPPORT_PERSON].longitude,FIRST_SUPPORT_PERSON_LONGITUDE,min(strlen(FIRST_SUPPORT_PERSON_LONGITUDE),DB_MAX_LATLONG_LENGTH));
+     
+     // Second Support Person
+     memset((void *)&(this->m_db[SECOND_SUPPORT_PERSON]),0,sizeof(SupportPersonEntry));
+     this->m_db[SECOND_SUPPORT_PERSON].rfid = SECOND_SUPPORT_PERSON_RFID;
+     strncpy(this->m_db[SECOND_SUPPORT_PERSON].name,SECOND_SUPPORT_PERSON_NAME,min(strlen(SECOND_SUPPORT_PERSON_NAME),DB_MAX_NAME_LENGTH));
+     strncpy(this->m_db[SECOND_SUPPORT_PERSON].description,SECOND_SUPPORT_PERSON_DESCRIPTION,min(strlen(SECOND_SUPPORT_PERSON_DESCRIPTION),DB_MAX_DESCRIPTION_LENGTH));
+     strncpy(this->m_db[SECOND_SUPPORT_PERSON].status,SECOND_SUPPORT_PERSON_STATUS,min(strlen(SECOND_SUPPORT_PERSON_STATUS),DB_MAX_STATUS_LENGTH));
+     strncpy(this->m_db[SECOND_SUPPORT_PERSON].latitude,SECOND_SUPPORT_PERSON_LATITUDE,min(strlen(SECOND_SUPPORT_PERSON_LATITUDE),DB_MAX_LATLONG_LENGTH));
+     strncpy(this->m_db[SECOND_SUPPORT_PERSON].longitude,SECOND_SUPPORT_PERSON_LONGITUDE,min(strlen(SECOND_SUPPORT_PERSON_LONGITUDE),DB_MAX_LATLONG_LENGTH));
+     
+     // Third Support Person 
+     memset((void *)&(this->m_db[THIRD_SUPPORT_PERSON]),0,sizeof(SupportPersonEntry));
+     this->m_db[THIRD_SUPPORT_PERSON].rfid = THIRD_SUPPORT_PERSON_RFID;
+     strncpy(this->m_db[THIRD_SUPPORT_PERSON].name,THIRD_SUPPORT_PERSON_NAME,min(strlen(THIRD_SUPPORT_PERSON_NAME),DB_MAX_NAME_LENGTH));
+     strncpy(this->m_db[THIRD_SUPPORT_PERSON].description,THIRD_SUPPORT_PERSON_DESCRIPTION,min(strlen(THIRD_SUPPORT_PERSON_DESCRIPTION),DB_MAX_DESCRIPTION_LENGTH));
+     strncpy(this->m_db[THIRD_SUPPORT_PERSON].status,THIRD_SUPPORT_PERSON_STATUS,min(strlen(THIRD_SUPPORT_PERSON_STATUS),DB_MAX_STATUS_LENGTH));
+     strncpy(this->m_db[THIRD_SUPPORT_PERSON].latitude,THIRD_SUPPORT_PERSON_LATITUDE,min(strlen(THIRD_SUPPORT_PERSON_LATITUDE),DB_MAX_LATLONG_LENGTH));
+     strncpy(this->m_db[THIRD_SUPPORT_PERSON].longitude,THIRD_SUPPORT_PERSON_LONGITUDE,min(strlen(THIRD_SUPPORT_PERSON_LONGITUDE),DB_MAX_LATLONG_LENGTH));
+ }
\ No newline at end of file
diff -r ea6ac7464011 -r 90df92778e77 SupportPersonnelDB.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SupportPersonnelDB.h	Thu Oct 09 04:03:14 2014 +0000
@@ -0,0 +1,55 @@
+/* Copyright C2014 ARM, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files the "Software", to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+ 
+ #ifndef _SUPPORT_PERSONNEL_DB_H_
+ #define _SUPPORT_PERSONNEL_DB_H_
+ 
+ #include "Definitions.h"
+ 
+ // trivial support personal db entry...
+ typedef struct {
+     int  rfid;
+     char name[DB_MAX_NAME_LENGTH+1];
+     char description[DB_MAX_DESCRIPTION_LENGTH+1];
+     char status[DB_MAX_STATUS_LENGTH+1];
+     char latitude[DB_MAX_LATLONG_LENGTH+1];
+     char longitude[DB_MAX_LATLONG_LENGTH+1];
+     
+ } SupportPersonEntry;
+ 
+ // trivial database of support personnel who can generate cases    
+ class SupportPersonnelDB {
+     private:
+        SupportPersonEntry m_db[DB_MAX_NUM_SUPPORT_PERSONS];
+     
+     public:
+        SupportPersonnelDB();
+        virtual ~SupportPersonnelDB();
+        
+        char *lookupName(int rfid);
+        char *lookupDescription(int rfid);
+        char *lookupStatus(int rfid);
+        char *lookupLocationLatitude(int rfid);
+        char *lookupLocationLongitude(int rfid);
+        
+     private:
+        void initDB();
+        SupportPersonEntry *lookup(int rfid);
+ };
+ 
+ #endif // _SUPPORT_PERSONNEL_DB_H_
\ No newline at end of file