Main file renamed.
authorFrancoisGrondin <francois.grondin2@usherbrooke.ca>
Tue, 24 Oct 2017 19:56:29 +0000 (15:56 -0400)
committerFrancoisGrondin <francois.grondin2@usherbrooke.ca>
Tue, 24 Oct 2017 19:56:29 +0000 (15:56 -0400)
CMakeLists.txt
demo/client.c [new file with mode: 0644]
demo/main.c [deleted file]

index 2edfaee7a7b9c856f7f333d70ddb18c9a168618e..2e1958d478279e44542e710da543d4ab8c6d974a 100644 (file)
@@ -181,7 +181,7 @@ target_link_libraries(odas
 )
 
 add_executable(odascore
-    demo/main.c
+    demo/client.c
     demo/configs.c
     demo/objects.c
     demo/parameters.c
diff --git a/demo/client.c b/demo/client.c
new file mode 100644 (file)
index 0000000..be5736d
--- /dev/null
@@ -0,0 +1,291 @@
+
+    #include <odas/odas.h>
+
+    #include "parameters.h"
+    #include "configs.h"
+    #include "objects.h"
+    #include "threads.h"
+    #include "profiler.h"
+
+    #include <getopt.h>
+    #include <time.h>
+    #include <signal.h>
+
+    // +----------------------------------------------------------+
+    // | Variables                                                |
+    // +----------------------------------------------------------+  
+
+        // +------------------------------------------------------+
+        // | Type                                                 |
+        // +------------------------------------------------------+   
+
+            enum processing {
+                processing_singlethread,
+                processing_multithread
+            } type;
+
+        // +------------------------------------------------------+
+        // | Getopt                                               |
+        // +------------------------------------------------------+   
+
+            int c;
+            char * file_config;
+
+        // +------------------------------------------------------+
+        // | Objects                                              |
+        // +------------------------------------------------------+   
+
+            objects * objs;
+            aobjects * aobjs;
+
+        // +------------------------------------------------------+
+        // | Configurations                                       |
+        // +------------------------------------------------------+        
+
+            configs * cfgs;   
+
+        // +------------------------------------------------------+
+        // | Profiler                                             |
+        // +------------------------------------------------------+   
+
+            profiler * prf;
+
+        // +------------------------------------------------------+
+        // | Flag                                                 |
+        // +------------------------------------------------------+                   
+
+            char stopProcess;
+
+    // +----------------------------------------------------------+
+    // | Signal handler                                           |
+    // +----------------------------------------------------------+  
+
+    void sighandler(int signum) {
+        
+        if (type == processing_singlethread) {
+            stopProcess = 1;
+        }
+        if (type == processing_multithread) {
+            threads_multiple_stop(aobjs);
+        }        
+
+    }
+
+    // +----------------------------------------------------------+
+    // | Main routine                                             |
+    // +----------------------------------------------------------+  
+
+    int main(int argc, char * argv[]) {
+
+        // +------------------------------------------------------+
+        // | Arguments                                            |
+        // +------------------------------------------------------+  
+
+            file_config = (char *) NULL;
+            char verbose = 0x00;
+
+            type = processing_multithread;
+
+            while ((c = getopt(argc,argv, "c:hsv")) != -1) {
+
+                switch(c) {
+
+                    case 'c':
+
+                        file_config = (char *) malloc(sizeof(char) * (strlen(optarg)+1));
+                        strcpy(file_config, optarg);                        
+
+                    break;
+
+                    case 'h':
+
+                        printf("+----------------------------------------------------+\n");
+                        printf("|        ODAS (Open embeddeD Audition System)        |\n");
+                        printf("+----------------------------------------------------+\n");
+                        printf("| Author:      Francois Grondin                      |\n");
+                        printf("| Email:       francois.grondin2@usherbrooke.ca      |\n");
+                        printf("| Website:     introlab.3it.usherbrooke.ca           |\n");
+                        printf("| Version:     1.0                                   |\n");
+                        printf("+----------------------------------------------------+\n");        
+                        printf("| -c       Configuration file (.cfg)                 |\n");
+                        printf("| -h       Help                                      |\n");
+                        printf("| -s       Process sequentially (no multithread)     |\n");
+                        printf("| -v       Verbose                                   |\n");
+                        printf("+----------------------------------------------------+\n");                
+
+                        exit(EXIT_SUCCESS);
+
+                    break;
+
+                    case 's':
+
+                        type = processing_singlethread;
+
+                    break;
+
+                    case 'v':
+
+                        verbose = 0x01;
+
+                    break;
+
+                }
+
+            }
+
+            if (file_config == NULL) {
+                printf("Missing configuration file.\n");
+                exit(EXIT_FAILURE);
+            }
+
+        // +------------------------------------------------------+
+        // | Copyright                                            |
+        // +------------------------------------------------------+ 
+
+            if (verbose == 0x01) {
+
+            printf("+--------------------------------------------+\n");
+            printf("|    ODAS (Open embeddeD Audition System)    |\n");
+            printf("+--------------------------------------------+\n");
+            printf("| Author:  Francois Grondin                  |\n");
+            printf("| Email:   francois.grondin2@usherbrooke.ca  |\n");
+            printf("| Website: introlab.3it.usherbrooke.ca       |\n");
+            printf("| Version: 1.0                               |\n");
+            printf("+--------------------------------------------+\n");
+
+            }
+
+        // +------------------------------------------------------+
+        // | Single thread                                        |
+        // +------------------------------------------------------+  
+
+            if (type == processing_singlethread) {
+
+            // +--------------------------------------------------+
+            // | Profiler                                         |
+            // +--------------------------------------------------+ 
+
+                prf = profiler_construct();
+
+            // +--------------------------------------------------+
+            // | Configure                                        |
+            // +--------------------------------------------------+ 
+
+                if (verbose == 0x01) printf("| + Initializing configurations...... "); fflush(stdout); 
+
+                cfgs = configs_construct(file_config);
+
+                if (verbose == 0x01) printf("[Done] |\n");
+
+            // +--------------------------------------------------+
+            // | Construct                                        |
+            // +--------------------------------------------------+  
+
+                if (verbose == 0x01) printf("| + Initializing objects............. "); fflush(stdout); 
+
+                objs = objects_construct(cfgs);    
+                
+                if (verbose == 0x01) printf("[Done] |\n");   
+
+            // +--------------------------------------------------+
+            // | Processing                                       |
+            // +--------------------------------------------------+  
+
+                if (verbose == 0x01) printf("| + Processing....................... "); fflush(stdout);
+
+                threads_single_open(objs);
+                stopProcess = 0;
+                while((threads_single_process(objs, prf) == 0) && (stopProcess == 0));
+                threads_single_close(objs);
+
+                if (verbose == 0x01) printf("[Done] |\n");
+
+            // +--------------------------------------------------+
+            // | Free memory                                      |
+            // +--------------------------------------------------+  
+
+                if (verbose == 0x01) printf("| + Free memory...................... "); fflush(stdout);
+
+                objects_destroy(objs); 
+                configs_destroy(cfgs);
+                free((void *) file_config);
+
+                if (verbose == 0x01) printf("[Done] |\n");
+
+            // +--------------------------------------------------+
+            // | Results                                          |
+            // +--------------------------------------------------+  
+
+                if (verbose == 0x01) profiler_printf(prf);
+
+                profiler_destroy(prf);
+
+            }
+
+        // +------------------------------------------------------+
+        // | Multiple threads                                     |
+        // +------------------------------------------------------+  
+
+            if (type == processing_multithread) {
+
+            // +--------------------------------------------------+
+            // | Configure                                        |
+            // +--------------------------------------------------+ 
+
+                if (verbose == 0x01) printf("| + Initializing configurations...... "); fflush(stdout); 
+
+                cfgs = configs_construct(file_config);
+
+                if (verbose == 0x01) printf("[Done] |\n");
+
+            // +--------------------------------------------------+
+            // | Construct                                        |
+            // +--------------------------------------------------+  
+
+                if (verbose == 0x01) printf("| + Initializing objects............. "); fflush(stdout); 
+                
+                aobjs = aobjects_construct(cfgs);    
+
+                if (verbose == 0x01) printf("[Done] |\n");
+
+            // +--------------------------------------------------+
+            // | Launch threads                                   |
+            // +--------------------------------------------------+  
+
+                signal(SIGINT, sighandler);
+
+                if (verbose == 0x01) printf("| + Launch threads................... "); fflush(stdout); 
+
+                threads_multiple_start(aobjs);
+
+                if (verbose == 0x01) printf("[Done] |\n");
+
+            // +--------------------------------------------------+
+            // | Wait                                             |
+            // +--------------------------------------------------+  
+
+                if (verbose == 0x01) printf("| + Threads running.................. "); fflush(stdout); 
+                
+                threads_multiple_join(aobjs);
+
+                if (verbose == 0x01) printf("[Done] |\n");
+
+            // +--------------------------------------------------+
+            // | Free memory                                      |
+            // +--------------------------------------------------+  
+
+                if (verbose == 0x01) printf("| + Free memory...................... "); fflush(stdout);
+
+                aobjects_destroy(aobjs);
+                configs_destroy(cfgs);
+                free((void *) file_config);
+
+                if (verbose == 0x01) printf("[Done] |\n");
+
+                if (verbose == 0x01) printf("+--------------------------------------------+\n");
+
+            }
+
+        return 0;
+
+    }
diff --git a/demo/main.c b/demo/main.c
deleted file mode 100644 (file)
index be5736d..0000000
+++ /dev/null
@@ -1,291 +0,0 @@
-
-    #include <odas/odas.h>
-
-    #include "parameters.h"
-    #include "configs.h"
-    #include "objects.h"
-    #include "threads.h"
-    #include "profiler.h"
-
-    #include <getopt.h>
-    #include <time.h>
-    #include <signal.h>
-
-    // +----------------------------------------------------------+
-    // | Variables                                                |
-    // +----------------------------------------------------------+  
-
-        // +------------------------------------------------------+
-        // | Type                                                 |
-        // +------------------------------------------------------+   
-
-            enum processing {
-                processing_singlethread,
-                processing_multithread
-            } type;
-
-        // +------------------------------------------------------+
-        // | Getopt                                               |
-        // +------------------------------------------------------+   
-
-            int c;
-            char * file_config;
-
-        // +------------------------------------------------------+
-        // | Objects                                              |
-        // +------------------------------------------------------+   
-
-            objects * objs;
-            aobjects * aobjs;
-
-        // +------------------------------------------------------+
-        // | Configurations                                       |
-        // +------------------------------------------------------+        
-
-            configs * cfgs;   
-
-        // +------------------------------------------------------+
-        // | Profiler                                             |
-        // +------------------------------------------------------+   
-
-            profiler * prf;
-
-        // +------------------------------------------------------+
-        // | Flag                                                 |
-        // +------------------------------------------------------+                   
-
-            char stopProcess;
-
-    // +----------------------------------------------------------+
-    // | Signal handler                                           |
-    // +----------------------------------------------------------+  
-
-    void sighandler(int signum) {
-        
-        if (type == processing_singlethread) {
-            stopProcess = 1;
-        }
-        if (type == processing_multithread) {
-            threads_multiple_stop(aobjs);
-        }        
-
-    }
-
-    // +----------------------------------------------------------+
-    // | Main routine                                             |
-    // +----------------------------------------------------------+  
-
-    int main(int argc, char * argv[]) {
-
-        // +------------------------------------------------------+
-        // | Arguments                                            |
-        // +------------------------------------------------------+  
-
-            file_config = (char *) NULL;
-            char verbose = 0x00;
-
-            type = processing_multithread;
-
-            while ((c = getopt(argc,argv, "c:hsv")) != -1) {
-
-                switch(c) {
-
-                    case 'c':
-
-                        file_config = (char *) malloc(sizeof(char) * (strlen(optarg)+1));
-                        strcpy(file_config, optarg);                        
-
-                    break;
-
-                    case 'h':
-
-                        printf("+----------------------------------------------------+\n");
-                        printf("|        ODAS (Open embeddeD Audition System)        |\n");
-                        printf("+----------------------------------------------------+\n");
-                        printf("| Author:      Francois Grondin                      |\n");
-                        printf("| Email:       francois.grondin2@usherbrooke.ca      |\n");
-                        printf("| Website:     introlab.3it.usherbrooke.ca           |\n");
-                        printf("| Version:     1.0                                   |\n");
-                        printf("+----------------------------------------------------+\n");        
-                        printf("| -c       Configuration file (.cfg)                 |\n");
-                        printf("| -h       Help                                      |\n");
-                        printf("| -s       Process sequentially (no multithread)     |\n");
-                        printf("| -v       Verbose                                   |\n");
-                        printf("+----------------------------------------------------+\n");                
-
-                        exit(EXIT_SUCCESS);
-
-                    break;
-
-                    case 's':
-
-                        type = processing_singlethread;
-
-                    break;
-
-                    case 'v':
-
-                        verbose = 0x01;
-
-                    break;
-
-                }
-
-            }
-
-            if (file_config == NULL) {
-                printf("Missing configuration file.\n");
-                exit(EXIT_FAILURE);
-            }
-
-        // +------------------------------------------------------+
-        // | Copyright                                            |
-        // +------------------------------------------------------+ 
-
-            if (verbose == 0x01) {
-
-            printf("+--------------------------------------------+\n");
-            printf("|    ODAS (Open embeddeD Audition System)    |\n");
-            printf("+--------------------------------------------+\n");
-            printf("| Author:  Francois Grondin                  |\n");
-            printf("| Email:   francois.grondin2@usherbrooke.ca  |\n");
-            printf("| Website: introlab.3it.usherbrooke.ca       |\n");
-            printf("| Version: 1.0                               |\n");
-            printf("+--------------------------------------------+\n");
-
-            }
-
-        // +------------------------------------------------------+
-        // | Single thread                                        |
-        // +------------------------------------------------------+  
-
-            if (type == processing_singlethread) {
-
-            // +--------------------------------------------------+
-            // | Profiler                                         |
-            // +--------------------------------------------------+ 
-
-                prf = profiler_construct();
-
-            // +--------------------------------------------------+
-            // | Configure                                        |
-            // +--------------------------------------------------+ 
-
-                if (verbose == 0x01) printf("| + Initializing configurations...... "); fflush(stdout); 
-
-                cfgs = configs_construct(file_config);
-
-                if (verbose == 0x01) printf("[Done] |\n");
-
-            // +--------------------------------------------------+
-            // | Construct                                        |
-            // +--------------------------------------------------+  
-
-                if (verbose == 0x01) printf("| + Initializing objects............. "); fflush(stdout); 
-
-                objs = objects_construct(cfgs);    
-                
-                if (verbose == 0x01) printf("[Done] |\n");   
-
-            // +--------------------------------------------------+
-            // | Processing                                       |
-            // +--------------------------------------------------+  
-
-                if (verbose == 0x01) printf("| + Processing....................... "); fflush(stdout);
-
-                threads_single_open(objs);
-                stopProcess = 0;
-                while((threads_single_process(objs, prf) == 0) && (stopProcess == 0));
-                threads_single_close(objs);
-
-                if (verbose == 0x01) printf("[Done] |\n");
-
-            // +--------------------------------------------------+
-            // | Free memory                                      |
-            // +--------------------------------------------------+  
-
-                if (verbose == 0x01) printf("| + Free memory...................... "); fflush(stdout);
-
-                objects_destroy(objs); 
-                configs_destroy(cfgs);
-                free((void *) file_config);
-
-                if (verbose == 0x01) printf("[Done] |\n");
-
-            // +--------------------------------------------------+
-            // | Results                                          |
-            // +--------------------------------------------------+  
-
-                if (verbose == 0x01) profiler_printf(prf);
-
-                profiler_destroy(prf);
-
-            }
-
-        // +------------------------------------------------------+
-        // | Multiple threads                                     |
-        // +------------------------------------------------------+  
-
-            if (type == processing_multithread) {
-
-            // +--------------------------------------------------+
-            // | Configure                                        |
-            // +--------------------------------------------------+ 
-
-                if (verbose == 0x01) printf("| + Initializing configurations...... "); fflush(stdout); 
-
-                cfgs = configs_construct(file_config);
-
-                if (verbose == 0x01) printf("[Done] |\n");
-
-            // +--------------------------------------------------+
-            // | Construct                                        |
-            // +--------------------------------------------------+  
-
-                if (verbose == 0x01) printf("| + Initializing objects............. "); fflush(stdout); 
-                
-                aobjs = aobjects_construct(cfgs);    
-
-                if (verbose == 0x01) printf("[Done] |\n");
-
-            // +--------------------------------------------------+
-            // | Launch threads                                   |
-            // +--------------------------------------------------+  
-
-                signal(SIGINT, sighandler);
-
-                if (verbose == 0x01) printf("| + Launch threads................... "); fflush(stdout); 
-
-                threads_multiple_start(aobjs);
-
-                if (verbose == 0x01) printf("[Done] |\n");
-
-            // +--------------------------------------------------+
-            // | Wait                                             |
-            // +--------------------------------------------------+  
-
-                if (verbose == 0x01) printf("| + Threads running.................. "); fflush(stdout); 
-                
-                threads_multiple_join(aobjs);
-
-                if (verbose == 0x01) printf("[Done] |\n");
-
-            // +--------------------------------------------------+
-            // | Free memory                                      |
-            // +--------------------------------------------------+  
-
-                if (verbose == 0x01) printf("| + Free memory...................... "); fflush(stdout);
-
-                aobjects_destroy(aobjs);
-                configs_destroy(cfgs);
-                free((void *) file_config);
-
-                if (verbose == 0x01) printf("[Done] |\n");
-
-                if (verbose == 0x01) printf("+--------------------------------------------+\n");
-
-            }
-
-        return 0;
-
-    }