Index: vtcross/trunk/src/service_management_layer/ServiceManagementLayer.cpp
===================================================================
--- vtcross/trunk/src/service_management_layer/ServiceManagementLayer.cpp	(revision 465)
+++ vtcross/trunk/src/service_management_layer/ServiceManagementLayer.cpp	(revision 479)
@@ -108,26 +108,4 @@
 
 
-/* Useful for spotchecking what's in the database */
-void
-printDatabase() 
-{
-    /*
-    LOG("\n\n\n");
-    data_DB->command = "select ";
-    data_DB->command.append(data_DB->tablename);
-    data_DB->command.append(".* from ");
-    data_DB->command.append(data_DB->tablename);
-    data_DB->command.append(";");
-
-    char *errorMsg;
-    int32_t rc = sqlite3_exec(data_DB->db, data_DB->command.c_str(), callback, 0, &errorMsg);
-    if((rc != SQLITE_OK) && (rc != 101))
-        WARNING("SQL error: %s\n", errorMsg);
-
-    LOG("database %s, table %s:\n", data_DB->filename, data_DB->tablename);
-    LOG("\n\n\n");
-    */
-}
-
 ServiceManagementLayer::ServiceManagementLayer()
 {
@@ -139,4 +117,5 @@
     cogEngSrv = 1;
 }
+
 
 /* Free and clear the DB's associated with this SML in the destructor.
@@ -177,4 +156,5 @@
 }
 
+
 /* Note that sizes of CE_List, miss, and service are hardcoded for now.
  * Also, their sizes are hardcoded into the code in various places; a fix 
@@ -204,4 +184,5 @@
 }
 
+
 /* CALLED BY: constructor
  * INPUTS: <none>
@@ -221,12 +202,10 @@
     sqlite3_open(services_DB->filename.c_str(), &(services_DB->db));
 
-    char *cols[] = {(char *)"ID_Num", (char *)"Service_Name"};
-
     services_DB->tablename="Services";
 
-    /* ifprogram execution ends in anything other than a ordered shutdown, DB's will still 
+    /* If program execution ends in anything other than a ordered shutdown, DB's will still 
      * be there for next run. Need to get rid of it so that old data isn't inadvertantly 
      * used in the next execution cycle. */
-    services_DB->command = "DROP TABLE ifEXISTS Services;";     
+    services_DB->command = "DROP TABLE if EXISTS Services;";     
 
     rc = sqlite3_prepare_v2(services_DB->db, services_DB->command.c_str(), 128, &ppStmt, &pzTail);
@@ -243,9 +222,5 @@
     services_DB->command="CREATE TABLE ";
     services_DB->command.append(services_DB->tablename);
-    services_DB->command.append("(");
-    services_DB->command.append(cols[0]);
-    services_DB->command.append(" INT, ");
-    services_DB->command.append(cols[1]);
-    services_DB->command.append(" TEXT);");
+    services_DB->command.append("(ID_Num INT, Service_Name TEXT);");
 
     /* Execute create table command */
@@ -259,4 +234,5 @@
 }
 
+
 /* CALLED BY: constructor
  * INPUTS: <none>
@@ -277,8 +253,6 @@
     sqlite3_open(data_DB->filename.c_str(), &(data_DB->db));
 
-    char *cols[] = {(char *)"Tag", (char *)"Data"};
-
     data_DB->tablename = "Data";
-    data_DB->command = "DROP TABLE ifEXISTS Data;";     
+    data_DB->command = "DROP TABLE if EXISTS Data;";     
 
     rc = sqlite3_prepare_v2(data_DB->db, data_DB->command.c_str(), 128, &ppStmt, &pzTail);
@@ -292,15 +266,9 @@
     data_DB->num_columns = 2;
 
-    /* Generate command */
+    /* First column is the name of the data (corresponding to the name of the output/input pair)
+     * It is the primary key so any subsequent data with the same name will replace the row. */
     data_DB->command = "CREATE TABLE ";
     data_DB->command.append(data_DB->tablename);
-    data_DB->command.append("(");
-    data_DB->command.append(cols[0]);
-
-    /* First column is the name of the data (corresponding to the name of the output/input pair)
-     * It is the primary key so any subsequent data with the same name will replace the row. */
-    data_DB->command.append(" TEXT PRIMARY KEY ON CONFLICT REPLACE, ");
-    data_DB->command.append(cols[1]);
-    data_DB->command.append(" TEXT);");
+    data_DB->command.append("(Tag TEXT PRIMARY KEY ON CONFLICT REPLACE, Data TEXT);");
 
     rc = sqlite3_prepare_v2(data_DB->db, data_DB->command.c_str(), 128, &ppStmt, &pzTail);
@@ -313,4 +281,5 @@
 }
 
