- Timestamp:
- Jul 28, 2014, 4:11:30 PM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/FileLib/CMakeLists.txt
r302 r312 68 68 ) 69 69 list(APPEND LIBS 70 ${QT_LIBRARIES}71 optimized PacpusLib debug PacpusLib_d72 70 optimized ${PROJECT_NAME} debug ${PROJECT_NAME}_d 73 71 ) -
trunk/src/FileLib/test/TestFileLib.cpp
r303 r312 53 53 template < 54 54 typename ErrorInfo, 55 typename E = typename ErrorInfo:: error_info::value_type55 typename E = typename ErrorInfo::value_type 56 56 > 57 57 struct HasErrorInfo -
trunk/src/PacpusLib/ComponentBase.cpp
r292 r312 91 91 LOG_INFO("component " << getName() << " was created"); 92 92 93 addParameter("name", value<string>(&mName)->required(), "component name"); 94 addParameter("type", value<string>(&mTypeName)->required(), "component type"); 93 95 addParameters() 94 ("name", po::value<string>(&mName)->required(), "component name")95 ("type", po::value<string>(&mTypeName)->required(), "component type")96 ("ui", po::value<bool>(&mHasGui)->default_value(false), "whether to show GUI")97 ("verbose", po::value<bool>(&mVerbose)->default_value(false), "set output verbose")98 ("verbosity-level", po::value<int>(&mVerbosityLevel)->default_value(0), "set verbosity level")99 ("recording", po::value<bool>(&mIsRecording)->default_value(false), "whether to record data")96 //("name", value<string>(&mName)->required(), "component name") 97 //("type", value<string>(&mTypeName)->required(), "component type") 98 ("ui", value<bool>(&mHasGui)->default_value(false), "whether to show GUI") 99 ("verbose", value<bool>(&mVerbose)->default_value(false), "set output verbose") 100 ("verbosity-level", value<int>(&mVerbosityLevel)->default_value(0), "set verbosity level") 101 ("recording", value<bool>(&mIsRecording)->default_value(false), "whether to record data") 100 102 ; 101 103 } … … 283 285 } 284 286 287 void ComponentBase::addParameter(const char* name, const char* description) 288 { 289 addParameters()(name, description); 290 } 291 292 void ComponentBase::addParameter(const char* name, const po::value_semantic* s) 293 { 294 addParameters()(name, s); 295 } 296 297 void ComponentBase::addParameter(const char* name, const po::value_semantic* s, const char* description) 298 { 299 addParameters()(name, s, description); 300 } 301 285 302 class DomElementParser 286 303 : boost::noncopyable -
trunk/src/PacpusTools/src/PosixShMem.cpp
r162 r312 66 66 result = true; 67 67 } 68 68 69 69 ///////////////////////////////////////// 70 70 if (result) { -
trunk/src/PacpusTools/src/SharedMemory.cpp
r303 r312 62 62 << ". Message: " << (const char *) lpMsgBuf 63 63 << ". Program will exit" 64 ); 65 ::exit(-1); 64 ); 65 ::exit(-1); 66 66 } 67 67 68 68 // create the event - autoreset mode 69 event_ = CreateEvent(NULL, false, false, eventName.c_str()); 69 event_ = CreateEvent(NULL, false, false, eventName.c_str()); 70 70 71 71 // lock the semaphore and try to create the shared memory 72 lockMemory(); 73 shMemHandle_ = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, size, name); 72 lockMemory(); 73 shMemHandle_ = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, size, name); 74 74 if (shMemHandle_ == NULL) { 75 75 LOG_FATAL("cannot create shared memory segment '" << name << "'" 76 76 << ". Error: " << GetLastError() 77 77 << ". Program will exit" 78 ); 78 ); 79 79 ::exit(-1); 80 80 } 81 81 82 82 // Map the memory to a local pointer 83 shMem_ = MapViewOfFile(shMemHandle_, FILE_MAP_ALL_ACCESS, 0, 0, 0); 83 shMem_ = MapViewOfFile(shMemHandle_, FILE_MAP_ALL_ACCESS, 0, 0, 0); 84 84 if (shMem_ == NULL) { 85 85 LOG_FATAL("cannot map the view of file of the shared memory segment '" << name << "'" 86 86 << ". Error: " << GetLastError() 87 87 << ". Program will exit" 88 ); 88 ); 89 89 ::exit(-1); 90 90 } 91 91 92 LOG_INFO("created Win32 shared memory '" << name << "'"); 92 LOG_INFO("created Win32 shared memory '" << name << "'"); 93 93 94 94 unlockMemory(); … … 135 135 result = true; 136 136 } 137 137 138 138 ///////////////////////////////////////// 139 139 if (result) { … … 168 168 LOG_TRACE("destructor"); 169 169 #if PACPUS_OS_WINDOWS 170 // free the semaphore 171 CloseHandle(semaphore_); 172 UnmapViewOfFile(shMem_); 173 CloseHandle(shMemHandle_); 170 // free the semaphore 171 CloseHandle(semaphore_); 172 UnmapViewOfFile(shMem_); 173 CloseHandle(shMemHandle_); 174 174 #elif PACPUS_OS_UNIX 175 175 // detach this process from the shared memory … … 186 186 #if PACPUS_OS_WINDOWS 187 187 if (timeout == 0) { 188 timeout = INFINITE; 189 } 190 191 DWORD status = 0; 192 status = WaitForSingleObject(event_, timeout); 188 timeout = INFINITE; 189 } 190 191 DWORD status = 0; 192 status = WaitForSingleObject(event_, timeout); 193 193 194 194 if (status == WAIT_OBJECT_0) { 195 return true; 195 return true; 196 196 } else { 197 return false; 197 return false; 198 198 } 199 199 #elif PACPUS_OS_UNIX … … 209 209 void* shMem; 210 210 #if PACPUS_OS_WINDOWS 211 lockMemory(); 211 lockMemory(); 212 212 #endif 213 213 shMem = shMem_; 214 214 #if PACPUS_OS_WINDOWS 215 unlockMemory(); 215 unlockMemory(); 216 216 #endif 217 217 return shMem; … … 221 221 { 222 222 lockMemory(); 223 memcpy(dst, shMem_, size); 223 memcpy(dst, shMem_, size); 224 224 unlockMemory(); 225 225 } … … 228 228 { 229 229 #if PACPUS_OS_WINDOWS 230 return event_; 230 return event_; 231 231 #elif PACPUS_OS_UNIX 232 232 LOG_TRACE("no event identifier"); … … 241 241 LOG_TRACE("writing " << size << " bytes to shared memory at offset " << offset); 242 242 #if PACPUS_OS_WINDOWS 243 lockMemory(); 243 lockMemory(); 244 244 //unsigned long * dest = (unsigned long *)shMem_ + offset; 245 245 char * dest = (char *)shMem_ + offset; 246 //printf("adresses : shm : %x dest : %x offset : %x \n",shMem_, dest, offset); 246 //printf("adresses : shm : %x dest : %x offset : %x \n",shMem_, dest, offset); 247 247 memcpy(dest, data, size); 248 248 unlockMemory(); 249 SetEvent(event_); 249 SetEvent(event_); 250 250 #elif PACPUS_OS_UNIX 251 251 lockMemory(); … … 267 267 { 268 268 #if PACPUS_OS_WINDOWS 269 WaitForSingleObject(semaphore_, INFINITE); 269 WaitForSingleObject(semaphore_, INFINITE); 270 270 #elif PACPUS_OS_UNIX 271 271 BOOST_ASSERT(memory_); … … 279 279 { 280 280 #if PACPUS_OS_WINDOWS 281 ReleaseSemaphore(semaphore_, 1, NULL); 281 ReleaseSemaphore(semaphore_, 1, NULL); 282 282 #elif PACPUS_OS_UNIX 283 283 BOOST_ASSERT(memory_);
Note:
See TracChangeset
for help on using the changeset viewer.