main.cpp

Go to the documentation of this file.
00001 /*
00002 *       This file contains DLL that represents simple working unit.
00003 *
00004 *       You can use this project to create new simple unit.
00005 *
00006 *       Author:
00007 *                       Tomas Mrkvicka
00008 *                       xmrkvi03@stud.fit.vutbr.cz
00009 *
00010 */
00011 
00012 #include <crtdbg.h>
00013 #include <windows.h>
00014 
00015 #include "MemoryAlloc.h"
00016 
00017 #include "pipeline/SimpleUnit.h"
00018 #include "DerivedUnit.h"
00019 
00020 ////////////////////////////////////////////////////////////////////////////////
00021 ////////////////////////////////////////////////////////////////////////////////
00022 ////////////////////////////////////////////////////////////////////////////////
00023 // EXPORT TABLE
00024 
00025 //tyto funkce musi exportovat kazda DLL knihovna s jednotkou
00026 extern "C" __declspec(dllexport) EnumDLLType            GetType(void);
00027 extern "C" __declspec(dllexport) TUnitInterface*        CreateUnit( TDispatcherInterface * dispatcher );
00028 extern "C" __declspec(dllexport) EnumUnitType           GetUnitResultType(void);
00029 extern "C" __declspec(dllexport) const char *           GetUnitCreateInfo(void);
00030 extern "C" __declspec(dllexport) const char *           GetUnitResultInfo(void);
00031 
00032 
00033 /** Funkce pro urceni typu funkce "CreateUnit"
00034 */
00035 extern "C" EnumDLLType GetType(void)
00036 {
00037         return ENUM_DLLTYPE_BASIC;
00038 }
00039 
00040 /** Funkce pro vytvoreni tridy a preneseni ven z DLL.
00041 *
00042 *       Presny typ funkce (jejich parametru) lze ziskat pomoci funkce GetType().
00043 *
00044 *       \param  dispatcher      [in] platne rozhrani dispatcheru
00045 */
00046 extern "C" TUnitInterface*      CreateUnit( TDispatcherInterface * dispatcher )
00047 {
00048         TTestUnit * test        = new TTestUnit;
00049         TSimpleUnit * unit      = new TSimpleUnit( dispatcher, test, FALSE );
00050 
00051         return unit;
00052 }
00053 
00054 /** Funkce vraci informaci o datovem typu vysledku dane jednotky pouzite v teto DLL.
00055 */
00056 extern "C" __declspec(dllexport) EnumUnitType GetUnitResultType(void)
00057 {
00058         return ENUM_UNITTYPE_INTEGER;
00059 }
00060 
00061 /** Tato funkce vraci textovy retezec s informacemi o funkci CreateUnit, ktera vytvari
00062 *       jednotku.
00063 *
00064 *       Retezec by mel obsahovat napr. deklaraci funkce a popis parametru - pokud existuji
00065 */
00066 extern "C" const char * GetUnitCreateInfo(void)
00067 {
00068         return 
00069         "TUnitInterface * CreateUnit( TDispatcherInterface * dispatcher )\n"
00070         "\n"
00071         "dispatcher [in] interface to valid dispatcher";
00072 }
00073 
00074 /** Tato funkce vraci textovy retezec s informacemi o typu navratovych hodnot teto jednotky.
00075 *
00076 *       Mel by zde byt obsazen typ navratove hodnoty a dale napr. informace o tom, co je vlastne
00077 *       ve vysledku obsazeno.
00078 */
00079 extern "C" const char * GetUnitResultInfo(void)
00080 {
00081         return
00082         "TUnitRetType_integer\n"
00083         "\n"
00084         "This is testing unit that returns average intensity of pixels in gray image.";
00085 }
00086 
00087 // EXPORT TABLE
00088 ////////////////////////////////////////////////////////////////////////////////
00089 ////////////////////////////////////////////////////////////////////////////////
00090 ////////////////////////////////////////////////////////////////////////////////
00091 
00092 /** Standardni vstupni funkce DLL knihovny.
00093 *
00094 *       \param  hinstDLL        [in] handle aktualni instance processu
00095 *       \param  fdwReason       [in] duvod zavolani teto funkce
00096 *       \param  lpReserved      [in] nepouzito
00097 */
00098 BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpReserved)
00099 {
00100     // Perform actions based on the reason for calling.
00101     switch( fdwReason ) 
00102     { 
00103         case DLL_PROCESS_ATTACH:
00104          // Initialize once for each new process.
00105          // Return FALSE to fail DLL load.
00106 #ifdef _DEBUG
00107                         _CrtDbgReport(_CRT_WARN, NULL, NULL,NULL, 
00108                         "============================\n"
00109                         "DLL with working unit loaded\n"
00110                         "============================\n"
00111                         "Example of unit that compute intensity of frames.\n"
00112                         );
00113 #endif
00114                 break;
00115 
00116         case DLL_THREAD_ATTACH:
00117          // Do thread-specific initialization.
00118             break;
00119 
00120         case DLL_THREAD_DETACH:
00121          // Do thread-specific cleanup.
00122             break;
00123 
00124         case DLL_PROCESS_DETACH:
00125          // Perform any necessary cleanup.
00126 #ifdef _DEBUG
00127                         _CrtDbgReport(_CRT_WARN, NULL, NULL,NULL, 
00128                         "============================================\n"
00129                         "DLL with working unit unloaded\n"
00130                         "Memory using:\n"
00131                         "\t Blocks via \"operator new\"  : %d\n"
00132                         "\t Blocks via \"operator new[]\": %d\n"
00133                         "\n"
00134                         "Allocated objects for results: %u\n"
00135                         "============================================\n",
00136                         TMemoryAllocStats::m_alloc_normal,
00137                         TMemoryAllocStats::m_alloc_array,
00138                         TManager<TUnitRetType_integer_implemented>::GetAllocCount()
00139                         );                      
00140 #endif
00141             break;
00142     }
00143     return TRUE;  // Successful DLL_PROCESS_ATTACH.
00144 }

Generated on Sat Nov 17 16:23:26 2007 for Image Processing Pipeline by  doxygen 1.4.6-NO