+
 /* CALLED BY: MessageHandler
  * INPUTS: <none>
@@ -325,4 +294,5 @@
     LOG("SML responded to GetRemoteComponentType query.\n");
 }
+
 
 /* CALLED BY: constructor
@@ -342,4 +312,5 @@
     RegisterComponent();
 }
+
 
 /* CALLED BY: StartSMLServer
@@ -363,34 +334,6 @@
 
     ReadMessage(_FD, buffer);
-    
-    //--------Policy Engine Stuff - no policy engine support in this version-------//
-
-    //printf("********* %s **********\n", buffer);
-    // TODO
-    // ifwe send integer op codes rather than strings, this process will be
-    // MUCH faster since instead of donig string compares we can simply
-    // switch on the integer value...
-    /*if(strcmp(buffer, "register_service") == 0) {
-        if(strcmp(buffer, "policy_geo") == 0) {
-        }
-        else if(strcmp(buffer, "policy_time") == 0) {
-        }
-        else if(strcmp(buffer, "policy_spectrum") == 0) {
-        }
-        else if(strcmp(buffer, "policy_spacial") == 0) {
-        }
-    }
-    else if(strcmp(buffer, "deregister_service") == 0) {
-        if(strcmp(buffer, "policy_geo") == 0) {
-        }
-        else if(strcmp(buffer, "policy_time") == 0) {
-        }
-        else if(strcmp(buffer, "policy_spectrum") == 0) {
-        }
-        else if(strcmp(buffer, "policy_spacial") == 0) {
-        }
-    }*/
-
-    //Go down the list to call the appropriate function
+   
+    /* Go down the list to call the appropriate function */
     if(strcmp(buffer, "query_component_type") == 0) {
         SendComponentType();
@@ -428,5 +371,5 @@
 }
 
-//TODO Finish
+
 /* CALLED BY: MessageHandler
  * INPUTS: <none>
@@ -441,5 +384,5 @@
 }
 
-//TODO Finish
+
 /* CALLED BY: MessageHandler
  * INPUTS: <none>
@@ -455,4 +398,5 @@
 }
 
+
 /* CALLED BY: ConnectToShell
  * INPUTS: <none>
@@ -467,4 +411,5 @@
     LOG("ServiceManagementLayer:: Registration message sent.\n");
 }
+
 
 /* CALLED BY: Shutdown
@@ -571,4 +516,5 @@
 }
 
+
 /* CALLED BY: MessageHandler
  * INPUTS: |ID| The ID number of the component where service is located
@@ -584,15 +530,8 @@
     ReadMessage(CE_List[ID].FD, buffer);
 
-    char *cols[] = {(char *) "ID_Num", (char *) "Service_Name"};
-
     /* Generate command */
     services_DB->command = "insert into ";
     services_DB->command.append(services_DB->tablename); 
-    services_DB->command.append(" (");
-    services_DB->command.append(cols[0]);
-    services_DB->command.append(", ");
-    services_DB->command.append(cols[1]);
-    services_DB->command.append(") ");
-    services_DB->command.append(" values(");
+    services_DB->command.append(" (ID_Num, Service_Name) values(");
 
     char temp[3];
@@ -611,4 +550,5 @@
         WARNING("ServiceManagementLayer::RecieveServices DB Error %s\n", errorMsg);
 }
+
 
 /* CALLED BY: MessageHandler
@@ -682,4 +622,5 @@
 }
 
+
 /* CALLED BY: PerformActiveMission
  * INPUTS: |sourceID| ID of the service that is being processed
@@ -699,5 +640,4 @@
     char buffer[256];
     std::string data;
-    char *cols[] = {(char *) "Tag", (char *) "Data"};
     char *token;
 
@@ -795,5 +735,4 @@
     int32_t rc;
     char *errorMsg;
-    char *cols[] = {(char *) "Tag", (char *) "Data"};
 
     LOG("ServiceManagementLayer:: Received PerformActiveMission command.\n");
@@ -812,9 +751,5 @@
         data_DB->command="insert into ";
         data_DB->command.append(data_DB->tablename); 
-        data_DB->command.append(" (");
-        data_DB->command.append(cols[0]);
-        data_DB->command.append(", ");
-        data_DB->command.append(cols[1]);
-        data_DB->command.append(") ");
+        data_DB->command.append(" (Tag, Data) ");
 
         memset(buffer, 0, 256);
@@ -1300,4 +1235,5 @@
 }
 
+
 /* CALLED BY: Reset
  * INPUTS: <none>
@@ -1319,4 +1255,5 @@
     LoadConfiguration(_SML_Config.c_str(), miss);
 }
+
 
 /* CALLED BY: constructor
@@ -1498,4 +1435,5 @@
 }
 
+
 /* CALLED BY: MessageHandler
  * INPUTS: |ID| The ID number of the engine to be registered
@@ -1522,4 +1460,5 @@
     CE_Present = true;
 }
+
 
 /* CALLED BY: MessageHandler
@@ -1558,4 +1497,5 @@
         WARNING("SQL error: %s\n", errorMsg);
 }
+
 
 /* CALLED BY: MessageHandler
