From c4078c377d74290ebe4e66da0b4975da91732376 Mon Sep 17 00:00:00 2001 From: "William R. Otte" Date: Tue, 4 Mar 2008 13:56:48 +0000 Subject: swap in externals for ACE and TAO --- ACE/ace/ACE.cpp | 3409 ---------------- ACE/ace/ACE.h | 825 ---- ACE/ace/ACE.inl | 350 -- ACE/ace/ACE.pc.in | 10 - ACE/ace/ACE_crc32.cpp | 161 - ACE/ace/ACE_crc_ccitt.cpp | 128 - ACE/ace/ACE_export.h | 76 - ACE/ace/ARGV.cpp | 359 -- ACE/ace/ARGV.h | 306 -- ACE/ace/ARGV.inl | 104 - ACE/ace/ATM_Acceptor.cpp | 309 -- ACE/ace/ATM_Acceptor.h | 123 - ACE/ace/ATM_Acceptor.inl | 43 - ACE/ace/ATM_Addr.cpp | 522 --- ACE/ace/ATM_Addr.h | 197 - ACE/ace/ATM_Addr.inl | 37 - ACE/ace/ATM_Connector.cpp | 138 - ACE/ace/ATM_Connector.h | 164 - ACE/ace/ATM_Connector.inl | 132 - ACE/ace/ATM_Params.cpp | 20 - ACE/ace/ATM_Params.h | 214 -- ACE/ace/ATM_Params.inl | 235 -- ACE/ace/ATM_QoS.cpp | 631 --- ACE/ace/ATM_QoS.h | 115 - ACE/ace/ATM_QoS.inl | 29 - ACE/ace/ATM_Stream.cpp | 290 -- ACE/ace/ATM_Stream.h | 107 - ACE/ace/ATM_Stream.inl | 133 - ACE/ace/Acceptor.cpp | 1226 ------ ACE/ace/Acceptor.h | 684 ---- ACE/ace/Activation_Queue.cpp | 138 - ACE/ace/Activation_Queue.h | 173 - ACE/ace/Activation_Queue.inl | 31 - ACE/ace/Active_Map_Manager.cpp | 9 - ACE/ace/Active_Map_Manager.h | 116 - ACE/ace/Active_Map_Manager.inl | 95 - ACE/ace/Active_Map_Manager_T.cpp | 22 - ACE/ace/Active_Map_Manager_T.h | 211 - ACE/ace/Active_Map_Manager_T.inl | 311 -- ACE/ace/Addr.cpp | 73 - ACE/ace/Addr.h | 104 - ACE/ace/Addr.inl | 61 - ACE/ace/Arg_Shifter.cpp | 230 -- ACE/ace/Arg_Shifter.h | 221 -- ACE/ace/Argv_Type_Converter.cpp | 204 - ACE/ace/Argv_Type_Converter.h | 119 - ACE/ace/Argv_Type_Converter.inl | 44 - ACE/ace/Array.h | 29 - ACE/ace/Array_Base.cpp | 235 -- ACE/ace/Array_Base.h | 256 -- ACE/ace/Array_Base.inl | 146 - ACE/ace/Array_Map.cpp | 299 -- ACE/ace/Array_Map.h | 300 -- ACE/ace/Array_Map.inl | 133 - ACE/ace/Assert.cpp | 24 - ACE/ace/Assert.h | 38 - ACE/ace/Asynch_Acceptor.cpp | 516 --- ACE/ace/Asynch_Acceptor.h | 281 -- ACE/ace/Asynch_Connector.cpp | 296 -- ACE/ace/Asynch_Connector.h | 171 - ACE/ace/Asynch_IO.cpp | 1411 ------- ACE/ace/Asynch_IO.h | 1690 -------- ACE/ace/Asynch_IO_Impl.cpp | 117 - ACE/ace/Asynch_IO_Impl.h | 816 ---- ACE/ace/Asynch_IO_Impl.inl | 106 - ACE/ace/Asynch_Pseudo_Task.cpp | 130 - ACE/ace/Asynch_Pseudo_Task.h | 73 - ACE/ace/Atomic_Op.cpp | 310 -- ACE/ace/Atomic_Op.h | 260 -- ACE/ace/Atomic_Op.inl | 335 -- ACE/ace/Atomic_Op_Sparc.c | 187 - ACE/ace/Atomic_Op_Sparc.h | 14 - ACE/ace/Atomic_Op_T.cpp | 82 - ACE/ace/Atomic_Op_T.h | 369 -- ACE/ace/Atomic_Op_T.inl | 340 -- ACE/ace/Auto_Event.cpp | 49 - ACE/ace/Auto_Event.h | 73 - ACE/ace/Auto_Event.inl | 12 - ACE/ace/Auto_Functor.cpp | 39 - ACE/ace/Auto_Functor.h | 127 - ACE/ace/Auto_Functor.inl | 134 - ACE/ace/Auto_IncDec_T.cpp | 34 - ACE/ace/Auto_IncDec_T.h | 91 - ACE/ace/Auto_IncDec_T.inl | 25 - ACE/ace/Auto_Ptr.cpp | 21 - ACE/ace/Auto_Ptr.h | 242 -- ACE/ace/Auto_Ptr.inl | 171 - ACE/ace/Barrier.cpp | 197 - ACE/ace/Barrier.h | 215 -- ACE/ace/Barrier.inl | 22 - ACE/ace/Base_Thread_Adapter.cpp | 120 - ACE/ace/Base_Thread_Adapter.h | 186 - ACE/ace/Base_Thread_Adapter.inl | 48 - ACE/ace/Based_Pointer_Repository.cpp | 119 - ACE/ace/Based_Pointer_Repository.h | 91 - ACE/ace/Based_Pointer_T.cpp | 121 - ACE/ace/Based_Pointer_T.h | 205 - ACE/ace/Based_Pointer_T.inl | 139 - ACE/ace/Basic_Stats.cpp | 78 - ACE/ace/Basic_Stats.h | 87 - ACE/ace/Basic_Stats.inl | 53 - ACE/ace/Basic_Types.cpp | 139 - ACE/ace/Basic_Types.h | 890 ----- ACE/ace/Basic_Types.inl | 954 ----- ACE/ace/Bound_Ptr.h | 388 -- ACE/ace/Bound_Ptr.inl | 494 --- ACE/ace/CDR_Base.cpp | 799 ---- ACE/ace/CDR_Base.h | 353 -- ACE/ace/CDR_Base.inl | 255 -- ACE/ace/CDR_Size.cpp | 244 -- ACE/ace/CDR_Size.h | 241 -- ACE/ace/CDR_Size.inl | 424 -- ACE/ace/CDR_Stream.cpp | 1892 --------- ACE/ace/CDR_Stream.h | 1364 ------- ACE/ace/CDR_Stream.inl | 1700 -------- ACE/ace/CE_Screen_Output.cpp | 158 - ACE/ace/CE_Screen_Output.h | 109 - ACE/ace/CORBA_macros.h | 575 --- ACE/ace/Cache_Map_Manager_T.cpp | 420 -- ACE/ace/Cache_Map_Manager_T.h | 405 -- ACE/ace/Cache_Map_Manager_T.inl | 245 -- ACE/ace/Cached_Connect_Strategy_T.cpp | 734 ---- ACE/ace/Cached_Connect_Strategy_T.h | 262 -- ACE/ace/Caching_Strategies_T.cpp | 59 - ACE/ace/Caching_Strategies_T.h | 552 --- ACE/ace/Caching_Strategies_T.inl | 456 --- ACE/ace/Caching_Utility_T.cpp | 499 --- ACE/ace/Caching_Utility_T.h | 347 -- ACE/ace/Capabilities.cpp | 355 -- ACE/ace/Capabilities.h | 221 -- ACE/ace/Capabilities.inl | 52 - ACE/ace/Cleanup.cpp | 192 - ACE/ace/Cleanup.h | 137 - ACE/ace/Cleanup.inl | 12 - ACE/ace/Cleanup_Strategies_T.cpp | 95 - ACE/ace/Cleanup_Strategies_T.h | 155 - ACE/ace/Codecs.cpp | 234 -- ACE/ace/Codecs.h | 121 - ACE/ace/Codeset_IBM1047.cpp | 312 -- ACE/ace/Codeset_IBM1047.h | 128 - ACE/ace/Codeset_Registry.cpp | 111 - ACE/ace/Codeset_Registry.h | 104 - ACE/ace/Codeset_Registry.inl | 102 - ACE/ace/Codeset_Registry_db.cpp | 29 - ACE/ace/Codeset_Symbols.h | 220 -- ACE/ace/Condition_Recursive_Thread_Mutex.cpp | 129 - ACE/ace/Condition_Recursive_Thread_Mutex.h | 118 - ACE/ace/Condition_T.cpp | 123 - ACE/ace/Condition_T.h | 167 - ACE/ace/Condition_T.inl | 51 - ACE/ace/Condition_Thread_Mutex.cpp | 126 - ACE/ace/Condition_Thread_Mutex.h | 190 - ACE/ace/Condition_Thread_Mutex.inl | 74 - ACE/ace/Configuration.cpp | 2148 ----------- ACE/ace/Configuration.h | 896 ----- ACE/ace/Configuration.inl | 13 - ACE/ace/Configuration_Import_Export.cpp | 670 ---- ACE/ace/Configuration_Import_Export.h | 215 -- ACE/ace/Connection_Recycling_Strategy.cpp | 13 - ACE/ace/Connection_Recycling_Strategy.h | 63 - ACE/ace/Connector.cpp | 964 ----- ACE/ace/Connector.h | 563 --- ACE/ace/Containers.cpp | 12 - ACE/ace/Containers.h | 71 - ACE/ace/Containers.inl | 25 - ACE/ace/Containers_T.cpp | 1930 ---------- ACE/ace/Containers_T.h | 2024 ---------- ACE/ace/Containers_T.inl | 479 --- ACE/ace/Copy_Disabled.cpp | 23 - ACE/ace/Copy_Disabled.h | 65 - ACE/ace/Countdown_Time.cpp | 66 - ACE/ace/Countdown_Time.h | 80 - ACE/ace/DEV.cpp | 43 - ACE/ace/DEV.h | 78 - ACE/ace/DEV.inl | 18 - ACE/ace/DEV_Addr.cpp | 108 - ACE/ace/DEV_Addr.h | 90 - ACE/ace/DEV_Addr.inl | 51 - ACE/ace/DEV_Connector.cpp | 53 - ACE/ace/DEV_Connector.h | 110 - ACE/ace/DEV_Connector.inl | 34 - ACE/ace/DEV_IO.cpp | 131 - ACE/ace/DEV_IO.h | 185 - ACE/ace/DEV_IO.inl | 126 - ACE/ace/DLL.cpp | 267 -- ACE/ace/DLL.h | 196 - ACE/ace/DLL_Manager.cpp | 787 ---- ACE/ace/DLL_Manager.h | 269 -- ACE/ace/Date_Time.cpp | 10 - ACE/ace/Date_Time.h | 125 - ACE/ace/Date_Time.inl | 219 -- ACE/ace/Default_Constants.h | 573 --- ACE/ace/Dev_Poll_Reactor.cpp | 2513 ------------ ACE/ace/Dev_Poll_Reactor.h | 1252 ------ ACE/ace/Dev_Poll_Reactor.inl | 228 -- ACE/ace/Dirent.cpp | 7 - ACE/ace/Dirent.h | 122 - ACE/ace/Dirent.inl | 99 - ACE/ace/Dirent_Selector.cpp | 59 - ACE/ace/Dirent_Selector.h | 75 - ACE/ace/Dirent_Selector.inl | 19 - ACE/ace/Dump.cpp | 141 - ACE/ace/Dump.h | 172 - ACE/ace/Dump_T.cpp | 48 - ACE/ace/Dump_T.h | 82 - ACE/ace/Dynamic.cpp | 34 - ACE/ace/Dynamic.h | 75 - ACE/ace/Dynamic.inl | 34 - ACE/ace/Dynamic_Message_Strategy.cpp | 205 - ACE/ace/Dynamic_Message_Strategy.h | 217 -- ACE/ace/Dynamic_Message_Strategy.inl | 75 - ACE/ace/Dynamic_Service.cpp | 63 - ACE/ace/Dynamic_Service.h | 89 - ACE/ace/Dynamic_Service.inl | 40 - ACE/ace/Dynamic_Service_Base.cpp | 101 - ACE/ace/Dynamic_Service_Base.h | 74 - ACE/ace/Dynamic_Service_Dependency.cpp | 51 - ACE/ace/Dynamic_Service_Dependency.h | 70 - ACE/ace/Encoding_Converter.cpp | 12 - ACE/ace/Encoding_Converter.h | 70 - ACE/ace/Encoding_Converter_Factory.cpp | 74 - ACE/ace/Encoding_Converter_Factory.h | 54 - ACE/ace/Env_Value_T.cpp | 12 - ACE/ace/Env_Value_T.h | 166 - ACE/ace/Env_Value_T.inl | 60 - ACE/ace/Event.cpp | 93 - ACE/ace/Event.h | 143 - ACE/ace/Event.inl | 18 - ACE/ace/Event_Handler.cpp | 396 -- ACE/ace/Event_Handler.h | 388 -- ACE/ace/Event_Handler.inl | 12 - ACE/ace/Event_Handler_T.cpp | 125 - ACE/ace/Event_Handler_T.h | 191 - ACE/ace/Event_Handler_T.inl | 135 - ACE/ace/Exception_Macros.h | 55 - ACE/ace/FIFO.cpp | 78 - ACE/ace/FIFO.h | 85 - ACE/ace/FIFO.inl | 25 - ACE/ace/FIFO_Recv.cpp | 88 - ACE/ace/FIFO_Recv.h | 85 - ACE/ace/FIFO_Recv.inl | 24 - ACE/ace/FIFO_Recv_Msg.cpp | 67 - ACE/ace/FIFO_Recv_Msg.h | 138 - ACE/ace/FIFO_Recv_Msg.inl | 111 - ACE/ace/FIFO_Send.cpp | 58 - ACE/ace/FIFO_Send.h | 75 - ACE/ace/FIFO_Send.inl | 24 - ACE/ace/FIFO_Send_Msg.cpp | 80 - ACE/ace/FIFO_Send_Msg.h | 91 - ACE/ace/FIFO_Send_Msg.inl | 53 - ACE/ace/FILE.cpp | 147 - ACE/ace/FILE.h | 139 - ACE/ace/FILE.inl | 18 - ACE/ace/FILE_Addr.cpp | 124 - ACE/ace/FILE_Addr.h | 89 - ACE/ace/FILE_Addr.inl | 34 - ACE/ace/FILE_Connector.cpp | 84 - ACE/ace/FILE_Connector.h | 113 - ACE/ace/FILE_Connector.inl | 36 - ACE/ace/FILE_IO.cpp | 142 - ACE/ace/FILE_IO.h | 170 - ACE/ace/FILE_IO.inl | 152 - ACE/ace/File_Lock.cpp | 72 - ACE/ace/File_Lock.h | 170 - ACE/ace/File_Lock.inl | 96 - ACE/ace/Filecache.cpp | 754 ---- ACE/ace/Filecache.h | 353 -- ACE/ace/FlReactor/ACE_FlReactor.pc.in | 11 - ACE/ace/FlReactor/ACE_FlReactor_export.h | 58 - ACE/ace/FlReactor/FlReactor.cpp | 330 -- ACE/ace/FlReactor/FlReactor.h | 110 - ACE/ace/Flag_Manip.cpp | 95 - ACE/ace/Flag_Manip.h | 58 - ACE/ace/Flag_Manip.inl | 26 - ACE/ace/FoxReactor/ACE_FoxReactor.pc.in | 11 - ACE/ace/FoxReactor/ACE_FoxReactor_export.h | 58 - ACE/ace/FoxReactor/FoxReactor.cpp | 337 -- ACE/ace/FoxReactor/FoxReactor.h | 115 - ACE/ace/Framework_Component.cpp | 280 -- ACE/ace/Framework_Component.h | 210 - ACE/ace/Framework_Component.inl | 39 - ACE/ace/Framework_Component_T.cpp | 33 - ACE/ace/Framework_Component_T.h | 71 - ACE/ace/Free_List.cpp | 157 - ACE/ace/Free_List.h | 150 - ACE/ace/Functor.cpp | 43 - ACE/ace/Functor.h | 593 --- ACE/ace/Functor.inl | 284 -- ACE/ace/Functor_String.cpp | 7 - ACE/ace/Functor_String.h | 141 - ACE/ace/Functor_String.inl | 56 - ACE/ace/Functor_T.cpp | 49 - ACE/ace/Functor_T.h | 158 - ACE/ace/Functor_T.inl | 42 - ACE/ace/Future.cpp | 436 --- ACE/ace/Future.h | 387 -- ACE/ace/Future_Set.cpp | 136 - ACE/ace/Future_Set.h | 146 - ACE/ace/Get_Opt.cpp | 730 ---- ACE/ace/Get_Opt.h | 474 --- ACE/ace/Get_Opt.inl | 43 - ACE/ace/Global_Macros.h | 1133 ------ ACE/ace/Guard_T.cpp | 61 - ACE/ace/Guard_T.h | 365 -- ACE/ace/Guard_T.inl | 170 - ACE/ace/Handle_Gobbler.h | 68 - ACE/ace/Handle_Gobbler.inl | 78 - ACE/ace/Handle_Ops.cpp | 48 - ACE/ace/Handle_Ops.h | 50 - ACE/ace/Handle_Set.cpp | 570 --- ACE/ace/Handle_Set.h | 240 -- ACE/ace/Handle_Set.inl | 193 - ACE/ace/Hash_Cache_Map_Manager_T.cpp | 232 -- ACE/ace/Hash_Cache_Map_Manager_T.h | 214 -- ACE/ace/Hash_Cache_Map_Manager_T.inl | 73 - ACE/ace/Hash_Map_Manager.h | 31 - ACE/ace/Hash_Map_Manager_T.cpp | 530 --- ACE/ace/Hash_Map_Manager_T.h | 1274 ------ ACE/ace/Hash_Map_Manager_T.inl | 1253 ------ ACE/ace/Hash_Map_With_Allocator_T.cpp | 35 - ACE/ace/Hash_Map_With_Allocator_T.h | 112 - ACE/ace/Hash_Map_With_Allocator_T.inl | 82 - ACE/ace/Hash_Multi_Map_Manager_T.cpp | 605 --- ACE/ace/Hash_Multi_Map_Manager_T.h | 967 ----- ACE/ace/Hash_Multi_Map_Manager_T.inl | 994 ----- ACE/ace/Hashable.cpp | 36 - ACE/ace/Hashable.h | 65 - ACE/ace/Hashable.inl | 14 - ACE/ace/High_Res_Timer.cpp | 537 --- ACE/ace/High_Res_Timer.h | 315 -- ACE/ace/High_Res_Timer.inl | 154 - ACE/ace/ICMP_Socket.cpp | 186 - ACE/ace/ICMP_Socket.h | 110 - ACE/ace/INET_Addr.cpp | 1168 ------ ACE/ace/INET_Addr.h | 399 -- ACE/ace/INET_Addr.inl | 257 -- ACE/ace/IOStream.cpp | 665 ---- ACE/ace/IOStream.h | 512 --- ACE/ace/IOStream_T.cpp | 247 -- ACE/ace/IOStream_T.h | 297 -- ACE/ace/IOStream_T.inl | 123 - ACE/ace/IO_Cntl_Msg.cpp | 51 - ACE/ace/IO_Cntl_Msg.h | 112 - ACE/ace/IO_Cntl_Msg.inl | 61 - ACE/ace/IO_SAP.cpp | 142 - ACE/ace/IO_SAP.h | 96 - ACE/ace/IO_SAP.inl | 42 - ACE/ace/IPC_SAP.cpp | 193 - ACE/ace/IPC_SAP.h | 96 - ACE/ace/IPC_SAP.inl | 40 - ACE/ace/If_Then_Else.h | 89 - ACE/ace/Init_ACE.cpp | 45 - ACE/ace/Init_ACE.h | 62 - ACE/ace/Intrusive_List.cpp | 153 - ACE/ace/Intrusive_List.h | 144 - ACE/ace/Intrusive_List.inl | 40 - ACE/ace/Intrusive_List_Node.cpp | 27 - ACE/ace/Intrusive_List_Node.h | 85 - ACE/ace/Intrusive_List_Node.inl | 31 - ACE/ace/LOCK_SOCK_Acceptor.cpp | 35 - ACE/ace/LOCK_SOCK_Acceptor.h | 67 - ACE/ace/LSOCK.cpp | 181 - ACE/ace/LSOCK.h | 84 - ACE/ace/LSOCK.inl | 43 - ACE/ace/LSOCK_Acceptor.cpp | 143 - ACE/ace/LSOCK_Acceptor.h | 95 - ACE/ace/LSOCK_CODgram.cpp | 62 - ACE/ace/LSOCK_CODgram.h | 78 - ACE/ace/LSOCK_CODgram.inl | 30 - ACE/ace/LSOCK_Connector.cpp | 59 - ACE/ace/LSOCK_Connector.h | 91 - ACE/ace/LSOCK_Connector.inl | 27 - ACE/ace/LSOCK_Dgram.cpp | 71 - ACE/ace/LSOCK_Dgram.h | 74 - ACE/ace/LSOCK_Dgram.inl | 22 - ACE/ace/LSOCK_Stream.cpp | 137 - ACE/ace/LSOCK_Stream.h | 82 - ACE/ace/LSOCK_Stream.inl | 25 - ACE/ace/Lib_Find.cpp | 769 ---- ACE/ace/Lib_Find.h | 131 - ACE/ace/Local_Memory_Pool.cpp | 144 - ACE/ace/Local_Memory_Pool.h | 133 - ACE/ace/Local_Name_Space.cpp | 169 - ACE/ace/Local_Name_Space.h | 132 - ACE/ace/Local_Name_Space_T.cpp | 966 ----- ACE/ace/Local_Name_Space_T.h | 280 -- ACE/ace/Local_Tokens.cpp | 1623 -------- ACE/ace/Local_Tokens.h | 1121 ------ ACE/ace/Local_Tokens.inl | 289 -- ACE/ace/Lock.cpp | 88 - ACE/ace/Lock.h | 161 - ACE/ace/Lock.inl | 12 - ACE/ace/Lock_Adapter_T.cpp | 117 - ACE/ace/Lock_Adapter_T.h | 123 - ACE/ace/Lock_Adapter_T.inl | 16 - ACE/ace/Log_Msg.cpp | 2510 ------------ ACE/ace/Log_Msg.h | 746 ---- ACE/ace/Log_Msg.inl | 235 -- ACE/ace/Log_Msg_Backend.cpp | 14 - ACE/ace/Log_Msg_Backend.h | 88 - ACE/ace/Log_Msg_Callback.cpp | 13 - ACE/ace/Log_Msg_Callback.h | 69 - ACE/ace/Log_Msg_IPC.cpp | 111 - ACE/ace/Log_Msg_IPC.h | 79 - ACE/ace/Log_Msg_NT_Event_Log.cpp | 162 - ACE/ace/Log_Msg_NT_Event_Log.h | 72 - ACE/ace/Log_Msg_UNIX_Syslog.cpp | 207 - ACE/ace/Log_Msg_UNIX_Syslog.h | 76 - ACE/ace/Log_Priority.h | 85 - ACE/ace/Log_Record.cpp | 412 -- ACE/ace/Log_Record.h | 223 -- ACE/ace/Log_Record.inl | 123 - ACE/ace/Logging_Strategy.cpp | 566 --- ACE/ace/Logging_Strategy.h | 195 - ACE/ace/MEM_Acceptor.cpp | 265 -- ACE/ace/MEM_Acceptor.h | 192 - ACE/ace/MEM_Acceptor.inl | 103 - ACE/ace/MEM_Addr.cpp | 170 - ACE/ace/MEM_Addr.h | 155 - ACE/ace/MEM_Addr.inl | 111 - ACE/ace/MEM_Connector.cpp | 149 - ACE/ace/MEM_Connector.h | 179 - ACE/ace/MEM_Connector.inl | 30 - ACE/ace/MEM_IO.cpp | 541 --- ACE/ace/MEM_IO.h | 310 -- ACE/ace/MEM_IO.inl | 233 -- ACE/ace/MEM_SAP.cpp | 97 - ACE/ace/MEM_SAP.h | 169 - ACE/ace/MEM_SAP.inl | 64 - ACE/ace/MEM_Stream.cpp | 47 - ACE/ace/MEM_Stream.h | 158 - ACE/ace/MEM_Stream.inl | 180 - ACE/ace/MMAP_Memory_Pool.cpp | 578 --- ACE/ace/MMAP_Memory_Pool.h | 327 -- ACE/ace/MMAP_Memory_Pool.inl | 21 - ACE/ace/Makefile.am | 1419 ------- ACE/ace/Malloc.cpp | 187 - ACE/ace/Malloc.h | 396 -- ACE/ace/Malloc.inl | 26 - ACE/ace/Malloc_Allocator.cpp | 361 -- ACE/ace/Malloc_Allocator.h | 146 - ACE/ace/Malloc_Allocator.inl | 16 - ACE/ace/Malloc_Base.h | 168 - ACE/ace/Malloc_T.cpp | 1262 ------ ACE/ace/Malloc_T.h | 931 ----- ACE/ace/Malloc_T.inl | 184 - ACE/ace/Managed_Object.cpp | 25 - ACE/ace/Managed_Object.h | 168 - ACE/ace/Managed_Object.inl | 23 - ACE/ace/Manual_Event.cpp | 48 - ACE/ace/Manual_Event.h | 74 - ACE/ace/Manual_Event.inl | 12 - ACE/ace/Map.h | 32 - ACE/ace/Map_Manager.cpp | 701 ---- ACE/ace/Map_Manager.h | 719 ---- ACE/ace/Map_Manager.inl | 729 ---- ACE/ace/Map_T.cpp | 1343 ------- ACE/ace/Map_T.h | 1611 -------- ACE/ace/Map_T.inl | 415 -- ACE/ace/Mem_Map.cpp | 310 -- ACE/ace/Mem_Map.h | 235 -- ACE/ace/Mem_Map.inl | 238 -- ACE/ace/Memory_Pool.h | 31 - ACE/ace/Message_Block.cpp | 1273 ------ ACE/ace/Message_Block.h | 871 ----- ACE/ace/Message_Block.inl | 508 --- ACE/ace/Message_Block_T.cpp | 54 - ACE/ace/Message_Block_T.h | 88 - ACE/ace/Message_Block_T.inl | 31 - ACE/ace/Message_Queue.cpp | 28 - ACE/ace/Message_Queue.h | 237 -- ACE/ace/Message_Queue.inl | 12 - ACE/ace/Message_Queue_NT.cpp | 237 -- ACE/ace/Message_Queue_NT.h | 231 -- ACE/ace/Message_Queue_NT.inl | 131 - ACE/ace/Message_Queue_T.cpp | 2814 -------------- ACE/ace/Message_Queue_T.h | 1476 ------- ACE/ace/Message_Queue_Vx.cpp | 368 -- ACE/ace/Message_Queue_Vx.h | 227 -- ACE/ace/Message_Queue_Vx.inl | 19 - ACE/ace/Method_Object.h | 38 - ACE/ace/Method_Request.cpp | 30 - ACE/ace/Method_Request.h | 100 - ACE/ace/Metrics_Cache.h | 140 - ACE/ace/Metrics_Cache_T.cpp | 237 -- ACE/ace/Metrics_Cache_T.h | 243 -- ACE/ace/Metrics_Cache_T.inl | 240 -- ACE/ace/Min_Max.h | 70 - ACE/ace/Module.cpp | 273 -- ACE/ace/Module.h | 215 -- ACE/ace/Module.inl | 65 - ACE/ace/Msg_WFMO_Reactor.cpp | 85 - ACE/ace/Msg_WFMO_Reactor.h | 120 - ACE/ace/Msg_WFMO_Reactor.inl | 35 - ACE/ace/Multihomed_INET_Addr.cpp | 300 -- ACE/ace/Multihomed_INET_Addr.h | 198 - ACE/ace/Multihomed_INET_Addr.inl | 15 - ACE/ace/Mutex.cpp | 125 - ACE/ace/Mutex.h | 192 - ACE/ace/Mutex.inl | 175 - ACE/ace/NT_Service.cpp | 618 --- ACE/ace/NT_Service.h | 439 --- ACE/ace/NT_Service.inl | 85 - ACE/ace/Name_Proxy.cpp | 209 - ACE/ace/Name_Proxy.h | 101 - ACE/ace/Name_Request_Reply.cpp | 577 --- ACE/ace/Name_Request_Reply.h | 265 -- ACE/ace/Name_Space.cpp | 73 - ACE/ace/Name_Space.h | 165 - ACE/ace/Naming_Context.cpp | 647 ---- ACE/ace/Naming_Context.h | 387 -- ACE/ace/Naming_Context.inl | 44 - ACE/ace/Netlink_Addr.cpp | 68 - ACE/ace/Netlink_Addr.h | 120 - ACE/ace/Netlink_Addr.inl | 51 - ACE/ace/Node.cpp | 46 - ACE/ace/Node.h | 85 - ACE/ace/Notification_Queue.cpp | 222 -- ACE/ace/Notification_Queue.h | 156 - ACE/ace/Notification_Queue.inl | 47 - ACE/ace/Notification_Strategy.cpp | 22 - ACE/ace/Notification_Strategy.h | 75 - ACE/ace/Notification_Strategy.inl | 31 - ACE/ace/Null_Barrier.h | 59 - ACE/ace/Null_Condition.h | 85 - ACE/ace/Null_Mutex.h | 232 -- ACE/ace/Null_Semaphore.h | 105 - ACE/ace/Numeric_Limits.h | 270 -- ACE/ace/OS.cpp | 53 - ACE/ace/OS.h | 329 -- ACE/ace/OS.inl | 93 - ACE/ace/OS_Dirent.h | 32 - ACE/ace/OS_Errno.cpp | 47 - ACE/ace/OS_Errno.h | 101 - ACE/ace/OS_Errno.inl | 67 - ACE/ace/OS_Log_Msg_Attributes.cpp | 9 - ACE/ace/OS_Log_Msg_Attributes.h | 90 - ACE/ace/OS_Log_Msg_Attributes.inl | 12 - ACE/ace/OS_Memory.h | 338 -- ACE/ace/OS_NS_Thread.cpp | 5328 -------------------------- ACE/ace/OS_NS_Thread.h | 2026 ---------- ACE/ace/OS_NS_Thread.inl | 3636 ------------------ ACE/ace/OS_NS_arpa_inet.cpp | 53 - ACE/ace/OS_NS_arpa_inet.h | 74 - ACE/ace/OS_NS_arpa_inet.inl | 98 - ACE/ace/OS_NS_ctype.cpp | 11 - ACE/ace/OS_NS_ctype.h | 130 - ACE/ace/OS_NS_ctype.inl | 163 - ACE/ace/OS_NS_dirent.cpp | 274 -- ACE/ace/OS_NS_dirent.h | 153 - ACE/ace/OS_NS_dirent.inl | 184 - ACE/ace/OS_NS_dlfcn.cpp | 10 - ACE/ace/OS_NS_dlfcn.h | 69 - ACE/ace/OS_NS_dlfcn.inl | 286 -- ACE/ace/OS_NS_errno.cpp | 11 - ACE/ace/OS_NS_errno.h | 100 - ACE/ace/OS_NS_errno.inl | 83 - ACE/ace/OS_NS_fcntl.cpp | 245 -- ACE/ace/OS_NS_fcntl.h | 83 - ACE/ace/OS_NS_fcntl.inl | 23 - ACE/ace/OS_NS_macros.h | 114 - ACE/ace/OS_NS_math.cpp | 10 - ACE/ace/OS_NS_math.h | 115 - ACE/ace/OS_NS_math.inl | 41 - ACE/ace/OS_NS_netdb.cpp | 421 -- ACE/ace/OS_NS_netdb.h | 146 - ACE/ace/OS_NS_netdb.inl | 750 ---- ACE/ace/OS_NS_poll.cpp | 10 - ACE/ace/OS_NS_poll.h | 66 - ACE/ace/OS_NS_poll.inl | 45 - ACE/ace/OS_NS_pwd.cpp | 10 - ACE/ace/OS_NS_pwd.h | 81 - ACE/ace/OS_NS_pwd.inl | 120 - ACE/ace/OS_NS_regex.cpp | 10 - ACE/ace/OS_NS_regex.h | 65 - ACE/ace/OS_NS_regex.inl | 39 - ACE/ace/OS_NS_signal.cpp | 26 - ACE/ace/OS_NS_signal.h | 153 - ACE/ace/OS_NS_signal.inl | 232 -- ACE/ace/OS_NS_stdio.cpp | 456 --- ACE/ace/OS_NS_stdio.h | 530 --- ACE/ace/OS_NS_stdio.inl | 1224 ------ ACE/ace/OS_NS_stdlib.cpp | 801 ---- ACE/ace/OS_NS_stdlib.h | 313 -- ACE/ace/OS_NS_stdlib.inl | 499 --- ACE/ace/OS_NS_string.cpp | 377 -- ACE/ace/OS_NS_string.h | 471 --- ACE/ace/OS_NS_string.inl | 560 --- ACE/ace/OS_NS_strings.cpp | 84 - ACE/ace/OS_NS_strings.h | 86 - ACE/ace/OS_NS_strings.inl | 59 - ACE/ace/OS_NS_stropts.cpp | 195 - ACE/ace/OS_NS_stropts.h | 172 - ACE/ace/OS_NS_stropts.inl | 201 - ACE/ace/OS_NS_sys_mman.cpp | 10 - ACE/ace/OS_NS_sys_mman.h | 97 - ACE/ace/OS_NS_sys_mman.inl | 302 -- ACE/ace/OS_NS_sys_msg.cpp | 10 - ACE/ace/OS_NS_sys_msg.h | 77 - ACE/ace/OS_NS_sys_msg.inl | 78 - ACE/ace/OS_NS_sys_resource.cpp | 10 - ACE/ace/OS_NS_sys_resource.h | 67 - ACE/ace/OS_NS_sys_resource.inl | 98 - ACE/ace/OS_NS_sys_select.cpp | 10 - ACE/ace/OS_NS_sys_select.h | 77 - ACE/ace/OS_NS_sys_select.inl | 80 - ACE/ace/OS_NS_sys_sendfile.cpp | 53 - ACE/ace/OS_NS_sys_sendfile.h | 65 - ACE/ace/OS_NS_sys_sendfile.inl | 24 - ACE/ace/OS_NS_sys_shm.cpp | 10 - ACE/ace/OS_NS_sys_shm.h | 74 - ACE/ace/OS_NS_sys_shm.inl | 76 - ACE/ace/OS_NS_sys_socket.cpp | 161 - ACE/ace/OS_NS_sys_socket.h | 302 -- ACE/ace/OS_NS_sys_socket.inl | 993 ----- ACE/ace/OS_NS_sys_stat.cpp | 10 - ACE/ace/OS_NS_sys_stat.h | 149 - ACE/ace/OS_NS_sys_stat.inl | 292 -- ACE/ace/OS_NS_sys_time.cpp | 10 - ACE/ace/OS_NS_sys_time.h | 69 - ACE/ace/OS_NS_sys_time.inl | 96 - ACE/ace/OS_NS_sys_uio.cpp | 130 - ACE/ace/OS_NS_sys_uio.h | 80 - ACE/ace/OS_NS_sys_uio.inl | 55 - ACE/ace/OS_NS_sys_utsname.cpp | 237 -- ACE/ace/OS_NS_sys_utsname.h | 71 - ACE/ace/OS_NS_sys_wait.cpp | 9 - ACE/ace/OS_NS_sys_wait.h | 87 - ACE/ace/OS_NS_sys_wait.inl | 105 - ACE/ace/OS_NS_time.cpp | 634 --- ACE/ace/OS_NS_time.h | 288 -- ACE/ace/OS_NS_time.inl | 505 --- ACE/ace/OS_NS_unistd.cpp | 859 ----- ACE/ace/OS_NS_unistd.h | 375 -- ACE/ace/OS_NS_unistd.inl | 1193 ------ ACE/ace/OS_NS_wchar.cpp | 377 -- ACE/ace/OS_NS_wchar.h | 199 - ACE/ace/OS_NS_wchar.inl | 87 - ACE/ace/OS_QoS.cpp | 476 --- ACE/ace/OS_QoS.h | 449 --- ACE/ace/OS_String.h | 32 - ACE/ace/OS_TLI.cpp | 9 - ACE/ace/OS_TLI.h | 285 -- ACE/ace/OS_TLI.inl | 390 -- ACE/ace/OS_Thread_Adapter.cpp | 153 - ACE/ace/OS_Thread_Adapter.h | 72 - ACE/ace/OS_main.cpp | 127 - ACE/ace/OS_main.h | 303 -- ACE/ace/Obchunk.cpp | 36 - ACE/ace/Obchunk.h | 77 - ACE/ace/Obchunk.inl | 12 - ACE/ace/Object_Manager.cpp | 888 ----- ACE/ace/Object_Manager.h | 466 --- ACE/ace/Object_Manager.inl | 40 - ACE/ace/Object_Manager_Base.cpp | 506 --- ACE/ace/Object_Manager_Base.h | 248 -- ACE/ace/Obstack.h | 31 - ACE/ace/Obstack_T.cpp | 226 -- ACE/ace/Obstack_T.h | 134 - ACE/ace/Obstack_T.inl | 19 - ACE/ace/PI_Malloc.cpp | 165 - ACE/ace/PI_Malloc.h | 213 - ACE/ace/PI_Malloc.inl | 33 - ACE/ace/POSIX_Asynch_IO.cpp | 2416 ------------ ACE/ace/POSIX_Asynch_IO.h | 1302 ------- ACE/ace/POSIX_CB_Proactor.cpp | 185 - ACE/ace/POSIX_CB_Proactor.h | 97 - ACE/ace/POSIX_Proactor.cpp | 2064 ---------- ACE/ace/POSIX_Proactor.h | 659 ---- ACE/ace/POSIX_Proactor.inl | 13 - ACE/ace/Pagefile_Memory_Pool.cpp | 384 -- ACE/ace/Pagefile_Memory_Pool.h | 201 - ACE/ace/Pagefile_Memory_Pool.inl | 54 - ACE/ace/Pair.h | 32 - ACE/ace/Pair_T.cpp | 16 - ACE/ace/Pair_T.h | 129 - ACE/ace/Pair_T.inl | 90 - ACE/ace/Parse_Node.cpp | 838 ---- ACE/ace/Parse_Node.h | 522 --- ACE/ace/Ping_Socket.cpp | 377 -- ACE/ace/Ping_Socket.h | 119 - ACE/ace/Ping_Socket.inl | 13 - ACE/ace/Pipe.cpp | 360 -- ACE/ace/Pipe.h | 165 - ACE/ace/Pipe.inl | 188 - ACE/ace/Priority_Reactor.cpp | 188 - ACE/ace/Priority_Reactor.h | 100 - ACE/ace/Proactor.cpp | 1177 ------ ACE/ace/Proactor.h | 691 ---- ACE/ace/Proactor.inl | 80 - ACE/ace/Proactor_Impl.cpp | 21 - ACE/ace/Proactor_Impl.h | 265 -- ACE/ace/Process.cpp | 1275 ------ ACE/ace/Process.h | 617 --- ACE/ace/Process.inl | 412 -- ACE/ace/Process_Manager.cpp | 1015 ----- ACE/ace/Process_Manager.h | 478 --- ACE/ace/Process_Manager.inl | 13 - ACE/ace/Process_Mutex.cpp | 90 - ACE/ace/Process_Mutex.h | 216 -- ACE/ace/Process_Mutex.inl | 118 - ACE/ace/Process_Semaphore.cpp | 111 - ACE/ace/Process_Semaphore.h | 161 - ACE/ace/Process_Semaphore.inl | 66 - ACE/ace/Profile_Timer.cpp | 438 --- ACE/ace/Profile_Timer.h | 139 - ACE/ace/Profile_Timer.inl | 129 - ACE/ace/QoS/ACE_QoS.pc.in | 11 - ACE/ace/QoS/ACE_QoS_Export.h | 46 - ACE/ace/QoS/Makefile.am | 74 - ACE/ace/QoS/QoS_Decorator.cpp | 165 - ACE/ace/QoS/QoS_Decorator.h | 179 - ACE/ace/QoS/QoS_Manager.cpp | 41 - ACE/ace/QoS/QoS_Manager.h | 74 - ACE/ace/QoS/QoS_Session.h | 183 - ACE/ace/QoS/QoS_Session_Factory.cpp | 105 - ACE/ace/QoS/QoS_Session_Factory.h | 96 - ACE/ace/QoS/QoS_Session_Impl.cpp | 718 ---- ACE/ace/QoS/QoS_Session_Impl.h | 265 -- ACE/ace/QoS/QoS_Session_Impl.inl | 229 -- ACE/ace/QoS/README | 55 - ACE/ace/QoS/SOCK_Dgram_Mcast_QoS.cpp | 258 -- ACE/ace/QoS/SOCK_Dgram_Mcast_QoS.h | 142 - ACE/ace/QoS/SOCK_Dgram_Mcast_QoS.inl | 57 - ACE/ace/QoS/qos.mpc | 17 - ACE/ace/QtReactor/ACE_QtReactor.pc.in | 11 - ACE/ace/QtReactor/ACE_QtReactor_export.h | 58 - ACE/ace/QtReactor/QtReactor.cpp | 644 ---- ACE/ace/QtReactor/QtReactor.h | 231 -- ACE/ace/RB_Tree.cpp | 1204 ------ ACE/ace/RB_Tree.h | 904 ----- ACE/ace/RB_Tree.inl | 1169 ------ ACE/ace/README | 1876 --------- ACE/ace/RW_Mutex.cpp | 55 - ACE/ace/RW_Mutex.h | 141 - ACE/ace/RW_Mutex.inl | 83 - ACE/ace/RW_Process_Mutex.cpp | 54 - ACE/ace/RW_Process_Mutex.h | 133 - ACE/ace/RW_Process_Mutex.inl | 77 - ACE/ace/RW_Thread_Mutex.cpp | 45 - ACE/ace/RW_Thread_Mutex.h | 74 - ACE/ace/RW_Thread_Mutex.inl | 19 - ACE/ace/Reactor.cpp | 512 --- ACE/ace/Reactor.h | 875 ----- ACE/ace/Reactor.inl | 498 --- ACE/ace/Reactor_Impl.cpp | 15 - ACE/ace/Reactor_Impl.h | 569 --- ACE/ace/Reactor_Notification_Strategy.cpp | 38 - ACE/ace/Reactor_Notification_Strategy.h | 66 - ACE/ace/Reactor_Notification_Strategy.inl | 19 - ACE/ace/Reactor_Timer_Interface.cpp | 16 - ACE/ace/Reactor_Timer_Interface.h | 60 - ACE/ace/Reactor_Token_T.cpp | 70 - ACE/ace/Reactor_Token_T.h | 93 - ACE/ace/Read_Buffer.cpp | 176 - ACE/ace/Read_Buffer.h | 129 - ACE/ace/Read_Buffer.inl | 32 - ACE/ace/Recursive_Thread_Mutex.cpp | 125 - ACE/ace/Recursive_Thread_Mutex.h | 194 - ACE/ace/Recursive_Thread_Mutex.inl | 95 - ACE/ace/Recyclable.cpp | 22 - ACE/ace/Recyclable.h | 79 - ACE/ace/Recyclable.inl | 20 - ACE/ace/Refcountable.cpp | 20 - ACE/ace/Refcountable.h | 58 - ACE/ace/Refcountable.inl | 31 - ACE/ace/Refcounted_Auto_Ptr.cpp | 18 - ACE/ace/Refcounted_Auto_Ptr.h | 199 - ACE/ace/Refcounted_Auto_Ptr.inl | 190 - ACE/ace/Registry.cpp | 1127 ------ ACE/ace/Registry.h | 559 --- ACE/ace/Registry_Name_Space.cpp | 293 -- ACE/ace/Registry_Name_Space.h | 140 - ACE/ace/Remote_Name_Space.cpp | 380 -- ACE/ace/Remote_Name_Space.h | 147 - ACE/ace/Remote_Tokens.cpp | 527 --- ACE/ace/Remote_Tokens.h | 322 -- ACE/ace/Remote_Tokens.inl | 48 - ACE/ace/Reverse_Lock_T.cpp | 93 - ACE/ace/Reverse_Lock_T.h | 139 - ACE/ace/Reverse_Lock_T.inl | 19 - ACE/ace/Rtems_init.c | 219 -- ACE/ace/SOCK.cpp | 185 - ACE/ace/SOCK.h | 138 - ACE/ace/SOCK.inl | 39 - ACE/ace/SOCK_Acceptor.cpp | 406 -- ACE/ace/SOCK_Acceptor.h | 178 - ACE/ace/SOCK_Acceptor.inl | 13 - ACE/ace/SOCK_CODgram.cpp | 112 - ACE/ace/SOCK_CODgram.h | 78 - ACE/ace/SOCK_CODgram.inl | 19 - ACE/ace/SOCK_Connector.cpp | 359 -- ACE/ace/SOCK_Connector.h | 321 -- ACE/ace/SOCK_Connector.inl | 38 - ACE/ace/SOCK_Dgram.cpp | 750 ---- ACE/ace/SOCK_Dgram.h | 239 -- ACE/ace/SOCK_Dgram.inl | 167 - ACE/ace/SOCK_Dgram_Bcast.cpp | 380 -- ACE/ace/SOCK_Dgram_Bcast.h | 140 - ACE/ace/SOCK_Dgram_Bcast.inl | 37 - ACE/ace/SOCK_Dgram_Mcast.cpp | 928 ----- ACE/ace/SOCK_Dgram_Mcast.h | 384 -- ACE/ace/SOCK_Dgram_Mcast.inl | 52 - ACE/ace/SOCK_IO.cpp | 181 - ACE/ace/SOCK_IO.h | 136 - ACE/ace/SOCK_IO.inl | 123 - ACE/ace/SOCK_Netlink.cpp | 113 - ACE/ace/SOCK_Netlink.h | 106 - ACE/ace/SOCK_Netlink.inl | 37 - ACE/ace/SOCK_SEQPACK_Acceptor.cpp | 596 --- ACE/ace/SOCK_SEQPACK_Acceptor.h | 190 - ACE/ace/SOCK_SEQPACK_Acceptor.inl | 13 - ACE/ace/SOCK_SEQPACK_Association.cpp | 339 -- ACE/ace/SOCK_SEQPACK_Association.h | 202 - ACE/ace/SOCK_SEQPACK_Association.inl | 177 - ACE/ace/SOCK_SEQPACK_Connector.cpp | 443 --- ACE/ace/SOCK_SEQPACK_Connector.h | 331 -- ACE/ace/SOCK_SEQPACK_Connector.inl | 38 - ACE/ace/SOCK_Stream.cpp | 40 - ACE/ace/SOCK_Stream.h | 184 - ACE/ace/SOCK_Stream.inl | 177 - ACE/ace/SPIPE.cpp | 82 - ACE/ace/SPIPE.h | 116 - ACE/ace/SPIPE.inl | 18 - ACE/ace/SPIPE_Acceptor.cpp | 337 -- ACE/ace/SPIPE_Acceptor.h | 168 - ACE/ace/SPIPE_Addr.cpp | 167 - ACE/ace/SPIPE_Addr.h | 122 - ACE/ace/SPIPE_Addr.inl | 59 - ACE/ace/SPIPE_Connector.cpp | 160 - ACE/ace/SPIPE_Connector.h | 118 - ACE/ace/SPIPE_Connector.inl | 15 - ACE/ace/SPIPE_Stream.cpp | 104 - ACE/ace/SPIPE_Stream.h | 171 - ACE/ace/SPIPE_Stream.inl | 275 -- ACE/ace/SSL/ACE_SSL.pc.in | 11 - ACE/ace/SSL/Makefile.am | 85 - ACE/ace/SSL/SSL_Asynch_BIO.cpp | 252 -- ACE/ace/SSL/SSL_Asynch_BIO.h | 42 - ACE/ace/SSL/SSL_Asynch_Stream.cpp | 1042 ----- ACE/ace/SSL/SSL_Asynch_Stream.h | 425 -- ACE/ace/SSL/SSL_Context.cpp | 636 --- ACE/ace/SSL/SSL_Context.h | 384 -- ACE/ace/SSL/SSL_Context.inl | 113 - ACE/ace/SSL/SSL_Export.h | 44 - ACE/ace/SSL/SSL_SOCK.cpp | 72 - ACE/ace/SSL/SSL_SOCK.h | 103 - ACE/ace/SSL/SSL_SOCK.inl | 71 - ACE/ace/SSL/SSL_SOCK_Acceptor.cpp | 249 -- ACE/ace/SSL/SSL_SOCK_Acceptor.h | 198 - ACE/ace/SSL/SSL_SOCK_Acceptor.inl | 85 - ACE/ace/SSL/SSL_SOCK_Connector.cpp | 411 -- ACE/ace/SSL/SSL_SOCK_Connector.h | 318 -- ACE/ace/SSL/SSL_SOCK_Connector.inl | 28 - ACE/ace/SSL/SSL_SOCK_Stream.cpp | 583 --- ACE/ace/SSL/SSL_SOCK_Stream.h | 321 -- ACE/ace/SSL/SSL_SOCK_Stream.inl | 323 -- ACE/ace/SSL/ssl.mpc | 13 - ACE/ace/SSL/ssl_for_tao.mpc | 42 - ACE/ace/SSL/sslconf.h | 55 - ACE/ace/SString.cpp | 550 --- ACE/ace/SString.h | 499 --- ACE/ace/SString.inl | 299 -- ACE/ace/SStringfwd.h | 55 - ACE/ace/SUN_Proactor.cpp | 324 -- ACE/ace/SUN_Proactor.h | 126 - ACE/ace/SV_Message.cpp | 24 - ACE/ace/SV_Message.h | 67 - ACE/ace/SV_Message.inl | 37 - ACE/ace/SV_Message_Queue.cpp | 44 - ACE/ace/SV_Message_Queue.h | 105 - ACE/ace/SV_Message_Queue.inl | 81 - ACE/ace/SV_Semaphore_Complex.cpp | 259 -- ACE/ace/SV_Semaphore_Complex.h | 159 - ACE/ace/SV_Semaphore_Complex.inl | 84 - ACE/ace/SV_Semaphore_Simple.cpp | 237 -- ACE/ace/SV_Semaphore_Simple.h | 197 - ACE/ace/SV_Semaphore_Simple.inl | 128 - ACE/ace/SV_Shared_Memory.cpp | 88 - ACE/ace/SV_Shared_Memory.h | 121 - ACE/ace/SV_Shared_Memory.inl | 118 - ACE/ace/Sample_History.cpp | 73 - ACE/ace/Sample_History.h | 91 - ACE/ace/Sample_History.inl | 26 - ACE/ace/Sbrk_Memory_Pool.cpp | 124 - ACE/ace/Sbrk_Memory_Pool.h | 118 - ACE/ace/Sched_Params.cpp | 332 -- ACE/ace/Sched_Params.h | 232 -- ACE/ace/Sched_Params.inl | 134 - ACE/ace/Select_Reactor.h | 69 - ACE/ace/Select_Reactor_Base.cpp | 1104 ------ ACE/ace/Select_Reactor_Base.h | 611 --- ACE/ace/Select_Reactor_Base.inl | 152 - ACE/ace/Select_Reactor_T.cpp | 1594 -------- ACE/ace/Select_Reactor_T.h | 718 ---- ACE/ace/Select_Reactor_T.inl | 236 -- ACE/ace/Semaphore.cpp | 62 - ACE/ace/Semaphore.h | 183 - ACE/ace/Semaphore.inl | 119 - ACE/ace/Service_Config.cpp | 586 --- ACE/ace/Service_Config.h | 610 --- ACE/ace/Service_Config.inl | 190 - ACE/ace/Service_Gestalt.cpp | 1281 ------- ACE/ace/Service_Gestalt.h | 502 --- ACE/ace/Service_Gestalt.inl | 74 - ACE/ace/Service_Manager.cpp | 387 -- ACE/ace/Service_Manager.h | 120 - ACE/ace/Service_Object.cpp | 173 - ACE/ace/Service_Object.h | 207 - ACE/ace/Service_Object.inl | 79 - ACE/ace/Service_Repository.cpp | 577 --- ACE/ace/Service_Repository.h | 281 -- ACE/ace/Service_Repository.inl | 51 - ACE/ace/Service_Templates.h | 29 - ACE/ace/Service_Types.cpp | 458 --- ACE/ace/Service_Types.h | 206 - ACE/ace/Service_Types.inl | 32 - ACE/ace/Shared_Memory.cpp | 13 - ACE/ace/Shared_Memory.h | 58 - ACE/ace/Shared_Memory_MM.cpp | 111 - ACE/ace/Shared_Memory_MM.h | 120 - ACE/ace/Shared_Memory_MM.inl | 42 - ACE/ace/Shared_Memory_Pool.cpp | 461 --- ACE/ace/Shared_Memory_Pool.h | 210 - ACE/ace/Shared_Memory_SV.cpp | 88 - ACE/ace/Shared_Memory_SV.h | 101 - ACE/ace/Shared_Memory_SV.inl | 30 - ACE/ace/Shared_Object.cpp | 54 - ACE/ace/Shared_Object.h | 59 - ACE/ace/Shared_Object.inl | 12 - ACE/ace/Sig_Adapter.cpp | 80 - ACE/ace/Sig_Adapter.h | 81 - ACE/ace/Sig_Handler.cpp | 614 --- ACE/ace/Sig_Handler.h | 236 -- ACE/ace/Sig_Handler.inl | 15 - ACE/ace/Signal.cpp | 221 -- ACE/ace/Signal.h | 267 -- ACE/ace/Signal.inl | 265 -- ACE/ace/Singleton.cpp | 534 --- ACE/ace/Singleton.h | 327 -- ACE/ace/Singleton.inl | 42 - ACE/ace/Sock_Connect.cpp | 1642 -------- ACE/ace/Sock_Connect.h | 107 - ACE/ace/Static_Object_Lock.h | 78 - ACE/ace/Stats.cpp | 426 -- ACE/ace/Stats.h | 222 -- ACE/ace/Stats.inl | 104 - ACE/ace/Strategies.h | 33 - ACE/ace/Strategies_T.cpp | 1498 -------- ACE/ace/Strategies_T.h | 1076 ------ ACE/ace/Strategies_T.inl | 230 -- ACE/ace/Stream.cpp | 619 --- ACE/ace/Stream.h | 241 -- ACE/ace/Stream.inl | 51 - ACE/ace/Stream_Modules.cpp | 380 -- ACE/ace/Stream_Modules.h | 166 - ACE/ace/String_Base.cpp | 563 --- ACE/ace/String_Base.h | 612 --- ACE/ace/String_Base.inl | 159 - ACE/ace/String_Base_Const.cpp | 20 - ACE/ace/String_Base_Const.h | 52 - ACE/ace/Svc_Conf.h | 100 - ACE/ace/Svc_Conf.y | 425 -- ACE/ace/Svc_Conf_Lexer.cpp | 676 ---- ACE/ace/Svc_Conf_Lexer.h | 70 - ACE/ace/Svc_Conf_Param.h | 142 - ACE/ace/Svc_Conf_Tokens.h | 81 - ACE/ace/Svc_Conf_y.cpp | 1759 --------- ACE/ace/Svc_Handler.cpp | 525 --- ACE/ace/Svc_Handler.h | 339 -- ACE/ace/Synch.h | 65 - ACE/ace/Synch_Options.cpp | 110 - ACE/ace/Synch_Options.h | 163 - ACE/ace/Synch_T.cpp | 22 - ACE/ace/Synch_T.h | 42 - ACE/ace/Synch_Traits.h | 152 - ACE/ace/System_Time.cpp | 140 - ACE/ace/System_Time.h | 99 - ACE/ace/TLI.cpp | 273 -- ACE/ace/TLI.h | 116 - ACE/ace/TLI.inl | 50 - ACE/ace/TLI_Acceptor.cpp | 553 --- ACE/ace/TLI_Acceptor.h | 123 - ACE/ace/TLI_Connector.cpp | 256 -- ACE/ace/TLI_Connector.h | 130 - ACE/ace/TLI_Connector.inl | 49 - ACE/ace/TLI_Stream.cpp | 229 -- ACE/ace/TLI_Stream.h | 141 - ACE/ace/TLI_Stream.inl | 25 - ACE/ace/TP_Reactor.cpp | 686 ---- ACE/ace/TP_Reactor.h | 320 -- ACE/ace/TP_Reactor.inl | 119 - ACE/ace/TSS_Adapter.cpp | 45 - ACE/ace/TSS_Adapter.h | 61 - ACE/ace/TSS_T.cpp | 725 ---- ACE/ace/TSS_T.h | 253 -- ACE/ace/TSS_T.inl | 42 - ACE/ace/TTY_IO.cpp | 583 --- ACE/ace/TTY_IO.h | 122 - ACE/ace/Task.cpp | 299 -- ACE/ace/Task.h | 307 -- ACE/ace/Task.inl | 77 - ACE/ace/Task_Ex_T.cpp | 114 - ACE/ace/Task_Ex_T.h | 205 - ACE/ace/Task_Ex_T.inl | 109 - ACE/ace/Task_T.cpp | 108 - ACE/ace/Task_T.h | 198 - ACE/ace/Task_T.inl | 105 - ACE/ace/Test_and_Set.cpp | 51 - ACE/ace/Test_and_Set.h | 75 - ACE/ace/Thread.cpp | 99 - ACE/ace/Thread.h | 282 -- ACE/ace/Thread.inl | 286 -- ACE/ace/Thread_Adapter.cpp | 225 -- ACE/ace/Thread_Adapter.h | 100 - ACE/ace/Thread_Adapter.inl | 13 - ACE/ace/Thread_Control.cpp | 96 - ACE/ace/Thread_Control.h | 102 - ACE/ace/Thread_Control.inl | 46 - ACE/ace/Thread_Exit.cpp | 123 - ACE/ace/Thread_Exit.h | 111 - ACE/ace/Thread_Hook.cpp | 33 - ACE/ace/Thread_Hook.h | 65 - ACE/ace/Thread_Manager.cpp | 2163 ----------- ACE/ace/Thread_Manager.h | 1136 ------ ACE/ace/Thread_Manager.inl | 308 -- ACE/ace/Thread_Mutex.cpp | 62 - ACE/ace/Thread_Mutex.h | 175 - ACE/ace/Thread_Mutex.inl | 97 - ACE/ace/Thread_Semaphore.cpp | 62 - ACE/ace/Thread_Semaphore.h | 89 - ACE/ace/Thread_Semaphore.inl | 12 - ACE/ace/Throughput_Stats.cpp | 202 - ACE/ace/Throughput_Stats.h | 86 - ACE/ace/Time_Value.cpp | 264 -- ACE/ace/Time_Value.h | 360 -- ACE/ace/Time_Value.inl | 407 -- ACE/ace/Timeprobe.cpp | 15 - ACE/ace/Timeprobe.h | 201 - ACE/ace/Timeprobe.inl | 14 - ACE/ace/Timeprobe_T.cpp | 427 --- ACE/ace/Timeprobe_T.h | 220 -- ACE/ace/Timer_Hash.h | 75 - ACE/ace/Timer_Hash_T.cpp | 873 ----- ACE/ace/Timer_Hash_T.h | 342 -- ACE/ace/Timer_Heap.h | 41 - ACE/ace/Timer_Heap_T.cpp | 889 ----- ACE/ace/Timer_Heap_T.h | 338 -- ACE/ace/Timer_List.h | 42 - ACE/ace/Timer_List_T.cpp | 418 -- ACE/ace/Timer_List_T.h | 226 -- ACE/ace/Timer_Queue.h | 52 - ACE/ace/Timer_Queue_Adapters.cpp | 361 -- ACE/ace/Timer_Queue_Adapters.h | 261 -- ACE/ace/Timer_Queue_Adapters.inl | 29 - ACE/ace/Timer_Queue_T.cpp | 481 --- ACE/ace/Timer_Queue_T.h | 562 --- ACE/ace/Timer_Queue_T.inl | 222 -- ACE/ace/Timer_Queuefwd.h | 38 - ACE/ace/Timer_Wheel.h | 42 - ACE/ace/Timer_Wheel_T.cpp | 967 ----- ACE/ace/Timer_Wheel_T.h | 226 -- ACE/ace/TkReactor/ACE_TkReactor.pc.in | 11 - ACE/ace/TkReactor/ACE_TkReactor_export.h | 58 - ACE/ace/TkReactor/TkReactor.cpp | 439 --- ACE/ace/TkReactor/TkReactor.h | 136 - ACE/ace/Token.cpp | 545 --- ACE/ace/Token.h | 376 -- ACE/ace/Token.inl | 176 - ACE/ace/Token_Collection.cpp | 294 -- ACE/ace/Token_Collection.h | 243 -- ACE/ace/Token_Collection.inl | 17 - ACE/ace/Token_Invariants.cpp | 355 -- ACE/ace/Token_Invariants.h | 245 -- ACE/ace/Token_Manager.cpp | 273 -- ACE/ace/Token_Manager.h | 150 - ACE/ace/Token_Manager.inl | 25 - ACE/ace/Token_Request_Reply.cpp | 186 - ACE/ace/Token_Request_Reply.h | 270 -- ACE/ace/Token_Request_Reply.inl | 205 - ACE/ace/Trace.cpp | 137 - ACE/ace/Trace.h | 96 - ACE/ace/Truncate.h | 1016 ----- ACE/ace/Typed_SV_Message.cpp | 30 - ACE/ace/Typed_SV_Message.h | 107 - ACE/ace/Typed_SV_Message.inl | 96 - ACE/ace/Typed_SV_Message_Queue.cpp | 56 - ACE/ace/Typed_SV_Message_Queue.h | 92 - ACE/ace/Typed_SV_Message_Queue.inl | 80 - ACE/ace/UNIX_Addr.cpp | 151 - ACE/ace/UNIX_Addr.h | 117 - ACE/ace/UNIX_Addr.inl | 57 - ACE/ace/UPIPE_Acceptor.cpp | 129 - ACE/ace/UPIPE_Acceptor.h | 99 - ACE/ace/UPIPE_Acceptor.inl | 14 - ACE/ace/UPIPE_Addr.h | 33 - ACE/ace/UPIPE_Connector.cpp | 101 - ACE/ace/UPIPE_Connector.h | 115 - ACE/ace/UPIPE_Connector.inl | 34 - ACE/ace/UPIPE_Stream.cpp | 231 -- ACE/ace/UPIPE_Stream.h | 140 - ACE/ace/UPIPE_Stream.inl | 14 - ACE/ace/UTF16_Encoding_Converter.cpp | 364 -- ACE/ace/UTF16_Encoding_Converter.h | 86 - ACE/ace/UTF16_Encoding_Converter.inl | 76 - ACE/ace/UTF32_Encoding_Converter.cpp | 254 -- ACE/ace/UTF32_Encoding_Converter.h | 67 - ACE/ace/UTF8_Encoding_Converter.cpp | 92 - ACE/ace/UTF8_Encoding_Converter.h | 72 - ACE/ace/UUID.cpp | 554 --- ACE/ace/UUID.h | 239 -- ACE/ace/UUID.inl | 200 - ACE/ace/Unbounded_Queue.cpp | 434 --- ACE/ace/Unbounded_Queue.h | 297 -- ACE/ace/Unbounded_Queue.inl | 27 - ACE/ace/Unbounded_Set.cpp | 478 --- ACE/ace/Unbounded_Set.h | 322 -- ACE/ace/Unbounded_Set.inl | 23 - ACE/ace/Value_Ptr.h | 167 - ACE/ace/Vector_T.cpp | 154 - ACE/ace/Vector_T.h | 316 -- ACE/ace/Vector_T.inl | 107 - ACE/ace/Version.h | 9 - ACE/ace/Versioned_Namespace.h | 51 - ACE/ace/WFMO_Reactor.cpp | 2754 ------------- ACE/ace/WFMO_Reactor.h | 1368 ------- ACE/ace/WFMO_Reactor.inl | 1173 ------ ACE/ace/WIN32_Asynch_IO.cpp | 3767 ------------------ ACE/ace/WIN32_Asynch_IO.h | 1937 ---------- ACE/ace/WIN32_Proactor.cpp | 804 ---- ACE/ace/WIN32_Proactor.h | 325 -- ACE/ace/XML_Svc_Conf.cpp | 15 - ACE/ace/XML_Svc_Conf.h | 65 - ACE/ace/XTI_ATM_Mcast.cpp | 70 - ACE/ace/XTI_ATM_Mcast.h | 137 - ACE/ace/XTI_ATM_Mcast.inl | 65 - ACE/ace/XtReactor/ACE_XtReactor.pc.in | 11 - ACE/ace/XtReactor/ACE_XtReactor_export.h | 58 - ACE/ace/XtReactor/XtReactor.cpp | 450 --- ACE/ace/XtReactor/XtReactor.h | 138 - ACE/ace/ace.mpc | 464 --- ACE/ace/ace.mwc | 14 - ACE/ace/ace.rc | 38 - ACE/ace/ace_ce_dll.cfg | 1 - ACE/ace/ace_flreactor.mpc | 32 - ACE/ace/ace_for_tao.mpc | 377 -- ACE/ace/ace_foxreactor.mpc | 32 - ACE/ace/ace_message_table.bin | Bin 28 -> 0 bytes ACE/ace/ace_qtreactor.mpc | 38 - ACE/ace/ace_tkreactor.mpc | 32 - ACE/ace/ace_wchar.cpp | 17 - ACE/ace/ace_wchar.h | 377 -- ACE/ace/ace_wchar.inl | 183 - ACE/ace/ace_xtreactor.mpc | 32 - ACE/ace/checked_iterator.h | 58 - ACE/ace/codecs.mpb | 8 - ACE/ace/config-WinCE.h | 238 -- ACE/ace/config-aix-5.x.h | 333 -- ACE/ace/config-all.h | 81 - ACE/ace/config-borland-common.h | 75 - ACE/ace/config-cray.h | 215 -- ACE/ace/config-cxx-common.h | 87 - ACE/ace/config-cygwin32.h | 204 - ACE/ace/config-doxygen.h | 120 - ACE/ace/config-freebsd.h | 284 -- ACE/ace/config-g++-common.h | 137 - ACE/ace/config-ghs-common.h | 43 - ACE/ace/config-hpux-11.00.h | 446 --- ACE/ace/config-icc-common.h | 114 - ACE/ace/config-integritySCA.h | 234 -- ACE/ace/config-irix6.5.x-sgic++.h | 18 - ACE/ace/config-irix6.x-common.h | 256 -- ACE/ace/config-irix6.x-g++.h | 23 - ACE/ace/config-irix6.x-sgic++.h | 38 - ACE/ace/config-linux-common.h | 442 --- ACE/ace/config-linux.h | 75 - ACE/ace/config-lite.h | 164 - ACE/ace/config-lynxos.h | 159 - ACE/ace/config-macosx-leopard.h | 224 -- ACE/ace/config-macosx-panther.h | 191 - ACE/ace/config-macosx-tiger.h | 219 -- ACE/ace/config-macosx.h | 191 - ACE/ace/config-macros.h | 639 --- ACE/ace/config-minimal.h | 39 - ACE/ace/config-mvs.h | 130 - ACE/ace/config-netbsd.h | 167 - ACE/ace/config-openbsd.h | 235 -- ACE/ace/config-openvms.h | 198 - ACE/ace/config-pharlap.h | 86 - ACE/ace/config-posix-nonetworking.h | 86 - ACE/ace/config-posix.h | 72 - ACE/ace/config-qnx-neutrino.h | 137 - ACE/ace/config-qnx-rtp-62x.h | 129 - ACE/ace/config-qnx-rtp-common.h | 46 - ACE/ace/config-qnx-rtp-pre62x.h | 151 - ACE/ace/config-qnx-rtp.h | 25 - ACE/ace/config-rtems.h | 165 - ACE/ace/config-sco-5.0.0-nothread.h | 14 - ACE/ace/config-sco-5.0.0.h | 97 - ACE/ace/config-suncc-common.h | 68 - ACE/ace/config-sunos5.10.h | 46 - ACE/ace/config-sunos5.11.h | 15 - ACE/ace/config-sunos5.4-g++.h | 180 - ACE/ace/config-sunos5.4-sunc++-4.x.h | 191 - ACE/ace/config-sunos5.5.h | 414 -- ACE/ace/config-sunos5.6.h | 129 - ACE/ace/config-sunos5.7.h | 78 - ACE/ace/config-sunos5.8.h | 39 - ACE/ace/config-sunos5.9.h | 18 - ACE/ace/config-tandem-nsk-mips-v2.h | 404 -- ACE/ace/config-tandem-nsk-mips-v3.h | 474 --- ACE/ace/config-tandem.h | 192 - ACE/ace/config-tru64.h | 155 - ACE/ace/config-unixware-7.1.0.h | 414 -- ACE/ace/config-unixware-7.1.0.udk.h | 465 --- ACE/ace/config-visualage.h | 20 - ACE/ace/config-vxworks.h | 33 - ACE/ace/config-vxworks5.x.h | 334 -- ACE/ace/config-vxworks6.2.h | 332 -- ACE/ace/config-vxworks6.3.h | 322 -- ACE/ace/config-vxworks6.4.h | 345 -- ACE/ace/config-vxworks6.5.h | 25 - ACE/ace/config-vxworks6.6.h | 29 - ACE/ace/config-win32-borland.h | 121 - ACE/ace/config-win32-common.h | 660 ---- ACE/ace/config-win32-dmc.h | 109 - ACE/ace/config-win32-ghs.h | 95 - ACE/ace/config-win32-interix.h | 100 - ACE/ace/config-win32-mingw.h | 98 - ACE/ace/config-win32-msvc-7.h | 126 - ACE/ace/config-win32-msvc-8.h | 149 - ACE/ace/config-win32-msvc-9.h | 141 - ACE/ace/config-win32-msvc.h | 164 - ACE/ace/config-win32.h | 53 - ACE/ace/filecache.mpb | 8 - ACE/ace/gethrtime.cpp | 60 - ACE/ace/iosfwd.h | 99 - ACE/ace/os_include/arpa/os_inet.h | 74 - ACE/ace/os_include/net/os_if.h | 119 - ACE/ace/os_include/netinet/os_in.h | 185 - ACE/ace/os_include/netinet/os_tcp.h | 46 - ACE/ace/os_include/os_aio.h | 47 - ACE/ace/os_include/os_assert.h | 46 - ACE/ace/os_include/os_byteswap.h | 41 - ACE/ace/os_include/os_complex.h | 42 - ACE/ace/os_include/os_cpio.h | 42 - ACE/ace/os_include/os_ctype.h | 45 - ACE/ace/os_include/os_dirent.h | 108 - ACE/ace/os_include/os_dlfcn.h | 107 - ACE/ace/os_include/os_errno.h | 153 - ACE/ace/os_include/os_fcntl.h | 106 - ACE/ace/os_include/os_fenv.h | 42 - ACE/ace/os_include/os_float.h | 42 - ACE/ace/os_include/os_fmtmsg.h | 42 - ACE/ace/os_include/os_fnmatch.h | 42 - ACE/ace/os_include/os_ftw.h | 44 - ACE/ace/os_include/os_glob.h | 44 - ACE/ace/os_include/os_grp.h | 44 - ACE/ace/os_include/os_iconv.h | 44 - ACE/ace/os_include/os_intrin.h | 57 - ACE/ace/os_include/os_inttypes.h | 46 - ACE/ace/os_include/os_iso646.h | 42 - ACE/ace/os_include/os_langinfo.h | 44 - ACE/ace/os_include/os_libgen.h | 42 - ACE/ace/os_include/os_limits.h | 143 - ACE/ace/os_include/os_local.h | 44 - ACE/ace/os_include/os_math.h | 44 - ACE/ace/os_include/os_monetary.h | 44 - ACE/ace/os_include/os_mqueue.h | 44 - ACE/ace/os_include/os_ndbm.h | 44 - ACE/ace/os_include/os_netdb.h | 108 - ACE/ace/os_include/os_nl_types.h | 42 - ACE/ace/os_include/os_poll.h | 42 - ACE/ace/os_include/os_pthread.h | 424 -- ACE/ace/os_include/os_pwd.h | 58 - ACE/ace/os_include/os_regex.h | 48 - ACE/ace/os_include/os_sched.h | 52 - ACE/ace/os_include/os_search.h | 44 - ACE/ace/os_include/os_semaphore.h | 77 - ACE/ace/os_include/os_setjmp.h | 42 - ACE/ace/os_include/os_signal.h | 253 -- ACE/ace/os_include/os_spawn.h | 46 - ACE/ace/os_include/os_stdarg.h | 50 - ACE/ace/os_include/os_stdbool.h | 42 - ACE/ace/os_include/os_stddef.h | 97 - ACE/ace/os_include/os_stdint.h | 141 - ACE/ace/os_include/os_stdio.h | 87 - ACE/ace/os_include/os_stdlib.h | 77 - ACE/ace/os_include/os_string.h | 76 - ACE/ace/os_include/os_strings.h | 52 - ACE/ace/os_include/os_stropts.h | 120 - ACE/ace/os_include/os_syslog.h | 42 - ACE/ace/os_include/os_tar.h | 42 - ACE/ace/os_include/os_termios.h | 46 - ACE/ace/os_include/os_tgmath.h | 45 - ACE/ace/os_include/os_time.h | 123 - ACE/ace/os_include/os_trace.h | 44 - ACE/ace/os_include/os_ucontext.h | 48 - ACE/ace/os_include/os_ulimit.h | 42 - ACE/ace/os_include/os_unistd.h | 203 - ACE/ace/os_include/os_utime.h | 44 - ACE/ace/os_include/os_utmpx.h | 44 - ACE/ace/os_include/os_wchar.h | 49 - ACE/ace/os_include/os_wctype.h | 45 - ACE/ace/os_include/os_wordexp.h | 44 - ACE/ace/os_include/sys/os_ipc.h | 74 - ACE/ace/os_include/sys/os_loadavg.h | 41 - ACE/ace/os_include/sys/os_mman.h | 122 - ACE/ace/os_include/sys/os_msg.h | 55 - ACE/ace/os_include/sys/os_pstat.h | 42 - ACE/ace/os_include/sys/os_resource.h | 104 - ACE/ace/os_include/sys/os_select.h | 59 - ACE/ace/os_include/sys/os_sem.h | 90 - ACE/ace/os_include/sys/os_shm.h | 48 - ACE/ace/os_include/sys/os_socket.h | 307 -- ACE/ace/os_include/sys/os_stat.h | 127 - ACE/ace/os_include/sys/os_statvfs.h | 44 - ACE/ace/os_include/sys/os_sysctl.h | 41 - ACE/ace/os_include/sys/os_time.h | 60 - ACE/ace/os_include/sys/os_timeb.h | 49 - ACE/ace/os_include/sys/os_times.h | 44 - ACE/ace/os_include/sys/os_types.h | 158 - ACE/ace/os_include/sys/os_uio.h | 77 - ACE/ace/os_include/sys/os_un.h | 52 - ACE/ace/os_include/sys/os_utsname.h | 42 - ACE/ace/os_include/sys/os_wait.h | 97 - ACE/ace/other.mpb | 15 - ACE/ace/post.h | 22 - ACE/ace/pre.h | 24 - ACE/ace/streams.h | 141 - ACE/ace/svc_export.h | 44 - ACE/ace/svcconf.mpb | 64 - ACE/ace/token.mpb | 15 - ACE/ace/uuid.mpb | 8 - 1334 files changed, 326233 deletions(-) delete mode 100644 ACE/ace/ACE.cpp delete mode 100644 ACE/ace/ACE.h delete mode 100644 ACE/ace/ACE.inl delete mode 100644 ACE/ace/ACE.pc.in delete mode 100644 ACE/ace/ACE_crc32.cpp delete mode 100644 ACE/ace/ACE_crc_ccitt.cpp delete mode 100644 ACE/ace/ACE_export.h delete mode 100644 ACE/ace/ARGV.cpp delete mode 100644 ACE/ace/ARGV.h delete mode 100644 ACE/ace/ARGV.inl delete mode 100644 ACE/ace/ATM_Acceptor.cpp delete mode 100644 ACE/ace/ATM_Acceptor.h delete mode 100644 ACE/ace/ATM_Acceptor.inl delete mode 100644 ACE/ace/ATM_Addr.cpp delete mode 100644 ACE/ace/ATM_Addr.h delete mode 100644 ACE/ace/ATM_Addr.inl delete mode 100644 ACE/ace/ATM_Connector.cpp delete mode 100644 ACE/ace/ATM_Connector.h delete mode 100644 ACE/ace/ATM_Connector.inl delete mode 100644 ACE/ace/ATM_Params.cpp delete mode 100644 ACE/ace/ATM_Params.h delete mode 100644 ACE/ace/ATM_Params.inl delete mode 100644 ACE/ace/ATM_QoS.cpp delete mode 100644 ACE/ace/ATM_QoS.h delete mode 100644 ACE/ace/ATM_QoS.inl delete mode 100644 ACE/ace/ATM_Stream.cpp delete mode 100644 ACE/ace/ATM_Stream.h delete mode 100644 ACE/ace/ATM_Stream.inl delete mode 100644 ACE/ace/Acceptor.cpp delete mode 100644 ACE/ace/Acceptor.h delete mode 100644 ACE/ace/Activation_Queue.cpp delete mode 100644 ACE/ace/Activation_Queue.h delete mode 100644 ACE/ace/Activation_Queue.inl delete mode 100644 ACE/ace/Active_Map_Manager.cpp delete mode 100644 ACE/ace/Active_Map_Manager.h delete mode 100644 ACE/ace/Active_Map_Manager.inl delete mode 100644 ACE/ace/Active_Map_Manager_T.cpp delete mode 100644 ACE/ace/Active_Map_Manager_T.h delete mode 100644 ACE/ace/Active_Map_Manager_T.inl delete mode 100644 ACE/ace/Addr.cpp delete mode 100644 ACE/ace/Addr.h delete mode 100644 ACE/ace/Addr.inl delete mode 100644 ACE/ace/Arg_Shifter.cpp delete mode 100644 ACE/ace/Arg_Shifter.h delete mode 100644 ACE/ace/Argv_Type_Converter.cpp delete mode 100644 ACE/ace/Argv_Type_Converter.h delete mode 100644 ACE/ace/Argv_Type_Converter.inl delete mode 100644 ACE/ace/Array.h delete mode 100644 ACE/ace/Array_Base.cpp delete mode 100644 ACE/ace/Array_Base.h delete mode 100644 ACE/ace/Array_Base.inl delete mode 100644 ACE/ace/Array_Map.cpp delete mode 100644 ACE/ace/Array_Map.h delete mode 100644 ACE/ace/Array_Map.inl delete mode 100644 ACE/ace/Assert.cpp delete mode 100644 ACE/ace/Assert.h delete mode 100644 ACE/ace/Asynch_Acceptor.cpp delete mode 100644 ACE/ace/Asynch_Acceptor.h delete mode 100644 ACE/ace/Asynch_Connector.cpp delete mode 100644 ACE/ace/Asynch_Connector.h delete mode 100644 ACE/ace/Asynch_IO.cpp delete mode 100644 ACE/ace/Asynch_IO.h delete mode 100644 ACE/ace/Asynch_IO_Impl.cpp delete mode 100644 ACE/ace/Asynch_IO_Impl.h delete mode 100644 ACE/ace/Asynch_IO_Impl.inl delete mode 100644 ACE/ace/Asynch_Pseudo_Task.cpp delete mode 100644 ACE/ace/Asynch_Pseudo_Task.h delete mode 100644 ACE/ace/Atomic_Op.cpp delete mode 100644 ACE/ace/Atomic_Op.h delete mode 100644 ACE/ace/Atomic_Op.inl delete mode 100644 ACE/ace/Atomic_Op_Sparc.c delete mode 100644 ACE/ace/Atomic_Op_Sparc.h delete mode 100644 ACE/ace/Atomic_Op_T.cpp delete mode 100644 ACE/ace/Atomic_Op_T.h delete mode 100644 ACE/ace/Atomic_Op_T.inl delete mode 100644 ACE/ace/Auto_Event.cpp delete mode 100644 ACE/ace/Auto_Event.h delete mode 100644 ACE/ace/Auto_Event.inl delete mode 100644 ACE/ace/Auto_Functor.cpp delete mode 100644 ACE/ace/Auto_Functor.h delete mode 100644 ACE/ace/Auto_Functor.inl delete mode 100644 ACE/ace/Auto_IncDec_T.cpp delete mode 100644 ACE/ace/Auto_IncDec_T.h delete mode 100644 ACE/ace/Auto_IncDec_T.inl delete mode 100644 ACE/ace/Auto_Ptr.cpp delete mode 100644 ACE/ace/Auto_Ptr.h delete mode 100644 ACE/ace/Auto_Ptr.inl delete mode 100644 ACE/ace/Barrier.cpp delete mode 100644 ACE/ace/Barrier.h delete mode 100644 ACE/ace/Barrier.inl delete mode 100644 ACE/ace/Base_Thread_Adapter.cpp delete mode 100644 ACE/ace/Base_Thread_Adapter.h delete mode 100644 ACE/ace/Base_Thread_Adapter.inl delete mode 100644 ACE/ace/Based_Pointer_Repository.cpp delete mode 100644 ACE/ace/Based_Pointer_Repository.h delete mode 100644 ACE/ace/Based_Pointer_T.cpp delete mode 100644 ACE/ace/Based_Pointer_T.h delete mode 100644 ACE/ace/Based_Pointer_T.inl delete mode 100644 ACE/ace/Basic_Stats.cpp delete mode 100644 ACE/ace/Basic_Stats.h delete mode 100644 ACE/ace/Basic_Stats.inl delete mode 100644 ACE/ace/Basic_Types.cpp delete mode 100644 ACE/ace/Basic_Types.h delete mode 100644 ACE/ace/Basic_Types.inl delete mode 100644 ACE/ace/Bound_Ptr.h delete mode 100644 ACE/ace/Bound_Ptr.inl delete mode 100644 ACE/ace/CDR_Base.cpp delete mode 100644 ACE/ace/CDR_Base.h delete mode 100644 ACE/ace/CDR_Base.inl delete mode 100644 ACE/ace/CDR_Size.cpp delete mode 100644 ACE/ace/CDR_Size.h delete mode 100644 ACE/ace/CDR_Size.inl delete mode 100644 ACE/ace/CDR_Stream.cpp delete mode 100644 ACE/ace/CDR_Stream.h delete mode 100644 ACE/ace/CDR_Stream.inl delete mode 100644 ACE/ace/CE_Screen_Output.cpp delete mode 100644 ACE/ace/CE_Screen_Output.h delete mode 100644 ACE/ace/CORBA_macros.h delete mode 100644 ACE/ace/Cache_Map_Manager_T.cpp delete mode 100644 ACE/ace/Cache_Map_Manager_T.h delete mode 100644 ACE/ace/Cache_Map_Manager_T.inl delete mode 100644 ACE/ace/Cached_Connect_Strategy_T.cpp delete mode 100644 ACE/ace/Cached_Connect_Strategy_T.h delete mode 100644 ACE/ace/Caching_Strategies_T.cpp delete mode 100644 ACE/ace/Caching_Strategies_T.h delete mode 100644 ACE/ace/Caching_Strategies_T.inl delete mode 100644 ACE/ace/Caching_Utility_T.cpp delete mode 100644 ACE/ace/Caching_Utility_T.h delete mode 100644 ACE/ace/Capabilities.cpp delete mode 100644 ACE/ace/Capabilities.h delete mode 100644 ACE/ace/Capabilities.inl delete mode 100644 ACE/ace/Cleanup.cpp delete mode 100644 ACE/ace/Cleanup.h delete mode 100644 ACE/ace/Cleanup.inl delete mode 100644 ACE/ace/Cleanup_Strategies_T.cpp delete mode 100644 ACE/ace/Cleanup_Strategies_T.h delete mode 100644 ACE/ace/Codecs.cpp delete mode 100644 ACE/ace/Codecs.h delete mode 100644 ACE/ace/Codeset_IBM1047.cpp delete mode 100644 ACE/ace/Codeset_IBM1047.h delete mode 100644 ACE/ace/Codeset_Registry.cpp delete mode 100644 ACE/ace/Codeset_Registry.h delete mode 100644 ACE/ace/Codeset_Registry.inl delete mode 100644 ACE/ace/Codeset_Registry_db.cpp delete mode 100644 ACE/ace/Codeset_Symbols.h delete mode 100644 ACE/ace/Condition_Recursive_Thread_Mutex.cpp delete mode 100644 ACE/ace/Condition_Recursive_Thread_Mutex.h delete mode 100644 ACE/ace/Condition_T.cpp delete mode 100644 ACE/ace/Condition_T.h delete mode 100644 ACE/ace/Condition_T.inl delete mode 100644 ACE/ace/Condition_Thread_Mutex.cpp delete mode 100644 ACE/ace/Condition_Thread_Mutex.h delete mode 100644 ACE/ace/Condition_Thread_Mutex.inl delete mode 100644 ACE/ace/Configuration.cpp delete mode 100644 ACE/ace/Configuration.h delete mode 100644 ACE/ace/Configuration.inl delete mode 100644 ACE/ace/Configuration_Import_Export.cpp delete mode 100644 ACE/ace/Configuration_Import_Export.h delete mode 100644 ACE/ace/Connection_Recycling_Strategy.cpp delete mode 100644 ACE/ace/Connection_Recycling_Strategy.h delete mode 100644 ACE/ace/Connector.cpp delete mode 100644 ACE/ace/Connector.h delete mode 100644 ACE/ace/Containers.cpp delete mode 100644 ACE/ace/Containers.h delete mode 100644 ACE/ace/Containers.inl delete mode 100644 ACE/ace/Containers_T.cpp delete mode 100644 ACE/ace/Containers_T.h delete mode 100644 ACE/ace/Containers_T.inl delete mode 100644 ACE/ace/Copy_Disabled.cpp delete mode 100644 ACE/ace/Copy_Disabled.h delete mode 100644 ACE/ace/Countdown_Time.cpp delete mode 100644 ACE/ace/Countdown_Time.h delete mode 100644 ACE/ace/DEV.cpp delete mode 100644 ACE/ace/DEV.h delete mode 100644 ACE/ace/DEV.inl delete mode 100644 ACE/ace/DEV_Addr.cpp delete mode 100644 ACE/ace/DEV_Addr.h delete mode 100644 ACE/ace/DEV_Addr.inl delete mode 100644 ACE/ace/DEV_Connector.cpp delete mode 100644 ACE/ace/DEV_Connector.h delete mode 100644 ACE/ace/DEV_Connector.inl delete mode 100644 ACE/ace/DEV_IO.cpp delete mode 100644 ACE/ace/DEV_IO.h delete mode 100644 ACE/ace/DEV_IO.inl delete mode 100644 ACE/ace/DLL.cpp delete mode 100644 ACE/ace/DLL.h delete mode 100644 ACE/ace/DLL_Manager.cpp delete mode 100644 ACE/ace/DLL_Manager.h delete mode 100644 ACE/ace/Date_Time.cpp delete mode 100644 ACE/ace/Date_Time.h delete mode 100644 ACE/ace/Date_Time.inl delete mode 100644 ACE/ace/Default_Constants.h delete mode 100644 ACE/ace/Dev_Poll_Reactor.cpp delete mode 100644 ACE/ace/Dev_Poll_Reactor.h delete mode 100644 ACE/ace/Dev_Poll_Reactor.inl delete mode 100644 ACE/ace/Dirent.cpp delete mode 100644 ACE/ace/Dirent.h delete mode 100644 ACE/ace/Dirent.inl delete mode 100644 ACE/ace/Dirent_Selector.cpp delete mode 100644 ACE/ace/Dirent_Selector.h delete mode 100644 ACE/ace/Dirent_Selector.inl delete mode 100644 ACE/ace/Dump.cpp delete mode 100644 ACE/ace/Dump.h delete mode 100644 ACE/ace/Dump_T.cpp delete mode 100644 ACE/ace/Dump_T.h delete mode 100644 ACE/ace/Dynamic.cpp delete mode 100644 ACE/ace/Dynamic.h delete mode 100644 ACE/ace/Dynamic.inl delete mode 100644 ACE/ace/Dynamic_Message_Strategy.cpp delete mode 100644 ACE/ace/Dynamic_Message_Strategy.h delete mode 100644 ACE/ace/Dynamic_Message_Strategy.inl delete mode 100644 ACE/ace/Dynamic_Service.cpp delete mode 100644 ACE/ace/Dynamic_Service.h delete mode 100644 ACE/ace/Dynamic_Service.inl delete mode 100644 ACE/ace/Dynamic_Service_Base.cpp delete mode 100644 ACE/ace/Dynamic_Service_Base.h delete mode 100644 ACE/ace/Dynamic_Service_Dependency.cpp delete mode 100644 ACE/ace/Dynamic_Service_Dependency.h delete mode 100644 ACE/ace/Encoding_Converter.cpp delete mode 100644 ACE/ace/Encoding_Converter.h delete mode 100644 ACE/ace/Encoding_Converter_Factory.cpp delete mode 100644 ACE/ace/Encoding_Converter_Factory.h delete mode 100644 ACE/ace/Env_Value_T.cpp delete mode 100644 ACE/ace/Env_Value_T.h delete mode 100644 ACE/ace/Env_Value_T.inl delete mode 100644 ACE/ace/Event.cpp delete mode 100644 ACE/ace/Event.h delete mode 100644 ACE/ace/Event.inl delete mode 100644 ACE/ace/Event_Handler.cpp delete mode 100644 ACE/ace/Event_Handler.h delete mode 100644 ACE/ace/Event_Handler.inl delete mode 100644 ACE/ace/Event_Handler_T.cpp delete mode 100644 ACE/ace/Event_Handler_T.h delete mode 100644 ACE/ace/Event_Handler_T.inl delete mode 100644 ACE/ace/Exception_Macros.h delete mode 100644 ACE/ace/FIFO.cpp delete mode 100644 ACE/ace/FIFO.h delete mode 100644 ACE/ace/FIFO.inl delete mode 100644 ACE/ace/FIFO_Recv.cpp delete mode 100644 ACE/ace/FIFO_Recv.h delete mode 100644 ACE/ace/FIFO_Recv.inl delete mode 100644 ACE/ace/FIFO_Recv_Msg.cpp delete mode 100644 ACE/ace/FIFO_Recv_Msg.h delete mode 100644 ACE/ace/FIFO_Recv_Msg.inl delete mode 100644 ACE/ace/FIFO_Send.cpp delete mode 100644 ACE/ace/FIFO_Send.h delete mode 100644 ACE/ace/FIFO_Send.inl delete mode 100644 ACE/ace/FIFO_Send_Msg.cpp delete mode 100644 ACE/ace/FIFO_Send_Msg.h delete mode 100644 ACE/ace/FIFO_Send_Msg.inl delete mode 100644 ACE/ace/FILE.cpp delete mode 100644 ACE/ace/FILE.h delete mode 100644 ACE/ace/FILE.inl delete mode 100644 ACE/ace/FILE_Addr.cpp delete mode 100644 ACE/ace/FILE_Addr.h delete mode 100644 ACE/ace/FILE_Addr.inl delete mode 100644 ACE/ace/FILE_Connector.cpp delete mode 100644 ACE/ace/FILE_Connector.h delete mode 100644 ACE/ace/FILE_Connector.inl delete mode 100644 ACE/ace/FILE_IO.cpp delete mode 100644 ACE/ace/FILE_IO.h delete mode 100644 ACE/ace/FILE_IO.inl delete mode 100644 ACE/ace/File_Lock.cpp delete mode 100644 ACE/ace/File_Lock.h delete mode 100644 ACE/ace/File_Lock.inl delete mode 100644 ACE/ace/Filecache.cpp delete mode 100644 ACE/ace/Filecache.h delete mode 100644 ACE/ace/FlReactor/ACE_FlReactor.pc.in delete mode 100644 ACE/ace/FlReactor/ACE_FlReactor_export.h delete mode 100644 ACE/ace/FlReactor/FlReactor.cpp delete mode 100644 ACE/ace/FlReactor/FlReactor.h delete mode 100644 ACE/ace/Flag_Manip.cpp delete mode 100644 ACE/ace/Flag_Manip.h delete mode 100644 ACE/ace/Flag_Manip.inl delete mode 100644 ACE/ace/FoxReactor/ACE_FoxReactor.pc.in delete mode 100644 ACE/ace/FoxReactor/ACE_FoxReactor_export.h delete mode 100644 ACE/ace/FoxReactor/FoxReactor.cpp delete mode 100644 ACE/ace/FoxReactor/FoxReactor.h delete mode 100644 ACE/ace/Framework_Component.cpp delete mode 100644 ACE/ace/Framework_Component.h delete mode 100644 ACE/ace/Framework_Component.inl delete mode 100644 ACE/ace/Framework_Component_T.cpp delete mode 100644 ACE/ace/Framework_Component_T.h delete mode 100644 ACE/ace/Free_List.cpp delete mode 100644 ACE/ace/Free_List.h delete mode 100644 ACE/ace/Functor.cpp delete mode 100644 ACE/ace/Functor.h delete mode 100644 ACE/ace/Functor.inl delete mode 100644 ACE/ace/Functor_String.cpp delete mode 100644 ACE/ace/Functor_String.h delete mode 100644 ACE/ace/Functor_String.inl delete mode 100644 ACE/ace/Functor_T.cpp delete mode 100644 ACE/ace/Functor_T.h delete mode 100644 ACE/ace/Functor_T.inl delete mode 100644 ACE/ace/Future.cpp delete mode 100644 ACE/ace/Future.h delete mode 100644 ACE/ace/Future_Set.cpp delete mode 100644 ACE/ace/Future_Set.h delete mode 100644 ACE/ace/Get_Opt.cpp delete mode 100644 ACE/ace/Get_Opt.h delete mode 100644 ACE/ace/Get_Opt.inl delete mode 100644 ACE/ace/Global_Macros.h delete mode 100644 ACE/ace/Guard_T.cpp delete mode 100644 ACE/ace/Guard_T.h delete mode 100644 ACE/ace/Guard_T.inl delete mode 100644 ACE/ace/Handle_Gobbler.h delete mode 100644 ACE/ace/Handle_Gobbler.inl delete mode 100644 ACE/ace/Handle_Ops.cpp delete mode 100644 ACE/ace/Handle_Ops.h delete mode 100644 ACE/ace/Handle_Set.cpp delete mode 100644 ACE/ace/Handle_Set.h delete mode 100644 ACE/ace/Handle_Set.inl delete mode 100644 ACE/ace/Hash_Cache_Map_Manager_T.cpp delete mode 100644 ACE/ace/Hash_Cache_Map_Manager_T.h delete mode 100644 ACE/ace/Hash_Cache_Map_Manager_T.inl delete mode 100644 ACE/ace/Hash_Map_Manager.h delete mode 100644 ACE/ace/Hash_Map_Manager_T.cpp delete mode 100644 ACE/ace/Hash_Map_Manager_T.h delete mode 100644 ACE/ace/Hash_Map_Manager_T.inl delete mode 100644 ACE/ace/Hash_Map_With_Allocator_T.cpp delete mode 100644 ACE/ace/Hash_Map_With_Allocator_T.h delete mode 100644 ACE/ace/Hash_Map_With_Allocator_T.inl delete mode 100644 ACE/ace/Hash_Multi_Map_Manager_T.cpp delete mode 100644 ACE/ace/Hash_Multi_Map_Manager_T.h delete mode 100644 ACE/ace/Hash_Multi_Map_Manager_T.inl delete mode 100644 ACE/ace/Hashable.cpp delete mode 100644 ACE/ace/Hashable.h delete mode 100644 ACE/ace/Hashable.inl delete mode 100644 ACE/ace/High_Res_Timer.cpp delete mode 100644 ACE/ace/High_Res_Timer.h delete mode 100644 ACE/ace/High_Res_Timer.inl delete mode 100644 ACE/ace/ICMP_Socket.cpp delete mode 100644 ACE/ace/ICMP_Socket.h delete mode 100644 ACE/ace/INET_Addr.cpp delete mode 100644 ACE/ace/INET_Addr.h delete mode 100644 ACE/ace/INET_Addr.inl delete mode 100644 ACE/ace/IOStream.cpp delete mode 100644 ACE/ace/IOStream.h delete mode 100644 ACE/ace/IOStream_T.cpp delete mode 100644 ACE/ace/IOStream_T.h delete mode 100644 ACE/ace/IOStream_T.inl delete mode 100644 ACE/ace/IO_Cntl_Msg.cpp delete mode 100644 ACE/ace/IO_Cntl_Msg.h delete mode 100644 ACE/ace/IO_Cntl_Msg.inl delete mode 100644 ACE/ace/IO_SAP.cpp delete mode 100644 ACE/ace/IO_SAP.h delete mode 100644 ACE/ace/IO_SAP.inl delete mode 100644 ACE/ace/IPC_SAP.cpp delete mode 100644 ACE/ace/IPC_SAP.h delete mode 100644 ACE/ace/IPC_SAP.inl delete mode 100644 ACE/ace/If_Then_Else.h delete mode 100644 ACE/ace/Init_ACE.cpp delete mode 100644 ACE/ace/Init_ACE.h delete mode 100644 ACE/ace/Intrusive_List.cpp delete mode 100644 ACE/ace/Intrusive_List.h delete mode 100644 ACE/ace/Intrusive_List.inl delete mode 100644 ACE/ace/Intrusive_List_Node.cpp delete mode 100644 ACE/ace/Intrusive_List_Node.h delete mode 100644 ACE/ace/Intrusive_List_Node.inl delete mode 100644 ACE/ace/LOCK_SOCK_Acceptor.cpp delete mode 100644 ACE/ace/LOCK_SOCK_Acceptor.h delete mode 100644 ACE/ace/LSOCK.cpp delete mode 100644 ACE/ace/LSOCK.h delete mode 100644 ACE/ace/LSOCK.inl delete mode 100644 ACE/ace/LSOCK_Acceptor.cpp delete mode 100644 ACE/ace/LSOCK_Acceptor.h delete mode 100644 ACE/ace/LSOCK_CODgram.cpp delete mode 100644 ACE/ace/LSOCK_CODgram.h delete mode 100644 ACE/ace/LSOCK_CODgram.inl delete mode 100644 ACE/ace/LSOCK_Connector.cpp delete mode 100644 ACE/ace/LSOCK_Connector.h delete mode 100644 ACE/ace/LSOCK_Connector.inl delete mode 100644 ACE/ace/LSOCK_Dgram.cpp delete mode 100644 ACE/ace/LSOCK_Dgram.h delete mode 100644 ACE/ace/LSOCK_Dgram.inl delete mode 100644 ACE/ace/LSOCK_Stream.cpp delete mode 100644 ACE/ace/LSOCK_Stream.h delete mode 100644 ACE/ace/LSOCK_Stream.inl delete mode 100644 ACE/ace/Lib_Find.cpp delete mode 100644 ACE/ace/Lib_Find.h delete mode 100644 ACE/ace/Local_Memory_Pool.cpp delete mode 100644 ACE/ace/Local_Memory_Pool.h delete mode 100644 ACE/ace/Local_Name_Space.cpp delete mode 100644 ACE/ace/Local_Name_Space.h delete mode 100644 ACE/ace/Local_Name_Space_T.cpp delete mode 100644 ACE/ace/Local_Name_Space_T.h delete mode 100644 ACE/ace/Local_Tokens.cpp delete mode 100644 ACE/ace/Local_Tokens.h delete mode 100644 ACE/ace/Local_Tokens.inl delete mode 100644 ACE/ace/Lock.cpp delete mode 100644 ACE/ace/Lock.h delete mode 100644 ACE/ace/Lock.inl delete mode 100644 ACE/ace/Lock_Adapter_T.cpp delete mode 100644 ACE/ace/Lock_Adapter_T.h delete mode 100644 ACE/ace/Lock_Adapter_T.inl delete mode 100644 ACE/ace/Log_Msg.cpp delete mode 100644 ACE/ace/Log_Msg.h delete mode 100644 ACE/ace/Log_Msg.inl delete mode 100644 ACE/ace/Log_Msg_Backend.cpp delete mode 100644 ACE/ace/Log_Msg_Backend.h delete mode 100644 ACE/ace/Log_Msg_Callback.cpp delete mode 100644 ACE/ace/Log_Msg_Callback.h delete mode 100644 ACE/ace/Log_Msg_IPC.cpp delete mode 100644 ACE/ace/Log_Msg_IPC.h delete mode 100644 ACE/ace/Log_Msg_NT_Event_Log.cpp delete mode 100644 ACE/ace/Log_Msg_NT_Event_Log.h delete mode 100644 ACE/ace/Log_Msg_UNIX_Syslog.cpp delete mode 100644 ACE/ace/Log_Msg_UNIX_Syslog.h delete mode 100644 ACE/ace/Log_Priority.h delete mode 100644 ACE/ace/Log_Record.cpp delete mode 100644 ACE/ace/Log_Record.h delete mode 100644 ACE/ace/Log_Record.inl delete mode 100644 ACE/ace/Logging_Strategy.cpp delete mode 100644 ACE/ace/Logging_Strategy.h delete mode 100644 ACE/ace/MEM_Acceptor.cpp delete mode 100644 ACE/ace/MEM_Acceptor.h delete mode 100644 ACE/ace/MEM_Acceptor.inl delete mode 100644 ACE/ace/MEM_Addr.cpp delete mode 100644 ACE/ace/MEM_Addr.h delete mode 100644 ACE/ace/MEM_Addr.inl delete mode 100644 ACE/ace/MEM_Connector.cpp delete mode 100644 ACE/ace/MEM_Connector.h delete mode 100644 ACE/ace/MEM_Connector.inl delete mode 100644 ACE/ace/MEM_IO.cpp delete mode 100644 ACE/ace/MEM_IO.h delete mode 100644 ACE/ace/MEM_IO.inl delete mode 100644 ACE/ace/MEM_SAP.cpp delete mode 100644 ACE/ace/MEM_SAP.h delete mode 100644 ACE/ace/MEM_SAP.inl delete mode 100644 ACE/ace/MEM_Stream.cpp delete mode 100644 ACE/ace/MEM_Stream.h delete mode 100644 ACE/ace/MEM_Stream.inl delete mode 100644 ACE/ace/MMAP_Memory_Pool.cpp delete mode 100644 ACE/ace/MMAP_Memory_Pool.h delete mode 100644 ACE/ace/MMAP_Memory_Pool.inl delete mode 100644 ACE/ace/Makefile.am delete mode 100644 ACE/ace/Malloc.cpp delete mode 100644 ACE/ace/Malloc.h delete mode 100644 ACE/ace/Malloc.inl delete mode 100644 ACE/ace/Malloc_Allocator.cpp delete mode 100644 ACE/ace/Malloc_Allocator.h delete mode 100644 ACE/ace/Malloc_Allocator.inl delete mode 100644 ACE/ace/Malloc_Base.h delete mode 100644 ACE/ace/Malloc_T.cpp delete mode 100644 ACE/ace/Malloc_T.h delete mode 100644 ACE/ace/Malloc_T.inl delete mode 100644 ACE/ace/Managed_Object.cpp delete mode 100644 ACE/ace/Managed_Object.h delete mode 100644 ACE/ace/Managed_Object.inl delete mode 100644 ACE/ace/Manual_Event.cpp delete mode 100644 ACE/ace/Manual_Event.h delete mode 100644 ACE/ace/Manual_Event.inl delete mode 100644 ACE/ace/Map.h delete mode 100644 ACE/ace/Map_Manager.cpp delete mode 100644 ACE/ace/Map_Manager.h delete mode 100644 ACE/ace/Map_Manager.inl delete mode 100644 ACE/ace/Map_T.cpp delete mode 100644 ACE/ace/Map_T.h delete mode 100644 ACE/ace/Map_T.inl delete mode 100644 ACE/ace/Mem_Map.cpp delete mode 100644 ACE/ace/Mem_Map.h delete mode 100644 ACE/ace/Mem_Map.inl delete mode 100644 ACE/ace/Memory_Pool.h delete mode 100644 ACE/ace/Message_Block.cpp delete mode 100644 ACE/ace/Message_Block.h delete mode 100644 ACE/ace/Message_Block.inl delete mode 100644 ACE/ace/Message_Block_T.cpp delete mode 100644 ACE/ace/Message_Block_T.h delete mode 100644 ACE/ace/Message_Block_T.inl delete mode 100644 ACE/ace/Message_Queue.cpp delete mode 100644 ACE/ace/Message_Queue.h delete mode 100644 ACE/ace/Message_Queue.inl delete mode 100644 ACE/ace/Message_Queue_NT.cpp delete mode 100644 ACE/ace/Message_Queue_NT.h delete mode 100644 ACE/ace/Message_Queue_NT.inl delete mode 100644 ACE/ace/Message_Queue_T.cpp delete mode 100644 ACE/ace/Message_Queue_T.h delete mode 100644 ACE/ace/Message_Queue_Vx.cpp delete mode 100644 ACE/ace/Message_Queue_Vx.h delete mode 100644 ACE/ace/Message_Queue_Vx.inl delete mode 100644 ACE/ace/Method_Object.h delete mode 100644 ACE/ace/Method_Request.cpp delete mode 100644 ACE/ace/Method_Request.h delete mode 100644 ACE/ace/Metrics_Cache.h delete mode 100644 ACE/ace/Metrics_Cache_T.cpp delete mode 100644 ACE/ace/Metrics_Cache_T.h delete mode 100644 ACE/ace/Metrics_Cache_T.inl delete mode 100644 ACE/ace/Min_Max.h delete mode 100644 ACE/ace/Module.cpp delete mode 100644 ACE/ace/Module.h delete mode 100644 ACE/ace/Module.inl delete mode 100644 ACE/ace/Msg_WFMO_Reactor.cpp delete mode 100644 ACE/ace/Msg_WFMO_Reactor.h delete mode 100644 ACE/ace/Msg_WFMO_Reactor.inl delete mode 100644 ACE/ace/Multihomed_INET_Addr.cpp delete mode 100644 ACE/ace/Multihomed_INET_Addr.h delete mode 100644 ACE/ace/Multihomed_INET_Addr.inl delete mode 100644 ACE/ace/Mutex.cpp delete mode 100644 ACE/ace/Mutex.h delete mode 100644 ACE/ace/Mutex.inl delete mode 100644 ACE/ace/NT_Service.cpp delete mode 100644 ACE/ace/NT_Service.h delete mode 100644 ACE/ace/NT_Service.inl delete mode 100644 ACE/ace/Name_Proxy.cpp delete mode 100644 ACE/ace/Name_Proxy.h delete mode 100644 ACE/ace/Name_Request_Reply.cpp delete mode 100644 ACE/ace/Name_Request_Reply.h delete mode 100644 ACE/ace/Name_Space.cpp delete mode 100644 ACE/ace/Name_Space.h delete mode 100644 ACE/ace/Naming_Context.cpp delete mode 100644 ACE/ace/Naming_Context.h delete mode 100644 ACE/ace/Naming_Context.inl delete mode 100644 ACE/ace/Netlink_Addr.cpp delete mode 100644 ACE/ace/Netlink_Addr.h delete mode 100644 ACE/ace/Netlink_Addr.inl delete mode 100644 ACE/ace/Node.cpp delete mode 100644 ACE/ace/Node.h delete mode 100644 ACE/ace/Notification_Queue.cpp delete mode 100644 ACE/ace/Notification_Queue.h delete mode 100644 ACE/ace/Notification_Queue.inl delete mode 100644 ACE/ace/Notification_Strategy.cpp delete mode 100644 ACE/ace/Notification_Strategy.h delete mode 100644 ACE/ace/Notification_Strategy.inl delete mode 100644 ACE/ace/Null_Barrier.h delete mode 100644 ACE/ace/Null_Condition.h delete mode 100644 ACE/ace/Null_Mutex.h delete mode 100644 ACE/ace/Null_Semaphore.h delete mode 100644 ACE/ace/Numeric_Limits.h delete mode 100644 ACE/ace/OS.cpp delete mode 100644 ACE/ace/OS.h delete mode 100644 ACE/ace/OS.inl delete mode 100644 ACE/ace/OS_Dirent.h delete mode 100644 ACE/ace/OS_Errno.cpp delete mode 100644 ACE/ace/OS_Errno.h delete mode 100644 ACE/ace/OS_Errno.inl delete mode 100644 ACE/ace/OS_Log_Msg_Attributes.cpp delete mode 100644 ACE/ace/OS_Log_Msg_Attributes.h delete mode 100644 ACE/ace/OS_Log_Msg_Attributes.inl delete mode 100644 ACE/ace/OS_Memory.h delete mode 100644 ACE/ace/OS_NS_Thread.cpp delete mode 100644 ACE/ace/OS_NS_Thread.h delete mode 100644 ACE/ace/OS_NS_Thread.inl delete mode 100644 ACE/ace/OS_NS_arpa_inet.cpp delete mode 100644 ACE/ace/OS_NS_arpa_inet.h delete mode 100644 ACE/ace/OS_NS_arpa_inet.inl delete mode 100644 ACE/ace/OS_NS_ctype.cpp delete mode 100644 ACE/ace/OS_NS_ctype.h delete mode 100644 ACE/ace/OS_NS_ctype.inl delete mode 100644 ACE/ace/OS_NS_dirent.cpp delete mode 100644 ACE/ace/OS_NS_dirent.h delete mode 100644 ACE/ace/OS_NS_dirent.inl delete mode 100644 ACE/ace/OS_NS_dlfcn.cpp delete mode 100644 ACE/ace/OS_NS_dlfcn.h delete mode 100644 ACE/ace/OS_NS_dlfcn.inl delete mode 100644 ACE/ace/OS_NS_errno.cpp delete mode 100644 ACE/ace/OS_NS_errno.h delete mode 100644 ACE/ace/OS_NS_errno.inl delete mode 100644 ACE/ace/OS_NS_fcntl.cpp delete mode 100644 ACE/ace/OS_NS_fcntl.h delete mode 100644 ACE/ace/OS_NS_fcntl.inl delete mode 100644 ACE/ace/OS_NS_macros.h delete mode 100644 ACE/ace/OS_NS_math.cpp delete mode 100644 ACE/ace/OS_NS_math.h delete mode 100644 ACE/ace/OS_NS_math.inl delete mode 100644 ACE/ace/OS_NS_netdb.cpp delete mode 100644 ACE/ace/OS_NS_netdb.h delete mode 100644 ACE/ace/OS_NS_netdb.inl delete mode 100644 ACE/ace/OS_NS_poll.cpp delete mode 100644 ACE/ace/OS_NS_poll.h delete mode 100644 ACE/ace/OS_NS_poll.inl delete mode 100644 ACE/ace/OS_NS_pwd.cpp delete mode 100644 ACE/ace/OS_NS_pwd.h delete mode 100644 ACE/ace/OS_NS_pwd.inl delete mode 100644 ACE/ace/OS_NS_regex.cpp delete mode 100644 ACE/ace/OS_NS_regex.h delete mode 100644 ACE/ace/OS_NS_regex.inl delete mode 100644 ACE/ace/OS_NS_signal.cpp delete mode 100644 ACE/ace/OS_NS_signal.h delete mode 100644 ACE/ace/OS_NS_signal.inl delete mode 100644 ACE/ace/OS_NS_stdio.cpp delete mode 100644 ACE/ace/OS_NS_stdio.h delete mode 100644 ACE/ace/OS_NS_stdio.inl delete mode 100644 ACE/ace/OS_NS_stdlib.cpp delete mode 100644 ACE/ace/OS_NS_stdlib.h delete mode 100644 ACE/ace/OS_NS_stdlib.inl delete mode 100644 ACE/ace/OS_NS_string.cpp delete mode 100644 ACE/ace/OS_NS_string.h delete mode 100644 ACE/ace/OS_NS_string.inl delete mode 100644 ACE/ace/OS_NS_strings.cpp delete mode 100644 ACE/ace/OS_NS_strings.h delete mode 100644 ACE/ace/OS_NS_strings.inl delete mode 100644 ACE/ace/OS_NS_stropts.cpp delete mode 100644 ACE/ace/OS_NS_stropts.h delete mode 100644 ACE/ace/OS_NS_stropts.inl delete mode 100644 ACE/ace/OS_NS_sys_mman.cpp delete mode 100644 ACE/ace/OS_NS_sys_mman.h delete mode 100644 ACE/ace/OS_NS_sys_mman.inl delete mode 100644 ACE/ace/OS_NS_sys_msg.cpp delete mode 100644 ACE/ace/OS_NS_sys_msg.h delete mode 100644 ACE/ace/OS_NS_sys_msg.inl delete mode 100644 ACE/ace/OS_NS_sys_resource.cpp delete mode 100644 ACE/ace/OS_NS_sys_resource.h delete mode 100644 ACE/ace/OS_NS_sys_resource.inl delete mode 100644 ACE/ace/OS_NS_sys_select.cpp delete mode 100644 ACE/ace/OS_NS_sys_select.h delete mode 100644 ACE/ace/OS_NS_sys_select.inl delete mode 100644 ACE/ace/OS_NS_sys_sendfile.cpp delete mode 100644 ACE/ace/OS_NS_sys_sendfile.h delete mode 100644 ACE/ace/OS_NS_sys_sendfile.inl delete mode 100644 ACE/ace/OS_NS_sys_shm.cpp delete mode 100644 ACE/ace/OS_NS_sys_shm.h delete mode 100644 ACE/ace/OS_NS_sys_shm.inl delete mode 100644 ACE/ace/OS_NS_sys_socket.cpp delete mode 100644 ACE/ace/OS_NS_sys_socket.h delete mode 100644 ACE/ace/OS_NS_sys_socket.inl delete mode 100644 ACE/ace/OS_NS_sys_stat.cpp delete mode 100644 ACE/ace/OS_NS_sys_stat.h delete mode 100644 ACE/ace/OS_NS_sys_stat.inl delete mode 100644 ACE/ace/OS_NS_sys_time.cpp delete mode 100644 ACE/ace/OS_NS_sys_time.h delete mode 100644 ACE/ace/OS_NS_sys_time.inl delete mode 100644 ACE/ace/OS_NS_sys_uio.cpp delete mode 100644 ACE/ace/OS_NS_sys_uio.h delete mode 100644 ACE/ace/OS_NS_sys_uio.inl delete mode 100644 ACE/ace/OS_NS_sys_utsname.cpp delete mode 100644 ACE/ace/OS_NS_sys_utsname.h delete mode 100644 ACE/ace/OS_NS_sys_wait.cpp delete mode 100644 ACE/ace/OS_NS_sys_wait.h delete mode 100644 ACE/ace/OS_NS_sys_wait.inl delete mode 100644 ACE/ace/OS_NS_time.cpp delete mode 100644 ACE/ace/OS_NS_time.h delete mode 100644 ACE/ace/OS_NS_time.inl delete mode 100644 ACE/ace/OS_NS_unistd.cpp delete mode 100644 ACE/ace/OS_NS_unistd.h delete mode 100644 ACE/ace/OS_NS_unistd.inl delete mode 100644 ACE/ace/OS_NS_wchar.cpp delete mode 100644 ACE/ace/OS_NS_wchar.h delete mode 100644 ACE/ace/OS_NS_wchar.inl delete mode 100644 ACE/ace/OS_QoS.cpp delete mode 100644 ACE/ace/OS_QoS.h delete mode 100644 ACE/ace/OS_String.h delete mode 100644 ACE/ace/OS_TLI.cpp delete mode 100644 ACE/ace/OS_TLI.h delete mode 100644 ACE/ace/OS_TLI.inl delete mode 100644 ACE/ace/OS_Thread_Adapter.cpp delete mode 100644 ACE/ace/OS_Thread_Adapter.h delete mode 100644 ACE/ace/OS_main.cpp delete mode 100644 ACE/ace/OS_main.h delete mode 100644 ACE/ace/Obchunk.cpp delete mode 100644 ACE/ace/Obchunk.h delete mode 100644 ACE/ace/Obchunk.inl delete mode 100644 ACE/ace/Object_Manager.cpp delete mode 100644 ACE/ace/Object_Manager.h delete mode 100644 ACE/ace/Object_Manager.inl delete mode 100644 ACE/ace/Object_Manager_Base.cpp delete mode 100644 ACE/ace/Object_Manager_Base.h delete mode 100644 ACE/ace/Obstack.h delete mode 100644 ACE/ace/Obstack_T.cpp delete mode 100644 ACE/ace/Obstack_T.h delete mode 100644 ACE/ace/Obstack_T.inl delete mode 100644 ACE/ace/PI_Malloc.cpp delete mode 100644 ACE/ace/PI_Malloc.h delete mode 100644 ACE/ace/PI_Malloc.inl delete mode 100644 ACE/ace/POSIX_Asynch_IO.cpp delete mode 100644 ACE/ace/POSIX_Asynch_IO.h delete mode 100644 ACE/ace/POSIX_CB_Proactor.cpp delete mode 100644 ACE/ace/POSIX_CB_Proactor.h delete mode 100644 ACE/ace/POSIX_Proactor.cpp delete mode 100644 ACE/ace/POSIX_Proactor.h delete mode 100644 ACE/ace/POSIX_Proactor.inl delete mode 100644 ACE/ace/Pagefile_Memory_Pool.cpp delete mode 100644 ACE/ace/Pagefile_Memory_Pool.h delete mode 100644 ACE/ace/Pagefile_Memory_Pool.inl delete mode 100644 ACE/ace/Pair.h delete mode 100644 ACE/ace/Pair_T.cpp delete mode 100644 ACE/ace/Pair_T.h delete mode 100644 ACE/ace/Pair_T.inl delete mode 100644 ACE/ace/Parse_Node.cpp delete mode 100644 ACE/ace/Parse_Node.h delete mode 100644 ACE/ace/Ping_Socket.cpp delete mode 100644 ACE/ace/Ping_Socket.h delete mode 100644 ACE/ace/Ping_Socket.inl delete mode 100644 ACE/ace/Pipe.cpp delete mode 100644 ACE/ace/Pipe.h delete mode 100644 ACE/ace/Pipe.inl delete mode 100644 ACE/ace/Priority_Reactor.cpp delete mode 100644 ACE/ace/Priority_Reactor.h delete mode 100644 ACE/ace/Proactor.cpp delete mode 100644 ACE/ace/Proactor.h delete mode 100644 ACE/ace/Proactor.inl delete mode 100644 ACE/ace/Proactor_Impl.cpp delete mode 100644 ACE/ace/Proactor_Impl.h delete mode 100644 ACE/ace/Process.cpp delete mode 100644 ACE/ace/Process.h delete mode 100644 ACE/ace/Process.inl delete mode 100644 ACE/ace/Process_Manager.cpp delete mode 100644 ACE/ace/Process_Manager.h delete mode 100644 ACE/ace/Process_Manager.inl delete mode 100644 ACE/ace/Process_Mutex.cpp delete mode 100644 ACE/ace/Process_Mutex.h delete mode 100644 ACE/ace/Process_Mutex.inl delete mode 100644 ACE/ace/Process_Semaphore.cpp delete mode 100644 ACE/ace/Process_Semaphore.h delete mode 100644 ACE/ace/Process_Semaphore.inl delete mode 100644 ACE/ace/Profile_Timer.cpp delete mode 100644 ACE/ace/Profile_Timer.h delete mode 100644 ACE/ace/Profile_Timer.inl delete mode 100644 ACE/ace/QoS/ACE_QoS.pc.in delete mode 100644 ACE/ace/QoS/ACE_QoS_Export.h delete mode 100644 ACE/ace/QoS/Makefile.am delete mode 100644 ACE/ace/QoS/QoS_Decorator.cpp delete mode 100644 ACE/ace/QoS/QoS_Decorator.h delete mode 100644 ACE/ace/QoS/QoS_Manager.cpp delete mode 100644 ACE/ace/QoS/QoS_Manager.h delete mode 100644 ACE/ace/QoS/QoS_Session.h delete mode 100644 ACE/ace/QoS/QoS_Session_Factory.cpp delete mode 100644 ACE/ace/QoS/QoS_Session_Factory.h delete mode 100644 ACE/ace/QoS/QoS_Session_Impl.cpp delete mode 100644 ACE/ace/QoS/QoS_Session_Impl.h delete mode 100644 ACE/ace/QoS/QoS_Session_Impl.inl delete mode 100644 ACE/ace/QoS/README delete mode 100644 ACE/ace/QoS/SOCK_Dgram_Mcast_QoS.cpp delete mode 100644 ACE/ace/QoS/SOCK_Dgram_Mcast_QoS.h delete mode 100644 ACE/ace/QoS/SOCK_Dgram_Mcast_QoS.inl delete mode 100644 ACE/ace/QoS/qos.mpc delete mode 100644 ACE/ace/QtReactor/ACE_QtReactor.pc.in delete mode 100644 ACE/ace/QtReactor/ACE_QtReactor_export.h delete mode 100644 ACE/ace/QtReactor/QtReactor.cpp delete mode 100644 ACE/ace/QtReactor/QtReactor.h delete mode 100644 ACE/ace/RB_Tree.cpp delete mode 100644 ACE/ace/RB_Tree.h delete mode 100644 ACE/ace/RB_Tree.inl delete mode 100644 ACE/ace/README delete mode 100644 ACE/ace/RW_Mutex.cpp delete mode 100644 ACE/ace/RW_Mutex.h delete mode 100644 ACE/ace/RW_Mutex.inl delete mode 100644 ACE/ace/RW_Process_Mutex.cpp delete mode 100644 ACE/ace/RW_Process_Mutex.h delete mode 100644 ACE/ace/RW_Process_Mutex.inl delete mode 100644 ACE/ace/RW_Thread_Mutex.cpp delete mode 100644 ACE/ace/RW_Thread_Mutex.h delete mode 100644 ACE/ace/RW_Thread_Mutex.inl delete mode 100644 ACE/ace/Reactor.cpp delete mode 100644 ACE/ace/Reactor.h delete mode 100644 ACE/ace/Reactor.inl delete mode 100644 ACE/ace/Reactor_Impl.cpp delete mode 100644 ACE/ace/Reactor_Impl.h delete mode 100644 ACE/ace/Reactor_Notification_Strategy.cpp delete mode 100644 ACE/ace/Reactor_Notification_Strategy.h delete mode 100644 ACE/ace/Reactor_Notification_Strategy.inl delete mode 100644 ACE/ace/Reactor_Timer_Interface.cpp delete mode 100644 ACE/ace/Reactor_Timer_Interface.h delete mode 100644 ACE/ace/Reactor_Token_T.cpp delete mode 100644 ACE/ace/Reactor_Token_T.h delete mode 100644 ACE/ace/Read_Buffer.cpp delete mode 100644 ACE/ace/Read_Buffer.h delete mode 100644 ACE/ace/Read_Buffer.inl delete mode 100644 ACE/ace/Recursive_Thread_Mutex.cpp delete mode 100644 ACE/ace/Recursive_Thread_Mutex.h delete mode 100644 ACE/ace/Recursive_Thread_Mutex.inl delete mode 100644 ACE/ace/Recyclable.cpp delete mode 100644 ACE/ace/Recyclable.h delete mode 100644 ACE/ace/Recyclable.inl delete mode 100644 ACE/ace/Refcountable.cpp delete mode 100644 ACE/ace/Refcountable.h delete mode 100644 ACE/ace/Refcountable.inl delete mode 100644 ACE/ace/Refcounted_Auto_Ptr.cpp delete mode 100644 ACE/ace/Refcounted_Auto_Ptr.h delete mode 100644 ACE/ace/Refcounted_Auto_Ptr.inl delete mode 100644 ACE/ace/Registry.cpp delete mode 100644 ACE/ace/Registry.h delete mode 100644 ACE/ace/Registry_Name_Space.cpp delete mode 100644 ACE/ace/Registry_Name_Space.h delete mode 100644 ACE/ace/Remote_Name_Space.cpp delete mode 100644 ACE/ace/Remote_Name_Space.h delete mode 100644 ACE/ace/Remote_Tokens.cpp delete mode 100644 ACE/ace/Remote_Tokens.h delete mode 100644 ACE/ace/Remote_Tokens.inl delete mode 100644 ACE/ace/Reverse_Lock_T.cpp delete mode 100644 ACE/ace/Reverse_Lock_T.h delete mode 100644 ACE/ace/Reverse_Lock_T.inl delete mode 100644 ACE/ace/Rtems_init.c delete mode 100644 ACE/ace/SOCK.cpp delete mode 100644 ACE/ace/SOCK.h delete mode 100644 ACE/ace/SOCK.inl delete mode 100644 ACE/ace/SOCK_Acceptor.cpp delete mode 100644 ACE/ace/SOCK_Acceptor.h delete mode 100644 ACE/ace/SOCK_Acceptor.inl delete mode 100644 ACE/ace/SOCK_CODgram.cpp delete mode 100644 ACE/ace/SOCK_CODgram.h delete mode 100644 ACE/ace/SOCK_CODgram.inl delete mode 100644 ACE/ace/SOCK_Connector.cpp delete mode 100644 ACE/ace/SOCK_Connector.h delete mode 100644 ACE/ace/SOCK_Connector.inl delete mode 100644 ACE/ace/SOCK_Dgram.cpp delete mode 100644 ACE/ace/SOCK_Dgram.h delete mode 100644 ACE/ace/SOCK_Dgram.inl delete mode 100644 ACE/ace/SOCK_Dgram_Bcast.cpp delete mode 100644 ACE/ace/SOCK_Dgram_Bcast.h delete mode 100644 ACE/ace/SOCK_Dgram_Bcast.inl delete mode 100644 ACE/ace/SOCK_Dgram_Mcast.cpp delete mode 100644 ACE/ace/SOCK_Dgram_Mcast.h delete mode 100644 ACE/ace/SOCK_Dgram_Mcast.inl delete mode 100644 ACE/ace/SOCK_IO.cpp delete mode 100644 ACE/ace/SOCK_IO.h delete mode 100644 ACE/ace/SOCK_IO.inl delete mode 100644 ACE/ace/SOCK_Netlink.cpp delete mode 100644 ACE/ace/SOCK_Netlink.h delete mode 100644 ACE/ace/SOCK_Netlink.inl delete mode 100644 ACE/ace/SOCK_SEQPACK_Acceptor.cpp delete mode 100644 ACE/ace/SOCK_SEQPACK_Acceptor.h delete mode 100644 ACE/ace/SOCK_SEQPACK_Acceptor.inl delete mode 100644 ACE/ace/SOCK_SEQPACK_Association.cpp delete mode 100644 ACE/ace/SOCK_SEQPACK_Association.h delete mode 100644 ACE/ace/SOCK_SEQPACK_Association.inl delete mode 100644 ACE/ace/SOCK_SEQPACK_Connector.cpp delete mode 100644 ACE/ace/SOCK_SEQPACK_Connector.h delete mode 100644 ACE/ace/SOCK_SEQPACK_Connector.inl delete mode 100644 ACE/ace/SOCK_Stream.cpp delete mode 100644 ACE/ace/SOCK_Stream.h delete mode 100644 ACE/ace/SOCK_Stream.inl delete mode 100644 ACE/ace/SPIPE.cpp delete mode 100644 ACE/ace/SPIPE.h delete mode 100644 ACE/ace/SPIPE.inl delete mode 100644 ACE/ace/SPIPE_Acceptor.cpp delete mode 100644 ACE/ace/SPIPE_Acceptor.h delete mode 100644 ACE/ace/SPIPE_Addr.cpp delete mode 100644 ACE/ace/SPIPE_Addr.h delete mode 100644 ACE/ace/SPIPE_Addr.inl delete mode 100644 ACE/ace/SPIPE_Connector.cpp delete mode 100644 ACE/ace/SPIPE_Connector.h delete mode 100644 ACE/ace/SPIPE_Connector.inl delete mode 100644 ACE/ace/SPIPE_Stream.cpp delete mode 100644 ACE/ace/SPIPE_Stream.h delete mode 100644 ACE/ace/SPIPE_Stream.inl delete mode 100644 ACE/ace/SSL/ACE_SSL.pc.in delete mode 100644 ACE/ace/SSL/Makefile.am delete mode 100644 ACE/ace/SSL/SSL_Asynch_BIO.cpp delete mode 100644 ACE/ace/SSL/SSL_Asynch_BIO.h delete mode 100644 ACE/ace/SSL/SSL_Asynch_Stream.cpp delete mode 100644 ACE/ace/SSL/SSL_Asynch_Stream.h delete mode 100644 ACE/ace/SSL/SSL_Context.cpp delete mode 100644 ACE/ace/SSL/SSL_Context.h delete mode 100644 ACE/ace/SSL/SSL_Context.inl delete mode 100644 ACE/ace/SSL/SSL_Export.h delete mode 100644 ACE/ace/SSL/SSL_SOCK.cpp delete mode 100644 ACE/ace/SSL/SSL_SOCK.h delete mode 100644 ACE/ace/SSL/SSL_SOCK.inl delete mode 100644 ACE/ace/SSL/SSL_SOCK_Acceptor.cpp delete mode 100644 ACE/ace/SSL/SSL_SOCK_Acceptor.h delete mode 100644 ACE/ace/SSL/SSL_SOCK_Acceptor.inl delete mode 100644 ACE/ace/SSL/SSL_SOCK_Connector.cpp delete mode 100644 ACE/ace/SSL/SSL_SOCK_Connector.h delete mode 100644 ACE/ace/SSL/SSL_SOCK_Connector.inl delete mode 100644 ACE/ace/SSL/SSL_SOCK_Stream.cpp delete mode 100644 ACE/ace/SSL/SSL_SOCK_Stream.h delete mode 100644 ACE/ace/SSL/SSL_SOCK_Stream.inl delete mode 100644 ACE/ace/SSL/ssl.mpc delete mode 100644 ACE/ace/SSL/ssl_for_tao.mpc delete mode 100644 ACE/ace/SSL/sslconf.h delete mode 100644 ACE/ace/SString.cpp delete mode 100644 ACE/ace/SString.h delete mode 100644 ACE/ace/SString.inl delete mode 100644 ACE/ace/SStringfwd.h delete mode 100644 ACE/ace/SUN_Proactor.cpp delete mode 100644 ACE/ace/SUN_Proactor.h delete mode 100644 ACE/ace/SV_Message.cpp delete mode 100644 ACE/ace/SV_Message.h delete mode 100644 ACE/ace/SV_Message.inl delete mode 100644 ACE/ace/SV_Message_Queue.cpp delete mode 100644 ACE/ace/SV_Message_Queue.h delete mode 100644 ACE/ace/SV_Message_Queue.inl delete mode 100644 ACE/ace/SV_Semaphore_Complex.cpp delete mode 100644 ACE/ace/SV_Semaphore_Complex.h delete mode 100644 ACE/ace/SV_Semaphore_Complex.inl delete mode 100644 ACE/ace/SV_Semaphore_Simple.cpp delete mode 100644 ACE/ace/SV_Semaphore_Simple.h delete mode 100644 ACE/ace/SV_Semaphore_Simple.inl delete mode 100644 ACE/ace/SV_Shared_Memory.cpp delete mode 100644 ACE/ace/SV_Shared_Memory.h delete mode 100644 ACE/ace/SV_Shared_Memory.inl delete mode 100644 ACE/ace/Sample_History.cpp delete mode 100644 ACE/ace/Sample_History.h delete mode 100644 ACE/ace/Sample_History.inl delete mode 100644 ACE/ace/Sbrk_Memory_Pool.cpp delete mode 100644 ACE/ace/Sbrk_Memory_Pool.h delete mode 100644 ACE/ace/Sched_Params.cpp delete mode 100644 ACE/ace/Sched_Params.h delete mode 100644 ACE/ace/Sched_Params.inl delete mode 100644 ACE/ace/Select_Reactor.h delete mode 100644 ACE/ace/Select_Reactor_Base.cpp delete mode 100644 ACE/ace/Select_Reactor_Base.h delete mode 100644 ACE/ace/Select_Reactor_Base.inl delete mode 100644 ACE/ace/Select_Reactor_T.cpp delete mode 100644 ACE/ace/Select_Reactor_T.h delete mode 100644 ACE/ace/Select_Reactor_T.inl delete mode 100644 ACE/ace/Semaphore.cpp delete mode 100644 ACE/ace/Semaphore.h delete mode 100644 ACE/ace/Semaphore.inl delete mode 100644 ACE/ace/Service_Config.cpp delete mode 100644 ACE/ace/Service_Config.h delete mode 100644 ACE/ace/Service_Config.inl delete mode 100644 ACE/ace/Service_Gestalt.cpp delete mode 100644 ACE/ace/Service_Gestalt.h delete mode 100644 ACE/ace/Service_Gestalt.inl delete mode 100644 ACE/ace/Service_Manager.cpp delete mode 100644 ACE/ace/Service_Manager.h delete mode 100644 ACE/ace/Service_Object.cpp delete mode 100644 ACE/ace/Service_Object.h delete mode 100644 ACE/ace/Service_Object.inl delete mode 100644 ACE/ace/Service_Repository.cpp delete mode 100644 ACE/ace/Service_Repository.h delete mode 100644 ACE/ace/Service_Repository.inl delete mode 100644 ACE/ace/Service_Templates.h delete mode 100644 ACE/ace/Service_Types.cpp delete mode 100644 ACE/ace/Service_Types.h delete mode 100644 ACE/ace/Service_Types.inl delete mode 100644 ACE/ace/Shared_Memory.cpp delete mode 100644 ACE/ace/Shared_Memory.h delete mode 100644 ACE/ace/Shared_Memory_MM.cpp delete mode 100644 ACE/ace/Shared_Memory_MM.h delete mode 100644 ACE/ace/Shared_Memory_MM.inl delete mode 100644 ACE/ace/Shared_Memory_Pool.cpp delete mode 100644 ACE/ace/Shared_Memory_Pool.h delete mode 100644 ACE/ace/Shared_Memory_SV.cpp delete mode 100644 ACE/ace/Shared_Memory_SV.h delete mode 100644 ACE/ace/Shared_Memory_SV.inl delete mode 100644 ACE/ace/Shared_Object.cpp delete mode 100644 ACE/ace/Shared_Object.h delete mode 100644 ACE/ace/Shared_Object.inl delete mode 100644 ACE/ace/Sig_Adapter.cpp delete mode 100644 ACE/ace/Sig_Adapter.h delete mode 100644 ACE/ace/Sig_Handler.cpp delete mode 100644 ACE/ace/Sig_Handler.h delete mode 100644 ACE/ace/Sig_Handler.inl delete mode 100644 ACE/ace/Signal.cpp delete mode 100644 ACE/ace/Signal.h delete mode 100644 ACE/ace/Signal.inl delete mode 100644 ACE/ace/Singleton.cpp delete mode 100644 ACE/ace/Singleton.h delete mode 100644 ACE/ace/Singleton.inl delete mode 100644 ACE/ace/Sock_Connect.cpp delete mode 100644 ACE/ace/Sock_Connect.h delete mode 100644 ACE/ace/Static_Object_Lock.h delete mode 100644 ACE/ace/Stats.cpp delete mode 100644 ACE/ace/Stats.h delete mode 100644 ACE/ace/Stats.inl delete mode 100644 ACE/ace/Strategies.h delete mode 100644 ACE/ace/Strategies_T.cpp delete mode 100644 ACE/ace/Strategies_T.h delete mode 100644 ACE/ace/Strategies_T.inl delete mode 100644 ACE/ace/Stream.cpp delete mode 100644 ACE/ace/Stream.h delete mode 100644 ACE/ace/Stream.inl delete mode 100644 ACE/ace/Stream_Modules.cpp delete mode 100644 ACE/ace/Stream_Modules.h delete mode 100644 ACE/ace/String_Base.cpp delete mode 100644 ACE/ace/String_Base.h delete mode 100644 ACE/ace/String_Base.inl delete mode 100644 ACE/ace/String_Base_Const.cpp delete mode 100644 ACE/ace/String_Base_Const.h delete mode 100644 ACE/ace/Svc_Conf.h delete mode 100644 ACE/ace/Svc_Conf.y delete mode 100644 ACE/ace/Svc_Conf_Lexer.cpp delete mode 100644 ACE/ace/Svc_Conf_Lexer.h delete mode 100644 ACE/ace/Svc_Conf_Param.h delete mode 100644 ACE/ace/Svc_Conf_Tokens.h delete mode 100644 ACE/ace/Svc_Conf_y.cpp delete mode 100644 ACE/ace/Svc_Handler.cpp delete mode 100644 ACE/ace/Svc_Handler.h delete mode 100644 ACE/ace/Synch.h delete mode 100644 ACE/ace/Synch_Options.cpp delete mode 100644 ACE/ace/Synch_Options.h delete mode 100644 ACE/ace/Synch_T.cpp delete mode 100644 ACE/ace/Synch_T.h delete mode 100644 ACE/ace/Synch_Traits.h delete mode 100644 ACE/ace/System_Time.cpp delete mode 100644 ACE/ace/System_Time.h delete mode 100644 ACE/ace/TLI.cpp delete mode 100644 ACE/ace/TLI.h delete mode 100644 ACE/ace/TLI.inl delete mode 100644 ACE/ace/TLI_Acceptor.cpp delete mode 100644 ACE/ace/TLI_Acceptor.h delete mode 100644 ACE/ace/TLI_Connector.cpp delete mode 100644 ACE/ace/TLI_Connector.h delete mode 100644 ACE/ace/TLI_Connector.inl delete mode 100644 ACE/ace/TLI_Stream.cpp delete mode 100644 ACE/ace/TLI_Stream.h delete mode 100644 ACE/ace/TLI_Stream.inl delete mode 100644 ACE/ace/TP_Reactor.cpp delete mode 100644 ACE/ace/TP_Reactor.h delete mode 100644 ACE/ace/TP_Reactor.inl delete mode 100644 ACE/ace/TSS_Adapter.cpp delete mode 100644 ACE/ace/TSS_Adapter.h delete mode 100644 ACE/ace/TSS_T.cpp delete mode 100644 ACE/ace/TSS_T.h delete mode 100644 ACE/ace/TSS_T.inl delete mode 100644 ACE/ace/TTY_IO.cpp delete mode 100644 ACE/ace/TTY_IO.h delete mode 100644 ACE/ace/Task.cpp delete mode 100644 ACE/ace/Task.h delete mode 100644 ACE/ace/Task.inl delete mode 100644 ACE/ace/Task_Ex_T.cpp delete mode 100644 ACE/ace/Task_Ex_T.h delete mode 100644 ACE/ace/Task_Ex_T.inl delete mode 100644 ACE/ace/Task_T.cpp delete mode 100644 ACE/ace/Task_T.h delete mode 100644 ACE/ace/Task_T.inl delete mode 100644 ACE/ace/Test_and_Set.cpp delete mode 100644 ACE/ace/Test_and_Set.h delete mode 100644 ACE/ace/Thread.cpp delete mode 100644 ACE/ace/Thread.h delete mode 100644 ACE/ace/Thread.inl delete mode 100644 ACE/ace/Thread_Adapter.cpp delete mode 100644 ACE/ace/Thread_Adapter.h delete mode 100644 ACE/ace/Thread_Adapter.inl delete mode 100644 ACE/ace/Thread_Control.cpp delete mode 100644 ACE/ace/Thread_Control.h delete mode 100644 ACE/ace/Thread_Control.inl delete mode 100644 ACE/ace/Thread_Exit.cpp delete mode 100644 ACE/ace/Thread_Exit.h delete mode 100644 ACE/ace/Thread_Hook.cpp delete mode 100644 ACE/ace/Thread_Hook.h delete mode 100644 ACE/ace/Thread_Manager.cpp delete mode 100644 ACE/ace/Thread_Manager.h delete mode 100644 ACE/ace/Thread_Manager.inl delete mode 100644 ACE/ace/Thread_Mutex.cpp delete mode 100644 ACE/ace/Thread_Mutex.h delete mode 100644 ACE/ace/Thread_Mutex.inl delete mode 100644 ACE/ace/Thread_Semaphore.cpp delete mode 100644 ACE/ace/Thread_Semaphore.h delete mode 100644 ACE/ace/Thread_Semaphore.inl delete mode 100644 ACE/ace/Throughput_Stats.cpp delete mode 100644 ACE/ace/Throughput_Stats.h delete mode 100644 ACE/ace/Time_Value.cpp delete mode 100644 ACE/ace/Time_Value.h delete mode 100644 ACE/ace/Time_Value.inl delete mode 100644 ACE/ace/Timeprobe.cpp delete mode 100644 ACE/ace/Timeprobe.h delete mode 100644 ACE/ace/Timeprobe.inl delete mode 100644 ACE/ace/Timeprobe_T.cpp delete mode 100644 ACE/ace/Timeprobe_T.h delete mode 100644 ACE/ace/Timer_Hash.h delete mode 100644 ACE/ace/Timer_Hash_T.cpp delete mode 100644 ACE/ace/Timer_Hash_T.h delete mode 100644 ACE/ace/Timer_Heap.h delete mode 100644 ACE/ace/Timer_Heap_T.cpp delete mode 100644 ACE/ace/Timer_Heap_T.h delete mode 100644 ACE/ace/Timer_List.h delete mode 100644 ACE/ace/Timer_List_T.cpp delete mode 100644 ACE/ace/Timer_List_T.h delete mode 100644 ACE/ace/Timer_Queue.h delete mode 100644 ACE/ace/Timer_Queue_Adapters.cpp delete mode 100644 ACE/ace/Timer_Queue_Adapters.h delete mode 100644 ACE/ace/Timer_Queue_Adapters.inl delete mode 100644 ACE/ace/Timer_Queue_T.cpp delete mode 100644 ACE/ace/Timer_Queue_T.h delete mode 100644 ACE/ace/Timer_Queue_T.inl delete mode 100644 ACE/ace/Timer_Queuefwd.h delete mode 100644 ACE/ace/Timer_Wheel.h delete mode 100644 ACE/ace/Timer_Wheel_T.cpp delete mode 100644 ACE/ace/Timer_Wheel_T.h delete mode 100644 ACE/ace/TkReactor/ACE_TkReactor.pc.in delete mode 100644 ACE/ace/TkReactor/ACE_TkReactor_export.h delete mode 100644 ACE/ace/TkReactor/TkReactor.cpp delete mode 100644 ACE/ace/TkReactor/TkReactor.h delete mode 100644 ACE/ace/Token.cpp delete mode 100644 ACE/ace/Token.h delete mode 100644 ACE/ace/Token.inl delete mode 100644 ACE/ace/Token_Collection.cpp delete mode 100644 ACE/ace/Token_Collection.h delete mode 100644 ACE/ace/Token_Collection.inl delete mode 100644 ACE/ace/Token_Invariants.cpp delete mode 100644 ACE/ace/Token_Invariants.h delete mode 100644 ACE/ace/Token_Manager.cpp delete mode 100644 ACE/ace/Token_Manager.h delete mode 100644 ACE/ace/Token_Manager.inl delete mode 100644 ACE/ace/Token_Request_Reply.cpp delete mode 100644 ACE/ace/Token_Request_Reply.h delete mode 100644 ACE/ace/Token_Request_Reply.inl delete mode 100644 ACE/ace/Trace.cpp delete mode 100644 ACE/ace/Trace.h delete mode 100644 ACE/ace/Truncate.h delete mode 100644 ACE/ace/Typed_SV_Message.cpp delete mode 100644 ACE/ace/Typed_SV_Message.h delete mode 100644 ACE/ace/Typed_SV_Message.inl delete mode 100644 ACE/ace/Typed_SV_Message_Queue.cpp delete mode 100644 ACE/ace/Typed_SV_Message_Queue.h delete mode 100644 ACE/ace/Typed_SV_Message_Queue.inl delete mode 100644 ACE/ace/UNIX_Addr.cpp delete mode 100644 ACE/ace/UNIX_Addr.h delete mode 100644 ACE/ace/UNIX_Addr.inl delete mode 100644 ACE/ace/UPIPE_Acceptor.cpp delete mode 100644 ACE/ace/UPIPE_Acceptor.h delete mode 100644 ACE/ace/UPIPE_Acceptor.inl delete mode 100644 ACE/ace/UPIPE_Addr.h delete mode 100644 ACE/ace/UPIPE_Connector.cpp delete mode 100644 ACE/ace/UPIPE_Connector.h delete mode 100644 ACE/ace/UPIPE_Connector.inl delete mode 100644 ACE/ace/UPIPE_Stream.cpp delete mode 100644 ACE/ace/UPIPE_Stream.h delete mode 100644 ACE/ace/UPIPE_Stream.inl delete mode 100644 ACE/ace/UTF16_Encoding_Converter.cpp delete mode 100644 ACE/ace/UTF16_Encoding_Converter.h delete mode 100644 ACE/ace/UTF16_Encoding_Converter.inl delete mode 100644 ACE/ace/UTF32_Encoding_Converter.cpp delete mode 100644 ACE/ace/UTF32_Encoding_Converter.h delete mode 100644 ACE/ace/UTF8_Encoding_Converter.cpp delete mode 100644 ACE/ace/UTF8_Encoding_Converter.h delete mode 100644 ACE/ace/UUID.cpp delete mode 100644 ACE/ace/UUID.h delete mode 100644 ACE/ace/UUID.inl delete mode 100644 ACE/ace/Unbounded_Queue.cpp delete mode 100644 ACE/ace/Unbounded_Queue.h delete mode 100644 ACE/ace/Unbounded_Queue.inl delete mode 100644 ACE/ace/Unbounded_Set.cpp delete mode 100644 ACE/ace/Unbounded_Set.h delete mode 100644 ACE/ace/Unbounded_Set.inl delete mode 100644 ACE/ace/Value_Ptr.h delete mode 100644 ACE/ace/Vector_T.cpp delete mode 100644 ACE/ace/Vector_T.h delete mode 100644 ACE/ace/Vector_T.inl delete mode 100644 ACE/ace/Version.h delete mode 100644 ACE/ace/Versioned_Namespace.h delete mode 100644 ACE/ace/WFMO_Reactor.cpp delete mode 100644 ACE/ace/WFMO_Reactor.h delete mode 100644 ACE/ace/WFMO_Reactor.inl delete mode 100644 ACE/ace/WIN32_Asynch_IO.cpp delete mode 100644 ACE/ace/WIN32_Asynch_IO.h delete mode 100644 ACE/ace/WIN32_Proactor.cpp delete mode 100644 ACE/ace/WIN32_Proactor.h delete mode 100644 ACE/ace/XML_Svc_Conf.cpp delete mode 100644 ACE/ace/XML_Svc_Conf.h delete mode 100644 ACE/ace/XTI_ATM_Mcast.cpp delete mode 100644 ACE/ace/XTI_ATM_Mcast.h delete mode 100644 ACE/ace/XTI_ATM_Mcast.inl delete mode 100644 ACE/ace/XtReactor/ACE_XtReactor.pc.in delete mode 100644 ACE/ace/XtReactor/ACE_XtReactor_export.h delete mode 100644 ACE/ace/XtReactor/XtReactor.cpp delete mode 100644 ACE/ace/XtReactor/XtReactor.h delete mode 100644 ACE/ace/ace.mpc delete mode 100644 ACE/ace/ace.mwc delete mode 100644 ACE/ace/ace.rc delete mode 100644 ACE/ace/ace_ce_dll.cfg delete mode 100644 ACE/ace/ace_flreactor.mpc delete mode 100644 ACE/ace/ace_for_tao.mpc delete mode 100644 ACE/ace/ace_foxreactor.mpc delete mode 100644 ACE/ace/ace_message_table.bin delete mode 100644 ACE/ace/ace_qtreactor.mpc delete mode 100644 ACE/ace/ace_tkreactor.mpc delete mode 100644 ACE/ace/ace_wchar.cpp delete mode 100644 ACE/ace/ace_wchar.h delete mode 100644 ACE/ace/ace_wchar.inl delete mode 100644 ACE/ace/ace_xtreactor.mpc delete mode 100644 ACE/ace/checked_iterator.h delete mode 100644 ACE/ace/codecs.mpb delete mode 100644 ACE/ace/config-WinCE.h delete mode 100644 ACE/ace/config-aix-5.x.h delete mode 100644 ACE/ace/config-all.h delete mode 100644 ACE/ace/config-borland-common.h delete mode 100644 ACE/ace/config-cray.h delete mode 100644 ACE/ace/config-cxx-common.h delete mode 100644 ACE/ace/config-cygwin32.h delete mode 100644 ACE/ace/config-doxygen.h delete mode 100644 ACE/ace/config-freebsd.h delete mode 100644 ACE/ace/config-g++-common.h delete mode 100644 ACE/ace/config-ghs-common.h delete mode 100644 ACE/ace/config-hpux-11.00.h delete mode 100644 ACE/ace/config-icc-common.h delete mode 100644 ACE/ace/config-integritySCA.h delete mode 100644 ACE/ace/config-irix6.5.x-sgic++.h delete mode 100644 ACE/ace/config-irix6.x-common.h delete mode 100644 ACE/ace/config-irix6.x-g++.h delete mode 100644 ACE/ace/config-irix6.x-sgic++.h delete mode 100644 ACE/ace/config-linux-common.h delete mode 100644 ACE/ace/config-linux.h delete mode 100644 ACE/ace/config-lite.h delete mode 100644 ACE/ace/config-lynxos.h delete mode 100644 ACE/ace/config-macosx-leopard.h delete mode 100644 ACE/ace/config-macosx-panther.h delete mode 100644 ACE/ace/config-macosx-tiger.h delete mode 100644 ACE/ace/config-macosx.h delete mode 100644 ACE/ace/config-macros.h delete mode 100644 ACE/ace/config-minimal.h delete mode 100644 ACE/ace/config-mvs.h delete mode 100644 ACE/ace/config-netbsd.h delete mode 100644 ACE/ace/config-openbsd.h delete mode 100644 ACE/ace/config-openvms.h delete mode 100644 ACE/ace/config-pharlap.h delete mode 100644 ACE/ace/config-posix-nonetworking.h delete mode 100644 ACE/ace/config-posix.h delete mode 100644 ACE/ace/config-qnx-neutrino.h delete mode 100644 ACE/ace/config-qnx-rtp-62x.h delete mode 100644 ACE/ace/config-qnx-rtp-common.h delete mode 100644 ACE/ace/config-qnx-rtp-pre62x.h delete mode 100644 ACE/ace/config-qnx-rtp.h delete mode 100644 ACE/ace/config-rtems.h delete mode 100644 ACE/ace/config-sco-5.0.0-nothread.h delete mode 100644 ACE/ace/config-sco-5.0.0.h delete mode 100644 ACE/ace/config-suncc-common.h delete mode 100644 ACE/ace/config-sunos5.10.h delete mode 100644 ACE/ace/config-sunos5.11.h delete mode 100644 ACE/ace/config-sunos5.4-g++.h delete mode 100644 ACE/ace/config-sunos5.4-sunc++-4.x.h delete mode 100644 ACE/ace/config-sunos5.5.h delete mode 100644 ACE/ace/config-sunos5.6.h delete mode 100644 ACE/ace/config-sunos5.7.h delete mode 100644 ACE/ace/config-sunos5.8.h delete mode 100644 ACE/ace/config-sunos5.9.h delete mode 100644 ACE/ace/config-tandem-nsk-mips-v2.h delete mode 100644 ACE/ace/config-tandem-nsk-mips-v3.h delete mode 100644 ACE/ace/config-tandem.h delete mode 100644 ACE/ace/config-tru64.h delete mode 100644 ACE/ace/config-unixware-7.1.0.h delete mode 100644 ACE/ace/config-unixware-7.1.0.udk.h delete mode 100644 ACE/ace/config-visualage.h delete mode 100644 ACE/ace/config-vxworks.h delete mode 100644 ACE/ace/config-vxworks5.x.h delete mode 100644 ACE/ace/config-vxworks6.2.h delete mode 100644 ACE/ace/config-vxworks6.3.h delete mode 100644 ACE/ace/config-vxworks6.4.h delete mode 100644 ACE/ace/config-vxworks6.5.h delete mode 100644 ACE/ace/config-vxworks6.6.h delete mode 100644 ACE/ace/config-win32-borland.h delete mode 100644 ACE/ace/config-win32-common.h delete mode 100644 ACE/ace/config-win32-dmc.h delete mode 100644 ACE/ace/config-win32-ghs.h delete mode 100644 ACE/ace/config-win32-interix.h delete mode 100644 ACE/ace/config-win32-mingw.h delete mode 100644 ACE/ace/config-win32-msvc-7.h delete mode 100644 ACE/ace/config-win32-msvc-8.h delete mode 100644 ACE/ace/config-win32-msvc-9.h delete mode 100644 ACE/ace/config-win32-msvc.h delete mode 100644 ACE/ace/config-win32.h delete mode 100644 ACE/ace/filecache.mpb delete mode 100644 ACE/ace/gethrtime.cpp delete mode 100644 ACE/ace/iosfwd.h delete mode 100644 ACE/ace/os_include/arpa/os_inet.h delete mode 100644 ACE/ace/os_include/net/os_if.h delete mode 100644 ACE/ace/os_include/netinet/os_in.h delete mode 100644 ACE/ace/os_include/netinet/os_tcp.h delete mode 100644 ACE/ace/os_include/os_aio.h delete mode 100644 ACE/ace/os_include/os_assert.h delete mode 100644 ACE/ace/os_include/os_byteswap.h delete mode 100644 ACE/ace/os_include/os_complex.h delete mode 100644 ACE/ace/os_include/os_cpio.h delete mode 100644 ACE/ace/os_include/os_ctype.h delete mode 100644 ACE/ace/os_include/os_dirent.h delete mode 100644 ACE/ace/os_include/os_dlfcn.h delete mode 100644 ACE/ace/os_include/os_errno.h delete mode 100644 ACE/ace/os_include/os_fcntl.h delete mode 100644 ACE/ace/os_include/os_fenv.h delete mode 100644 ACE/ace/os_include/os_float.h delete mode 100644 ACE/ace/os_include/os_fmtmsg.h delete mode 100644 ACE/ace/os_include/os_fnmatch.h delete mode 100644 ACE/ace/os_include/os_ftw.h delete mode 100644 ACE/ace/os_include/os_glob.h delete mode 100644 ACE/ace/os_include/os_grp.h delete mode 100644 ACE/ace/os_include/os_iconv.h delete mode 100644 ACE/ace/os_include/os_intrin.h delete mode 100644 ACE/ace/os_include/os_inttypes.h delete mode 100644 ACE/ace/os_include/os_iso646.h delete mode 100644 ACE/ace/os_include/os_langinfo.h delete mode 100644 ACE/ace/os_include/os_libgen.h delete mode 100644 ACE/ace/os_include/os_limits.h delete mode 100644 ACE/ace/os_include/os_local.h delete mode 100644 ACE/ace/os_include/os_math.h delete mode 100644 ACE/ace/os_include/os_monetary.h delete mode 100644 ACE/ace/os_include/os_mqueue.h delete mode 100644 ACE/ace/os_include/os_ndbm.h delete mode 100644 ACE/ace/os_include/os_netdb.h delete mode 100644 ACE/ace/os_include/os_nl_types.h delete mode 100644 ACE/ace/os_include/os_poll.h delete mode 100644 ACE/ace/os_include/os_pthread.h delete mode 100644 ACE/ace/os_include/os_pwd.h delete mode 100644 ACE/ace/os_include/os_regex.h delete mode 100644 ACE/ace/os_include/os_sched.h delete mode 100644 ACE/ace/os_include/os_search.h delete mode 100644 ACE/ace/os_include/os_semaphore.h delete mode 100644 ACE/ace/os_include/os_setjmp.h delete mode 100644 ACE/ace/os_include/os_signal.h delete mode 100644 ACE/ace/os_include/os_spawn.h delete mode 100644 ACE/ace/os_include/os_stdarg.h delete mode 100644 ACE/ace/os_include/os_stdbool.h delete mode 100644 ACE/ace/os_include/os_stddef.h delete mode 100644 ACE/ace/os_include/os_stdint.h delete mode 100644 ACE/ace/os_include/os_stdio.h delete mode 100644 ACE/ace/os_include/os_stdlib.h delete mode 100644 ACE/ace/os_include/os_string.h delete mode 100644 ACE/ace/os_include/os_strings.h delete mode 100644 ACE/ace/os_include/os_stropts.h delete mode 100644 ACE/ace/os_include/os_syslog.h delete mode 100644 ACE/ace/os_include/os_tar.h delete mode 100644 ACE/ace/os_include/os_termios.h delete mode 100644 ACE/ace/os_include/os_tgmath.h delete mode 100644 ACE/ace/os_include/os_time.h delete mode 100644 ACE/ace/os_include/os_trace.h delete mode 100644 ACE/ace/os_include/os_ucontext.h delete mode 100644 ACE/ace/os_include/os_ulimit.h delete mode 100644 ACE/ace/os_include/os_unistd.h delete mode 100644 ACE/ace/os_include/os_utime.h delete mode 100644 ACE/ace/os_include/os_utmpx.h delete mode 100644 ACE/ace/os_include/os_wchar.h delete mode 100644 ACE/ace/os_include/os_wctype.h delete mode 100644 ACE/ace/os_include/os_wordexp.h delete mode 100644 ACE/ace/os_include/sys/os_ipc.h delete mode 100644 ACE/ace/os_include/sys/os_loadavg.h delete mode 100644 ACE/ace/os_include/sys/os_mman.h delete mode 100644 ACE/ace/os_include/sys/os_msg.h delete mode 100644 ACE/ace/os_include/sys/os_pstat.h delete mode 100644 ACE/ace/os_include/sys/os_resource.h delete mode 100644 ACE/ace/os_include/sys/os_select.h delete mode 100644 ACE/ace/os_include/sys/os_sem.h delete mode 100644 ACE/ace/os_include/sys/os_shm.h delete mode 100644 ACE/ace/os_include/sys/os_socket.h delete mode 100644 ACE/ace/os_include/sys/os_stat.h delete mode 100644 ACE/ace/os_include/sys/os_statvfs.h delete mode 100644 ACE/ace/os_include/sys/os_sysctl.h delete mode 100644 ACE/ace/os_include/sys/os_time.h delete mode 100644 ACE/ace/os_include/sys/os_timeb.h delete mode 100644 ACE/ace/os_include/sys/os_times.h delete mode 100644 ACE/ace/os_include/sys/os_types.h delete mode 100644 ACE/ace/os_include/sys/os_uio.h delete mode 100644 ACE/ace/os_include/sys/os_un.h delete mode 100644 ACE/ace/os_include/sys/os_utsname.h delete mode 100644 ACE/ace/os_include/sys/os_wait.h delete mode 100644 ACE/ace/other.mpb delete mode 100644 ACE/ace/post.h delete mode 100644 ACE/ace/pre.h delete mode 100644 ACE/ace/streams.h delete mode 100644 ACE/ace/svc_export.h delete mode 100644 ACE/ace/svcconf.mpb delete mode 100644 ACE/ace/token.mpb delete mode 100644 ACE/ace/uuid.mpb (limited to 'ACE/ace') diff --git a/ACE/ace/ACE.cpp b/ACE/ace/ACE.cpp deleted file mode 100644 index 233ef720f4c..00000000000 --- a/ACE/ace/ACE.cpp +++ /dev/null @@ -1,3409 +0,0 @@ -// $Id$ - -#include "ace/ACE.h" - -#include "ace/Basic_Types.h" -#include "ace/Handle_Set.h" -#include "ace/Auto_Ptr.h" -#include "ace/SString.h" -#include "ace/Version.h" -#include "ace/Message_Block.h" -#include "ace/Log_Msg.h" -#include "ace/OS_NS_sys_select.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_strings.h" -#include "ace/OS_NS_signal.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_sys_resource.h" -#include "ace/OS_NS_sys_wait.h" -#include "ace/OS_NS_sys_time.h" -#include "ace/OS_NS_time.h" -#include "ace/OS_NS_sys_uio.h" -#include "ace/OS_NS_sys_stat.h" -#include "ace/OS_NS_ctype.h" -#include "ace/OS_TLI.h" -#include "ace/Truncate.h" - -#if defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x620) -extern "C" int maxFiles; -#endif /* ACE_VXWORKS */ - -#if !defined (__ACE_INLINE__) -#include "ace/ACE.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) -# include "ace/OS_NS_poll.h" -#endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ - - -ACE_RCSID (ace, - ACE, - "$Id$") - - -// Open versioned namespace, if enabled by the user. - ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -namespace ACE -{ - // private: - // Used internally so not exported. - - // Size of allocation granularity. - size_t allocation_granularity_ = 0; - - // Size of a VM page. - size_t pagesize_ = 0; - - // Are we debugging ACE? - // Keeps track of whether we're in some global debug mode. - char debug_; -} - - -int -ACE::out_of_handles (int error) -{ - // EMFILE is common to all platforms. - if (error == EMFILE || -#if defined (ACE_WIN32) - // On Win32, we need to check for ENOBUFS also. - error == ENOBUFS || -#elif defined (HPUX) - // On HPUX, we need to check for EADDRNOTAVAIL also. - error == EADDRNOTAVAIL || -#elif defined (linux) - // On linux, we need to check for ENOENT also. - error == ENOENT || - // For RedHat5.2, need to check for EINVAL too. - error == EINVAL || - // Without threads check for EOPNOTSUPP - error == EOPNOTSUPP || -#elif defined (sun) - // On sun, we need to check for ENOSR also. - error == ENOSR || - // Without threads check for ENOTSUP - error == ENOTSUP || -#elif defined (__FreeBSD__) - // On FreeBSD we need to check for EOPNOTSUPP (LinuxThreads) or - // ENOSYS (libc_r threads) also. - error == EOPNOTSUPP || - error == ENOSYS || -#elif defined (__OpenBSD__) - // OpenBSD appears to return EBADF. - error == EBADF || -#elif defined (__sgi) // irix - error == ENOTSUP || -#elif defined (DIGITAL_UNIX) // osf1 - error == ENOTSUP || -#endif /* ACE_WIN32 */ - error == ENFILE) - return 1; - else - return 0; -} - -u_int -ACE::major_version (void) -{ - return ACE_MAJOR_VERSION; -} - -u_int -ACE::minor_version (void) -{ - return ACE_MINOR_VERSION; -} - -u_int -ACE::beta_version (void) -{ - return ACE_BETA_VERSION; -} - -const ACE_TCHAR * -ACE::compiler_name (void) -{ -#ifdef ACE_CC_NAME - return ACE_CC_NAME; -#else - return ACE_TEXT (""); -#endif -} - -u_int -ACE::compiler_major_version (void) -{ -#ifdef ACE_CC_MAJOR_VERSION - return ACE_CC_MAJOR_VERSION; -#else - return 0; -#endif -} - -u_int -ACE::compiler_minor_version (void) -{ -#ifdef ACE_CC_MINOR_VERSION - return ACE_CC_MINOR_VERSION; -#else - return 0; -#endif -} - -u_int -ACE::compiler_beta_version (void) -{ -#ifdef ACE_CC_BETA_VERSION - return ACE_CC_BETA_VERSION; -#else - return 0; -#endif -} - -bool -ACE::debug (void) -{ - static const char* debug = ACE_OS::getenv ("ACE_DEBUG"); - return (ACE::debug_ != 0) ? ACE::debug_ : (debug != 0 ? (*debug != '0'): false); -} - -void -ACE::debug (bool onoff) -{ - ACE::debug_ = onoff; -} - -int -ACE::select (int width, - ACE_Handle_Set *readfds, - ACE_Handle_Set *writefds, - ACE_Handle_Set *exceptfds, - const ACE_Time_Value *timeout) -{ - int result = ACE_OS::select (width, - readfds ? readfds->fdset () : 0, - writefds ? writefds->fdset () : 0, - exceptfds ? exceptfds->fdset () : 0, - timeout); - if (result > 0) - { -# if !defined (ACE_WIN32) - // This isn't needed for Windows... it's a no-op anyway. - if (readfds) - readfds->sync ((ACE_HANDLE) width); - if (writefds) - writefds->sync ((ACE_HANDLE) width); - if (exceptfds) - exceptfds->sync ((ACE_HANDLE) width); -#endif /* ACE_WIN32 */ - } - return result; -} - -int -ACE::select (int width, - ACE_Handle_Set &readfds, - const ACE_Time_Value *timeout) -{ - int result = ACE_OS::select (width, - readfds.fdset (), - 0, - 0, - timeout); - -#if !defined (ACE_WIN32) - if (result > 0) - readfds.sync ((ACE_HANDLE) width); -#endif /* ACE_WIN32 */ - return result; -} - -int -ACE::terminate_process (pid_t pid) -{ -#if defined (ACE_HAS_PHARLAP) - ACE_UNUSED_ARG (pid); - ACE_NOTSUP_RETURN (-1); -#elif defined (ACE_WIN32) - // Create a handle for the given process id. - ACE_HANDLE process_handle = - ::OpenProcess (PROCESS_TERMINATE, - FALSE, // New handle is not inheritable. - pid); - - if (process_handle == ACE_INVALID_HANDLE - || process_handle == 0) - return -1; - else - { - // Kill the process associated with process_handle. - BOOL terminate_result = - ::TerminateProcess (process_handle, 0); - // Free up the kernel resources. - ACE_OS::close (process_handle); - return terminate_result ? 0 : -1; - } -#else - return ACE_OS::kill (pid, 9); -#endif /* ACE_HAS_PHARLAP */ -} - -int -ACE::process_active (pid_t pid) -{ -#if !defined(ACE_WIN32) - int retval = ACE_OS::kill (pid, 0); - - if (retval == 0) - return 1; - else if (errno == ESRCH) - return 0; - else - return -1; -#else - // Create a handle for the given process id. - ACE_HANDLE process_handle = - ::OpenProcess (PROCESS_QUERY_INFORMATION, FALSE, pid); - if (process_handle == ACE_INVALID_HANDLE - || process_handle == 0) - return 0; - else - { - DWORD status; - int result = 1; - if (::GetExitCodeProcess (process_handle, - &status) == 0 - || status != STILL_ACTIVE) - result = 0; - - ::CloseHandle (process_handle); - return result; - } -#endif /* !ACE_WIN32 */ -} - -const ACE_TCHAR * -ACE::execname (const ACE_TCHAR *old_name) -{ -#if defined (ACE_WIN32) - const ACE_TCHAR *suffix = ACE_OS::strrchr (old_name, ACE_TEXT ('.')); - if (suffix == 0 || ACE_OS::strcasecmp (suffix, ACE_TEXT (".exe")) != 0) - { - ACE_TCHAR *new_name; - - size_t size = - ACE_OS::strlen (old_name) - + ACE_OS::strlen (ACE_TEXT (".exe")) - + 1; - - ACE_NEW_RETURN (new_name, - ACE_TCHAR[size], - 0); - ACE_TCHAR *end = new_name; - - end = ACE_OS::strecpy (new_name, old_name); - - // Concatenate the .exe suffix onto the end of the executable. - // end points _after_ the terminating nul. - ACE_OS::strcpy (end - 1, ACE_TEXT (".exe")); - - return new_name; - } -#endif /* ACE_WIN32 */ - return old_name; -} - -u_long -ACE::hash_pjw (const char *str, size_t len) -{ - u_long hash = 0; - - for (size_t i = 0; i < len; i++) - { - const char temp = str[i]; - hash = (hash << 4) + (temp * 13); - - u_long g = hash & 0xf0000000; - - if (g) - { - hash ^= (g >> 24); - hash ^= g; - } - } - - return hash; -} - -u_long -ACE::hash_pjw (const char *str) -{ - return ACE::hash_pjw (str, ACE_OS::strlen (str)); -} - -#if defined (ACE_HAS_WCHAR) -u_long -ACE::hash_pjw (const wchar_t *str, size_t len) -{ - u_long hash = 0; - - for (size_t i = 0; i < len; i++) - { - // @@ UNICODE: Does this function do the correct thing with wchar's? - - const wchar_t temp = str[i]; - hash = (hash << 4) + (temp * 13); - - u_long g = hash & 0xf0000000; - - if (g) - { - hash ^= (g >> 24); - hash ^= g; - } - } - - return hash; -} - -u_long -ACE::hash_pjw (const wchar_t *str) -{ - return ACE::hash_pjw (str, ACE_OS::strlen (str)); -} -#endif /* ACE_HAS_WCHAR */ - -#if !defined (ACE_HAS_WINCE) -ACE_TCHAR * -ACE::strenvdup (const ACE_TCHAR *str) -{ - ACE_TRACE ("ACE::strenvdup"); - - return ACE_OS::strenvdup (str); -} -#endif /* ACE_HAS_WINCE */ - -/* - -Examples: - -Source NT UNIX -================================================================== -netsvc netsvc.dll libnetsvc.so -(PATH will be (LD_LIBRARY_PATH -evaluated) evaluated) - -libnetsvc.dll libnetsvc.dll libnetsvc.dll + warning -netsvc.so netsvc.so + warning libnetsvc.so - -..\../libs/netsvc ..\..\libs\netsvc.dll ../../libs/netsvc.so -(absolute path used) (absolute path used) - -*/ - -const ACE_TCHAR * -ACE::basename (const ACE_TCHAR *pathname, ACE_TCHAR delim) -{ - ACE_TRACE ("ACE::basename"); - const ACE_TCHAR *temp = ACE_OS::strrchr (pathname, delim); - - if (temp == 0) - return pathname; - else - return temp + 1; -} - -const ACE_TCHAR * -ACE::dirname (const ACE_TCHAR *pathname, ACE_TCHAR delim) -{ - ACE_TRACE ("ACE::dirname"); - static ACE_TCHAR return_dirname[MAXPATHLEN + 1]; - - const ACE_TCHAR *temp = ACE_OS::strrchr (pathname, delim); - - if (temp == 0) - { - return_dirname[0] = '.'; - return_dirname[1] = '\0'; - - return return_dirname; - } - else - { - // When the len is truncated, there are problems! This should - // not happen in normal circomstances - size_t len = temp - pathname + 1; - if (len > (sizeof return_dirname / sizeof (ACE_TCHAR))) - len = sizeof return_dirname / sizeof (ACE_TCHAR); - - ACE_OS::strsncpy (return_dirname, - pathname, - len); - return return_dirname; - } -} - -ssize_t -ACE::recv (ACE_HANDLE handle, - void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout) -{ - if (timeout == 0) - return ACE_OS::recv (handle, (char *) buf, len, flags); - else - { - int val = 0; - if (ACE::enter_recv_timedwait (handle, timeout, val) ==-1) - return -1; - else - { - ssize_t bytes_transferred = - ACE_OS::recv (handle, (char *) buf, len, flags); - ACE::restore_non_blocking_mode (handle, val); - return bytes_transferred; - } - } -} - -#if defined (ACE_HAS_TLI) - -ssize_t -ACE::t_rcv (ACE_HANDLE handle, - void *buf, - size_t len, - int *flags, - const ACE_Time_Value *timeout) -{ - if (timeout == 0) - return ACE_OS::t_rcv (handle, (char *) buf, len, flags); - else - { - int val = 0; - if (ACE::enter_recv_timedwait (handle, timeout, val) ==-1) - return -1; - else - { - ssize_t bytes_transferred = - ACE_OS::t_rcv (handle, (char *) buf, len, flags); - ACE::restore_non_blocking_mode (handle, val); - return bytes_transferred; - } - } -} - -#endif /* ACE_HAS_TLI */ - -ssize_t -ACE::recv (ACE_HANDLE handle, - void *buf, - size_t n, - const ACE_Time_Value *timeout) -{ - if (timeout == 0) - return ACE::recv_i (handle, buf, n); - else - { - int val = 0; - if (ACE::enter_recv_timedwait (handle, timeout, val) == -1) - return -1; - else - { - ssize_t bytes_transferred = ACE::recv_i (handle, buf, n); - ACE::restore_non_blocking_mode (handle, val); - return bytes_transferred; - } - } -} - -ssize_t -ACE::recvmsg (ACE_HANDLE handle, - struct msghdr *msg, - int flags, - const ACE_Time_Value *timeout) -{ - if (timeout == 0) - return ACE_OS::recvmsg (handle, msg, flags); - else - { - int val = 0; - if (ACE::enter_recv_timedwait (handle, timeout, val) == -1) - return -1; - else - { - ssize_t bytes_transferred = ACE_OS::recvmsg (handle, msg, flags); - ACE::restore_non_blocking_mode (handle, val); - return bytes_transferred; - } - } -} - -ssize_t -ACE::recvfrom (ACE_HANDLE handle, - char *buf, - int len, - int flags, - struct sockaddr *addr, - int *addrlen, - const ACE_Time_Value *timeout) -{ - if (timeout == 0) - return ACE_OS::recvfrom (handle, buf, len, flags, addr, addrlen); - else - { - int val = 0; - if (ACE::enter_recv_timedwait (handle, timeout, val) == -1) - return -1; - else - { - ssize_t bytes_transferred = - ACE_OS::recvfrom (handle, buf, len, flags, addr, addrlen); - ACE::restore_non_blocking_mode (handle, val); - return bytes_transferred; - } - } -} - -ssize_t -ACE::recv_n_i (ACE_HANDLE handle, - void *buf, - size_t len, - int flags, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - ssize_t n; - - for (bytes_transferred = 0; - bytes_transferred < len; - bytes_transferred += n) - { - // Try to transfer as much of the remaining data as possible. - n = ACE_OS::recv (handle, - static_cast (buf) + bytes_transferred, - len - bytes_transferred, - flags); - // Check EOF. - if (n == 0) - return 0; - - // Check for other errors. - if (n == -1) - { - // Check for possible blocking. - if (errno == EWOULDBLOCK) - { - // Wait for the blocking to subside. - int result = ACE::handle_read_ready (handle, - 0); - - // Did select() succeed? - if (result != -1) - { - // Blocking subsided. Continue data transfer. - n = 0; - continue; - } - } - - // Other data transfer or select() failures. - return -1; - } - } - - return static_cast (bytes_transferred); -} - -ssize_t -ACE::recv_n_i (ACE_HANDLE handle, - void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - ssize_t n; - ssize_t result = 0; - int error = 0; - - int val = 0; - ACE::record_and_set_non_blocking_mode (handle, val); - - for (bytes_transferred = 0; - bytes_transferred < len; - bytes_transferred += n) - { - // Try to transfer as much of the remaining data as possible. - // Since the socket is in non-blocking mode, this call will not - // block. - n = ACE_OS::recv (handle, - static_cast (buf) + bytes_transferred, - len - bytes_transferred, - flags); - - // Check for errors. - if (n == 0 || - n == -1) - { - // Check for possible blocking. - if (n == -1 && - errno == EWOULDBLOCK) - { - // Wait upto for the blocking to subside. - int rtn = ACE::handle_read_ready (handle, - timeout); - - // Did select() succeed? - if (rtn != -1) - { - // Blocking subsided in period. Continue - // data transfer. - n = 0; - continue; - } - } - - // Wait in select() timed out or other data transfer or - // select() failures. - error = 1; - result = n; - break; - } - } - - ACE::restore_non_blocking_mode (handle, val); - - if (error) - return result; - else - return static_cast (bytes_transferred); -} - -#if defined (ACE_HAS_TLI) - -ssize_t -ACE::t_rcv_n_i (ACE_HANDLE handle, - void *buf, - size_t len, - int *flags, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - ssize_t n; - - for (bytes_transferred = 0; - bytes_transferred < len; - bytes_transferred += n) - { - // Try to transfer as much of the remaining data as possible. - n = ACE_OS::t_rcv (handle, - (char *) buf + bytes_transferred, - len - bytes_transferred, - flags); - // Check EOF. - if (n == 0) - return 0; - - // Check for other errors. - if (n == -1) - { - // Check for possible blocking. - if (errno == EWOULDBLOCK) - { - // Wait for the blocking to subside. - int result = ACE::handle_read_ready (handle, - 0); - - // Did select() succeed? - if (result != -1) - { - // Blocking subsided. Continue data transfer. - n = 0; - continue; - } - } - - // Other data transfer or select() failures. - return -1; - } - } - - return bytes_transferred; -} - -ssize_t -ACE::t_rcv_n_i (ACE_HANDLE handle, - void *buf, - size_t len, - int *flags, - const ACE_Time_Value *timeout, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - ssize_t n; - ssize_t result = 0; - int error = 0; - - int val = 0; - ACE::record_and_set_non_blocking_mode (handle, val); - - for (bytes_transferred = 0; - bytes_transferred < len; - bytes_transferred += n) - { - // Try to transfer as much of the remaining data as possible. - // Since the socket is in non-blocking mode, this call will not - // block. - n = ACE_OS::t_rcv (handle, - (char *) buf + bytes_transferred, - len - bytes_transferred, - flags); - - // Check for errors. - if (n == 0 || - n == -1) - { - // Check for possible blocking. - if (n == -1 && - errno == EWOULDBLOCK) - { - // Wait upto for the blocking to subside. - int rtn = ACE::handle_read_ready (handle, - timeout); - - // Did select() succeed? - if (rtn != -1) - { - // Blocking subsided in period. Continue - // data transfer. - n = 0; - continue; - } - } - - // Wait in select() timed out or other data transfer or - // select() failures. - error = 1; - result = n; - break; - } - } - - ACE::restore_non_blocking_mode (handle, val); - - if (error) - return result; - else - return bytes_transferred; -} - -#endif /* ACE_HAS_TLI */ - -ssize_t -ACE::recv_n_i (ACE_HANDLE handle, - void *buf, - size_t len, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - ssize_t n; - - for (bytes_transferred = 0; - bytes_transferred < len; - bytes_transferred += n) - { - // Try to transfer as much of the remaining data as possible. - n = ACE::recv_i (handle, - static_cast (buf) + bytes_transferred, - len - bytes_transferred); - // Check EOF. - if (n == 0) - { - return 0; - } - // Check for other errors. - if (n == -1) - { - // Check for possible blocking. - if (errno == EWOULDBLOCK) - { - // Wait for the blocking to subside. - int result = ACE::handle_read_ready (handle, - 0); - - // Did select() succeed? - if (result != -1) - { - // Blocking subsided. Continue data transfer. - n = 0; - continue; - } - } - - // Other data transfer or select() failures. - return -1; - } - } - - return static_cast (bytes_transferred); -} - -ssize_t -ACE::recv_n_i (ACE_HANDLE handle, - void *buf, - size_t len, - const ACE_Time_Value *timeout, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - ssize_t n; - ssize_t result = 0; - int error = 0; - - int val = 0; - ACE::record_and_set_non_blocking_mode (handle, val); - - for (bytes_transferred = 0; - bytes_transferred < len; - bytes_transferred += n) - { - // Try to transfer as much of the remaining data as possible. - // Since the socket is in non-blocking mode, this call will not - // block. - n = ACE::recv_i (handle, - static_cast (buf) + bytes_transferred, - len - bytes_transferred); - - // Check for errors. - if (n == 0 || - n == -1) - { - // Check for possible blocking. - if (n == -1 && - errno == EWOULDBLOCK) - { - // Wait upto for the blocking to subside. - int rtn = ACE::handle_read_ready (handle, - timeout); - - // Did select() succeed? - if (rtn != -1) - { - // Blocking subsided in period. Continue - // data transfer. - n = 0; - continue; - } - } - - // Wait in select() timed out or other data transfer or - // select() failures. - error = 1; - result = n; - break; - } - } - - ACE::restore_non_blocking_mode (handle, val); - - if (error) - return result; - else - return static_cast (bytes_transferred); -} - -// This is basically an interface to ACE_OS::readv, that doesn't use -// the struct iovec explicitly. The ... can be passed as an arbitrary -// number of (char *ptr, int len) tuples. However, the count N is the -// *total* number of trailing arguments, *not* a couple of the number -// of tuple pairs! - -ssize_t -ACE::recv (ACE_HANDLE handle, size_t n, ...) -{ - va_list argp; - int total_tuples = static_cast (n / 2); - iovec *iovp; -#if defined (ACE_HAS_ALLOCA) - iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); -#else - ACE_NEW_RETURN (iovp, - iovec[total_tuples], - -1); -#endif /* !defined (ACE_HAS_ALLOCA) */ - - va_start (argp, n); - - for (int i = 0; i < total_tuples; i++) - { - iovp[i].iov_base = va_arg (argp, char *); - iovp[i].iov_len = va_arg (argp, int); - } - - ssize_t result = ACE_OS::recvv (handle, iovp, total_tuples); -#if !defined (ACE_HAS_ALLOCA) - delete [] iovp; -#endif /* !defined (ACE_HAS_ALLOCA) */ - va_end (argp); - return result; -} - -ssize_t -ACE::recvv (ACE_HANDLE handle, - iovec *iov, - int iovcnt, - const ACE_Time_Value *timeout) -{ - if (timeout == 0) - return ACE_OS::recvv (handle, iov, iovcnt); - else - { - int val = 0; - if (ACE::enter_recv_timedwait (handle, timeout, val) == -1) - return -1; - else - { - ssize_t bytes_transferred = ACE_OS::recvv (handle, iov, iovcnt); - ACE::restore_non_blocking_mode (handle, val); - return bytes_transferred; - } - } -} - -ssize_t -ACE::recvv_n_i (ACE_HANDLE handle, - iovec *iov, - int iovcnt, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - bytes_transferred = 0; - - for (int s = 0; - s < iovcnt; - ) - { - // Try to transfer as much of the remaining data as possible. - ssize_t n = ACE_OS::recvv (handle, - iov + s, - iovcnt - s); - // Check EOF. - if (n == 0) - return 0; - - // Check for other errors. - if (n == -1) - { - // Check for possible blocking. - if (errno == EWOULDBLOCK) - { - // Wait for the blocking to subside. - int result = ACE::handle_read_ready (handle, - 0); - - // Did select() succeed? - if (result != -1) - { - // Blocking subsided. Continue data transfer. - n = 0; - continue; - } - } - - // Other data transfer or select() failures. - return -1; - } - - for (bytes_transferred += n; - s < iovcnt - && n >= static_cast (iov[s].iov_len); - s++) - n -= iov[s].iov_len; - - if (n != 0) - { - char *base = static_cast (iov[s].iov_base); - iov[s].iov_base = base + n; - iov[s].iov_len = iov[s].iov_len - n; - } - } - - return bytes_transferred; -} - -ssize_t -ACE::recvv_n_i (ACE_HANDLE handle, - iovec *iov, - int iovcnt, - const ACE_Time_Value *timeout, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - bytes_transferred = 0; - ssize_t result = 0; - int error = 0; - - int val = 0; - ACE::record_and_set_non_blocking_mode (handle, val); - - for (int s = 0; - s < iovcnt; - ) - { - // Try to transfer as much of the remaining data as possible. - // Since the socket is in non-blocking mode, this call will not - // block. - ssize_t n = ACE_OS::recvv (handle, - iov + s, - iovcnt - s); - - // Check for errors. - if (n == 0 || - n == -1) - { - // Check for possible blocking. - if (n == -1 && - errno == EWOULDBLOCK) - { - // Wait upto for the blocking to subside. - int rtn = ACE::handle_read_ready (handle, - timeout); - - // Did select() succeed? - if (rtn != -1) - { - // Blocking subsided in period. Continue - // data transfer. - n = 0; - continue; - } - } - - // Wait in select() timed out or other data transfer or - // select() failures. - error = 1; - result = n; - break; - } - - for (bytes_transferred += n; - s < iovcnt - && n >= static_cast (iov[s].iov_len); - s++) - n -= iov[s].iov_len; - - if (n != 0) - { - char *base = reinterpret_cast (iov[s].iov_base); - iov[s].iov_base = base + n; - iov[s].iov_len = iov[s].iov_len - n; - } - } - - ACE::restore_non_blocking_mode (handle, val); - - if (error) - return result; - else - return bytes_transferred; -} - -ssize_t -ACE::recv_n (ACE_HANDLE handle, - ACE_Message_Block *message_block, - const ACE_Time_Value *timeout, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - bytes_transferred = 0; - - iovec iov[ACE_IOV_MAX]; - int iovcnt = 0; - - while (message_block != 0) - { - // Our current message block chain. - const ACE_Message_Block *current_message_block = message_block; - - while (current_message_block != 0) - { - size_t current_message_block_length = - current_message_block->length (); - char *this_rd_ptr = current_message_block->rd_ptr (); - - // Check if this block has any space for incoming data. - while (current_message_block_length > 0) - { - u_long const this_chunk_length = - ACE_Utils::truncate_cast ( - current_message_block_length); - - // Collect the data in the iovec. - iov[iovcnt].iov_base = this_rd_ptr; - iov[iovcnt].iov_len = this_chunk_length; - current_message_block_length -= this_chunk_length; - this_rd_ptr += this_chunk_length; - - // Increment iovec counter. - ++iovcnt; - - // The buffer is full make a OS call. @@ TODO find a way to - // find ACE_IOV_MAX for platforms that do not define it rather - // than simply setting ACE_IOV_MAX to some arbitrary value such - // as 16. - if (iovcnt == ACE_IOV_MAX) - { - size_t current_transfer = 0; - - ssize_t const result = ACE::recvv_n (handle, - iov, - iovcnt, - timeout, - ¤t_transfer); - - // Add to total bytes transferred. - bytes_transferred += current_transfer; - - // Errors. - if (result == -1 || result == 0) - return result; - - // Reset iovec counter. - iovcnt = 0; - } - } - - // Select the next message block in the chain. - current_message_block = current_message_block->cont (); - } - - // Selection of the next message block chain. - message_block = message_block->next (); - } - - // Check for remaining buffers to be sent. This will happen when - // ACE_IOV_MAX is not a multiple of the number of message blocks. - if (iovcnt != 0) - { - size_t current_transfer = 0; - - ssize_t const result = ACE::recvv_n (handle, - iov, - iovcnt, - timeout, - ¤t_transfer); - - // Add to total bytes transferred. - bytes_transferred += current_transfer; - - // Errors. - if (result == -1 || result == 0) - return result; - } - - // Return total bytes transferred. - return bytes_transferred; -} - -ssize_t -ACE::send (ACE_HANDLE handle, - const void *buf, - size_t n, - int flags, - const ACE_Time_Value *timeout) -{ - if (timeout == 0) - return ACE_OS::send (handle, (const char *) buf, n, flags); - else - { - int val = 0; - if (ACE::enter_send_timedwait (handle, timeout, val) == -1) - return -1; - else - { - ssize_t bytes_transferred = ACE_OS::send (handle, (const char *) buf, n, flags); - ACE::restore_non_blocking_mode (handle, val); - return bytes_transferred; - } - } -} - -#if defined (ACE_HAS_TLI) - -ssize_t -ACE::t_snd (ACE_HANDLE handle, - const void *buf, - size_t n, - int flags, - const ACE_Time_Value *timeout) -{ - if (timeout == 0) - return ACE_OS::t_snd (handle, (const char *) buf, n, flags); - else - { - int val = 0; - if (ACE::enter_send_timedwait (handle, timeout, val) == -1) - return -1; - else - { - ssize_t bytes_transferred = ACE_OS::t_snd (handle, (const char *) buf, n, flags); - ACE::restore_non_blocking_mode (handle, val); - return bytes_transferred; - } - } -} - -#endif /* ACE_HAS_TLI */ - -ssize_t -ACE::send (ACE_HANDLE handle, - const void *buf, - size_t n, - const ACE_Time_Value *timeout) -{ - if (timeout == 0) - return ACE::send_i (handle, buf, n); - else - { - int val = 0; - if (ACE::enter_send_timedwait (handle, timeout, val) == -1) - return -1; - else - { - ssize_t bytes_transferred = ACE::send_i (handle, buf, n); - ACE::restore_non_blocking_mode (handle, val); - return bytes_transferred; - } - } -} - -ssize_t -ACE::sendmsg (ACE_HANDLE handle, - const struct msghdr *msg, - int flags, - const ACE_Time_Value *timeout) -{ - if (timeout == 0) - return ACE_OS::sendmsg (handle, msg, flags); - else - { - int val = 0; - if (ACE::enter_send_timedwait (handle, timeout, val) == -1) - return -1; - else - { - ssize_t bytes_transferred = ACE_OS::sendmsg (handle, msg, flags); - ACE::restore_non_blocking_mode (handle, val); - return bytes_transferred; - } - } -} - -ssize_t -ACE::sendto (ACE_HANDLE handle, - const char *buf, - int len, - int flags, - const struct sockaddr *addr, - int addrlen, - const ACE_Time_Value *timeout) -{ - if (timeout == 0) - return ACE_OS::sendto (handle, buf, len, flags, addr, addrlen); - else - { - int val = 0; - if (ACE::enter_send_timedwait (handle, timeout, val) == -1) - return -1; - else - { - ssize_t bytes_transferred = - ACE_OS::sendto (handle, buf, len, flags, addr, addrlen); - ACE::restore_non_blocking_mode (handle, val); - return bytes_transferred; - } - } -} - -ssize_t -ACE::send_n_i (ACE_HANDLE handle, - const void *buf, - size_t len, - int flags, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - ssize_t n; - - for (bytes_transferred = 0; - bytes_transferred < len; - bytes_transferred += n) - { - // Try to transfer as much of the remaining data as possible. - n = ACE_OS::send (handle, - (char *) buf + bytes_transferred, - len - bytes_transferred, - flags); - // Check EOF. - if (n == 0) - return 0; - - // Check for other errors. - if (n == -1) - { - // Check for possible blocking. -#if defined (ACE_WIN32) - if (errno == EWOULDBLOCK) // If enobufs no need to loop -#else - if (errno == EWOULDBLOCK || errno == ENOBUFS) -#endif /* ACE_WIN32 */ - { - // Wait for the blocking to subside. - int result = ACE::handle_write_ready (handle, - 0); - - // Did select() succeed? - if (result != -1) - { - // Blocking subsided. Continue data transfer. - n = 0; - continue; - } - } - - // Other data transfer or select() failures. - return -1; - } - } - - return bytes_transferred; -} - -ssize_t -ACE::send_n_i (ACE_HANDLE handle, - const void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - ssize_t n; - ssize_t result = 0; - int error = 0; - - int val = 0; - ACE::record_and_set_non_blocking_mode (handle, val); - - for (bytes_transferred = 0; - bytes_transferred < len; - bytes_transferred += n) - { - // Try to transfer as much of the remaining data as possible. - // Since the socket is in non-blocking mode, this call will not - // block. - n = ACE_OS::send (handle, - (char *) buf + bytes_transferred, - len - bytes_transferred, - flags); - - // Check for errors. - if (n == 0 || - n == -1) - { - // Check for possible blocking. - if (n == -1 && - errno == EWOULDBLOCK || errno == ENOBUFS) - { - // Wait upto for the blocking to subside. - int rtn = ACE::handle_write_ready (handle, - timeout); - - // Did select() succeed? - if (rtn != -1) - { - // Blocking subsided in period. Continue - // data transfer. - n = 0; - continue; - } - } - - // Wait in select() timed out or other data transfer or - // select() failures. - error = 1; - result = n; - break; - } - } - - ACE::restore_non_blocking_mode (handle, val); - - if (error) - return result; - else - return bytes_transferred; -} - -#if defined (ACE_HAS_TLI) - -ssize_t -ACE::t_snd_n_i (ACE_HANDLE handle, - const void *buf, - size_t len, - int flags, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - ssize_t n; - - for (bytes_transferred = 0; - bytes_transferred < len; - bytes_transferred += n) - { - // Try to transfer as much of the remaining data as possible. - n = ACE_OS::t_snd (handle, - (char *) buf + bytes_transferred, - len - bytes_transferred, - flags); - // Check EOF. - if (n == 0) - return 0; - - // Check for other errors. - if (n == -1) - { - // Check for possible blocking. - if (errno == EWOULDBLOCK || errno == ENOBUFS) - { - // Wait for the blocking to subside. - int result = ACE::handle_write_ready (handle, - 0); - - // Did select() succeed? - if (result != -1) - { - // Blocking subsided. Continue data transfer. - n = 0; - continue; - } - } - - // Other data transfer or select() failures. - return -1; - } - } - - return bytes_transferred; -} - -ssize_t -ACE::t_snd_n_i (ACE_HANDLE handle, - const void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - ssize_t n; - ssize_t result = 0; - int error = 0; - - int val = 0; - ACE::record_and_set_non_blocking_mode (handle, val); - - for (bytes_transferred = 0; - bytes_transferred < len; - bytes_transferred += n) - { - // Try to transfer as much of the remaining data as possible. - // Since the socket is in non-blocking mode, this call will not - // block. - n = ACE_OS::t_snd (handle, - (char *) buf + bytes_transferred, - len - bytes_transferred, - flags); - - // Check for errors. - if (n == 0 || - n == -1) - { - // Check for possible blocking. - if (n == -1 && - errno == EWOULDBLOCK || errno == ENOBUFS) - { - // Wait upto for the blocking to subside. - int rtn = ACE::handle_write_ready (handle, - timeout); - - // Did select() succeed? - if (rtn != -1) - { - // Blocking subsided in period. Continue - // data transfer. - n = 0; - continue; - } - } - - // Wait in select() timed out or other data transfer or - // select() failures. - error = 1; - result = n; - break; - } - } - - ACE::restore_non_blocking_mode (handle, val); - - if (error) - return result; - else - return bytes_transferred; -} - -#endif /* ACE_HAS_TLI */ - -ssize_t -ACE::send_n_i (ACE_HANDLE handle, - const void *buf, - size_t len, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - ssize_t n; - - for (bytes_transferred = 0; - bytes_transferred < len; - bytes_transferred += n) - { - // Try to transfer as much of the remaining data as possible. - n = ACE::send_i (handle, - (char *) buf + bytes_transferred, - len - bytes_transferred); - // Check EOF. - if (n == 0) - return 0; - - // Check for other errors. - if (n == -1) - { - // Check for possible blocking. - if (errno == EWOULDBLOCK || errno == ENOBUFS) - { - // Wait for the blocking to subside. - int result = ACE::handle_write_ready (handle, - 0); - - // Did select() succeed? - if (result != -1) - { - // Blocking subsided. Continue data transfer. - n = 0; - continue; - } - } - - // Other data transfer or select() failures. - return -1; - } - } - - return bytes_transferred; -} - -ssize_t -ACE::send_n_i (ACE_HANDLE handle, - const void *buf, - size_t len, - const ACE_Time_Value *timeout, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - ssize_t n; - ssize_t result = 0; - int error = 0; - - int val = 0; - ACE::record_and_set_non_blocking_mode (handle, val); - - for (bytes_transferred = 0; - bytes_transferred < len; - bytes_transferred += n) - { - // Try to transfer as much of the remaining data as possible. - // Since the socket is in non-blocking mode, this call will not - // block. - n = ACE::send_i (handle, - (char *) buf + bytes_transferred, - len - bytes_transferred); - - // Check for errors. - if (n == 0 || - n == -1) - { - // Check for possible blocking. - if (n == -1 && - errno == EWOULDBLOCK || errno == ENOBUFS) - { - // Wait upto for the blocking to subside. - int rtn = ACE::handle_write_ready (handle, - timeout); - - // Did select() succeed? - if (rtn != -1) - { - // Blocking subsided in period. Continue - // data transfer. - n = 0; - continue; - } - } - - // Wait in select() timed out or other data transfer or - // select() failures. - error = 1; - result = n; - break; - } - } - - ACE::restore_non_blocking_mode (handle, val); - - if (error) - return result; - else - return bytes_transferred; -} - -// Send N char *ptrs and int lengths. Note that the char *'s precede -// the ints (basically, an varargs version of writev). The count N is -// the *total* number of trailing arguments, *not* a couple of the -// number of tuple pairs! - -ssize_t -ACE::send (ACE_HANDLE handle, size_t n, ...) -{ - va_list argp; - int total_tuples = static_cast (n / 2); - iovec *iovp; -#if defined (ACE_HAS_ALLOCA) - iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); -#else - ACE_NEW_RETURN (iovp, - iovec[total_tuples], - -1); -#endif /* !defined (ACE_HAS_ALLOCA) */ - - va_start (argp, n); - - for (int i = 0; i < total_tuples; i++) - { - iovp[i].iov_base = va_arg (argp, char *); - iovp[i].iov_len = va_arg (argp, int); - } - - ssize_t result = ACE_OS::sendv (handle, iovp, total_tuples); -#if !defined (ACE_HAS_ALLOCA) - delete [] iovp; -#endif /* !defined (ACE_HAS_ALLOCA) */ - va_end (argp); - return result; -} - -ssize_t -ACE::sendv (ACE_HANDLE handle, - const iovec *iov, - int iovcnt, - const ACE_Time_Value *timeout) -{ - if (timeout == 0) - return ACE_OS::sendv (handle, iov, iovcnt); - else - { - int val = 0; - if (ACE::enter_send_timedwait (handle, timeout, val) == -1) - return -1; - else - { - ssize_t bytes_transferred = ACE_OS::sendv (handle, iov, iovcnt); - ACE::restore_non_blocking_mode (handle, val); - return bytes_transferred; - } - } -} - -ssize_t -ACE::sendv_n_i (ACE_HANDLE handle, - const iovec *i, - int iovcnt, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - bytes_transferred = 0; - - iovec *iov = const_cast (i); - - for (int s = 0; - s < iovcnt; - ) - { - // Try to transfer as much of the remaining data as possible. - ssize_t n = ACE_OS::sendv (handle, - iov + s, - iovcnt - s); - // Check EOF. - if (n == 0) - return 0; - - // Check for other errors. - if (n == -1) - { - // Check for possible blocking. - if (errno == EWOULDBLOCK || errno == ENOBUFS) - { - // Wait for the blocking to subside. - int result = ACE::handle_write_ready (handle, - 0); - - // Did select() succeed? - if (result != -1) - { - // Blocking subsided. Continue data transfer. - n = 0; - continue; - } - } - - // Other data transfer or select() failures. - return -1; - } - - for (bytes_transferred += n; - s < iovcnt - && n >= static_cast (iov[s].iov_len); - s++) - n -= iov[s].iov_len; - - if (n != 0) - { - char *base = reinterpret_cast (iov[s].iov_base); - iov[s].iov_base = base + n; - iov[s].iov_len = iov[s].iov_len - n; - } - } - - return bytes_transferred; -} - -ssize_t -ACE::sendv_n_i (ACE_HANDLE handle, - const iovec *i, - int iovcnt, - const ACE_Time_Value *timeout, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - bytes_transferred = 0; - ssize_t result = 0; - int error = 0; - - int val = 0; - ACE::record_and_set_non_blocking_mode (handle, val); - - iovec *iov = const_cast (i); - - for (int s = 0; - s < iovcnt; - ) - { - // Try to transfer as much of the remaining data as possible. - // Since the socket is in non-blocking mode, this call will not - // block. - ssize_t n = ACE_OS::sendv (handle, - iov + s, - iovcnt - s); - - // Check for errors. - if (n == 0 || - n == -1) - { - // Check for possible blocking. - if (n == -1 && - errno == EWOULDBLOCK || errno == ENOBUFS) - { - // Wait upto for the blocking to subside. - int rtn = ACE::handle_write_ready (handle, - timeout); - - // Did select() succeed? - if (rtn != -1) - { - // Blocking subsided in period. Continue - // data transfer. - n = 0; - continue; - } - } - - // Wait in select() timed out or other data transfer or - // select() failures. - error = 1; - result = n; - break; - } - - for (bytes_transferred += n; - s < iovcnt - && n >= static_cast (iov[s].iov_len); - s++) - n -= iov[s].iov_len; - - if (n != 0) - { - char *base = reinterpret_cast (iov[s].iov_base); - iov[s].iov_base = base + n; - iov[s].iov_len = iov[s].iov_len - n; - } - } - - ACE::restore_non_blocking_mode (handle, val); - - if (error) - return result; - else - return bytes_transferred; -} - -ssize_t -ACE::write_n (ACE_HANDLE handle, - const ACE_Message_Block *message_block, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - bytes_transferred = 0; - - iovec iov[ACE_IOV_MAX]; - int iovcnt = 0; - - while (message_block != 0) - { - // Our current message block chain. - const ACE_Message_Block *current_message_block = message_block; - - while (current_message_block != 0) - { - size_t current_message_block_length = - current_message_block->length (); - char *this_block_ptr = current_message_block->rd_ptr (); - - // Check if this block has any data to be sent. - while (current_message_block_length > 0) - { - u_long const this_chunk_length = - ACE_Utils::truncate_cast ( - current_message_block_length); - - // Collect the data in the iovec. - iov[iovcnt].iov_base = this_block_ptr; - iov[iovcnt].iov_len = this_chunk_length; - current_message_block_length -= this_chunk_length; - this_block_ptr += this_chunk_length; - - // Increment iovec counter. - ++iovcnt; - - // The buffer is full make a OS call. @@ TODO find a way to - // find ACE_IOV_MAX for platforms that do not define it rather - // than simply setting ACE_IOV_MAX to some arbitrary value such - // as 16. - if (iovcnt == ACE_IOV_MAX) - { - size_t current_transfer = 0; - - ssize_t const result = ACE::writev_n (handle, - iov, - iovcnt, - ¤t_transfer); - - // Add to total bytes transferred. - bytes_transferred += current_transfer; - - // Errors. - if (result == -1 || result == 0) - return result; - - // Reset iovec counter. - iovcnt = 0; - } - } - - // Select the next message block in the chain. - current_message_block = current_message_block->cont (); - } - - // Selection of the next message block chain. - message_block = message_block->next (); - } - - // Check for remaining buffers to be sent. This will happen when - // ACE_IOV_MAX is not a multiple of the number of message blocks. - if (iovcnt != 0) - { - size_t current_transfer = 0; - - ssize_t const result = ACE::writev_n (handle, - iov, - iovcnt, - ¤t_transfer); - - // Add to total bytes transferred. - bytes_transferred += current_transfer; - - // Errors. - if (result == -1 || result == 0) - return result; - } - - // Return total bytes transferred. - return bytes_transferred; -} - -ssize_t -ACE::send_n (ACE_HANDLE handle, - const ACE_Message_Block *message_block, - const ACE_Time_Value *timeout, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - bytes_transferred = 0; - - iovec iov[ACE_IOV_MAX]; - int iovcnt = 0; - - while (message_block != 0) - { - // Our current message block chain. - const ACE_Message_Block *current_message_block = message_block; - - while (current_message_block != 0) - { - char *this_block_ptr = current_message_block->rd_ptr (); - size_t current_message_block_length = - current_message_block->length (); - - // Check if this block has any data to be sent. - while (current_message_block_length > 0) - { - u_long const this_chunk_length = - ACE_Utils::truncate_cast ( - current_message_block_length); - - // Collect the data in the iovec. - iov[iovcnt].iov_base = this_block_ptr; - iov[iovcnt].iov_len = this_chunk_length; - current_message_block_length -= this_chunk_length; - this_block_ptr += this_chunk_length; - - // Increment iovec counter. - ++iovcnt; - - // The buffer is full make a OS call. @@ TODO find a way to - // find ACE_IOV_MAX for platforms that do not define it rather - // than simply setting ACE_IOV_MAX to some arbitrary value such - // as 16. - if (iovcnt == ACE_IOV_MAX) - { - size_t current_transfer = 0; - - ssize_t const result = ACE::sendv_n (handle, - iov, - iovcnt, - timeout, - ¤t_transfer); - - // Add to total bytes transferred. - bytes_transferred += current_transfer; - - // Errors. - if (result == -1 || result == 0) - return result; - - // Reset iovec counter. - iovcnt = 0; - } - } - - // Select the next message block in the chain. - current_message_block = current_message_block->cont (); - } - - // Selection of the next message block chain. - message_block = message_block->next (); - } - - // Check for remaining buffers to be sent. This will happen when - // ACE_IOV_MAX is not a multiple of the number of message blocks. - if (iovcnt != 0) - { - size_t current_transfer = 0; - - ssize_t const result = ACE::sendv_n (handle, - iov, - iovcnt, - timeout, - ¤t_transfer); - - // Add to total bytes transferred. - bytes_transferred += current_transfer; - - // Errors. - if (result == -1 || result == 0) - return result; - } - - // Return total bytes transferred. - return bytes_transferred; -} - -ssize_t -ACE::readv_n (ACE_HANDLE handle, - iovec *iov, - int iovcnt, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - bytes_transferred = 0; - - for (int s = 0; - s < iovcnt; - ) - { - ssize_t n = ACE_OS::readv (handle, - iov + s, - iovcnt - s); - - if (n == -1 || n == 0) - return n; - - for (bytes_transferred += n; - s < iovcnt - && n >= static_cast (iov[s].iov_len); - s++) - n -= iov[s].iov_len; - - if (n != 0) - { - char *base = reinterpret_cast (iov[s].iov_base); - iov[s].iov_base = base + n; - iov[s].iov_len = iov[s].iov_len - n; - } - } - - return bytes_transferred; -} - -ssize_t -ACE::writev_n (ACE_HANDLE handle, - const iovec *i, - int iovcnt, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - bytes_transferred = 0; - - iovec *iov = const_cast (i); - - for (int s = 0; - s < iovcnt; - ) - { - ssize_t n = ACE_OS::writev (handle, - iov + s, - iovcnt - s); - if (n == -1 || n == 0) - return n; - - for (bytes_transferred += n; - s < iovcnt - && n >= static_cast (iov[s].iov_len); - s++) - n -= iov[s].iov_len; - - if (n != 0) - { - char *base = reinterpret_cast (iov[s].iov_base); - iov[s].iov_base = base + n; - iov[s].iov_len = iov[s].iov_len - n; - } - } - - return bytes_transferred; -} - -int -ACE::handle_ready (ACE_HANDLE handle, - const ACE_Time_Value *timeout, - int read_ready, - int write_ready, - int exception_ready) -{ -#if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) - ACE_UNUSED_ARG (write_ready); - ACE_UNUSED_ARG (exception_ready); - - struct pollfd fds; - - fds.fd = handle; - fds.events = read_ready ? POLLIN : POLLOUT; - fds.revents = 0; - - int result = ACE_OS::poll (&fds, 1, timeout); -#else - ACE_Handle_Set handle_set; - handle_set.set_bit (handle); - - // Wait for data or for the timeout to elapse. - int select_width; -# if defined (ACE_WIN32) - // This arg is ignored on Windows and causes pointer truncation - // warnings on 64-bit compiles. - select_width = 0; -# else - select_width = int (handle) + 1; -# endif /* ACE_WIN64 */ - int result = ACE_OS::select (select_width, - read_ready ? handle_set.fdset () : 0, // read_fds. - write_ready ? handle_set.fdset () : 0, // write_fds. - exception_ready ? handle_set.fdset () : 0, // exception_fds. - timeout); - -#endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ - - switch (result) - { - case 0: // Timer expired. - errno = ETIME; - /* FALLTHRU */ - case -1: // we got here directly - select() returned -1. - return -1; - case 1: // Handle has data. - /* FALLTHRU */ - default: // default is case result > 0; return a - // ACE_ASSERT (result == 1); - return result; - } -} - -int -ACE::enter_recv_timedwait (ACE_HANDLE handle, - const ACE_Time_Value *timeout, - int &val) -{ - int result = ACE::handle_read_ready (handle, - timeout); - - if (result == -1) - return -1; - - ACE::record_and_set_non_blocking_mode (handle, - val); - - return result; -} - -int -ACE::enter_send_timedwait (ACE_HANDLE handle, - const ACE_Time_Value *timeout, - int &val) -{ - int result = ACE::handle_write_ready (handle, - timeout); - - if (result == -1) - return -1; - - ACE::record_and_set_non_blocking_mode (handle, - val); - - return result; -} - -void -ACE::record_and_set_non_blocking_mode (ACE_HANDLE handle, - int &val) -{ - // We need to record whether we are already *in* nonblocking mode, - // so that we can correctly reset the state when we're done. - val = ACE::get_flags (handle); - - if (ACE_BIT_DISABLED (val, ACE_NONBLOCK)) - // Set the handle into non-blocking mode if it's not already in - // it. - ACE::set_flags (handle, ACE_NONBLOCK); -} - -void -ACE::restore_non_blocking_mode (ACE_HANDLE handle, - int val) -{ - if (ACE_BIT_DISABLED (val, - ACE_NONBLOCK)) - { - // Save/restore errno. - ACE_Errno_Guard error (errno); - // Only disable ACE_NONBLOCK if we weren't in non-blocking mode - // originally. - ACE::clr_flags (handle, ACE_NONBLOCK); - } -} - - -// Format buffer into printable format. This is useful for debugging. -// Portions taken from mdump by J.P. Knight (J.P.Knight@lut.ac.uk) -// Modifications by Todd Montgomery. - -size_t -ACE::format_hexdump (const char *buffer, - size_t size, - ACE_TCHAR *obuf, - size_t obuf_sz) -{ - ACE_TRACE ("ACE::format_hexdump"); - - u_char c; - ACE_TCHAR textver[16 + 1]; - - // We can fit 16 bytes output in text mode per line, 4 chars per byte. - size_t maxlen = (obuf_sz / 68) * 16; - - if (size > maxlen) - size = maxlen; - - size_t i; - - size_t lines = size / 16; - for (i = 0; i < lines; i++) - { - size_t j; - - for (j = 0 ; j < 16; j++) - { - c = (u_char) buffer[(i << 4) + j]; // or, buffer[i*16+j] - ACE_OS::sprintf (obuf, - ACE_TEXT ("%02x "), - c); - obuf += 3; - if (j == 7) - { - ACE_OS::sprintf (obuf, - ACE_TEXT (" ")); - ++obuf; - } - textver[j] = ACE_OS::ace_isprint (c) ? c : '.'; - } - - textver[j] = 0; - - ACE_OS::sprintf (obuf, - ACE_TEXT (" %s\n"), - textver); - - while (*obuf != '\0') - ++obuf; - } - - if (size % 16) - { - for (i = 0 ; i < size % 16; i++) - { - c = (u_char) buffer[size - size % 16 + i]; - ACE_OS::sprintf (obuf, - ACE_TEXT ("%02x "), - c); - obuf += 3; - if (i == 7) - { - ACE_OS::sprintf (obuf, - ACE_TEXT (" ")); - ++obuf; - } - textver[i] = ACE_OS::ace_isprint (c) ? c : '.'; - } - - for (i = size % 16; i < 16; i++) - { - ACE_OS::sprintf (obuf, - ACE_TEXT (" ")); - obuf += 3; - if (i == 7) - { - ACE_OS::sprintf (obuf, - ACE_TEXT (" ")); - ++obuf; - } - textver[i] = ' '; - } - - textver[i] = 0; - ACE_OS::sprintf (obuf, - ACE_TEXT (" %s\n"), - textver); - } - return size; -} - -// Returns the current timestamp in the form -// "hour:minute:second:microsecond." The month, day, and year are -// also stored in the beginning of the date_and_time array. - -ACE_TCHAR * -ACE::timestamp (ACE_TCHAR date_and_time[], - int date_and_timelen, - int return_pointer_to_first_digit) -{ - //ACE_TRACE ("ACE::timestamp"); - - if (date_and_timelen < 35) - { - errno = EINVAL; - return 0; - } - -#if defined (WIN32) - // Emulate Unix. Win32 does NOT support all the UNIX versions - // below, so DO we need this ifdef. - static const ACE_TCHAR *day_of_week_name[] = - { - ACE_TEXT ("Sun"), - ACE_TEXT ("Mon"), - ACE_TEXT ("Tue"), - ACE_TEXT ("Wed"), - ACE_TEXT ("Thu"), - ACE_TEXT ("Fri"), - ACE_TEXT ("Sat") - }; - - static const ACE_TCHAR *month_name[] = - { - ACE_TEXT ("Jan"), - ACE_TEXT ("Feb"), - ACE_TEXT ("Mar"), - ACE_TEXT ("Apr"), - ACE_TEXT ("May"), - ACE_TEXT ("Jun"), - ACE_TEXT ("Jul"), - ACE_TEXT ("Aug"), - ACE_TEXT ("Sep"), - ACE_TEXT ("Oct"), - ACE_TEXT ("Nov"), - ACE_TEXT ("Dec") - }; - - SYSTEMTIME local; - ::GetLocalTime (&local); - - ACE_OS::sprintf (date_and_time, - ACE_TEXT ("%3s %3s %2d %04d %02d:%02d:%02d.%06d"), - day_of_week_name[local.wDayOfWeek], - month_name[local.wMonth - 1], - (int) local.wDay, - (int) local.wYear, - (int) local.wHour, - (int) local.wMinute, - (int) local.wSecond, - (int) (local.wMilliseconds * 1000)); - return &date_and_time[15 + (return_pointer_to_first_digit != 0)]; -#else /* UNIX */ - ACE_TCHAR timebuf[26]; // This magic number is based on the ctime(3c) man page. - ACE_Time_Value cur_time = ACE_OS::gettimeofday (); - time_t secs = cur_time.sec (); - - ACE_OS::ctime_r (&secs, - timebuf, - sizeof timebuf); - // date_and_timelen > sizeof timebuf! - ACE_OS::strsncpy (date_and_time, - timebuf, - date_and_timelen); - ACE_TCHAR yeartmp[5]; - ACE_OS::strsncpy (yeartmp, - &date_and_time[20], - 5); - ACE_TCHAR timetmp[9]; - ACE_OS::strsncpy (timetmp, - &date_and_time[11], - 9); - ACE_OS::sprintf (&date_and_time[11], -# if defined (ACE_USES_WCHAR) - ACE_TEXT ("%ls %ls.%06ld"), -# else - ACE_TEXT ("%s %s.%06ld"), -# endif /* ACE_USES_WCHAR */ - yeartmp, - timetmp, - cur_time.usec ()); - date_and_time[33] = '\0'; - return &date_and_time[15 + (return_pointer_to_first_digit != 0)]; -#endif /* WIN32 */ -} - -// This function rounds the request to a multiple of the page size. - -size_t -ACE::round_to_pagesize (size_t len) -{ - ACE_TRACE ("ACE::round_to_pagesize"); - - if (ACE::pagesize_ == 0) - ACE::pagesize_ = ACE_OS::getpagesize (); - - return (len + (ACE::pagesize_ - 1)) & ~(ACE::pagesize_ - 1); -} - -size_t -ACE::round_to_allocation_granularity (size_t len) -{ - ACE_TRACE ("ACE::round_to_allocation_granularity"); - - if (ACE::allocation_granularity_ == 0) - ACE::allocation_granularity_ = ACE_OS::allocation_granularity (); - - return (len + (ACE::allocation_granularity_ - 1)) & ~(ACE::allocation_granularity_ - 1); -} - -ACE_HANDLE -ACE::handle_timed_complete (ACE_HANDLE h, - const ACE_Time_Value *timeout, - int is_tli) -{ - ACE_TRACE ("ACE::handle_timed_complete"); - -#if !defined (ACE_WIN32) && defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) - - struct pollfd fds; - - fds.fd = h; - fds.events = POLLIN | POLLOUT; - fds.revents = 0; - -#else - ACE_Handle_Set rd_handles; - ACE_Handle_Set wr_handles; - - rd_handles.set_bit (h); - wr_handles.set_bit (h); -#endif /* !ACE_WIN32 && ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ - -#if defined (ACE_WIN32) - // Winsock is different - it sets the exception bit for failed connect, - // unlike other platforms, where the read bit is set. - ACE_Handle_Set ex_handles; - ex_handles.set_bit (h); -#endif /* ACE_WIN32 */ - - bool need_to_check = false; - bool known_failure = false; - -#if defined (ACE_WIN32) - int n = ACE_OS::select (0, // Ignored on Windows: int (h) + 1, - 0, - wr_handles, - ex_handles, - timeout); -#else -# if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) - - int n = ACE_OS::poll (&fds, 1, timeout); - -# else - int n = ACE_OS::select (int (h) + 1, - rd_handles, - wr_handles, - 0, - timeout); -# endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ -#endif /* ACE_WIN32 */ - - // If we failed to connect within the time period allocated by the - // caller, then we fail (e.g., the remote host might have been too - // busy to accept our call). - if (n <= 0) - { - if (n == 0 && timeout != 0) - errno = ETIME; - return ACE_INVALID_HANDLE; - } - - // Usually, a ready-for-write handle is successfully connected, and - // ready-for-read (exception on Win32) is a failure. On fails, we - // need to grab the error code via getsockopt. On possible success for - // any platform where we can't tell just from select() (e.g. AIX), - // we also need to check for success/fail. -#if defined (ACE_WIN32) - ACE_UNUSED_ARG (is_tli); - - // On Win32, ex_handle set indicates a failure. We'll do the check - // to try and get an errno value, but the connect failed regardless of - // what getsockopt says about the error. - if (ex_handles.is_set (h)) - { - need_to_check = true; - known_failure = true; - } -#elif defined (ACE_VXWORKS) - ACE_UNUSED_ARG (is_tli); - - // Force the check on VxWorks. The read handle for "h" is not set, - // so "need_to_check" is false at this point. The write handle is - // set, for what it's worth. - need_to_check = true; -#else - if (is_tli) - -# if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) - need_to_check = (fds.revents & POLLIN) && !(fds.revents & POLLOUT); -# else - need_to_check = rd_handles.is_set (h) && !wr_handles.is_set (h); -# endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ - - else -#if defined(AIX) - // AIX is broken... both success and failed connect will set the - // write handle only, so always check. - need_to_check = true; -#else -# if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) - need_to_check = (fds.revents & POLLIN); -# else - need_to_check = rd_handles.is_set (h); -# endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ -#endif /* AIX */ -#endif /* ACE_WIN32 */ - - if (need_to_check) - { -#if defined (SOL_SOCKET) && defined (SO_ERROR) - int sock_err = 0; - int sock_err_len = sizeof (sock_err); - int sockopt_ret = ACE_OS::getsockopt (h, SOL_SOCKET, SO_ERROR, - (char *)&sock_err, &sock_err_len); - if (sockopt_ret < 0) - { - h = ACE_INVALID_HANDLE; - } - - if (sock_err != 0 || known_failure) - { - h = ACE_INVALID_HANDLE; - errno = sock_err; - } -#else - char dummy; - - // The following recv() won't block provided that the - // ACE_NONBLOCK flag has not been turned off . - n = ACE::recv (h, &dummy, 1, MSG_PEEK); - - // If no data was read/peeked at, check to see if it's because - // of a non-connected socket (and therefore an error) or there's - // just no data yet. - if (n <= 0) - { - if (n == 0) - { - errno = ECONNREFUSED; - h = ACE_INVALID_HANDLE; - } - else if (errno != EWOULDBLOCK && errno != EAGAIN) - h = ACE_INVALID_HANDLE; - } -#endif - } - - // 1. The HANDLE is ready for writing and doesn't need to be checked or - // 2. recv() returned an indication of the state of the socket - if there is - // either data present, or a recv is legit but there's no data yet, - // the connection was successfully established. - return h; -} - -// Wait up to amount of time to accept a connection. - -int -ACE::handle_timed_accept (ACE_HANDLE listener, - ACE_Time_Value *timeout, - int restart) -{ - ACE_TRACE ("ACE::handle_timed_accept"); - // Make sure we don't bomb out on erroneous values. - if (listener == ACE_INVALID_HANDLE) - return -1; - -#if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) - - struct pollfd fds; - - fds.fd = listener; - fds.events = POLLIN; - fds.revents = 0; - -#else - // Use the select() implementation rather than poll(). - ACE_Handle_Set rd_handle; - rd_handle.set_bit (listener); -#endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ - - // We need a loop here if is enabled. - - for (;;) - { -#if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) - - int n = ACE_OS::poll (&fds, 1, timeout); - -#else - int select_width; -# if defined (ACE_WIN32) - // This arg is ignored on Windows and causes pointer truncation - // warnings on 64-bit compiles. - select_width = 0; -# else - select_width = int (listener) + 1; -# endif /* ACE_WIN32 */ - int n = ACE_OS::select (select_width, - rd_handle, 0, 0, - timeout); -#endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ - - switch (n) - { - case -1: - if (errno == EINTR && restart) - continue; - else - return -1; - /* NOTREACHED */ - case 0: - if (timeout != 0 - && timeout->sec () == 0 - && timeout->usec () == 0) - errno = EWOULDBLOCK; - else - errno = ETIMEDOUT; - return -1; - /* NOTREACHED */ - case 1: - return 0; - /* NOTREACHED */ - default: - errno = EINVAL; - return -1; - /* NOTREACHED */ - } - } -} - -// Make the current process a UNIX daemon. This is based on Stevens -// code from APUE. - -int -ACE::daemonize (const ACE_TCHAR pathname[], - bool close_all_handles, - const ACE_TCHAR program_name[]) -{ - ACE_TRACE ("ACE::daemonize"); -#if !defined (ACE_LACKS_FORK) - pid_t pid = ACE_OS::fork (); - - if (pid == -1) - return -1; - else if (pid != 0) - ACE_OS::exit (0); // Parent exits. - - // 1st child continues. - ACE_OS::setsid (); // Become session leader. - - ACE_OS::signal (SIGHUP, SIG_IGN); - - pid = ACE_OS::fork (program_name); - - if (pid != 0) - ACE_OS::exit (0); // First child terminates. - - // Second child continues. - - if (pathname != 0) - // change working directory. - ACE_OS::chdir (pathname); - - ACE_OS::umask (0); // clear our file mode creation mask. - - // Close down the I/O handles. - if (close_all_handles) - for (int i = ACE::max_handles () - 1; i >= 0; i--) - ACE_OS::close (i); - - return 0; -#else - ACE_UNUSED_ARG (pathname); - ACE_UNUSED_ARG (close_all_handles); - ACE_UNUSED_ARG (program_name); - - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_LACKS_FORK */ -} - -pid_t -ACE::fork (const ACE_TCHAR *program_name, - int avoid_zombies) -{ - if (avoid_zombies == 0) - return ACE_OS::fork (program_name); - else - { - // This algorithm is adapted from an example in the Stevens book - // "Advanced Programming in the Unix Environment" and an item in - // Andrew Gierth's Unix Programming FAQ. It creates an orphan - // process that's inherited by the init process; init cleans up - // when the orphan process terminates. - // - // Another way to avoid zombies is to ignore or catch the - // SIGCHLD signal; we don't use that approach here. - - pid_t pid = ACE_OS::fork (); - if (pid == 0) - { - // The child process forks again to create a grandchild. - switch (ACE_OS::fork (program_name)) - { - case 0: // grandchild returns 0. - return 0; - case -1: // assumes all errnos are < 256 - ACE_OS::_exit (errno); - default: // child terminates, orphaning grandchild - ACE_OS::_exit (0); - } - } - - // Parent process waits for child to terminate. - ACE_exitcode status; - if (pid < 0 || ACE_OS::waitpid (pid, &status, 0) < 0) - return -1; - - // child terminated by calling exit()? - if (WIFEXITED ((status))) - { - // child terminated normally? - if (WEXITSTATUS ((status)) == 0) - return 1; - else - errno = WEXITSTATUS ((status)); - } - else - // child didn't call exit(); perhaps it received a signal? - errno = EINTR; - - return -1; - } -} - -int -ACE::max_handles (void) -{ - ACE_TRACE ("ACE::max_handles"); -#if defined (RLIMIT_NOFILE) && !defined (ACE_LACKS_RLIMIT) - rlimit rl; - int const r = ACE_OS::getrlimit (RLIMIT_NOFILE, &rl); -# if !defined (RLIM_INFINITY) - if (r == 0) - return rl.rlim_cur; -# else - if (r == 0 && rl.rlim_cur != RLIM_INFINITY) - return rl.rlim_cur; - // If == RLIM_INFINITY, fall through to the ACE_LACKS_RLIMIT sections -# endif /* RLIM_INFINITY */ -#endif /* RLIMIT_NOFILE && !ACE_LACKS_RLIMIT */ - -#if defined (_SC_OPEN_MAX) - return ACE_OS::sysconf (_SC_OPEN_MAX); -#elif defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x620) - return maxFiles; -#elif defined (FD_SETSIZE) - return FD_SETSIZE; -#else - ACE_NOTSUP_RETURN (-1); -#endif /* _SC_OPEN_MAX */ -} - -// Set the number of currently open handles in the process. -// -// If NEW_LIMIT == -1 set the limit to the maximum allowable. -// Otherwise, set it to be the value of NEW_LIMIT. - -int -ACE::set_handle_limit (int new_limit, - int increase_limit_only) -{ - ACE_TRACE ("ACE::set_handle_limit"); - int cur_limit = ACE::max_handles (); - int max_limit = cur_limit; - - if (cur_limit == -1) - return -1; - -#if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE) - struct rlimit rl; - - ACE_OS::memset ((void *) &rl, 0, sizeof rl); - int r = ACE_OS::getrlimit (RLIMIT_NOFILE, &rl); - if (r == 0) - max_limit = rl.rlim_max; -#endif /* ACE_LACKS_RLIMIT */ - - if (new_limit == -1) - new_limit = max_limit; - - if (new_limit < 0) - { - errno = EINVAL; - return -1; - } - else if (new_limit > cur_limit) - { - // Increase the limit. -#if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE) - rl.rlim_cur = new_limit; - return ACE_OS::setrlimit (RLIMIT_NOFILE, &rl); -#elif defined (ACE_LACKS_RLIMIT_NOFILE) - return 0; -#else - // Must return EINVAL errno. - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_LACKS_RLIMIT */ - } - else if (increase_limit_only == 0) - { - // Decrease the limit. -#if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE) - rl.rlim_cur = new_limit; - return ACE_OS::setrlimit (RLIMIT_NOFILE, &rl); -#else - // We give a chance to platforms without RLIMIT to work. - // Instead of ACE_NOTSUP_RETURN (0), just return 0 because - // new_limit is <= cur_limit, so it's a no-op. - return 0; -#endif /* ACE_LACKS_RLIMIT */ - } - - return 0; -} - -// Euclid's greatest common divisor algorithm. -u_long -ACE::gcd (u_long x, u_long y) -{ - while (y != 0) - { - u_long r = x % y; - x = y; - y = r; - } - - return x; -} - - -// Calculates the minimum enclosing frame size for the given values. -u_long -ACE::minimum_frame_size (u_long period1, u_long period2) -{ - // if one of the periods is zero, treat it as though it as - // uninitialized and return the other period as the frame size - if (0 == period1) - { - return period2; - } - if (0 == period2) - { - return period1; - } - - // if neither is zero, find the greatest common divisor of the two periods - u_long greatest_common_divisor = ACE::gcd (period1, period2); - - // explicitly consider cases to reduce risk of possible overflow errors - if (greatest_common_divisor == 1) - { - // periods are relative primes: just multiply them together - return period1 * period2; - } - else if (greatest_common_divisor == period1) - { - // the first period divides the second: return the second - return period2; - } - else if (greatest_common_divisor == period2) - { - // the second period divides the first: return the first - return period1; - } - else - { - // the current frame size and the entry's effective period - // have a non-trivial greatest common divisor: return the - // product of factors divided by those in their gcd. - return (period1 * period2) / greatest_common_divisor; - } -} - - -u_long -ACE::is_prime (const u_long n, - const u_long min_factor, - const u_long max_factor) -{ - if (n > 3) - for (u_long factor = min_factor; - factor <= max_factor; - ++factor) - if (n / factor * factor == n) - return factor; - - return 0; -} - -const ACE_TCHAR * -ACE::sock_error (int error) -{ -#if defined (ACE_WIN32) - static ACE_TCHAR unknown_msg[64]; - - switch (error) - { - case WSAVERNOTSUPPORTED: - return ACE_TEXT ("version of WinSock not supported"); - /* NOTREACHED */ - case WSASYSNOTREADY: - return ACE_TEXT ("WinSock not present or not responding"); - /* NOTREACHED */ - case WSAEINVAL: - return ACE_TEXT ("app version not supported by DLL"); - /* NOTREACHED */ - case WSAHOST_NOT_FOUND: - return ACE_TEXT ("Authoritive: Host not found"); - /* NOTREACHED */ - case WSATRY_AGAIN: - return ACE_TEXT ("Non-authoritive: host not found or server failure"); - /* NOTREACHED */ - case WSANO_RECOVERY: - return ACE_TEXT ("Non-recoverable: refused or not implemented"); - /* NOTREACHED */ - case WSANO_DATA: - return ACE_TEXT ("Valid name, no data record for type"); - /* NOTREACHED */ - /* - case WSANO_ADDRESS: - return "Valid name, no MX record"; - */ - case WSANOTINITIALISED: - return ACE_TEXT ("WSA Startup not initialized"); - /* NOTREACHED */ - case WSAENETDOWN: - return ACE_TEXT ("Network subsystem failed"); - /* NOTREACHED */ - case WSAEINPROGRESS: - return ACE_TEXT ("Blocking operation in progress"); - /* NOTREACHED */ - case WSAEINTR: - return ACE_TEXT ("Blocking call cancelled"); - /* NOTREACHED */ - case WSAEAFNOSUPPORT: - return ACE_TEXT ("address family not supported"); - /* NOTREACHED */ - case WSAEMFILE: - return ACE_TEXT ("no file handles available"); - /* NOTREACHED */ - case WSAENOBUFS: - return ACE_TEXT ("no buffer space available"); - /* NOTREACHED */ - case WSAEPROTONOSUPPORT: - return ACE_TEXT ("specified protocol not supported"); - /* NOTREACHED */ - case WSAEPROTOTYPE: - return ACE_TEXT ("protocol wrong type for this socket"); - /* NOTREACHED */ - case WSAESOCKTNOSUPPORT: - return ACE_TEXT ("socket type not supported for address family"); - /* NOTREACHED */ - case WSAENOTSOCK: - return ACE_TEXT ("handle is not a socket"); - /* NOTREACHED */ - case WSAEWOULDBLOCK: - return ACE_TEXT ("resource temporarily unavailable"); - /* NOTREACHED */ - case WSAEADDRINUSE: - return ACE_TEXT ("address already in use"); - /* NOTREACHED */ - case WSAECONNABORTED: - return ACE_TEXT ("connection aborted"); - /* NOTREACHED */ - case WSAECONNRESET: - return ACE_TEXT ("connection reset"); - /* NOTREACHED */ - case WSAENOTCONN: - return ACE_TEXT ("not connected"); - /* NOTREACHED */ - case WSAETIMEDOUT: - return ACE_TEXT ("connection timed out"); - /* NOTREACHED */ - case WSAECONNREFUSED: - return ACE_TEXT ("connection refused"); - /* NOTREACHED */ - case WSAEHOSTDOWN: - return ACE_TEXT ("host down"); - /* NOTREACHED */ - case WSAEHOSTUNREACH: - return ACE_TEXT ("host unreachable"); - /* NOTREACHED */ - case WSAEADDRNOTAVAIL: - return ACE_TEXT ("address not available"); - /* NOTREACHED */ - case WSAEISCONN: - return ACE_TEXT ("socket is already connected"); - /* NOTREACHED */ - case WSAENETRESET: - return ACE_TEXT ("network dropped connection on reset"); - /* NOTREACHED */ - case WSAEMSGSIZE: - return ACE_TEXT ("message too long"); - /* NOTREACHED */ - case WSAENETUNREACH: - return ACE_TEXT ("network is unreachable"); - /* NOTREACHED */ - case WSAEFAULT: - return ACE_TEXT ("bad address"); - /* NOTREACHED */ - case WSAEDISCON: - return ACE_TEXT ("graceful shutdown in progress"); - /* NOTREACHED */ - case WSAEACCES: - return ACE_TEXT ("permission denied"); - /* NOTREACHED */ - case WSAESHUTDOWN: - return ACE_TEXT ("cannot send after socket shutdown"); - /* NOTREACHED */ - case WSAEPROCLIM: - return ACE_TEXT ("too many processes"); - /* NOTREACHED */ - case WSAEALREADY: - return ACE_TEXT ("operation already in progress"); - /* NOTREACHED */ - case WSAEPFNOSUPPORT: - return ACE_TEXT ("protocol family not supported"); - /* NOTREACHED */ - case WSAENOPROTOOPT: - return ACE_TEXT ("bad protocol option"); - /* NOTREACHED */ - case WSATYPE_NOT_FOUND: - return ACE_TEXT ("class type not found"); - /* NOTREACHED */ - case WSAEOPNOTSUPP: - return ACE_TEXT ("operation not supported"); - /* NOTREACHED */ - case WSAEDESTADDRREQ: - return ACE_TEXT ("destination address required"); - /* NOTREACHED */ - default: - ACE_OS::sprintf (unknown_msg, ACE_TEXT ("unknown error: %d"), error); - return unknown_msg; - /* NOTREACHED */ - } -#else - ACE_UNUSED_ARG (error); - ACE_NOTSUP_RETURN (0); -#endif /* ACE_WIN32 */ -} - -bool -ACE::is_sock_error (int error) -{ -#if defined (ACE_WIN32) - switch (error) - { - case WSAVERNOTSUPPORTED: - case WSASYSNOTREADY: - case WSAEINVAL: - case WSAHOST_NOT_FOUND: - case WSATRY_AGAIN: - case WSANO_RECOVERY: - case WSANO_DATA: - /* - case WSANO_ADDRESS: - */ - case WSANOTINITIALISED: - case WSAENETDOWN: - case WSAEINPROGRESS: - case WSAEINTR: - case WSAEAFNOSUPPORT: - case WSAEMFILE: - case WSAENOBUFS: - case WSAEPROTONOSUPPORT: - case WSAEPROTOTYPE: - case WSAESOCKTNOSUPPORT: - case WSAENOTSOCK: - case WSAEWOULDBLOCK: - case WSAEADDRINUSE: - case WSAECONNABORTED: - case WSAECONNRESET: - case WSAENOTCONN: - case WSAETIMEDOUT: - case WSAECONNREFUSED: - case WSAEHOSTDOWN: - case WSAEHOSTUNREACH: - case WSAEADDRNOTAVAIL: - case WSAEISCONN: - case WSAENETRESET: - case WSAEMSGSIZE: - case WSAENETUNREACH: - case WSAEFAULT: - case WSAEDISCON: - case WSAEACCES: - case WSAESHUTDOWN: - case WSAEPROCLIM: - case WSAEALREADY: - case WSAEPFNOSUPPORT: - case WSAENOPROTOOPT: - case WSATYPE_NOT_FOUND: - case WSAEOPNOTSUPP: - return true; - } -#else - ACE_UNUSED_ARG (error); -#endif /* ACE_WIN32 */ - return false; -} - -char * -ACE::strndup (const char *str, size_t n) -{ - const char *t = str; - size_t len; - - // Figure out how long this string is (remember, it might not be - // NUL-terminated). - - for (len = 0; - len < n && *t++ != '\0'; - len++) - continue; - - char *s; - ACE_ALLOCATOR_RETURN (s, - (char *) ACE_OS::malloc (len + 1), - 0); - return ACE_OS::strsncpy (s, str, len + 1); -} - -#if defined (ACE_HAS_WCHAR) -wchar_t * -ACE::strndup (const wchar_t *str, size_t n) -{ - const wchar_t *t = str; - size_t len; - - // Figure out how long this string is (remember, it might not be - // NUL-terminated). - - for (len = 0; - len < n && *t++ != '\0'; - len++) - continue; - - wchar_t *s; - ACE_ALLOCATOR_RETURN (s, - static_cast ( - ACE_OS::malloc ((len + 1) * sizeof (wchar_t))), - 0); - return ACE_OS::strsncpy (s, str, len + 1); -} -#endif /* ACE_HAS_WCHAR */ - -char * -ACE::strnnew (const char *str, size_t n) -{ - const char *t = str; - size_t len; - - // Figure out how long this string is (remember, it might not be - // NUL-terminated). - - for (len = 0; - len < n && *t++ != L'\0'; - len++) - continue; - - char *s; - ACE_NEW_RETURN (s, - char[len + 1], - 0); - return ACE_OS::strsncpy (s, str, len + 1); -} - -#if defined (ACE_HAS_WCHAR) -wchar_t * -ACE::strnnew (const wchar_t *str, size_t n) -{ - const wchar_t *t = str; - size_t len; - - // Figure out how long this string is (remember, it might not be - // NUL-terminated). - - for (len = 0; - len < n && *t++ != ACE_TEXT_WIDE ('\0'); - len++) - continue; - - wchar_t *s; - ACE_NEW_RETURN (s, - wchar_t[len + 1], - 0); - return ACE_OS::strsncpy (s, str, len + 1); -} -#endif /* ACE_HAS_WCHAR */ - -const char * -ACE::strend (const char *s) -{ - while (*s++ != '\0') - continue; - - return s; -} - -#if defined ACE_HAS_WCHAR -const wchar_t * -ACE::strend (const wchar_t *s) -{ - while (*s++ != ACE_TEXT_WIDE ('\0')) - continue; - - return s; -} -#endif - -char * -ACE::strnew (const char *s) -{ - if (s == 0) - return 0; - char *t = 0; - ACE_NEW_RETURN (t, - char [ACE_OS::strlen (s) + 1], - 0); - if (t == 0) - return 0; - else - return ACE_OS::strcpy (t, s); -} - -#if defined (ACE_HAS_WCHAR) -wchar_t * -ACE::strnew (const wchar_t *s) -{ - if (s == 0) - return 0; - wchar_t *t = 0; - ACE_NEW_RETURN (t, - wchar_t[ACE_OS::strlen (s) + 1], - 0); - if (t == 0) - return 0; - else - return ACE_OS::strcpy (t, s); -} -#endif /* ACE_HAS_WCHAR */ - -inline static bool equal_char(char a, char b, bool case_sensitive) -{ - if (case_sensitive) - return a == b; - return ACE_OS::ace_tolower(a) == ACE_OS::ace_tolower(b); -} - -bool -ACE::wild_match(const char* str, const char* pat, bool case_sensitive) -{ - if (str == pat) - return true; - if (pat == 0 || str == 0) - return false; - - bool star = false; - const char* s = str; - const char* p = pat; - while (*s != '\0') - { - if (*p == '*') - { - star = true; - pat = p; - while (*++pat == '*'); - - if (*pat == '\0') - return true; - p = pat; - } - else if (*p == '?') - { - ++s; - ++p; - } - else if (! equal_char(*s, *p, case_sensitive)) - { - if (!star) - return false; - s = ++str; - p = pat; - } - else - { - ++s; - ++p; - } - } - if (*p == '*') - while (*++p == '*'); - - return *p == '\0'; -} - -// Close versioned namespace, if enabled by the user. -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/ACE.h b/ACE/ace/ACE.h deleted file mode 100644 index 7dec2712fa4..00000000000 --- a/ACE/ace/ACE.h +++ /dev/null @@ -1,825 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file ACE.h - * - * $Id$ - * - * This file contains value added ACE functions that extend the - * behavior of the UNIX and Win32 OS calls. - * - * All these ACE static functions are consolidated in a single place - * in order to manage the namespace better. These functions are put - * here rather than in @c ACE_OS in order to separate concerns. - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_ACE_H -#define ACE_ACE_H - -#include /**/ "ace/pre.h" - -#include "ace/config-lite.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/OS_NS_math.h" -#include "ace/Flag_Manip.h" -#include "ace/Handle_Ops.h" -#include "ace/Lib_Find.h" -#include "ace/Init_ACE.h" -#include "ace/Sock_Connect.h" -#include "ace/Default_Constants.h" - -#if defined (ACE_EXPORT_MACRO) -# undef ACE_EXPORT_MACRO -#endif -#define ACE_EXPORT_MACRO ACE_Export - -// Open versioned namespace, if enabled by the user. -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Forward declarations. -class ACE_Time_Value; -class ACE_Message_Block; -class ACE_Handle_Set; - -/** - * @namespace ACE - * - * @brief The namespace containing the ACE framework itself. - * - * The ACE namespace contains all types (classes, structures, - * typedefs, etc), and global functions and variables in the ACE - * framework. - */ -namespace ACE -{ - // = ACE version information. - /// e.g., the "5" in ACE 5.1.12. - extern ACE_Export u_int major_version (void); - - /// e.g., the "1" in ACE 5.1.12. - extern ACE_Export u_int minor_version (void); - - /// e.g., the "12" in ACE 5.1.12. - /// Returns 0 for "stable" (non-beta) releases. - extern ACE_Export u_int beta_version (void); - - // = C++ compiler version information. - /// E.g., the "SunPro C++" in SunPro C++ 4.32.0 - extern ACE_Export const ACE_TCHAR * compiler_name (void); - - /// E.g., the "4" in SunPro C++ 4.32.0 - extern ACE_Export u_int compiler_major_version (void); - - /// E.g., the "32" in SunPro C++ 4.32.0 - extern ACE_Export u_int compiler_minor_version (void); - - /// E.g., the "0" in SunPro C++ 4.32.0 - extern ACE_Export u_int compiler_beta_version (void); - - /// Check if error indicates the process being out of handles (file - /// descriptors). - extern ACE_Export int out_of_handles (int error); - - /// Simple wildcard matching function supporting '*' and '?' - /// return true if string s matches pattern. - extern ACE_Export bool wild_match(const char* s, const char* pattern, bool case_sensitive = true); - - /** - * @name I/O operations - * - * Notes on common parameters: - * - * @a handle is the connected endpoint that will be used for I/O. - * - * @a buf is the buffer to write from or receive into. - * - * @a len is the number of bytes to transfer. - * - * The @a timeout parameter in the following methods indicates how - * long to blocking trying to transfer data. If @a timeout == 0, - * then the call behaves as a normal send/recv call, i.e., for - * blocking sockets, the call will block until action is possible; - * for non-blocking sockets, @c EWOULDBLOCK will be returned if no - * action is immediately possible. - * - * If @a timeout != 0, the call will wait until the relative time - * specified in @a *timeout elapses. - * - * The "_n()" I/O methods keep looping until all the data has been - * transferred. These methods also work for sockets in non-blocking - * mode i.e., they keep looping on @c EWOULDBLOCK. @a timeout is - * used to make sure we keep making progress, i.e., the same timeout - * value is used for every I/O operation in the loop and the timeout - * is not counted down. - * - * The return values for the "*_n()" methods match the return values - * from the non "_n()" methods and are specified as follows: - * - * - On complete transfer, the number of bytes transferred is returned. - * - On timeout, -1 is returned, @c errno == @c ETIME. - * - On error, -1 is returned, @c errno is set to appropriate error. - * - On @c EOF, 0 is returned, @c errno is irrelevant. - * - * On partial transfers, i.e., if any data is transferred before - * timeout / error / @c EOF, @a bytes_transferred> will contain the - * number of bytes transferred. - * - * Methods with @a iovec parameter are I/O vector variants of the - * I/O operations. - * - * Methods with the extra @a flags argument will always result in - * @c send getting called. Methods without the extra @a flags - * argument will result in @c send getting called on Win32 - * platforms, and @c write getting called on non-Win32 platforms. - */ - //@{ - extern ACE_Export ssize_t recv (ACE_HANDLE handle, - void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout = 0); - -#if defined (ACE_HAS_TLI) - - extern ACE_Export ssize_t t_rcv (ACE_HANDLE handle, - void *buf, - size_t len, - int *flags, - const ACE_Time_Value *timeout = 0); - -#endif /* ACE_HAS_TLI */ - - extern ACE_Export ssize_t recv (ACE_HANDLE handle, - void *buf, - size_t len, - const ACE_Time_Value *timeout = 0); - - extern ACE_Export ssize_t recvmsg (ACE_HANDLE handle, - struct msghdr *msg, - int flags, - const ACE_Time_Value *timeout = 0); - - extern ACE_Export ssize_t recvfrom (ACE_HANDLE handle, - char *buf, - int len, - int flags, - struct sockaddr *addr, - int *addrlen, - const ACE_Time_Value *timeout = 0); - - ACE_NAMESPACE_INLINE_FUNCTION - ssize_t recv_n (ACE_HANDLE handle, - void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout = 0, - size_t *bytes_transferred = 0); - -#if defined (ACE_HAS_TLI) - - ACE_NAMESPACE_INLINE_FUNCTION - ssize_t t_rcv_n (ACE_HANDLE handle, - void *buf, - size_t len, - int *flags, - const ACE_Time_Value *timeout = 0, - size_t *bytes_transferred = 0); - -#endif /* ACE_HAS_TLI */ - - ACE_NAMESPACE_INLINE_FUNCTION - ssize_t recv_n (ACE_HANDLE handle, - void *buf, - size_t len, - const ACE_Time_Value *timeout = 0, - size_t *bytes_transferred = 0); - - /// Receive into a variable number of pieces. - /** - * Accepts a variable, caller-specified, number of pointer/length - * pairs. Arguments following @a n are char *, size_t pairs. - * - * @param handle The I/O handle to receive on - * @param n The total number of char *, size_t pairs following @a n. - * - * @return -1 on error, else total number of bytes received. - */ - extern ACE_Export ssize_t recv (ACE_HANDLE handle, size_t n, ...); - - extern ACE_Export ssize_t recvv (ACE_HANDLE handle, - iovec *iov, - int iovcnt, - const ACE_Time_Value *timeout = 0); - - ACE_NAMESPACE_INLINE_FUNCTION - ssize_t recvv_n (ACE_HANDLE handle, - iovec *iov, - int iovcnt, - const ACE_Time_Value *timeout = 0, - size_t *bytes_transferred = 0); - - extern ACE_Export ssize_t recv_n (ACE_HANDLE handle, - ACE_Message_Block *message_block, - const ACE_Time_Value *timeout = 0, - size_t *bytes_transferred = 0); - - extern ACE_Export ssize_t send (ACE_HANDLE handle, - const void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout = 0); - -#if defined (ACE_HAS_TLI) - - extern ACE_Export ssize_t t_snd (ACE_HANDLE handle, - const void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout = 0); - -#endif /* ACE_HAS_TLI */ - - extern ACE_Export ssize_t send (ACE_HANDLE handle, - const void *buf, - size_t len, - const ACE_Time_Value *timeout = 0); - - extern ACE_Export ssize_t sendmsg (ACE_HANDLE handle, - const struct msghdr *msg, - int flags, - const ACE_Time_Value *timeout = 0); - - extern ACE_Export ssize_t sendto (ACE_HANDLE handle, - const char *buf, - int len, - int flags, - const struct sockaddr *addr, - int addrlen, - const ACE_Time_Value *timeout = 0); - - ACE_NAMESPACE_INLINE_FUNCTION - ssize_t send_n (ACE_HANDLE handle, - const void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout = 0, - size_t *bytes_transferred = 0); - -#if defined (ACE_HAS_TLI) - - ACE_NAMESPACE_INLINE_FUNCTION - ssize_t t_snd_n (ACE_HANDLE handle, - const void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout = 0, - size_t *bytes_transferred = 0); - -#endif /* ACE_HAS_TLI */ - - ACE_NAMESPACE_INLINE_FUNCTION - ssize_t send_n (ACE_HANDLE handle, - const void *buf, - size_t len, - const ACE_Time_Value *timeout = 0, - size_t *bytes_transferred = 0); - - /// Varargs variant. - extern ACE_Export ssize_t send (ACE_HANDLE handle, size_t n, ...); - - extern ACE_Export ssize_t sendv (ACE_HANDLE handle, - const iovec *iov, - int iovcnt, - const ACE_Time_Value *timeout = 0); - - ACE_NAMESPACE_INLINE_FUNCTION - ssize_t sendv_n (ACE_HANDLE handle, - const iovec *iov, - int iovcnt, - const ACE_Time_Value *timeout = 0, - size_t *bytes_transferred = 0); - - /// Send all the @a message_blocks chained through their @c next and - /// @c cont pointers. This call uses the underlying OS gather-write - /// operation to reduce the domain-crossing penalty. - extern ACE_Export ssize_t send_n (ACE_HANDLE handle, - const ACE_Message_Block *message_block, - const ACE_Time_Value *timeout = 0, - size_t *bytes_transferred = 0); - - // = File system I/O functions (these don't support timeouts). - - ACE_NAMESPACE_INLINE_FUNCTION - ssize_t read_n (ACE_HANDLE handle, - void *buf, - size_t len, - size_t *bytes_transferred = 0); - - ACE_NAMESPACE_INLINE_FUNCTION - ssize_t write_n (ACE_HANDLE handle, - const void *buf, - size_t len, - size_t *bytes_transferred = 0); - - /// Write all the @a message_blocks chained through their @c next - /// and @c cont pointers. This call uses the underlying OS - /// gather-write operation to reduce the domain-crossing penalty. - extern ACE_Export ssize_t write_n (ACE_HANDLE handle, - const ACE_Message_Block *message_block, - size_t *bytes_transferred = 0); - - extern ACE_Export ssize_t readv_n (ACE_HANDLE handle, - iovec *iov, - int iovcnt, - size_t *bytes_transferred = 0); - - extern ACE_Export ssize_t writev_n (ACE_HANDLE handle, - const iovec *iov, - int iovcnt, - size_t *bytes_transferred = 0); - //@} - - /** - * Wait up to @a timeout amount of time to passively establish a - * connection. This method doesn't perform the @c accept, it just - * does the timed wait. - */ - extern ACE_Export int handle_timed_accept (ACE_HANDLE listener, - ACE_Time_Value *timeout, - int restart); - - /** - * Wait up to @a timeout amount of time to complete an actively - * established non-blocking connection. If @a is_tli is non-0 then - * we are being called by a TLI wrapper (which behaves slightly - * differently from a socket wrapper). - */ - extern ACE_Export ACE_HANDLE handle_timed_complete ( - ACE_HANDLE listener, - const ACE_Time_Value *timeout, - int is_tli = 0); - - /** - * Reset the limit on the number of open handles. If @a new_limit - * == -1 set the limit to the maximum allowable. Otherwise, set - * the limit value to @a new_limit. If @a increase_limit_only is - * non-0 then only allow increases to the limit. - */ - extern ACE_Export int set_handle_limit (int new_limit = -1, - int increase_limit_only = 0); - - /** - * Returns the maximum number of open handles currently permitted in - * this process. This maximum may be extended using - * @c ACE::set_handle_limit. - */ - extern ACE_Export int max_handles (void); - - // = String functions -#if !defined (ACE_HAS_WINCE) - /** - * Return a dynamically allocated duplicate of @a str, substituting - * the environment variable if @c str[0] @c == @c '$'. Note that - * the pointer is allocated with @c ACE_OS::malloc and must be freed - * by @c ACE_OS::free. - */ - extern ACE_Export ACE_TCHAR *strenvdup (const ACE_TCHAR *str); -#endif /* ACE_HAS_WINCE */ - - /// Returns a pointer to the "end" of the string, i.e., the character - /// past the '\0'. - extern ACE_Export const char *strend (const char *s); - - /// This method is just like @c strdup, except that it uses - /// @c operator @c new rather than @c malloc. If @a s is NULL - /// returns NULL rather than segfaulting. - extern ACE_Export char *strnew (const char *s); - - /// Delete the memory allocated by @c strnew. - ACE_NAMESPACE_INLINE_FUNCTION void strdelete (char *s); - - /// Create a fresh new copy of @a str, up to @a n chars long. Uses - /// @c ACE_OS::malloc to allocate the new string. - extern ACE_Export char *strndup (const char *str, size_t n); - - /// Create a fresh new copy of @a str, up to @a n chars long. Uses - /// @c ACE_OS::malloc to allocate the new string. - extern ACE_Export char *strnnew (const char *str, size_t n); - -#if defined (ACE_HAS_WCHAR) - extern ACE_Export const wchar_t *strend (const wchar_t *s); - - extern ACE_Export wchar_t *strnew (const wchar_t *s); - - ACE_NAMESPACE_INLINE_FUNCTION void strdelete (wchar_t *s); - - extern ACE_Export wchar_t *strndup (const wchar_t *str, size_t n); - - extern ACE_Export wchar_t *strnnew (const wchar_t *str, size_t n); - -#endif /* ACE_HAS_WCHAR */ - - /** - * On Windows, determines if a specified pathname ends with ".exe" - * (not case sensitive). If on Windows and there is no ".exe" suffix, - * a new ACE_TCHAR array is allocated and a copy of @c pathname with - * the ".exe" suffix is copied into it. In this case, the caller is - * responsible for calling delete [] on the returned pointer. - * - * @param pathname The name to check for a proper suffix. - * - * @retval @c pathname if there is a proper suffix for Windows. This is - * always the return value for non-Windows platforms. - * @retval If a suffix needs to be added, returns a pointer to new[] - * allocated memory containing the original @c pathname plus - * a ".exe" suffix. The caller is responsible for freeing the - * memory using delete []. - */ - extern ACE_Export const ACE_TCHAR *execname (const ACE_TCHAR *pathname); - - /** - * Returns the "basename" of a @a pathname separated by @a delim. - * For instance, the basename of "/tmp/foo.cpp" is "foo.cpp" when - * @a delim is @a '/'. - */ - extern ACE_Export const ACE_TCHAR *basename (const ACE_TCHAR *pathname, - ACE_TCHAR delim = - ACE_DIRECTORY_SEPARATOR_CHAR); - - /** - * Returns the "dirname" of a @a pathname. For instance, the - * dirname of "/tmp/foo.cpp" is "/tmp" when @a delim is @a '/'. If - * @a pathname has no @a delim ".\0" is returned. This method does - * not modify @a pathname and is not reentrant. - */ - extern ACE_Export const ACE_TCHAR *dirname (const ACE_TCHAR *pathname, - ACE_TCHAR delim = - ACE_DIRECTORY_SEPARATOR_CHAR); - - /** - * Returns the current timestamp in the form - * "hour:minute:second:microsecond." The month, day, and year are - * also stored in the beginning of the @a date_and_time array, which - * is a user-supplied array of size @a time_len> @c ACE_TCHARs. - * Returns 0 if unsuccessful, else returns pointer to beginning of the - * "time" portion of @a date_and_time. If @a - * return_pointer_to_first_digit is 0 then return a pointer to the - * space before the time, else return a pointer to the beginning of - * the time portion. - */ - extern ACE_Export ACE_TCHAR *timestamp (ACE_TCHAR date_and_time[], - int time_len, - int return_pointer_to_first_digit = - 0); - - /** - * if @a avoid_zombies == 0 call @c ACE_OS::fork directly, else - * create an orphan process that's inherited by the init process; - * init cleans up when the orphan process terminates so we don't - * create zombies. Returns -1 on failure and either the child PID - * on success if @a avoid_zombies == 0 or 1 on success if @a - * avoid_zombies != 0 (this latter behavior is a known bug that - * needs to be fixed). - */ - extern ACE_Export pid_t fork ( - const ACE_TCHAR *program_name = ACE_TEXT (""), - int avoid_zombies = 0); - - /** - * Become a daemon process using the algorithm in Richard Stevens - * "Advanced Programming in the UNIX Environment." If - * @a close_all_handles is non-zero then all open file handles are - * closed. - */ - extern ACE_Export int daemonize ( - const ACE_TCHAR pathname[] = ACE_TEXT ("/"), - bool close_all_handles = ACE_DEFAULT_CLOSE_ALL_HANDLES, - const ACE_TCHAR program_name[] = ACE_TEXT ("")); - - // = Miscellaneous functions. - /// Rounds the request to a multiple of the page size. - extern ACE_Export size_t round_to_pagesize (size_t len); - - /// Rounds the request to a multiple of the allocation granularity. - extern ACE_Export size_t round_to_allocation_granularity (size_t len); - - // @@ UNICODE what about buffer? - /// Format buffer into printable format. This is useful for - /// debugging. - extern ACE_Export size_t format_hexdump (const char *buffer, size_t size, - ACE_TCHAR *obuf, size_t obuf_sz); - - /// Computes the hash value of {str} using the "Hash PJW" routine. - extern ACE_Export u_long hash_pjw (const char *str); - - /// Computes the hash value of {str} using the "Hash PJW" routine. - extern ACE_Export u_long hash_pjw (const char *str, size_t len); - -#if defined (ACE_HAS_WCHAR) - /// Computes the hash value of {str} using the "Hash PJW" routine. - extern ACE_Export u_long hash_pjw (const wchar_t *str); - - /// Computes the hash value of {str} using the "Hash PJW" routine. - extern ACE_Export u_long hash_pjw (const wchar_t *str, size_t len); -#endif /* ACE_HAS_WCHAR */ - - /// Computes CRC-CCITT for the string. - extern ACE_Export ACE_UINT16 crc_ccitt(const char *str); - - /// Computes CRC-CCITT for the buffer. - extern ACE_Export ACE_UINT16 crc_ccitt(const void *buf, size_t len, - ACE_UINT16 crc = 0); - - /// Computes CRC-CCITT for the @ len iovec buffers. - extern ACE_Export ACE_UINT16 crc_ccitt(const iovec *iov, int len, - ACE_UINT16 crc = 0); - - /// Computes the ISO 8802-3 standard 32 bits CRC for the string. - extern ACE_Export ACE_UINT32 crc32 (const char *str); - - /// Computes the ISO 8802-3 standard 32 bits CRC for the buffer. - extern ACE_Export ACE_UINT32 crc32 (const void *buf, size_t len, - ACE_UINT32 crc = 0); - - /// Computes the ISO 8802-3 standard 32 bits CRC for the - /// @ len iovec buffers. - extern ACE_Export ACE_UINT32 crc32 (const iovec *iov, int len, - ACE_UINT32 crc = 0); - - /// Euclid's greatest common divisor algorithm. - extern ACE_Export u_long gcd (u_long x, u_long y); - - /// Calculates the minimum enclosing frame size for the given values. - extern ACE_Export u_long minimum_frame_size (u_long period1, u_long period2); - - /** - * Function that can burn up noticeable CPU time: brute-force - * determination of whether number @a n is prime. Returns 0 if - * it is prime, or the smallest factor if it is not prime. - * @a min_factor and @a max_factor can be used to partition the work - * among threads. For just one thread, typical values are 2 and - * n/2. - */ - extern ACE_Export u_long is_prime (const u_long n, - const u_long min_factor, - const u_long max_factor); - - /// Map troublesome win32 errno values to values that standard C - /// strerr function understands. Thank you Microsoft. - extern ACE_Export int map_errno (int error); - - /// Returns a string containing the error message corresponding to a - /// WinSock error. This works around an omission in the Win32 API. - /// @internal - extern ACE_Export const ACE_TCHAR * sock_error (int error); - - /// Determins whether the given error code corresponds to to a - /// WinSock error. If so returns true, false otherwise. - /// @internal - extern ACE_Export bool is_sock_error (int error); - - /** - * Checks if process with {pid} is still alive. Returns 1 if it is - * still alive, 0 if it isn't alive, and -1 if something weird - * happened. - */ - extern ACE_Export int process_active (pid_t pid); - - /** - * Terminate the process abruptly with id @a pid. On Win32 platforms - * this uses {TerminateProcess} and on POSIX platforms is uses - * {kill} with the -9 (SIGKILL) signal, which cannot be caught or - * ignored. Note that this call is potentially dangerous to use - * since the process being terminated may not have a chance to - * cleanup before it shuts down. - */ - extern ACE_Export int terminate_process (pid_t pid); - - /** - * This method uses process id and object pointer to come up with a - * machine wide unique name. The process ID will provide uniqueness - * between processes on the same machine. The "this" pointer of the - * {object} will provide uniqueness between other "live" objects in - * the same process. The uniqueness of this name is therefore only - * valid for the life of {object}. - */ - ACE_NAMESPACE_INLINE_FUNCTION void unique_name (const void *object, - ACE_TCHAR *name, - size_t length); - - /// Computes the base 2 logarithm of {num}. - ACE_NAMESPACE_INLINE_FUNCTION u_long log2 (u_long num); - - /// Hex conversion utility. - ACE_NAMESPACE_INLINE_FUNCTION ACE_TCHAR nibble2hex (u_int n); - - /// Convert a hex character to its byte representation. - ACE_NAMESPACE_INLINE_FUNCTION u_char hex2byte (ACE_TCHAR c); - - // = Set/get the debug level. - extern ACE_Export bool debug (void); - extern ACE_Export void debug (bool onoff); - - /// Wrapper facade for @c select that uses @c ACE_Handle_Sets. - extern ACE_Export int select (int width, - ACE_Handle_Set *readfds, - ACE_Handle_Set *writefds = 0, - ACE_Handle_Set *exceptfds = 0, - const ACE_Time_Value *timeout = 0); - - /// Wrapper facade for the most common use of @c select that uses - /// @c ACE_Handle_Sets. - extern ACE_Export int select (int width, - ACE_Handle_Set &readfds, - const ACE_Time_Value *timeout = 0); - - /// Timed wait for handle to get read ready. - ACE_NAMESPACE_INLINE_FUNCTION - int handle_read_ready (ACE_HANDLE handle, - const ACE_Time_Value *timeout); - - /// Timed wait for handle to get write ready. - ACE_NAMESPACE_INLINE_FUNCTION - int handle_write_ready (ACE_HANDLE handle, - const ACE_Time_Value *timeout); - - /// Timed wait for handle to get exception ready. - ACE_NAMESPACE_INLINE_FUNCTION - int handle_exception_ready (ACE_HANDLE handle, - const ACE_Time_Value *timeout); - - /// Timed wait for handle to get read, write, or exception ready. - extern ACE_Export int handle_ready (ACE_HANDLE handle, - const ACE_Time_Value *timeout, - int read_ready, - int write_ready, - int exception_ready); - - /// Wait for @a timeout before proceeding to a @c recv operation. - /// @a val keeps track of whether we're in non-blocking mode or - /// not. - extern ACE_Export int enter_recv_timedwait (ACE_HANDLE handle, - const ACE_Time_Value *timeout, - int &val); - - /// Wait for @a timeout before proceeding to a @c send operation. - /// @a val keeps track of whether we're in non-blocking mode or - /// not. - extern ACE_Export int enter_send_timedwait (ACE_HANDLE handle, - const ACE_Time_Value* timeout, - int &val); - - /// This makes sure that @a handle is set into non-blocking mode. - /// @a val keeps track of whether were in non-blocking mode or not. - extern ACE_Export void record_and_set_non_blocking_mode (ACE_HANDLE handle, - int &val); - - /// Cleanup after a timed operation, restore the appropriate - /// non-blocking status of @a handle. - extern ACE_Export void restore_non_blocking_mode (ACE_HANDLE handle, - int val); - - // private: - // These functions aren't meant to be used internally, so they are - // not exported. - - // - // = Recv_n helpers - // - - ACE_NAMESPACE_INLINE_FUNCTION ssize_t recv_i (ACE_HANDLE handle, - void *buf, - size_t len); - - extern ACE_Export ssize_t recv_n_i (ACE_HANDLE handle, - void *buf, - size_t len, - int flags, - size_t *bytes_transferred); - - extern ACE_Export ssize_t recv_n_i (ACE_HANDLE handle, - void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout, - size_t *bytes_transferred); - -#if defined (ACE_HAS_TLI) - - extern ACE_Export ssize_t t_rcv_n_i (ACE_HANDLE handle, - void *buf, - size_t len, - int *flags, - size_t *bytes_transferred); - - extern ACE_Export ssize_t t_rcv_n_i (ACE_HANDLE handle, - void *buf, - size_t len, - int *flags, - const ACE_Time_Value *timeout, - size_t *bytes_transferred); - -#endif /* ACE_HAS_TLI */ - - extern ACE_Export ssize_t recv_n_i (ACE_HANDLE handle, - void *buf, - size_t len, - size_t *bytes_transferred); - - extern ACE_Export ssize_t recv_n_i (ACE_HANDLE handle, - void *buf, - size_t len, - const ACE_Time_Value *timeout, - size_t *bytes_transferred); - - extern ACE_Export ssize_t recvv_n_i (ACE_HANDLE handle, - iovec *iov, - int iovcnt, - size_t *bytes_transferred); - - extern ACE_Export ssize_t recvv_n_i (ACE_HANDLE handle, - iovec *iov, - int iovcnt, - const ACE_Time_Value *timeout, - size_t *bytes_transferred); - - // - // = Send_n helpers - // - - ACE_NAMESPACE_INLINE_FUNCTION ssize_t send_i (ACE_HANDLE handle, - const void *buf, - size_t len); - - extern ACE_Export ssize_t send_n_i (ACE_HANDLE handle, - const void *buf, - size_t len, - int flags, - size_t *bytes_transferred); - - extern ACE_Export ssize_t send_n_i (ACE_HANDLE handle, - const void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout, - size_t *bytes_transferred); - -#if defined (ACE_HAS_TLI) - - extern ACE_Export ssize_t t_snd_n_i (ACE_HANDLE handle, - const void *buf, - size_t len, - int flags, - size_t *bytes_transferred); - - extern ACE_Export ssize_t t_snd_n_i (ACE_HANDLE handle, - const void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout, - size_t *bytes_transferred); - -#endif /* ACE_HAS_TLI */ - - extern ACE_Export ssize_t send_n_i (ACE_HANDLE handle, - const void *buf, - size_t len, - size_t *bytes_transferred); - - extern ACE_Export ssize_t send_n_i (ACE_HANDLE handle, - const void *buf, - size_t len, - const ACE_Time_Value *timeout, - size_t *bytes_transferred); - - extern ACE_Export ssize_t sendv_n_i (ACE_HANDLE handle, - const iovec *iov, - int iovcnt, - size_t *bytes_transferred); - - extern ACE_Export ssize_t sendv_n_i (ACE_HANDLE handle, - const iovec *iov, - int iovcnt, - const ACE_Time_Value *timeout, - size_t *bytes_transferred); - -} - -// Close versioned namespace, if enabled by the user. -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/ACE.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" - -#endif /* ACE_ACE_H */ diff --git a/ACE/ace/ACE.inl b/ACE/ace/ACE.inl deleted file mode 100644 index 573cae93357..00000000000 --- a/ACE/ace/ACE.inl +++ /dev/null @@ -1,350 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/OS_NS_unistd.h" -#include "ace/OS_NS_Thread.h" -#include "ace/OS_NS_ctype.h" -#include "ace/OS_NS_sys_socket.h" - -// Open versioned namespace, if enabled by the user. -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - - -// Wrappers for methods that have been moved to ACE_OS. - -ACE_INLINE ssize_t -ACE::read_n (ACE_HANDLE handle, - void *buf, - size_t len, - size_t *bytes_transferred) -{ - return ACE_OS::read_n (handle, - buf, - len, - bytes_transferred); -} - -ACE_INLINE ssize_t -ACE::write_n (ACE_HANDLE handle, - const void *buf, - size_t len, - size_t *bytes_transferred) -{ - return ACE_OS::write_n (handle, - buf, - len, - bytes_transferred); -} - -ACE_INLINE ssize_t -ACE::recv_n (ACE_HANDLE handle, - void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout, - size_t *bytes_transferred) -{ - if (timeout == 0) - return ACE::recv_n_i (handle, - buf, - len, - flags, - bytes_transferred); - else - return ACE::recv_n_i (handle, - buf, - len, - flags, - timeout, - bytes_transferred); -} - -#if defined (ACE_HAS_TLI) - -ACE_INLINE ssize_t -ACE::t_rcv_n (ACE_HANDLE handle, - void *buf, - size_t len, - int *flags, - const ACE_Time_Value *timeout, - size_t *bytes_transferred) -{ - if (timeout == 0) - return ACE::t_rcv_n_i (handle, - buf, - len, - flags, - bytes_transferred); - else - return ACE::t_rcv_n_i (handle, - buf, - len, - flags, - timeout, - bytes_transferred); -} - -#endif /* ACE_HAS_TLI */ - -ACE_INLINE ssize_t -ACE::recv_n (ACE_HANDLE handle, - void *buf, - size_t len, - const ACE_Time_Value *timeout, - size_t *bytes_transferred) -{ - if (timeout == 0) - return ACE::recv_n_i (handle, - buf, - len, - bytes_transferred); - else - return ACE::recv_n_i (handle, - buf, - len, - timeout, - bytes_transferred); -} - -ACE_INLINE ssize_t -ACE::recvv_n (ACE_HANDLE handle, - iovec *iov, - int iovcnt, - const ACE_Time_Value *timeout, - size_t *bytes_transferred) -{ - if (timeout == 0) - return ACE::recvv_n_i (handle, - iov, - iovcnt, - bytes_transferred); - else - return ACE::recvv_n_i (handle, - iov, - iovcnt, - timeout, - bytes_transferred); -} - -ACE_INLINE ssize_t -ACE::send_n (ACE_HANDLE handle, - const void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout, - size_t *bytes_transferred) -{ - if (timeout == 0) - return ACE::send_n_i (handle, - buf, - len, - flags, - bytes_transferred); - else - return ACE::send_n_i (handle, - buf, - len, - flags, - timeout, - bytes_transferred); -} - -#if defined (ACE_HAS_TLI) - -ACE_INLINE ssize_t -ACE::t_snd_n (ACE_HANDLE handle, - const void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout, - size_t *bytes_transferred) -{ - if (timeout == 0) - return ACE::t_snd_n_i (handle, - buf, - len, - flags, - bytes_transferred); - else - return ACE::t_snd_n_i (handle, - buf, - len, - flags, - timeout, - bytes_transferred); -} - -#endif /* ACE_HAS_TLI */ - -ACE_INLINE ssize_t -ACE::send_n (ACE_HANDLE handle, - const void *buf, - size_t len, - const ACE_Time_Value *timeout, - size_t *bytes_transferred) -{ - if (timeout == 0) - return ACE::send_n_i (handle, - buf, - len, - bytes_transferred); - else - return ACE::send_n_i (handle, - buf, - len, - timeout, - bytes_transferred); -} - -ACE_INLINE ssize_t -ACE::sendv_n (ACE_HANDLE handle, - const iovec *iov, - int iovcnt, - const ACE_Time_Value *timeout, - size_t *bytes_transferred) -{ - if (timeout == 0) - return ACE::sendv_n_i (handle, - iov, - iovcnt, - bytes_transferred); - else - return ACE::sendv_n_i (handle, - iov, - iovcnt, - timeout, - bytes_transferred); -} - -ACE_INLINE ssize_t -ACE::send_i (ACE_HANDLE handle, const void *buf, size_t len) -{ -#if defined (ACE_WIN32) || defined (HPUX) - return ACE_OS::send (handle, (const char *) buf, len); -#else - return ACE_OS::write (handle, (const char *) buf, len); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE ssize_t -ACE::recv_i (ACE_HANDLE handle, void *buf, size_t len) -{ -#if defined (ACE_WIN32) || defined (ACE_OPENVMS) || defined (ACE_TANDEM_T1248_PTHREADS) - return ACE_OS::recv (handle, (char *) buf, len); -#else - return ACE_OS::read (handle, (char *) buf, len); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE::handle_read_ready (ACE_HANDLE handle, - const ACE_Time_Value *timeout) -{ - return ACE::handle_ready (handle, - timeout, - 1, - 0, - 0); -} - -ACE_INLINE int -ACE::handle_write_ready (ACE_HANDLE handle, - const ACE_Time_Value *timeout) -{ - return ACE::handle_ready (handle, - timeout, - 0, - 1, - 0); -} - -ACE_INLINE int -ACE::handle_exception_ready (ACE_HANDLE handle, - const ACE_Time_Value *timeout) -{ - return ACE::handle_ready (handle, - timeout, - 0, - 0, - 1); -} - -ACE_INLINE void -ACE::strdelete (char *s) -{ - delete [] s; -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE void -ACE::strdelete (wchar_t *s) -{ - delete [] s; -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE void -ACE::unique_name (const void *object, - ACE_TCHAR *name, - size_t length) -{ - ACE_OS::unique_name (object, name, length); -} - -ACE_INLINE u_long -ACE::log2 (u_long num) -{ - u_long log = 0; - - for (; num > 1; ++log) - num >>= 1; - - return log; -} - -ACE_INLINE ACE_TCHAR -ACE::nibble2hex (u_int n) -{ - // Hexadecimal characters. -#if defined (ACE_VXWORKS) && !defined (__DCPLUSPLUS__) - // temporary solution to prevent Windriver GNU toolchains from spewing - // loads of warnings when inlining. - // problem (incorrect warning leftover from older GNU) has been reported as - // TSR to Windriver. - const ACE_TCHAR hex_chars[] = ACE_TEXT ("0123456789abcdef"); -#else - static const ACE_TCHAR hex_chars[] = ACE_TEXT ("0123456789abcdef"); -#endif - - // Yes, this works for UNICODE - return hex_chars[n & 0x0f]; -} - -ACE_INLINE int -ACE::map_errno (int error) -{ -#if defined (ACE_WIN32) - switch (error) - { - case WSAEWOULDBLOCK: - return EAGAIN; // Same as UNIX errno EWOULDBLOCK. - } -#endif /* ACE_WIN32 */ - - return error; -} - -ACE_INLINE u_char -ACE::hex2byte (ACE_TCHAR c) -{ - if (ACE_OS::ace_isdigit (c)) - return (u_char) (c - ACE_TEXT ('0')); - else if (ACE_OS::ace_islower (c)) - return (u_char) (10 + c - ACE_TEXT ('a')); - else - return (u_char) (10 + c - ACE_TEXT ('A')); -} - -// Close versioned namespace, if enabled by the user. -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/ACE.pc.in b/ACE/ace/ACE.pc.in deleted file mode 100644 index 90b2a9eebd7..00000000000 --- a/ACE/ace/ACE.pc.in +++ /dev/null @@ -1,10 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: ACE -Description: ADAPTIVE Communication Environment -Version: @VERSION@ -Libs: -L${libdir} -lACE @LIBS@ -Cflags: -I${includedir} diff --git a/ACE/ace/ACE_crc32.cpp b/ACE/ace/ACE_crc32.cpp deleted file mode 100644 index f9e91c652ce..00000000000 --- a/ACE/ace/ACE_crc32.cpp +++ /dev/null @@ -1,161 +0,0 @@ -// $Id$ - -#include "ace/ACE.h" - -ACE_RCSID (ace, - ACE_crc32, - "$Id$") - - -namespace -{ - /*****************************************************************/ - /* */ - /* CRC LOOKUP TABLE */ - /* ================ */ - /* The following CRC lookup table was generated automagically */ - /* by the Rocksoft^tm Model CRC Algorithm Table Generation */ - /* Program V1.0 using the following model parameters: */ - /* */ - /* Width : 4 bytes. */ - /* Poly : 0x04C11DB7L */ - /* Reverse : TRUE. */ - /* */ - /* For more information on the Rocksoft^tm Model CRC Algorithm, */ - /* see the document titled "A Painless Guide to CRC Error */ - /* Detection Algorithms" by Ross Williams */ - /* (ross@guest.adelaide.edu.au.). This document is likely to be */ - /* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */ - /* */ - /*****************************************************************/ - - const ACE_UINT32 crc_table[] = - { - 0x00000000L, 0x77073096L, 0xEE0E612CL, 0x990951BAL, - 0x076DC419L, 0x706AF48FL, 0xE963A535L, 0x9E6495A3L, - 0x0EDB8832L, 0x79DCB8A4L, 0xE0D5E91EL, 0x97D2D988L, - 0x09B64C2BL, 0x7EB17CBDL, 0xE7B82D07L, 0x90BF1D91L, - 0x1DB71064L, 0x6AB020F2L, 0xF3B97148L, 0x84BE41DEL, - 0x1ADAD47DL, 0x6DDDE4EBL, 0xF4D4B551L, 0x83D385C7L, - 0x136C9856L, 0x646BA8C0L, 0xFD62F97AL, 0x8A65C9ECL, - 0x14015C4FL, 0x63066CD9L, 0xFA0F3D63L, 0x8D080DF5L, - 0x3B6E20C8L, 0x4C69105EL, 0xD56041E4L, 0xA2677172L, - 0x3C03E4D1L, 0x4B04D447L, 0xD20D85FDL, 0xA50AB56BL, - 0x35B5A8FAL, 0x42B2986CL, 0xDBBBC9D6L, 0xACBCF940L, - 0x32D86CE3L, 0x45DF5C75L, 0xDCD60DCFL, 0xABD13D59L, - 0x26D930ACL, 0x51DE003AL, 0xC8D75180L, 0xBFD06116L, - 0x21B4F4B5L, 0x56B3C423L, 0xCFBA9599L, 0xB8BDA50FL, - 0x2802B89EL, 0x5F058808L, 0xC60CD9B2L, 0xB10BE924L, - 0x2F6F7C87L, 0x58684C11L, 0xC1611DABL, 0xB6662D3DL, - 0x76DC4190L, 0x01DB7106L, 0x98D220BCL, 0xEFD5102AL, - 0x71B18589L, 0x06B6B51FL, 0x9FBFE4A5L, 0xE8B8D433L, - 0x7807C9A2L, 0x0F00F934L, 0x9609A88EL, 0xE10E9818L, - 0x7F6A0DBBL, 0x086D3D2DL, 0x91646C97L, 0xE6635C01L, - 0x6B6B51F4L, 0x1C6C6162L, 0x856530D8L, 0xF262004EL, - 0x6C0695EDL, 0x1B01A57BL, 0x8208F4C1L, 0xF50FC457L, - 0x65B0D9C6L, 0x12B7E950L, 0x8BBEB8EAL, 0xFCB9887CL, - 0x62DD1DDFL, 0x15DA2D49L, 0x8CD37CF3L, 0xFBD44C65L, - 0x4DB26158L, 0x3AB551CEL, 0xA3BC0074L, 0xD4BB30E2L, - 0x4ADFA541L, 0x3DD895D7L, 0xA4D1C46DL, 0xD3D6F4FBL, - 0x4369E96AL, 0x346ED9FCL, 0xAD678846L, 0xDA60B8D0L, - 0x44042D73L, 0x33031DE5L, 0xAA0A4C5FL, 0xDD0D7CC9L, - 0x5005713CL, 0x270241AAL, 0xBE0B1010L, 0xC90C2086L, - 0x5768B525L, 0x206F85B3L, 0xB966D409L, 0xCE61E49FL, - 0x5EDEF90EL, 0x29D9C998L, 0xB0D09822L, 0xC7D7A8B4L, - 0x59B33D17L, 0x2EB40D81L, 0xB7BD5C3BL, 0xC0BA6CADL, - 0xEDB88320L, 0x9ABFB3B6L, 0x03B6E20CL, 0x74B1D29AL, - 0xEAD54739L, 0x9DD277AFL, 0x04DB2615L, 0x73DC1683L, - 0xE3630B12L, 0x94643B84L, 0x0D6D6A3EL, 0x7A6A5AA8L, - 0xE40ECF0BL, 0x9309FF9DL, 0x0A00AE27L, 0x7D079EB1L, - 0xF00F9344L, 0x8708A3D2L, 0x1E01F268L, 0x6906C2FEL, - 0xF762575DL, 0x806567CBL, 0x196C3671L, 0x6E6B06E7L, - 0xFED41B76L, 0x89D32BE0L, 0x10DA7A5AL, 0x67DD4ACCL, - 0xF9B9DF6FL, 0x8EBEEFF9L, 0x17B7BE43L, 0x60B08ED5L, - 0xD6D6A3E8L, 0xA1D1937EL, 0x38D8C2C4L, 0x4FDFF252L, - 0xD1BB67F1L, 0xA6BC5767L, 0x3FB506DDL, 0x48B2364BL, - 0xD80D2BDAL, 0xAF0A1B4CL, 0x36034AF6L, 0x41047A60L, - 0xDF60EFC3L, 0xA867DF55L, 0x316E8EEFL, 0x4669BE79L, - 0xCB61B38CL, 0xBC66831AL, 0x256FD2A0L, 0x5268E236L, - 0xCC0C7795L, 0xBB0B4703L, 0x220216B9L, 0x5505262FL, - 0xC5BA3BBEL, 0xB2BD0B28L, 0x2BB45A92L, 0x5CB36A04L, - 0xC2D7FFA7L, 0xB5D0CF31L, 0x2CD99E8BL, 0x5BDEAE1DL, - 0x9B64C2B0L, 0xEC63F226L, 0x756AA39CL, 0x026D930AL, - 0x9C0906A9L, 0xEB0E363FL, 0x72076785L, 0x05005713L, - 0x95BF4A82L, 0xE2B87A14L, 0x7BB12BAEL, 0x0CB61B38L, - 0x92D28E9BL, 0xE5D5BE0DL, 0x7CDCEFB7L, 0x0BDBDF21L, - 0x86D3D2D4L, 0xF1D4E242L, 0x68DDB3F8L, 0x1FDA836EL, - 0x81BE16CDL, 0xF6B9265BL, 0x6FB077E1L, 0x18B74777L, - 0x88085AE6L, 0xFF0F6A70L, 0x66063BCAL, 0x11010B5CL, - 0x8F659EFFL, 0xF862AE69L, 0x616BFFD3L, 0x166CCF45L, - 0xA00AE278L, 0xD70DD2EEL, 0x4E048354L, 0x3903B3C2L, - 0xA7672661L, 0xD06016F7L, 0x4969474DL, 0x3E6E77DBL, - 0xAED16A4AL, 0xD9D65ADCL, 0x40DF0B66L, 0x37D83BF0L, - 0xA9BCAE53L, 0xDEBB9EC5L, 0x47B2CF7FL, 0x30B5FFE9L, - 0xBDBDF21CL, 0xCABAC28AL, 0x53B39330L, 0x24B4A3A6L, - 0xBAD03605L, 0xCDD70693L, 0x54DE5729L, 0x23D967BFL, - 0xB3667A2EL, 0xC4614AB8L, 0x5D681B02L, 0x2A6F2B94L, - 0xB40BBE37L, 0xC30C8EA1L, 0x5A05DF1BL, 0x2D02EF8DL - }; - - /*****************************************************************/ - /* End of CRC Lookup Table */ - /*****************************************************************/ -} - -#define COMPUTE(var, ch) (var) = (crc_table[(var ^ ch) & 0xFF] ^ (var >> 8)) - -// Open versioned namespace, if enabled by the user. -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_UINT32 -ACE::crc32 (const char *string) -{ - ACE_UINT32 crc = 0xFFFFFFFF; - - for (const char *p = string; - *p != 0; - ++p) - { - COMPUTE (crc, *p); - } - - return ~crc; -} - -ACE_UINT32 -ACE::crc32 (const void *buffer, size_t len, ACE_UINT32 crc) -{ - crc = ~crc; - - for (const char *p = (const char *) buffer, - *e = (const char *) buffer + len; - p != e; - ++p) - { - COMPUTE (crc, *p); - } - - return ~crc; -} - -ACE_UINT32 -ACE::crc32 (const iovec *iov, int len, ACE_UINT32 crc) -{ - crc = ~crc; - - for (int i = 0; i < len; ++i) - { - for (const char *p = (const char *) iov[i].iov_base, - *e = (const char *) iov[i].iov_base + iov[i].iov_len; - p != e; - ++p) - COMPUTE (crc, *p); - } - - return ~crc; -} - -// Close versioned namespace, if enabled by the user. -ACE_END_VERSIONED_NAMESPACE_DECL - -#undef COMPUTE diff --git a/ACE/ace/ACE_crc_ccitt.cpp b/ACE/ace/ACE_crc_ccitt.cpp deleted file mode 100644 index f591b53aa10..00000000000 --- a/ACE/ace/ACE_crc_ccitt.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// $Id$ - -#include "ace/ACE.h" - -ACE_RCSID (ace, - ACE_crc_ccitt, - "$Id$") - -namespace -{ - /*****************************************************************/ - /* */ - /* CRC LOOKUP TABLE */ - /* ================ */ - /* The following CRC lookup table was generated automagically */ - /* by the Rocksoft^tm Model CRC Algorithm Table Generation */ - /* Program V1.0 using the following model parameters: */ - /* */ - /* Width : 2 bytes. */ - /* Poly : 0x1021 */ - /* Reverse : TRUE. */ - /* */ - /* For more information on the Rocksoft^tm Model CRC Algorithm, */ - /* see the document titled "A Painless Guide to CRC Error */ - /* Detection Algorithms" by Ross Williams */ - /* (ross@guest.adelaide.edu.au.). This document is likely to be */ - /* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */ - /* */ - /*****************************************************************/ - - const ACE_UINT16 crc_table[] = - { - 0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF, - 0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7, - 0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E, - 0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876, - 0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD, - 0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5, - 0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C, - 0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974, - 0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB, - 0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3, - 0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A, - 0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72, - 0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9, - 0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1, - 0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738, - 0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70, - 0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7, - 0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF, - 0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036, - 0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E, - 0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5, - 0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD, - 0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134, - 0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C, - 0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3, - 0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB, - 0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232, - 0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A, - 0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1, - 0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9, - 0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330, - 0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78 - }; - - /*****************************************************************/ - /* End of CRC Lookup Table */ - /*****************************************************************/ -} - -#define COMPUTE(var, ch) (var) = (crc_table[(var ^ ch) & 0xFF] ^ (var >> 8)) - -// Open versioned namespace, if enabled by the user. -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_UINT16 -ACE::crc_ccitt (const char *string) -{ - ACE_UINT16 crc = 0xFFFF; - - for (const char *p = string; - *p != 0; - ++p) - { - COMPUTE (crc, *p); - } - - return ~crc; -} - -ACE_UINT16 -ACE::crc_ccitt (const void *buffer, size_t len, ACE_UINT16 crc) -{ - crc = ~crc; - - for (const char *p = (const char *) buffer, - *e = (const char *) buffer + len; - p != e; - ++p) - { - COMPUTE (crc, *p); - } - - return ~crc; -} - -ACE_UINT16 -ACE::crc_ccitt (const iovec *iov, int len, ACE_UINT16 crc) -{ - crc = ~crc; - - for (int i = 0; i < len; ++i) - { - for (const char *p = (const char *) iov[i].iov_base, - *e = (const char *) iov[i].iov_base + iov[i].iov_len; - p != e; - ++p) - COMPUTE (crc, *p); - } - - return ~crc; -} - -// Close versioned namespace, if enabled by the user. -ACE_END_VERSIONED_NAMESPACE_DECL - -#undef COMPUTE diff --git a/ACE/ace/ACE_export.h b/ACE/ace/ACE_export.h deleted file mode 100644 index a988b143427..00000000000 --- a/ACE/ace/ACE_export.h +++ /dev/null @@ -1,76 +0,0 @@ -// -*- C++ -*- -// $Id$ -// Definition for Win32 Export directives. -// This file is generated automatically by -// generate_export_file.pl -// ------------------------------ - -#ifndef ACE_EXPORT_H -#define ACE_EXPORT_H - -#include "ace/config-lite.h" - -#if defined (ACE_AS_STATIC_LIBS) - -# if !defined (ACE_HAS_DLL) -# define ACE_HAS_DLL 0 -# endif /* ! ACE_HAS_DLL */ -#else -# if !defined (ACE_HAS_DLL) -# define ACE_HAS_DLL 1 -# endif /* ! ACE_HAS_DLL */ -#endif /* ACE_AS_STATIC_LIB */ - -#if defined (ACE_HAS_DLL) -# if (ACE_HAS_DLL == 1) -# if defined (ACE_BUILD_DLL) -# define ACE_Export ACE_Proper_Export_Flag -# define ACE_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) -# define ACE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -# else -# define ACE_Export ACE_Proper_Import_Flag -# define ACE_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) -# define ACE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -# endif /* ACE_BUILD_DLL */ -# else -# define ACE_Export -# define ACE_SINGLETON_DECLARATION(T) -# define ACE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -# endif /* ! ACE_HAS_DLL == 1 */ -#else -# define ACE_Export -# define ACE_SINGLETON_DECLARATION(T) -# define ACE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -#endif /* ACE_HAS_DLL */ - -// Added by hand to help with ACE_OS namespace -#if defined (__TANDEM) && defined (USE_EXPLICIT_EXPORT) -#define ACE_NAMESPACE_STORAGE_CLASS ACE_EXPORT_MACRO extern -#else -#define ACE_NAMESPACE_STORAGE_CLASS extern ACE_EXPORT_MACRO -#endif - -#if defined (__ACE_INLINE__) -# if defined (_MSC_VER) || defined (__MINGW32__) || defined (CYGWIN32) || \ - (defined (__SUNPRO_CC) && __SUNPRO_CC >= 0x560) || \ - (defined (__HP_aCC) && (__HP_aCC >= 60500)) || \ - (defined (__sgi) && \ - defined (_COMPILER_VERSION) && _COMPILER_VERSION <= 730) -# define ACE_NAMESPACE_INLINE_FUNCTION inline -# else -# define ACE_NAMESPACE_INLINE_FUNCTION ACE_NAMESPACE_STORAGE_CLASS inline -# endif -# define ACE_INLINE_TEMPLATE_FUNCTION inline -#else -# define ACE_NAMESPACE_INLINE_FUNCTION ACE_NAMESPACE_STORAGE_CLASS -// Microsoft Visual C++ will accept 'extern'; others refuse. -# if defined (_MSC_VER) || defined (__BORLANDC__) -# define ACE_INLINE_TEMPLATE_FUNCTION ACE_Export -# else -# define ACE_INLINE_TEMPLATE_FUNCTION -# endif -#endif - -#endif /* ACE_EXPORT_H */ - -// End of auto generated file. diff --git a/ACE/ace/ARGV.cpp b/ACE/ace/ARGV.cpp deleted file mode 100644 index 431db5b0ee7..00000000000 --- a/ACE/ace/ARGV.cpp +++ /dev/null @@ -1,359 +0,0 @@ -// $Id$ - -#ifndef ACE_ARGV_CPP -#define ACE_ARGV_CPP - -#include "ace/Log_Msg.h" -#include "ace/OS_NS_unistd.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_Memory.h" - -#if !defined (__ACE_INLINE__) -#include "ace/ARGV.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, ARGV, "$Id$") - -// Open versioned namespace, if enabled by the user. -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE (ACE_ARGV_Queue_Entry) -ACE_ALLOC_HOOK_DEFINE (ACE_ARGV) - -template -void -ACE_ARGV_Queue_Entry_T::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_ARGV_Queue_Entry_T::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("arg_ = %s"), this->arg_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("quote_arg_ = %d"), (int)this->quote_arg_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -template -void -ACE_ARGV_T::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_ARGV_T::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("argc_ = %d"), this->argc_)); - - ACE_ARGV *this_obj = const_cast (this); - - for (int i = 0; i < this->argc_; i++) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("\nargv_[%i] = %s"), - i, - this_obj->argv ()[i])); - - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nbuf = %s\n"), this->buf_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -// Creates this->argv_ out of this->buf_. New memory is allocated for -// each element of the array. This is used by the array-to-string -// style constructor and for creating this->argv_ when in iterative -// mode. - -template -int -ACE_ARGV_T::string_to_argv (void) -{ - ACE_TRACE ("ACE_ARGV_T::string_to_argv"); - - return ACE_OS::string_to_argv (this->buf_, - this->argc_, - this->argv_, - this->substitute_env_args_); -} - -template -ACE_ARGV_T::ACE_ARGV_T (const CHAR_TYPE buf[], - bool substitute_env_args) - : substitute_env_args_ (substitute_env_args), - iterative_ (false), - argc_ (0), - argv_ (0), - buf_ (0), - length_ (0), - queue_ () -{ - ACE_TRACE ("ACE_ARGV_T::ACE_ARGV_T CHAR_TYPE[] to CHAR_TYPE *[]"); - - if (buf == 0 || buf[0] == 0) - return; - - // Make an internal copy of the string. - ACE_NEW (this->buf_, - CHAR_TYPE[ACE_OS::strlen (buf) + 1]); - ACE_OS::strcpy (this->buf_, buf); - - // Create this->argv_. - if (this->string_to_argv () == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("string_to_argv"))); -} - -template -ACE_ARGV_T::ACE_ARGV_T (CHAR_TYPE *argv[], - bool substitute_env_args, - bool quote_arg) - : substitute_env_args_ (substitute_env_args), - iterative_ (false), - argc_ (0), - argv_ (0), - buf_ (0), - length_ (0), - queue_ () -{ - ACE_TRACE ("ACE_ARGV_T::ACE_ARGV_T CHAR_TYPE*[] to CHAR_TYPE[]"); - - if (argv == 0 || argv[0] == 0) - return; - - this->argc_ = ACE_OS::argv_to_string (argv, - this->buf_, - substitute_env_args, - quote_arg); -} - -template -ACE_ARGV_T::ACE_ARGV_T (CHAR_TYPE *first_argv[], - CHAR_TYPE *second_argv[], - bool substitute_env_args, - bool quote_args) - : substitute_env_args_ (substitute_env_args), - iterative_ (false), - argc_ (0), - argv_ (0), - buf_ (0), - length_ (0), - queue_ () -{ - ACE_TRACE ("ACE_ARGV_T::ACE_ARGV_T CHAR_TYPE*[] + CHAR_TYPE *[] to CHAR_TYPE[]"); - - int first_argc = 0; - int second_argc = 0; - - CHAR_TYPE *first_buf = 0; - CHAR_TYPE *second_buf = 0; - - // convert the first argv to a string - if (first_argv != 0 && first_argv[0] != 0) - { - first_argc = ACE_OS::argv_to_string (first_argv, - first_buf, - substitute_env_args, - quote_args); - } - - // convert the second argv to a string - if (second_argv != 0 && second_argv[0] != 0) - { - second_argc = ACE_OS::argv_to_string (second_argv, - second_buf, - substitute_env_args, - quote_args); - } - - // Add the number of arguments in both the argvs. - this->argc_ = first_argc + second_argc; - - size_t buf_len = - ACE_OS::strlen (first_buf) + ACE_OS::strlen (second_buf) + 1; - - // Allocate memory to the lenght of the combined argv string. - ACE_NEW (this->buf_, - CHAR_TYPE[buf_len + 1]); - - // copy the first argv string to the buffer - ACE_OS::strcpy (this->buf_, first_buf); - - // concatenate the second argv string to the buffer - ACE_OS::strcat (this->buf_, second_buf); - - // Delete the first and second buffers - delete [] first_buf; - delete [] second_buf; -} - -template -ACE_ARGV_T::ACE_ARGV_T (bool substitute_env_args) - : substitute_env_args_ (substitute_env_args), - iterative_ (true), - argc_ (0), - argv_ (0), - buf_ (0), - length_ (0), - queue_ () -{ - ACE_TRACE ("ACE_ARGV_T::ACE_ARGV_T Iterative"); - - // Nothing to do yet -- the user puts in arguments via add () -} - -template -int -ACE_ARGV_T::add (const CHAR_TYPE *next_arg, bool quote_arg) -{ - // Only allow this to work in the "iterative" verion -- the - // ACE_ARGVs created with the one argument constructor. - if (!this->iterative_) - { - errno = EINVAL; - return -1; - } - - this->length_ += ACE_OS::strlen (next_arg); - if (quote_arg && ACE_OS::strchr (next_arg, ' ') != 0) - { - this->length_ += 2; - if (ACE_OS::strchr (next_arg, '"') != 0) - for (const CHAR_TYPE * p = next_arg; *p != '\0'; ++p) - if (*p == '"') ++this->length_; - } - else - { - quote_arg = false; - } - - // Put the new argument at the end of the queue. - if (this->queue_.enqueue_tail (ACE_ARGV_Queue_Entry_T (next_arg, quote_arg)) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("Can't add more to ARGV queue")), - -1); - - ++this->argc_; - - // Wipe argv_ and buf_ away so that they will be recreated if the - // user calls argv () or buf (). - if (this->argv_ != 0) - { - for (int i = 0; this->argv_[i] != 0; i++) - ACE_OS::free ((void *) this->argv_[i]); - - delete [] this->argv_; - this->argv_ = 0; - } - - delete [] this->buf_; - this->buf_ = 0; - - return 0; -} - -template -int -ACE_ARGV_T::add (CHAR_TYPE *argv[], bool quote_args) -{ - for (int i = 0; argv[i] != 0; i++) - if (this->add (argv[i], quote_args) == -1) - return -1; - - return 0; -} - -// Free up argv_ and buf_ - -template -ACE_ARGV_T::~ACE_ARGV_T (void) -{ - ACE_TRACE ("ACE_ARGV_T::~ACE_ARGV_T"); - - if (this->argv_ != 0) - for (int i = 0; this->argv_[i] != 0; i++) - ACE_OS::free ((void *) this->argv_[i]); - - delete [] this->argv_; - delete [] this->buf_; -} - -// Create buf_ out of the queue_. This is only used in the -// "iterative" mode. - -template -int -ACE_ARGV_T::create_buf_from_queue (void) -{ - ACE_TRACE ("ACE_ARGV_T::create_buf_from_queue"); - - // If the are no arguments, don't do anything - if (this->argc_ <= 0) - return -1; - - delete [] this->buf_; - - ACE_NEW_RETURN (this->buf_, - CHAR_TYPE[this->length_ + this->argc_], - -1); - - // Get an iterator over the queue - ACE_Unbounded_Queue_Iterator > iter (this->queue_); - - ACE_ARGV_Queue_Entry_T *arg = 0; - CHAR_TYPE *ptr = this->buf_; - size_t len; - - while (!iter.done ()) - { - // Get next argument from the queue. - iter.next (arg); - iter.advance (); - - if (arg->quote_arg_) - { - *ptr++ = '"'; - if (ACE_OS::strchr (arg->arg_, '"') != 0) - { - for (const CHAR_TYPE * p = arg->arg_; *p != '\0'; ++p) - { - if (*p == '"') *ptr++ = '\\'; - *ptr++ = *p; - } - } - else - { - len = ACE_OS::strlen (arg->arg_); - // Copy the argument into buf_ - ACE_OS::memcpy ((void *) ptr, - (const void *) (arg->arg_), - len * sizeof (CHAR_TYPE)); - // Move the pointer down. - ptr += len; - } - *ptr++ = '"'; - } - else - { - len = ACE_OS::strlen (arg->arg_); - // Copy the argument into buf_ - ACE_OS::memcpy ((void *) ptr, - (const void *) (arg->arg_), - len * sizeof (CHAR_TYPE)); - // Move the pointer down. - ptr += len; - } - - // Put in an argument separating space. - *ptr++ = ' '; - } - - // Put in the NUL terminator - ptr[-1] = '\0'; - - return 0; -} - -// Close versioned namespace, if enabled by the user. -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_ARGV_CPP */ diff --git a/ACE/ace/ARGV.h b/ACE/ace/ARGV.h deleted file mode 100644 index a50535f1dea..00000000000 --- a/ACE/ace/ARGV.h +++ /dev/null @@ -1,306 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file ARGV.h - * - * $Id$ - * - * @author Doug Schmidt - * @author Everett Anderson - */ -//========================================================================== - -#ifndef ACE_ARGUMENT_VECTOR_H -#define ACE_ARGUMENT_VECTOR_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Global_Macros.h" -#include "ace/Unbounded_Queue.h" - -// Open versioned namespace, if enabled by the user. -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_ARGV_Queue_Entry_T - * - * @brief An entry in the queue which keeps user supplied arguments. - */ -template -class ACE_ARGV_Queue_Entry_T -{ -public: - // = Initialization and termination. - /// Initialize a ACE_ARGV_Queue_Entry_T. - ACE_ARGV_Queue_Entry_T (void); - - /** - * Initialize a ACE_ARGV_Queue_Entry_T. - * - * @param arg Pointer to an argument - * - * @param quote_arg The argument @a arg need to be quoted - * while adding to the vector. - */ - ACE_ARGV_Queue_Entry_T (const CHAR_TYPE *arg, - bool quote_arg); - - /** - * Initialize a ACE_ARGV_Queue_Entry_T. - * - * @param entry Pointer to a queue entry - */ - ACE_ARGV_Queue_Entry_T (const ACE_ARGV_Queue_Entry_T &entry); - - /// We need this destructor to keep some compilers from complaining. - /// It's just a no-op, however. - ~ACE_ARGV_Queue_Entry_T (void); - - /// Dump the state of this object. - void dump (void) const; - - // Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - - /// Pointer to the argument. - const CHAR_TYPE * arg_; - - /// The argument need to be quoted while adding to the vector. - bool quote_arg_; -}; - -/** - * @class ACE_ARGV_T - * - * @brief Builds a counted argument vector (ala argc/argv) from either - * a string or a set of separate tokens. This class preserves whitespace - * within tokens only if the whitespace-containing token is enclosed in - * either single (') or double (") quotes. This is consistent with the - * expected behavior if an argument vector obtained using this class is - * passed to, for example, ACE_Get_Opt. - * - * This class can substitute environment variable values for tokens that - * are environment variable references (e.g., @c $VAR). This only works - * if the token is an environment variable reference and nothing else; it - * doesn't substitute environment variable references within a token. - * For example, @c $HOME/file will not substitute the value of the HOME - * environment variable. - */ -template -class ACE_ARGV_T -{ -public: - // = Initialization and termination. - /** - * Splits the specified string into an argument vector. Arguments in the - * string are delimited by whitespace. Whitespace-containing arguments - * must be enclosed in quotes, either single (') or double ("). - * - * @param buf A nul-terminated CHAR_TYPE array to split into arguments - * for the vector. - * - * @param substitute_env_args If non-zero, any token that is an - * environment variable reference (e.g., @c $VAR) will have - * its environment variable value in the resultant vector - * in place of the environment variable name. - */ - explicit ACE_ARGV_T (const CHAR_TYPE buf[], - bool substitute_env_args = true); - - /** - * Initializes the argument vector from a set of arguments. Any environment - * variable references are translated (if applicable) during execution of - * this method. - * - * @param argv An array of tokens to initialize the object with. The - * array must be terminated with a 0 pointer. All needed - * data is copied from @a argv during this call; the pointers - * in @a argv are not needed after this call, and the memory - * referred to by @a argv is not referenced by this object. - * - * @param substitute_env_args If non-zero, any element of @a argv that is - * an environment variable reference (e.g., @c $VAR) will have - * its environment variable value in the resultant vector - * in place of the environment variable name. - * - * @param quote_args If non-zero each argument @a argv[i] needs to - * be enclosed in double quotes ('"'). - */ - explicit ACE_ARGV_T (CHAR_TYPE *argv[], - bool substitute_env_args = true, - bool quote_args = false); - - /** - * Initializes the argument vector from two combined argument vectors. - * - * @param first_argv An array of tokens to initialize the object with. - * The array must be terminated with a 0 pointer. - * @param second_argv An array of tokens that is concatenated with the - * the tokens in @a first_argv. The array must be - * terminated with a 0 pointer. - * @param substitute_env_args If non-zero, any element of @a first_argv - * or @a second_argv that is an environment variable - * reference (e.g., @c $VAR) will have its environment - * variable value in the resultant vector in place - * of the environment variable name. - * - * @param quote_args If non-zero each arguments @a first_argv[i] and - * @a second_argv[i] needs to be enclosed - * in double quotes ('"'). - */ - ACE_ARGV_T (CHAR_TYPE *first_argv[], - CHAR_TYPE *second_argv[], - bool substitute_env_args = true, - bool quote_args = false); - - /** - * Initialize this object so arguments can be added later using one - * of the add methods. This is referred to as the @i iterative method - * of adding arguments to this object. - */ - explicit ACE_ARGV_T (bool substitute_env_args = true); - - /// Destructor. - ~ACE_ARGV_T (void); - - /** @name Accessor methods - * - * These methods access the argument vector contained in this object. - */ - //@{ - /** - * Returns the specified element of the current argument vector. - * - * @param index Index to the desired element. - * - * @retval Pointer to the indexed string. - * @retval 0 if @a index is out of bounds. - */ - const CHAR_TYPE *operator[] (size_t index); - - /** - * Returns the current argument vector. The returned pointers are to data - * maintained internally to this class. Do not change or delete either the - * pointers or the memory to which they refer. - */ - CHAR_TYPE **argv (void); - - /// Returns the current number of arguments. - int argc (void) const; - - /** - * Returns a single string form of the current arguments. The returned - * pointer refers to memory maintained internally to this class. Do not - * change or delete it. - */ - const CHAR_TYPE *buf (void); - - //@} - - /// Dump the state of this object. - void dump (void) const; - - // Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - - /** - * Add another argument. This only works in the iterative mode. - * - * @note This method copies the specified pointer, but not the data - * contained in the referenced memory. Thus, if the content of - * the memory referred to by @a next_arg are changed after this - * method returns, the results are undefined. - * - * @param next_arg Pointer to the next argument to add to the vector. - * - * @param quote_arg The argument @a next_arg need to be quoted while - * adding to the vector. - * - * @retval 0 on success; -1 on failure. Most likely @c errno values are: - * - EINVAL: This object is not in iterative mode. - * - ENOMEM: Not enough memory available to save @a next_arg. - */ - int add (const CHAR_TYPE *next_arg, bool quote_arg = false); - - /** - * Add an array of arguments. This only works in the iterative mode. - * - * @note This method copies the specified pointers, but not the data - * contained in the referenced memory. Thus, if the content of - * the memory referred to by any of the @a argv elements is - * changed after this method returns, the results are undefined. - * - * @param argv Pointers to the arguments to add to the vector. - * @a argv must be terminated by a 0 pointer. - * - * @param quote_args If non-zero each argument @a argv[i] needs to - * be enclosed in double quotes ('"'). - * - * @retval 0 on success; -1 on failure. Most likely @c errno values are: - * - EINVAL: This object is not in iterative mode. - * - ENOMEM: Not enough memory available to save @a next_arg. - */ - int add (CHAR_TYPE *argv[], bool quote_args = false); - -private: - /// Copy constructor not implemented. - ACE_UNIMPLEMENTED_FUNC (ACE_ARGV_T (const ACE_ARGV_T&)) - - /// Assignment operator not implemented. - ACE_UNIMPLEMENTED_FUNC (ACE_ARGV_T operator= (const ACE_ARGV_T&)) - - /// Creates buf_ from the queue of added args, deletes previous buf_. - int create_buf_from_queue (void); - - /// Converts buf_ into the CHAR_TYPE *argv[] format. - int string_to_argv (void); - - /// Replace args with environment variable values? - bool substitute_env_args_; - - bool iterative_; - - /// Number of arguments in the ARGV array. - int argc_; - - /// The array of string arguments. - CHAR_TYPE **argv_; - - /// Buffer containing the contents. - CHAR_TYPE *buf_; - - /// Total length of the arguments in the queue, not counting - /// separating spaces - size_t length_; - - /// Queue which keeps user supplied arguments. This is only - /// active in the "iterative" mode. - ACE_Unbounded_Queue > queue_; -}; - -typedef ACE_ARGV_Queue_Entry_T ACE_ARGV_Queue_Entry; -typedef ACE_ARGV_T ACE_ARGV; - -// Close versioned namespace, if enabled by the user. -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/ARGV.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/ARGV.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("ARGV.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" -#endif /* ACE_ARGUMENT_VECTOR_H */ diff --git a/ACE/ace/ARGV.inl b/ACE/ace/ARGV.inl deleted file mode 100644 index e84166f49ba..00000000000 --- a/ACE/ace/ARGV.inl +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -#include "ace/Global_Macros.h" - -// Open versioned namespace, if enabled by the user. -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template ACE_INLINE -ACE_ARGV_Queue_Entry_T::ACE_ARGV_Queue_Entry_T (void) - : arg_(0), - quote_arg_(false) -{ - // No-op -} - -template ACE_INLINE -ACE_ARGV_Queue_Entry_T::ACE_ARGV_Queue_Entry_T (const CHAR_TYPE *arg, - bool quote_arg) - : arg_(arg), - quote_arg_(quote_arg) -{ - // No-op -} - -template ACE_INLINE -ACE_ARGV_Queue_Entry_T::ACE_ARGV_Queue_Entry_T (const ACE_ARGV_Queue_Entry_T &entry) - : arg_(entry.arg_), - quote_arg_(entry.quote_arg_) -{ - // No-op -} - -template ACE_INLINE -ACE_ARGV_Queue_Entry_T::~ACE_ARGV_Queue_Entry_T (void) -{ - // No-op just to keep some compilers happy... -} - -// Return the number of args -template -ACE_INLINE int -ACE_ARGV_T::argc (void) const -{ - ACE_TRACE ("ACE_ARGV_T::argc"); - // Try to create the argv_ if it isn't there - ACE_ARGV_T *nonconst_this = - const_cast *> (this); - (void) nonconst_this->argv (); - return this->argc_; -} - -// Return the arguments in a space-separated string -template -ACE_INLINE const CHAR_TYPE * -ACE_ARGV_T::buf (void) -{ - ACE_TRACE ("ACE_ARGV_T::buf"); - - if (this->buf_ == 0 && this->iterative_) - this->create_buf_from_queue (); - - return (const CHAR_TYPE *) this->buf_; -} - -// Return the arguments in an entry-per-argument array - -template -ACE_INLINE CHAR_TYPE ** -ACE_ARGV_T::argv (void) -{ - ACE_TRACE ("ACE_ARGV_T::argv"); - - // Try to create the argv_ if it isn't there - if (this->argv_ == 0) - { - if (this->iterative_ && this->buf_ == 0) - this->create_buf_from_queue (); - - // Convert buf_ to argv_ - if (this->string_to_argv () == -1) - return (CHAR_TYPE **) 0; - } - - return (CHAR_TYPE **) this->argv_; -} - -// Subscript operator. - -template -ACE_INLINE const CHAR_TYPE * -ACE_ARGV_T::operator[] (size_t i) -{ - ACE_TRACE ("ACE_ARGV_T::operator[]"); - - // Don't go out of bounds. - if (i >= static_cast (this->argc_)) - return 0; - - return (const CHAR_TYPE *) this->argv ()[i]; -} - -// Close versioned namespace, if enabled by the user. -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/ATM_Acceptor.cpp b/ACE/ace/ATM_Acceptor.cpp deleted file mode 100644 index 5a78f1c32c8..00000000000 --- a/ACE/ace/ATM_Acceptor.cpp +++ /dev/null @@ -1,309 +0,0 @@ -// $Id$ - -#include "ace/ATM_Acceptor.h" - -ACE_RCSID(ace, ATM_Acceptor, "$Id$") - -#if defined (ACE_HAS_ATM) - -#if defined (ACE_HAS_LINUX_ATM) -#include /**/ "linux/atmdev.h" -#endif /* ACE_HAS_LINUX_ATM */ - -#if !defined (__ACE_INLINE__) -#include "ace/ATM_Acceptor.inl" -#endif /* __ACE_INLINE__ */ - - -// Open versioned namespace, if enabled by the user. -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Put the actual definitions of the ACE_ATM_Request and -// ACE_ATM_Request_Queue classes here to hide them from clients... - -ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Acceptor) - -ACE_ATM_Acceptor::ACE_ATM_Acceptor (void) -{ - ACE_TRACE ("ACE_ATM_Acceptor::ACE_ATM_Acceptor"); -} - -ACE_ATM_Acceptor::~ACE_ATM_Acceptor (void) -{ - ACE_TRACE ("ACE_ATM_Acceptor::~ACE_ATM_Acceptor"); -} - -int -ACE_ATM_Acceptor::get_local_addr (ACE_ATM_Addr &local_addr) -{ - ACE_TRACE ("ACE_ATM_Acceptor::get_local_addr"); - -#if defined (ACE_HAS_FORE_ATM_WS2) - unsigned long ret = 0; - DWORD deviceID = 0; - ATM_ADDRESS addr; - struct sockaddr_atm *laddr; - - if (::WSAIoctl ((int) ((ACE_SOCK_Acceptor *)this) -> get_handle (), - SIO_GET_ATM_ADDRESS, - (LPVOID) &deviceID, - sizeof (DWORD), - (LPVOID)&addr, - sizeof (ATM_ADDRESS), - &ret, - 0, - 0) == SOCKET_ERROR) { - ACE_OS::printf ("ATM_Acceptor (get_local_addr): WSIoctl: %d\n", - ::WSAGetLastError ()); - return -1; - } - - laddr = (struct sockaddr_atm *)local_addr.get_addr (); - ACE_OS::memcpy ((void *)& (laddr -> satm_number), - (void *)&addr, - ATM_ADDR_SIZE - 1); - - return 0; -#elif defined (ACE_HAS_FORE_ATM_XTI) - ACE_UNUSED_ARG (local_addr); - - return 0; -#elif defined (ACE_HAS_LINUX_ATM) - ATM_Addr *myaddr = (ATM_Addr *)local_addr.get_addr (); - int addrlen = sizeof (myaddr->sockaddratmsvc); - - if (ACE_OS::getsockname (acceptor_.get_handle (), - (struct sockaddr *) & (myaddr->sockaddratmsvc), - &addrlen) < 0) { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("ATM_Acceptor (get_local_addr): ioctl: %d\n"), - errno)); - return -1; - } - - return (0); -#else - ACE_UNUSED_ARG (local_addr); - - return 0; -#endif /* ACE_HAS_FORE_ATM_WS2 && ACE_HAS_FORE_ATM_XTI */ -} - -ACE_HANDLE -ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap, - int backlog, - ACE_ATM_Params params) -{ - ACE_TRACE ("ACE_ATM_Acceptor::open"); -#if defined (ACE_HAS_FORE_ATM_XTI) - ACE_HANDLE handle = acceptor_.open (remote_sap, - params.get_reuse_addr (), - params.get_oflag (), - params.get_info (), - backlog, - params.get_device ()); - return (handle == ACE_INVALID_HANDLE ? -1 : 0); -#elif defined (ACE_HAS_FORE_ATM_WS2) - struct sockaddr_atm local_atm_addr; - ACE_HANDLE ret; - DWORD flags = 0; - - /* Create a local endpoint of communication */ - - // Only leaves can listen. - flags = ACE_FLAG_MULTIPOINT_C_LEAF | ACE_FLAG_MULTIPOINT_D_LEAF; - - if ((ret = ACE_OS::socket (AF_ATM, - SOCK_RAW, - ATMPROTO_AAL5, - 0, - 0, - flags)) - == ACE_INVALID_HANDLE) { - ACE_OS::printf ("Acceptor (open): socket %d\n", - ::WSAGetLastError ()); - return (ret); - } - - ((ACE_SOCK_Acceptor *)this) -> set_handle (ret); - - /* Set up the address information to become a server */ - ACE_OS::memset ((void *) &local_atm_addr, 0, sizeof local_atm_addr); - local_atm_addr.satm_family = AF_ATM; - local_atm_addr.satm_number.AddressType = SAP_FIELD_ANY_AESA_REST; - local_atm_addr.satm_number.Addr[ ATM_ADDR_SIZE - 1 ] - = ((ACE_ATM_Addr *)&remote_sap) -> get_selector (); - local_atm_addr.satm_blli.Layer2Protocol = SAP_FIELD_ANY; - local_atm_addr.satm_blli.Layer3Protocol = SAP_FIELD_ABSENT; - local_atm_addr.satm_bhli.HighLayerInfoType = SAP_FIELD_ABSENT; - - /* Associate address with endpoint */ - if (ACE_OS::bind (((ACE_SOCK_Acceptor *)this) -> get_handle (), - reinterpret_cast (&local_atm_addr), - sizeof local_atm_addr) == -1) { - ACE_OS::printf ("Acceptor (open): bind %d\n", ::WSAGetLastError ()); - return (ACE_INVALID_HANDLE); - } - - /* Make endpoint listen for service requests */ - if (ACE_OS::listen (( (ACE_SOCK_Acceptor *)this) -> get_handle (), - backlog) - == -1) { - ACE_OS::printf ("Acceptor (open): listen %d\n", ::WSAGetLastError ()); - return (ACE_INVALID_HANDLE); - } - - return 0; -#elif defined (ACE_HAS_LINUX_ATM) - //we need to set the qos before binding to the socket - //use remote_sap as local_sap - - ACE_ATM_Addr local_sap; - ATM_Addr *local_sap_addr = (ATM_Addr*)local_sap.get_addr (); - ACE_ATM_QoS def_qos; - ATM_QoS qos = def_qos.get_qos (); - - ACE_HANDLE handle; - if ((handle = ACE_OS::socket (params.get_protocol_family (), - params.get_type (), - params.get_protocol (), - params.get_protocol_info (), - params.get_sock_group (), - params.get_flags () - )) - == ACE_INVALID_HANDLE) { - ACE_DEBUG (LM_DEBUG, - ACE_TEXT ("Acceptor (socket): socket %d\n"), - errno); - return (ACE_INVALID_HANDLE); - } - - ((ACE_SOCK_Acceptor *)this) -> set_handle (handle); - if (ACE_OS::setsockopt (handle, - SOL_ATM, - SO_ATMQOS, - reinterpret_cast (&qos), - sizeof (qos)) < 0) { - ACE_OS::printf ("Acceptor (setsockopt): setsockopt:%d\n", - errno); - } - - struct atmif_sioc req; - struct sockaddr_atmsvc aux_addr[1024]; - - req.number = 0; - req.arg = aux_addr; - req.length = sizeof (aux_addr); - if (ACE_OS::ioctl (handle, - ATM_GETADDR, - &req) < 0) { - ACE_OS::perror ("Acceptor (setsockopt): ioctl:"); - } - else { - local_sap_addr->sockaddratmsvc = aux_addr[0]; - } - local_sap.set_selector (( (ACE_ATM_Addr*)&remote_sap)->get_selector ()); - - if (ACE_OS::bind (handle, - reinterpret_cast ( - &(local_sap_addr->sockaddratmsvc)), - sizeof (local_sap_addr->sockaddratmsvc) - ) == -1) { - ACE_DEBUG (LM_DEBUG, - ACE_TEXT ("Acceptor (open): bind %d\n"), - errno); - return -1; - } - // Make endpoint listen for service requests - if (ACE_OS::listen (handle, - backlog) - == -1) { - ACE_DEBUG (LM_DEBUG, - ACE_TEXT ("Acceptor (listen): listen %d\n"), - errno); - return -1; - } - - return 0; -#else - ACE_UNUSED_ARG (remote_sap); - ACE_UNUSED_ARG (backlog); - ACE_UNUSED_ARG (params); -#endif /* ACE_HAS_FORE_ATM_XTI/ACE_HAS_FORE_ATM_WS2/ACE_HAS_LINUX_ATM */ -} - -int -ACE_ATM_Acceptor::accept (ACE_ATM_Stream &new_sap, - ACE_Addr *remote_addr, - ACE_Time_Value *timeout, - int restart, - int reset_new_handle, - ACE_ATM_Params params, - ACE_ATM_QoS qos) -{ - ACE_TRACE ("ACE_ATM_Acceptor::accept"); -#if defined (ACE_HAS_FORE_ATM_XTI) - ATM_QoS optbuf = qos.get_qos (); - - return (acceptor_.accept (new_sap.get_stream (), - remote_addr, - timeout, - restart, - reset_new_handle, - params.get_rw_flag (), - params.get_user_data (), - &optbuf)); -#elif defined (ACE_HAS_FORE_ATM_WS2) - ACE_HANDLE n_handle; - ACE_HANDLE s_handle = ((ACE_SOCK_Acceptor *) this) -> get_handle (); - struct sockaddr_atm *cli_addr - = (struct sockaddr_atm *)remote_addr -> get_addr (); - int caddr_len = sizeof (struct sockaddr_atm); - - do { - n_handle = ACE_OS::accept (s_handle, - reinterpret_cast (cli_addr), - &caddr_len); - } while (n_handle == ACE_INVALID_HANDLE && errno == EINTR); - - ((ACE_ATM_Addr *)remote_addr) -> set (cli_addr, - ((ACE_ATM_Addr *)remote_addr) -> get_selector ()); - ((ACE_IPC_SAP *)&new_sap) -> set_handle (n_handle); - - return 0; -#elif defined (ACE_HAS_LINUX_ATM) - ACE_UNUSED_ARG (params); - - ACE_HANDLE s_handle = ((ACE_SOCK_Acceptor *) this) -> get_handle (); - struct atm_qos accept_qos = qos.get_qos (); - - if (ACE_OS::setsockopt (s_handle, - SOL_ATM, - SO_ATMQOS, - reinterpret_cast (&accept_qos), - sizeof (accept_qos)) < 0) { - ACE_OS::printf ("Acceptor (accept): error setting Qos"); - } - - return (acceptor_.accept (new_sap.get_stream (), - remote_addr, - timeout, - restart, - reset_new_handle)); -#else - ACE_UNUSED_ARG (new_sap); - ACE_UNUSED_ARG (remote_addr); - ACE_UNUSED_ARG (timeout); - ACE_UNUSED_ARG (restart); - ACE_UNUSED_ARG (reset_new_handle); - ACE_UNUSED_ARG (params); - ACE_UNUSED_ARG (qos); - return (0); -#endif /* ACE_HAS_FORE_ATM_XTI */ -} - -// Close versioned namespace, if enabled by the user. -ACE_END_VERSIONED_NAMESPACE_DECL - - -#endif /* ACE_HAS_ATM */ diff --git a/ACE/ace/ATM_Acceptor.h b/ACE/ace/ATM_Acceptor.h deleted file mode 100644 index 5ed236099e3..00000000000 --- a/ACE/ace/ATM_Acceptor.h +++ /dev/null @@ -1,123 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file ATM_Acceptor.h - * - * $Id$ - * - * @author Joe Hoffert - */ -//============================================================================= - - -#ifndef ACE_ATM_ACCEPTOR_H -#define ACE_ATM_ACCEPTOR_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_ATM) - -#include "ace/ATM_Stream.h" -#include "ace/ATM_Params.h" -#include "ace/ATM_QoS.h" - -#if defined (ACE_HAS_LINUX_ATM) -#include /**/ "atm.h" -#endif /* ACE_HAS_LINUX_ATM */ - -#if defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM) -#include "ace/SOCK_Acceptor.h" -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -typedef ACE_SOCK_Acceptor ATM_Acceptor; -ACE_END_VERSIONED_NAMESPACE_DECL -#elif defined (ACE_HAS_FORE_ATM_XTI) -#include "ace/TLI_Acceptor.h" -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -typedef ACE_TLI_Acceptor ATM_Acceptor; -ACE_END_VERSIONED_NAMESPACE_DECL -#endif // ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM - -// Open versioned namespace, if enabled by the user. -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Forward declarations. -class ACE_Time_Value; - -/** - * @class ACE_ATM_Acceptor - * - * @brief Defines the member functions for ACE_ATM_Acceptor abstraction. - * - * This class wraps up the ACE_SOCK_Acceptor and ACE_TLI_Acceptor - * to make the mechanism for the ATM protocol transparent. - */ -class ACE_Export ACE_ATM_Acceptor -{ - -public: - // = Initialization and termination methods. - /// Default constructor. - ACE_ATM_Acceptor (void); - - ~ACE_ATM_Acceptor (); - - /// Initiate a passive mode connection. - ACE_ATM_Acceptor (const ACE_Addr &remote_sap, - int backlog = ACE_DEFAULT_BACKLOG, - ACE_ATM_Params params = ACE_ATM_Params()); - - /// Initiate a passive mode socket. - ACE_HANDLE open (const ACE_Addr &remote_sap, - int backlog = ACE_DEFAULT_BACKLOG, - ACE_ATM_Params params = ACE_ATM_Params()); - - /// Close down the acceptor and release resources. - int close (void); - - // = Passive connection acceptance method. - - /// Accept a new data transfer connection. A @a timeout of 0 means - /// block forever, a @a timeout of {0, 0} means poll. @a restart == 1 - /// means "restart if interrupted." - int accept (ACE_ATM_Stream &new_sap, - ACE_Addr *remote_addr = 0, - ACE_Time_Value *timeout = 0, - int restart = 1, - int reset_new_handle = 0, - ACE_ATM_Params params = ACE_ATM_Params(), - ACE_ATM_QoS qos = ACE_ATM_QoS()); - - /// Get the local address currently listening on - int get_local_addr( ACE_ATM_Addr &local_addr ); - - // = Meta-type info - typedef ACE_ATM_Addr PEER_ADDR; - typedef ACE_ATM_Stream PEER_STREAM; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - ATM_Acceptor acceptor_; -}; - -// Close versioned namespace, if enabled by the user. -ACE_END_VERSIONED_NAMESPACE_DECL - - -#if defined (__ACE_INLINE__) -#include "ace/ATM_Acceptor.inl" -#endif /* __ACE_INLINE__ */ - -#endif /* ACE_HAS_ATM */ -#include /**/ "ace/post.h" -#endif /* ACE_ATM_ACCEPTOR_H */ diff --git a/ACE/ace/ATM_Acceptor.inl b/ACE/ace/ATM_Acceptor.inl deleted file mode 100644 index c08fd048f68..00000000000 --- a/ACE/ace/ATM_Acceptor.inl +++ /dev/null @@ -1,43 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -// Open versioned namespace, if enabled by the user. -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE void -ACE_ATM_Acceptor::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_ATM_Acceptor::dump"); -#endif /* ACE_HAS_DUMP */ -} - -ACE_INLINE -ACE_ATM_Acceptor::ACE_ATM_Acceptor (const ACE_Addr &remote_sap, - int backlog, - ACE_ATM_Params params) -{ - ACE_TRACE ("ACE_ATM_Acceptor::ACE_ATM_Acceptor"); - - //FUZZ: disable check_for_lack_ACE_OS - if (open (remote_sap, backlog, params) < 0) - //FUZZ: enable check_for_lack_ACE_OS - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_ATM_Acceptor::ACE_ATM_Acceptor"))); -} - -ACE_INLINE -int -ACE_ATM_Acceptor::close (void) -{ -#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM) - return (acceptor_.close()); -#else - return 0; -#endif // ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM -} - -// Close versioned namespace, if enabled by the user. -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/ATM_Addr.cpp b/ACE/ace/ATM_Addr.cpp deleted file mode 100644 index 19088cef5b1..00000000000 --- a/ACE/ace/ATM_Addr.cpp +++ /dev/null @@ -1,522 +0,0 @@ -// $Id$ - -// Defines the Internet domain address family address format. - -#include "ace/ATM_Addr.h" -#if defined (ACE_HAS_ATM) - -#include "ace/Log_Msg.h" - -#if defined (ACE_HAS_FORE_ATM_WS2) -#include /**/ "forews2.h" -#endif /* ACE_HAS_FORE_ATM_WS2 */ - -#if !defined (__ACE_INLINE__) -#include "ace/ATM_Addr.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, ATM_Addr, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Addr) - -#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) -#define BHLI_MAGIC "FORE_ATM" -// This is line rate in cells/s for an OC-3 MM interface. -const long ACE_ATM_Addr::LINE_RATE = 353207; -const int ACE_ATM_Addr::OPT_FLAGS_CPID = 0x1; -const int ACE_ATM_Addr::OPT_FLAGS_PMP = 0x2; -const int ACE_ATM_Addr::DEFAULT_SELECTOR = 0x99; -#elif defined (ACE_HAS_LINUX_ATM) -//pbrandao:for Linux: -//pbrandao:for now stick with current definitions -//pbrandao:see if later need to change -const long ACE_ATM_Addr::LINE_RATE = 353207; -const int ACE_ATM_Addr::OPT_FLAGS_CPID = 0; -const int ACE_ATM_Addr::OPT_FLAGS_PMP = 0; -const int ACE_ATM_Addr::DEFAULT_SELECTOR = 0x99; -#else -const long ACE_ATM_Addr::LINE_RATE = 0L; -const int ACE_ATM_Addr::OPT_FLAGS_CPID = 0; -const int ACE_ATM_Addr::OPT_FLAGS_PMP = 0; -const int ACE_ATM_Addr::DEFAULT_SELECTOR = 0x0; -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ - -// Default constructor - -ACE_ATM_Addr::ACE_ATM_Addr (u_char selector) -#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) - : ACE_Addr (AF_ATM, -#elif defined (ACE_HAS_LINUX_ATM) - : ACE_Addr (PF_ATMSVC, -#else - : ACE_Addr (AF_UNSPEC, -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ - sizeof this->atm_addr_) -{ - // ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr"); - (void) ACE_OS::memset ((void *) &this->atm_addr_, - 0, - sizeof this->atm_addr_); - this->init (selector); -} - -// Copy constructor. - -ACE_ATM_Addr::ACE_ATM_Addr (const ACE_ATM_Addr &sap, - u_char selector) -#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) - : ACE_Addr (AF_ATM, -#elif defined (ACE_HAS_LINUX_ATM) - : ACE_Addr (PF_ATMSVC, -#else - : ACE_Addr (AF_UNSPEC, -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ - sizeof this->atm_addr_) -{ - ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr"); - this->set (sap, selector); -#if defined (ACE_HAS_LINUX_ATM) - this->atm_addr_.sockaddratmsvc.sas_family = PF_ATMSVC; - this->atm_addr_.atmsap.blli[0].l3_proto = ATM_L3_NONE; - this->atm_addr_.atmsap.blli[0].l2_proto = ATM_L2_NONE; - this->atm_addr_.atmsap.bhli.hl_type = ATM_HL_NONE; -#endif /* ACE_HAS_LINUX_ATM */ -} - -ACE_ATM_Addr::ACE_ATM_Addr (const ATM_Addr *sap, - u_char selector) -#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) - : ACE_Addr (AF_ATM, -#elif defined (ACE_HAS_LINUX_ATM) - : ACE_Addr (PF_ATMSVC, -#else - : ACE_Addr (AF_UNSPEC, -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ - sizeof this->atm_addr_) -{ - ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr"); - this->set (sap, selector); -} - - -ACE_ATM_Addr::ACE_ATM_Addr (const ACE_TCHAR sap[], - u_char selector) -#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) - : ACE_Addr (AF_ATM, -#elif defined (ACE_HAS_LINUX_ATM) - : ACE_Addr (PF_ATMSVC, -#else - : ACE_Addr (AF_UNSPEC, -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ - sizeof this->atm_addr_) -{ - ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr"); - this->set (sap, selector); -} - -ACE_ATM_Addr::~ACE_ATM_Addr (void) -{ -} - -// Return the address. - -void * -ACE_ATM_Addr::get_addr (void) const -{ - ACE_TRACE ("ACE_ATM_Addr::get_addr"); - return (void *) &this->atm_addr_; -} - -void -ACE_ATM_Addr::init (u_char selector) -{ -#if defined (ACE_HAS_FORE_ATM_XTI) - // Note: this approach may be FORE implementation-specific. When we - // bind with tag_addr ABSENT and tag_selector PRESENT, only the - // selector (i.e. address[19]) is used by the TP. The rest of the - // local address is filled in by the TP and can be obtained via the - // 'ret' parameter or with t_getname ()/t_getprotaddr (). - - atm_addr_.addressType = (u_int16_t) AF_ATM; - - atm_addr_.sap.t_atm_sap_addr.SVE_tag_addr = (int8_t) T_ATM_ABSENT; - atm_addr_.sap.t_atm_sap_addr.SVE_tag_selector = (int8_t) T_ATM_PRESENT; - - atm_addr_.sap.t_atm_sap_addr.address_format = (u_int8_t) T_ATM_ENDSYS_ADDR; - atm_addr_.sap.t_atm_sap_addr.address_length = ATMNSAP_ADDR_LEN; - atm_addr_.sap.t_atm_sap_addr.address[ATMNSAP_ADDR_LEN - 1] = selector; - - atm_addr_.sap.t_atm_sap_layer2.SVE_tag = (int8_t) T_ATM_ABSENT; - atm_addr_.sap.t_atm_sap_layer3.SVE_tag = (int8_t) T_ATM_ABSENT; - - atm_addr_.sap.t_atm_sap_appl.SVE_tag = (int8_t) T_ATM_PRESENT; - atm_addr_.sap.t_atm_sap_appl.ID_type = (u_int8_t) T_ATM_USER_APP_ID; - - ACE_OS::memcpy (atm_addr_.sap.t_atm_sap_appl.ID.user_defined_ID, - BHLI_MAGIC, - sizeof atm_addr_.sap.t_atm_sap_appl.ID); -#elif defined (ACE_HAS_FORE_ATM_WS2) - ACE_OS::memset ((void *)&atm_addr_, 0, sizeof atm_addr_); - atm_addr_.satm_number.Addr[ ATM_ADDR_SIZE - 1 ] = (char)selector; - atm_addr_.satm_family = AF_ATM; - atm_addr_.satm_number.AddressType = ATM_NSAP; - atm_addr_.satm_number.NumofDigits = ATM_ADDR_SIZE; - atm_addr_.satm_blli.Layer2Protocol = SAP_FIELD_ABSENT; - atm_addr_.satm_blli.Layer3Protocol = SAP_FIELD_ABSENT; - atm_addr_.satm_bhli.HighLayerInfoType = SAP_FIELD_ABSENT; - - // Need to know the correspondence. - //atm_addr_.sap.t_atm_sap_appl.SVE_tag = (int8_t) T_ATM_PRESENT; - //atm_addr_.sap.t_atm_sap_appl.ID_type = (u_int8_t) T_ATM_USER_APP_ID; - //ACE_OS::memcpy (atm_addr_.sap.t_atm_sap_appl.ID.user_defined_ID, - // BHLI_MAGIC, - // sizeof atm_addr_.sap.t_atm_sap_appl.ID); -#elif defined (ACE_HAS_LINUX_ATM) - atm_addr_.sockaddratmsvc.sas_family = AF_ATMSVC; - atm_addr_.sockaddratmsvc.sas_addr.prv[ATM_ESA_LEN - 1] = (char)selector; - atm_addr_.atmsap.blli[0].l3_proto = ATM_L3_NONE; - atm_addr_.atmsap.blli[0].l2_proto = ATM_L2_NONE; - atm_addr_.atmsap.bhli.hl_type = ATM_HL_NONE; -#else - ACE_UNUSED_ARG (selector); -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ -} - -int -ACE_ATM_Addr::set (const ACE_ATM_Addr &sap, - u_char selector) -{ - ACE_TRACE ("ACE_ATM_Addr::set"); - - this->init (selector); - - this->ACE_Addr::base_set (sap.get_type (), - sap.get_size ()); - -#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) - ACE_ASSERT (sap.get_type () == AF_ATM); -#elif defined (ACE_HAS_LINUX_ATM) - ACE_ASSERT (sap.get_type () == PF_ATMSVC); -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */ - - (void) ACE_OS::memcpy ((void *) &this->atm_addr_, - (void *) &sap.atm_addr_, - sizeof this->atm_addr_); - return 0; -} - -int -ACE_ATM_Addr::set (const ATM_Addr *sap, - u_char selector) -{ - ACE_TRACE ("ACE_ATM_Addr::set"); - - this->init (selector); - -#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) - this->ACE_Addr::base_set (AF_ATM, -#elif defined (ACE_HAS_LINUX_ATM) - this->ACE_Addr::base_set (PF_ATMSVC, -#else - this->ACE_Addr::base_set (AF_UNSPEC, -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */ - sizeof (*sap)); - - (void) ACE_OS::memcpy ((void *) &this->atm_addr_, - (void *) sap, - sizeof this->atm_addr_); - return 0; -} - -int -ACE_ATM_Addr::set (const ACE_TCHAR address[], - u_char selector) -{ - ACE_TRACE ("ACE_ATM_Addr::set"); - int ret; - - this->init (selector); - -#if defined (ACE_HAS_FORE_ATM_XTI) - atm_addr_.sap.t_atm_sap_addr.SVE_tag_addr = - (int8_t) T_ATM_PRESENT; -#endif /* ACE_HAS_FORE_ATM_XTI */ - - ret = this -> string_to_addr (address); - this -> set_selector (selector); - return ret; -} - -// Transform the string into the current addressing format. - -int -ACE_ATM_Addr::string_to_addr (const ACE_TCHAR sap[]) -{ - ACE_TRACE ("ACE_ATM_Addr::string_to_addr"); - -#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) - this->ACE_Addr::base_set (AF_ATM, -#elif defined (ACE_HAS_LINUX_ATM) - this->ACE_Addr::base_set (PF_ATMSVC, -#else - this->ACE_Addr::base_set (AF_UNSPEC, -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ - sizeof this->atm_addr_); -#if defined (ACE_HAS_FORE_ATM_XTI) - struct hostent *entry; - struct atmnsap_addr *nsap; - - // Yow, someone gave us a NULL ATM address! - if (sap == 0) - { - errno = EINVAL; - return -1; - } - else if ((entry = gethostbyname_atmnsap ((ACE_TCHAR *)sap)) != 0) - { - ACE_OS::memcpy (atm_addr_.sap.t_atm_sap_addr.address, - entry->h_addr_list[0], - ATMNSAP_ADDR_LEN - 1); - } - else if ((nsap = atmnsap_addr (sap)) != 0) - { - ACE_OS::memcpy (atm_addr_.sap.t_atm_sap_addr.address, - nsap->atmnsap, - ATMNSAP_ADDR_LEN); - } - else { - errno = EINVAL; - return -1; - } -#elif defined (ACE_HAS_FORE_ATM_WS2) - DWORD dwValue; - HANDLE hLookup; - WSAQUERYSETW qsRestrictions; - CSADDR_INFO csaBuffer; - WCHAR tmpWStr[100]; - - MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, sap, -1, tmpWStr, 100); - - csaBuffer.LocalAddr.iSockaddrLength = sizeof (struct sockaddr_atm); - csaBuffer.LocalAddr.lpSockaddr = (struct sockaddr *)&atm_addr_; - csaBuffer.RemoteAddr.iSockaddrLength = sizeof (struct sockaddr_atm); - csaBuffer.RemoteAddr.lpSockaddr = (struct sockaddr *)&atm_addr_; - - qsRestrictions.dwSize = sizeof (WSAQUERYSETW); - qsRestrictions.lpszServiceInstanceName = 0; - qsRestrictions.lpServiceClassId = &FORE_NAME_CLASS; - qsRestrictions.lpVersion = 0; - qsRestrictions.lpszComment = 0; - qsRestrictions.dwNameSpace = FORE_NAME_SPACE; - qsRestrictions.lpNSProviderId = 0; - qsRestrictions.lpszContext = L""; - qsRestrictions.dwNumberOfProtocols = 0; - qsRestrictions.lpafpProtocols = 0; - qsRestrictions.lpszQueryString = tmpWStr; - qsRestrictions.dwNumberOfCsAddrs = 1; - qsRestrictions.lpcsaBuffer = &csaBuffer; - qsRestrictions.lpBlob = 0; //&blob; - - if (::WSALookupServiceBeginW (&qsRestrictions, LUP_RETURN_ALL, &hLookup) - == SOCKET_ERROR) { - ACE_OS::printf ("Error: WSALookupServiceBeginW failed! %d\n", - ::WSAGetLastError ()); - return -1; - } - - dwValue = sizeof (WSAQUERYSETW); - - if (::WSALookupServiceNextW (hLookup, 0, &dwValue, &qsRestrictions) - == SOCKET_ERROR) { - if (WSAGetLastError () != WSA_E_NO_MORE) { - ACE_OS::printf ("Error: WSALookupServiceNextW failed! %d\n", - ::WSAGetLastError ()); - return -1; - } - } - - if (WSALookupServiceEnd (hLookup) == SOCKET_ERROR) { - ACE_OS::printf ("Error : WSALookupServiceEnd failed! %d \n", - ::WSAGetLastError ()); - errno = EINVAL; - return -1; - } -#elif defined (ACE_HAS_LINUX_ATM) - if (sap == 0 || !ACE_OS::strcmp (sap,"")) { - errno = EINVAL; - return -1; - } - - if (text2atm ((ACE_TCHAR *)sap, - (struct sockaddr *)& (atm_addr_.sockaddratmsvc), - sizeof (atm_addr_.sockaddratmsvc), - T2A_SVC | T2A_NAME) < 0) { - ACE_DEBUG (LM_DEBUG, - "Error : text2atm failed!\n"); - errno = EINVAL; - return -1; - } -#else - ACE_UNUSED_ARG (sap); - - return 0; -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ - -#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM) - return 0; -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */ -} - -// Transform the current address into string format. - -int -ACE_ATM_Addr::addr_to_string (ACE_TCHAR addr[], - size_t addrlen) const -{ - ACE_TRACE ("ACE_ATM_Addr::addr_to_string"); - -#if defined (ACE_HAS_FORE_ATM_XTI) - ACE_TCHAR buffer[MAXNAMELEN + 1]; - struct atmnsap_addr nsap; - ACE_OS::memcpy (nsap.atmnsap, - atm_addr_.sap.t_atm_sap_addr.address, - ATMNSAP_ADDR_LEN); - ACE_OS::sprintf (buffer, - ACE_TEXT ("%s"), - atmnsap_ntoa (nsap)); - - size_t total_len = ACE_OS::strlen (buffer) + sizeof ('\0'); - - if (addrlen < total_len) - return -1; - else - ACE_OS::strcpy (addr, buffer); - - return 0; -#elif defined (ACE_HAS_FORE_ATM_WS2) - ACE_TCHAR buffer[MAXNAMELEN + 1]; - int i; - - if (addrlen < ATM_ADDR_SIZE + 1) - return -1; - - for (i = 0; i < ATM_ADDR_SIZE; i++) { - buffer[ i * 3 ] = '\0'; - ACE_OS::sprintf (buffer, ACE_TEXT ("%s%02x."), - buffer, - atm_addr_.satm_number.Addr[ i ]); - } - - buffer[ ATM_ADDR_SIZE * 3 - 1 ] = '\0'; - ACE_OS::strcpy (addr, buffer); - - return 0; -#elif defined (ACE_HAS_LINUX_ATM) - ACE_TCHAR buffer[MAX_ATM_ADDR_LEN + 1]; - int total_len; - if ((total_len = atm2text (buffer, - sizeof buffer, - (struct sockaddr *)& (atm_addr_.sockaddratmsvc), - A2T_PRETTY)) < 0) { - ACE_DEBUG ((LM_DEBUG,"ACE_ATM_Addr (addr_to_string): atm2text failed\n")); - return -1; - } - if (addrlen < (size_t)total_len) - return -1; - else - ACE_OS::strcpy (addr, - buffer); - - return 0; -#else - ACE_UNUSED_ARG (addr); - ACE_UNUSED_ARG (addrlen); - return -1; -#endif /* ACE_HAS_FORE_ATM_XTI && ACE_HAS_FORE_ATM_WS2 */ -} - -const ACE_TCHAR * -ACE_ATM_Addr::addr_to_string (void) const -{ - ACE_TRACE ("ACE_ATM_Addr::addr_to_string"); - - static ACE_TCHAR addr[MAXHOSTNAMELEN + 1]; - if (this->addr_to_string (addr, - MAXHOSTNAMELEN + 1) < 0) - return 0; - - return addr; -} - -// Set a pointer to the address. -void -ACE_ATM_Addr::set_addr (void *addr, int len) -{ - ACE_TRACE ("ACE_ATM_Addr::set_addr"); - -#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) - this->ACE_Addr::base_set (AF_ATM, -#elif defined (ACE_HAS_LINUX_ATM) - this->ACE_Addr::base_set (PF_ATMSVC, -#else - this->ACE_Addr::base_set (AF_UNSPEC, -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_WS2 */ - len); - ACE_OS::memcpy ((void *) &this->atm_addr_, - (void *) addr, len); -} - -// Compare two addresses for inequality. - -bool -ACE_ATM_Addr::operator != (const ACE_ATM_Addr &sap) const -{ - ACE_TRACE ("ACE_ATM_Addr::operator !="); - return ! ((*this) == sap); -} - -// Compare two addresses for equality. - -bool -ACE_ATM_Addr::operator == (const ACE_ATM_Addr &sap) const -{ - ACE_TRACE ("ACE_ATM_Addr::operator =="); - -#if defined (ACE_HAS_LINUX_ATM) - return (atm_equal ((const struct sockaddr *)& (this->atm_addr_.sockaddratmsvc), - (const struct sockaddr *)& (sap.atm_addr_.sockaddratmsvc), - 0, - 0) - && - sap_equal (& (this->atm_addr_.atmsap), - & (sap.atm_addr_.atmsap), - 0)); -#else - return ACE_OS::memcmp (&atm_addr_, - &sap.atm_addr_, - sizeof (ATM_Addr)) == 0; -#endif /* ACE_HAS_LINUX_ATM */ -} - -void -ACE_ATM_Addr::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_ATM_Addr::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - - ACE_TCHAR s[ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 16]; - ACE_OS::sprintf (s, - ACE_TEXT ("%s"), - this->addr_to_string ()); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s"), s)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_ATM */ diff --git a/ACE/ace/ATM_Addr.h b/ACE/ace/ATM_Addr.h deleted file mode 100644 index 34cbfd876a6..00000000000 --- a/ACE/ace/ATM_Addr.h +++ /dev/null @@ -1,197 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file ATM_Addr.h - * - * $Id$ - * - * @author Joe Hoffert - */ -//========================================================================== - -#ifndef ACE_ATM_ADDR_H -#define ACE_ATM_ADDR_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_ATM) - -#include /**/ "ace/ACE_export.h" -#include "ace/Addr.h" - -#if defined (ACE_HAS_FORE_ATM_XTI) -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -typedef ATMSAPAddress ATM_Addr; -ACE_END_VERSIONED_NAMESPACE_DECL -#elif defined (ACE_HAS_FORE_ATM_WS2) -#define FORE_NAME_SPACE NS_ALL -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -typedef struct sockaddr_atm ATM_Addr; -ACE_END_VERSIONED_NAMESPACE_DECL -#elif defined (ACE_HAS_LINUX_ATM) - -#include /**/ "atm.h" - -// Open versioned namespace, if enabled by the user. -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -//pbrandao:as Linux has this 2 structs separeted we "link it" here -typedef struct _linux_atm_addr -{ - struct sockaddr_atmsvc sockaddratmsvc; - struct atm_sap atmsap; -} ATM_Addr; -#else -typedef int ATM_Addr; -#endif /* ACE_HAS_FORE_ATM_XTI/ACE_HAS_FORE_ATM_WS2/ACE_HAS_LINUX_ATM */ - -/** - * @class ACE_ATM_Addr - * - * @brief Defines the ATM domain address family address format. - */ -class ACE_Export ACE_ATM_Addr : public ACE_Addr -{ -public: - // Constants used for ATM options - static const long LINE_RATE; - static const int OPT_FLAGS_CPID; - static const int OPT_FLAGS_PMP; - static const int DEFAULT_SELECTOR; - - // = Initialization methods. - /// Default constructor. - ACE_ATM_Addr (u_char selector = DEFAULT_SELECTOR); - - /// Copy constructor. - ACE_ATM_Addr (const ACE_ATM_Addr &, - u_char selector = DEFAULT_SELECTOR); - - /** - * Creates an ACE_ATM_Addr from an ATMSAPAddress structure. This - * is vendor specific (FORE systems). May need to change when other - * vendors are supported. - */ - ACE_ATM_Addr (const ATM_Addr *, - u_char selector = DEFAULT_SELECTOR); - - /** - * Initializes an ACE_ATM_Addr from the which can be - * "atm-address" (e.g., - * "47.0005.80.ffe100.0000.f20f.2200.0020480694f9.00") or "hostname" - * (e.g., "frisbee.cs.wustl.edu"). - */ - ACE_ATM_Addr (const ACE_TCHAR sap[], - u_char selector = DEFAULT_SELECTOR); - - /// Default dtor. - ~ACE_ATM_Addr (void); - - // = Initialization methods (useful after object construction). - /// Default initialization for non-address values (e.g., - /// t_atm_sap_addr.SVE_tag_addr, t_atm_sap_addr.SVE_tag_selector) - void init (u_char selector = DEFAULT_SELECTOR); - - /// Initializes from another ACE_ATM_Addr. - int set (const ACE_ATM_Addr &, - u_char selector = DEFAULT_SELECTOR); - - /** - * Initializes an ACE_ATM_Addr from an ATMSAPAddress/sockaddr_atm - * structure. This is vendor specific (FORE systems). May need to - * change when other vendors are supported. - */ - int set (const ATM_Addr *, - u_char selector = DEFAULT_SELECTOR); - - /** - * Initializes an ACE_ATM_Addr from the which can be - * "atm-address" (e.g., - * "47.0005.80.ffe100.0000.f20f.2200.0020480694f9.00") or "hostname" - * (e.g., "frisbee.cs.wustl.edu"). - */ - int set (const ACE_TCHAR sap[], - u_char selector = DEFAULT_SELECTOR); - - /** - * Initializes an ACE_ATM_Addr from the which can be - * "atm-address" (e.g., - * "47.0005.80.ffe100.0000.f20f.2200.0020480694f9.00") or "hostname" - * (e.g., "frisbee.cs.wustl.edu"). - */ - virtual int string_to_addr (const ACE_TCHAR sap[]); - - /** - * Return the character representation of the ATM address (e.g., - * "47.0005.80.ffe100.0000.f20f.2200.0020480694f9.00") storing it in - * the @a addr (which is assumed to be bytes long). This - * version is reentrant. Returns -1 if the of the @a addr - * is too small, else 0. - */ - virtual int addr_to_string (ACE_TCHAR addr[], - size_t addrlen) const; - - /** - * Return the character representation of the ATM address (e.g., - * "47.0005.80.ffe100.0000.f20f.2200.0020480694f9.00"). Returns -1 - * if the of the is too small, else 0.(This version - * is non-reentrant since it returns a pointer to a static data - * area.) - */ - const ACE_TCHAR *addr_to_string (void) const; - - /// Return a pointer to the underlying network address. - virtual void *get_addr (void) const; - - /// Set a pointer to the address. - virtual void set_addr (void *, int); - - /// Return the selector for network address. - u_char get_selector (void) const; - - /// Set the selector for the network address. - void set_selector (u_char selector); - - /** - * Compare two addresses for equality. The addresses are considered - * equal if they contain the same ATM address. Q: Is there any - * other check for equality needed for ATM? - */ - bool operator == (const ACE_ATM_Addr &SAP) const; - - /// Compare two addresses for inequality. - bool operator != (const ACE_ATM_Addr &SAP) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -// char *construct_options (ACE_HANDLE fd, -// int qos_kb, -// int flags, -// long *optsize); -// // Construct options for ATM connections - -private: - ATM_Addr atm_addr_; -}; - -// Close versioned namespace, if enabled by the user. -ACE_END_VERSIONED_NAMESPACE_DECL - - -#if defined (__ACE_INLINE__) -#include "ace/ATM_Addr.inl" -#endif /* __ACE_INLINE__ */ - -#endif /* ACE_HAS_ATM */ -#include /**/ "ace/post.h" -#endif /* ACE_ATM_ADDR_H */ diff --git a/ACE/ace/ATM_Addr.inl b/ACE/ace/ATM_Addr.inl deleted file mode 100644 index 8120c6d11d5..00000000000 --- a/ACE/ace/ATM_Addr.inl +++ /dev/null @@ -1,37 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE u_char -ACE_ATM_Addr::get_selector (void) const -{ - ACE_TRACE ("ACE_ATM_Addr::get_selector"); -#if defined (ACE_HAS_FORE_ATM_XTI) - return atm_addr_.sap.t_atm_sap_addr.address[ATMNSAP_ADDR_LEN - 1]; -#elif defined (ACE_HAS_FORE_ATM_WS2) - return atm_addr_.satm_number.Addr[ ATM_ADDR_SIZE - 1 ]; -#elif defined (ACE_HAS_LINUX_ATM) - return atm_addr_.sockaddratmsvc.sas_addr.prv[ATM_ESA_LEN - 1]; -#else - return 0; -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ -} - -ACE_INLINE void -ACE_ATM_Addr::set_selector (u_char selector) -{ - ACE_TRACE ("ACE_ATM_Addr::set_selector"); -#if defined (ACE_HAS_FORE_ATM_XTI) - atm_addr_.sap.t_atm_sap_addr.address[ATMNSAP_ADDR_LEN - 1] = selector; -#elif defined (ACE_HAS_FORE_ATM_WS2) - atm_addr_.satm_number.Addr[ ATM_ADDR_SIZE - 1 ] = selector; -#elif defined (ACE_HAS_LINUX_ATM) - atm_addr_.sockaddratmsvc.sas_addr.prv[ATM_ESA_LEN - 1] = selector; -#else - ACE_UNUSED_ARG (selector); -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/ATM_Connector.cpp b/ACE/ace/ATM_Connector.cpp deleted file mode 100644 index ca33a2bb833..00000000000 --- a/ACE/ace/ATM_Connector.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// ATM_Connector.cpp -// $Id$ - -#include "ace/ATM_Connector.h" -#if defined (ACE_HAS_ATM) - -#include "ace/Handle_Set.h" - -ACE_RCSID(ace, ATM_Connector, "$Id$") - -#if !defined (__ACE_INLINE__) -#include "ace/ATM_Connector.inl" -#endif /* __ACE_INLINE__ */ - -// Open versioned namespace, if enabled by the user. -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Connector) - -ACE_ATM_Connector::ACE_ATM_Connector (void) -{ - ACE_TRACE ("ACE_ATM_Connector::ACE_ATM_Connector"); -} - -// Actively connect and produce a new ACE_ATM_Stream if things go well... -// Connect the to the , waiting up to -// amount of time if necessary. - -int -ACE_ATM_Connector::connect (ACE_ATM_Stream &new_stream, - const ACE_ATM_Addr &remote_sap, - ACE_ATM_Params params, - ACE_ATM_QoS options, - ACE_Time_Value *timeout, - const ACE_ATM_Addr &local_sap, - int reuse_addr, - int flags, - int perms) -{ - ACE_TRACE ("ACE_ATM_Connector::connect"); -#if defined (ACE_HAS_FORE_ATM_XTI) - return connector_.connect(new_stream.get_stream(), - remote_sap, - timeout, - local_sap, - reuse_addr, - flags, - perms, - params.get_device(), - params.get_info(), - params.get_rw_flag(), - params.get_user_data(), - &options.get_qos()); -#elif defined (ACE_HAS_FORE_ATM_WS2) - ACE_DEBUG(LM_DEBUG, - ACE_TEXT ("ATM_Connector(connect): set QoS parameters\n" )); - - ACE_HANDLE s = new_stream.get_handle(); - struct sockaddr_atm *saddr = ( struct sockaddr_atm *)remote_sap.get_addr(); - ACE_QoS cqos = options.get_qos(); - - ACE_QoS_Params qos_params = ACE_QoS_Params(0, - 0, - &cqos, - 0, - 0); - - ACE_DEBUG(LM_DEBUG, - ACE_TEXT ("ATM_Connector(connect): connecting...\n")); - - int result = ACE_OS::connect( s, - ( struct sockaddr *)saddr, - sizeof( struct sockaddr_atm ), - qos_params ); - - if ( result != 0 ) - ACE_OS::printf( "ATM_Connector(connect): connection failed, %d\n", - ::WSAGetLastError()); - - return result; -#elif defined (ACE_HAS_LINUX_ATM) - ACE_UNUSED_ARG (params); - ACE_UNUSED_ARG (timeout); - ACE_UNUSED_ARG (reuse_addr); - ACE_UNUSED_ARG (perms); - ACE_UNUSED_ARG (flags); - - ACE_HANDLE handle = new_stream.get_handle(); - ATM_QoS qos =options.get_qos(); - ATM_Addr *local_addr=(ATM_Addr*)local_sap.get_addr(), - *remote_addr=(ATM_Addr*)remote_sap.get_addr(); - - if (ACE_OS::setsockopt(handle, - SOL_ATM, - SO_ATMSAP, - reinterpret_cast (&(local_addr->atmsap)), - sizeof(local_addr->atmsap)) < 0) { - ACE_OS::printf( "ATM_Connector(connect): unable to set atmsap %d\nContinuing...", - errno); - } - if (ACE_OS::setsockopt(handle, - SOL_ATM, - SO_ATMQOS, - reinterpret_cast (&qos), - sizeof(qos)) < 0) { - ACE_DEBUG((LM_DEBUG,ACE_TEXT ("ATM_Connector(connect): unable to set qos %d\n"), - errno)); - return -1; - } - - int result = ACE_OS::connect(handle, - (struct sockaddr *)&(remote_addr->sockaddratmsvc), - sizeof( remote_addr->sockaddratmsvc)); - - if ( result != 0 ) - ACE_DEBUG(LM_DEBUG, - ACE_TEXT ("ATM_Connector(connect): connection failed, %d\n"), - errno); - - return result; -#else - ACE_UNUSED_ARG (new_stream); - ACE_UNUSED_ARG (remote_sap); - ACE_UNUSED_ARG (params); - ACE_UNUSED_ARG (options); - ACE_UNUSED_ARG (timeout); - ACE_UNUSED_ARG (local_sap); - ACE_UNUSED_ARG (reuse_addr); - ACE_UNUSED_ARG (flags); - ACE_UNUSED_ARG (perms); - return 0; -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ -} - -// Close versioned namespace, if enabled by the user. -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_ATM */ diff --git a/ACE/ace/ATM_Connector.h b/ACE/ace/ATM_Connector.h deleted file mode 100644 index 7e820ae765e..00000000000 --- a/ACE/ace/ATM_Connector.h +++ /dev/null @@ -1,164 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file ATM_Connector.h - * - * $Id$ - * - * @author Joe Hoffert - */ -//============================================================================= - -#ifndef ACE_ATM_CONNECTOR_H -#define ACE_ATM_CONNECTOR_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_ATM) - -#include "ace/ATM_Stream.h" -#include "ace/ATM_Params.h" -#include "ace/ATM_QoS.h" - -#if defined (ACE_WIN32) || defined (ACE_HAS_LINUX_ATM) -#include "ace/SOCK_Connector.h" -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -typedef ACE_SOCK_Connector ATM_Connector; -ACE_END_VERSIONED_NAMESPACE_DECL -#else -#include "ace/XTI_ATM_Mcast.h" -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -typedef ACE_XTI_ATM_Mcast ATM_Connector; -// Open versioned namespace, if enabled by the user. -ACE_END_VERSIONED_NAMESPACE_DECL -#endif - -// Open versioned namespace, if enabled by the user. -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_ATM_Connector - * - * @brief Defines an active connection factory for the ACE_ATM C++ - * wrappers. - */ -class ACE_Export ACE_ATM_Connector -{ -public: - // = Initialization methods. - /// Default constructor. - ACE_ATM_Connector (void); - - /** - * Actively connect and produce a @a new_stream if things go well. - * The @a remote_sap is the address that we are trying to connect - * with. The are the parameters needed for either socket - * or XTI/ATM connections. The @a timeout is the amount of time to - * wait to connect. If it's 0 then we block indefinitely. If - * *timeout == {0, 0} then the connection is done using non-blocking - * mode. In this case, if the connection can't be made immediately - * the value of -1 is returned with @c errno == EWOULDBLOCK. If - * *timeout > {0, 0} then this is the maximum amount of time to wait before - * timing out. If the time expires before the connection is made - * @c errno == ETIME. The @a local_sap is the value of local address - * to bind to. If it's the default value of then - * the user is letting the OS do the binding. If @a reuse_addr == 1 - * then the is reused, even if it hasn't been cleanedup yet. - */ - ACE_ATM_Connector (ACE_ATM_Stream &new_stream, - const ACE_ATM_Addr &remote_sap, - ACE_ATM_Params params = ACE_ATM_Params(), - ACE_ATM_QoS options = ACE_ATM_QoS(), - ACE_Time_Value *timeout = 0, - const ACE_ATM_Addr &local_sap = ACE_ATM_Addr( "", 0 ), - int reuse_addr = 0, -#if defined (ACE_WIN32) - int flags = 0, -#else - int flags = O_RDWR, -#endif /* ACE_WIN32 */ - int perms = 0); - - /** - * Actively connect and produce a @a new_stream if things go well. - * The @a remote_sap is the address that we are trying to connect - * with. The are the parameters needed for either socket - * or XTI/ATM connections. The @a timeout is the amount of time to - * wait to connect. If it's 0 then we block indefinitely. If - * *timeout == {0, 0} then the connection is done using non-blocking - * mode. In this case, if the connection can't be made immediately - * the value of -1 is returned with @c errno == EWOULDBLOCK. If - * *timeout > {0, 0} then this is the maximum amount of time to wait before - * timing out. If the time expires before the connection is made - * @c errno == ETIME. The @a local_sap is the value of local address - * to bind to. If it's the default value of then - * the user is letting the OS do the binding. If @a reuse_addr == 1 - * then the is reused, even if it hasn't been cleanedup yet. - */ - int connect (ACE_ATM_Stream &new_stream, - const ACE_ATM_Addr &remote_sap, - ACE_ATM_Params params = ACE_ATM_Params(), - ACE_ATM_QoS options = ACE_ATM_QoS(), - ACE_Time_Value *timeout = 0, - const ACE_ATM_Addr &local_sap = ACE_ATM_Addr( "", - 0 ), - int reuse_addr = 0, -#if defined (ACE_WIN32) - int flags = 0, -#else - int flags = O_RDWR, -#endif /* ACE_WIN32 */ - int perms = 0); - - /** - * Try to complete a non-blocking connection. - * If connection completion is successful then @a new_stream contains - * the connected ACE_SOCK_Stream. If @a remote_sap is non-NULL then it - * will contain the address of the connected peer. - */ - int complete (ACE_ATM_Stream &new_stream, - ACE_ATM_Addr *remote_sap, - ACE_Time_Value *tv); - - /** - * Actively add a leaf to the root (i.e., point-to-multipoint). The - * @a remote_sap is the address of the leaf that we - * are trying to add. - */ - int add_leaf (ACE_ATM_Stream ¤t_stream, - const ACE_Addr &remote_sap, - ACE_ATM_QoS &qos); - - /// Resets any event associations on this handle - int reset_new_handle (ACE_HANDLE handle); - - // = Meta-type info - typedef ACE_ATM_Addr PEER_ADDR; - typedef ACE_ATM_Stream PEER_STREAM; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - ATM_Connector connector_; -}; - -// Open versioned namespace, if enabled by the user. -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/ATM_Connector.inl" -#endif /* __ACE_INLINE__ */ - -#endif /* ACE_HAS_ATM */ -#include /**/ "ace/post.h" -#endif /* ACE_ATM_CONNECTOR_H */ diff --git a/ACE/ace/ATM_Connector.inl b/ACE/ace/ATM_Connector.inl deleted file mode 100644 index b9372ccb34d..00000000000 --- a/ACE/ace/ATM_Connector.inl +++ /dev/null @@ -1,132 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -// Open versioned namespace, if enabled by the user. -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE void -ACE_ATM_Connector::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_ATM_Connector::dump"); -#endif /* ACE_HAS_DUMP */ -} - -ACE_INLINE -ACE_ATM_Connector::ACE_ATM_Connector (ACE_ATM_Stream &new_stream, - const ACE_ATM_Addr &remote_sap, - ACE_ATM_Params params, - ACE_ATM_QoS options, - ACE_Time_Value *timeout, - const ACE_ATM_Addr &local_sap, - int reuse_addr, - int flags, - int perms) -{ - ACE_TRACE ("ACE_ATM_Connector::ACE_ATM_Connector"); - if ((ACE_HANDLE)this->connect (new_stream, - remote_sap, - params, - options, - timeout, - local_sap, - reuse_addr, - flags, - perms) == ACE_INVALID_HANDLE - && timeout != 0 && !(errno == EWOULDBLOCK || errno == ETIME)) - ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_ATM_Stream::ACE_ATM_Stream"))); -} - -// Try to complete a non-blocking connection. - -ACE_INLINE -int -ACE_ATM_Connector::complete (ACE_ATM_Stream &new_stream, - ACE_ATM_Addr *remote_sap, - ACE_Time_Value *tv) -{ - ACE_TRACE ("ACE_ATM_Connector::complete"); -#if defined (ACE_HAS_ATM) - return connector_.complete(new_stream.get_stream(), - remote_sap, - tv); -#else - ACE_UNUSED_ARG(new_stream); - ACE_UNUSED_ARG(remote_sap); - ACE_UNUSED_ARG(tv); - return 0; -#endif -} - -ACE_INLINE -int -ACE_ATM_Connector::add_leaf (ACE_ATM_Stream ¤t_stream, - const ACE_Addr &remote_sap, - ACE_ATM_QoS &qos) -{ - ACE_TRACE ("ACE_ATM_Connector::add_leaf"); -#if defined (ACE_HAS_FORE_ATM_XTI) - return connector_.add_leaf(current_stream.get_stream(), - remote_sap, - leaf_id, - timeout); -#elif defined (ACE_HAS_FORE_ATM_WS2) - struct sockaddr_atm *saddr = (struct sockaddr_atm *)remote_sap.get_addr(); - ACE_QoS cqos = qos.get_qos(); - int addr_len = sizeof( struct sockaddr_atm ); - - ACE_QoS_Params qos_params(0, - 0, - &cqos, - 0, - (JL_SENDER_ONLY)); - - ACE_OS::printf( "ATM_Connector::add_leaf: connecting...\n" ); - - ACE_HANDLE result = ACE_OS::join_leaf(current_stream.get_handle(), - (struct sockaddr *)saddr, - addr_len, - qos_params); - - if ( result == ACE_INVALID_HANDLE ) - ACE_OS::printf( "ATM_Connector(add_leaf): connection failed, %d\n", - ::WSAGetLastError()); - - return (result != ACE_INVALID_HANDLE); -#elif defined (ACE_HAS_LINUX_ATM) - ACE_OS::printf("ATM_Connector(add_leaf): not yet implemented in Linux \n"); - - ACE_UNUSED_ARG(current_stream); - ACE_UNUSED_ARG(remote_sap); - ACE_UNUSED_ARG(leaf_id); - ACE_UNUSED_ARG(timeout); - - return 0; -#else - ACE_UNUSED_ARG(current_stream); - ACE_UNUSED_ARG(remote_sap); - ACE_UNUSED_ARG(leaf_id); - ACE_UNUSED_ARG(timeout); - return 0; -#endif -} - -ACE_INLINE -int -ACE_ATM_Connector::reset_new_handle (ACE_HANDLE handle) -{ -#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) - // Reset the event association - return ::WSAEventSelect ((SOCKET) handle, - 0, - 0); -#else /* !defined ACE_HAS_WINSOCK2 */ - ACE_UNUSED_ARG (handle); - return 0; -#endif /* ACE_WIN32 */ -} - -// Close versioned namespace, if enabled by the user. -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/ATM_Params.cpp b/ACE/ace/ATM_Params.cpp deleted file mode 100644 index cc6ec674ece..00000000000 --- a/ACE/ace/ATM_Params.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// $Id$ - -#include "ace/ATM_Params.h" - -#if defined (ACE_HAS_ATM) - -ACE_RCSID(ace, ATM_Params, "$Id$") - -#if !defined (__ACE_INLINE__) -#include "ace/ATM_Params.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Params) - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_ATM */ - diff --git a/ACE/ace/ATM_Params.h b/ACE/ace/ATM_Params.h deleted file mode 100644 index 82cf6999b3b..00000000000 --- a/ACE/ace/ATM_Params.h +++ /dev/null @@ -1,214 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file ATM_Params.h - * - * $Id$ - * - * @author Joe Hoffert - */ -//========================================================================== - - -#ifndef ACE_ATM_PARAMS_H -#define ACE_ATM_PARAMS_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_ATM) - -#include /**/ "ace/ACE_export.h" - -#if defined (ACE_HAS_FORE_ATM_XTI) -#include "ace/TLI.h" -#define ATM_PROTOCOL_DEFAULT 0 -typedef struct t_info Param_Info; -typedef struct netbuf Param_Udata; -#elif defined (ACE_HAS_FORE_ATM_WS2) -#include "ace/SOCK.h" -#define ATM_PROTOCOL_DEFAULT ATMPROTO_AAL5 -#define ACE_XTI_ATM_DEVICE "" -typedef int Param_Info; -typedef int Param_Udata; -#elif defined (ACE_HAS_LINUX_ATM) -#include /**/ "atm.h" -#define AF_ATM PF_ATMSVC -#define ACE_XTI_ATM_DEVICE "" -#define ATM_PROTOCOL_DEFAULT ATM_AAL5 -typedef int Param_Info; -typedef int Param_Udata; -#else -#define ACE_XTI_ATM_DEVICE "" -typedef int Param_Info; -typedef int Param_Udata; -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_ATM_Params - * - * @brief Wrapper class that simplifies the information passed to the ATM - * enabled ACE_ATM_Connector class. - */ -class ACE_Export ACE_ATM_Params -{ -public: - /** - * Initialize the data members. This class combines options from - * ACE_SOCK_Connector (@a protocol_family, @a protocol, , - * @a protocol_info, , and @a flags) and - * ACE_TLI_Connector (, , , , and ) - * so that either mechanism can be used transparently for ATM. - */ - ACE_ATM_Params (int rw_flag = 1, - const char device[] = ACE_XTI_ATM_DEVICE, - Param_Info *info = 0, - Param_Udata *udata = 0, - int oflag = O_RDWR, - int protocol_family = AF_ATM, - int protocol = ATM_PROTOCOL_DEFAULT, - int type = -#if defined (ACE_HAS_LINUX_ATM) - SOCK_DGRAM, -#else - SOCK_RAW, -#endif /* ACE_HAS_LINUX_ATM */ - ACE_Protocol_Info *protocol_info = 0, - ACE_SOCK_GROUP g = 0, - u_long flags - = ACE_FLAG_MULTIPOINT_C_ROOT - | ACE_FLAG_MULTIPOINT_D_ROOT, // connector by default - int reuse_addr = 0); - - /// Destructor. - ~ACE_ATM_Params (); - - /// Get protocol family. - int get_protocol_family (void) const; - - /// Set protocol family. - void set_protocol_family (int); - - /// Get protocol. - int get_protocol (void) const; - - /// Set protocol. - void set_protocol (int); - - /// Get type. - int get_type (void) const; - - /// Set type. - void set_type (int); - - /// Get protocol info. - ACE_Protocol_Info *get_protocol_info( void ); - - /// Set protocol info. - void set_protocol_info( ACE_Protocol_Info *); - - /// Get socket group. - ACE_SOCK_GROUP get_sock_group( void ); - - /// Set socket group. - void set_sock_group( ACE_SOCK_GROUP ); - - /// Get socket flags. - u_long get_flags( void ); - - /// Set socket flags. - void set_flags( u_long ); - - /// Get reuse_addr flag. - int get_reuse_addr (void) const; - - /// Set reuse_addr flag. - void set_reuse_addr (int); - - /// Get device. - const char* get_device (void) const; - - /// Get info. - Param_Info* get_info (void) const; - - /// Set info. - void set_info (Param_Info *); - - /// Get r/w flag. - int get_rw_flag (void) const; - - /// Set r/w flag. - void set_rw_flag (int); - - /// Get user data. - Param_Udata* get_user_data (void) const; - - /// Set user data. - void set_user_data (Param_Udata*); - - /// Get open flag. - int get_oflag (void) const; - - /// Set open flag. - void set_oflag (int); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - /// Protocol family for sockets connections. - int protocol_family_; - - /// Protocol for sockets connections. - int protocol_; - - /// Type for opening sockets. - int type_; - - /// Information about the protocol. - ACE_Protocol_Info *protocol_info_; - - /// Socket group used (for sockets only). - ACE_SOCK_GROUP group_; - - /// Flags for sockets (for sockets only). - u_long flags_; - - /// Flag for reusing address for opening sockets. - int reuse_addr_; - - /// Device name for XTI/ATM connections. - const char *device_; - - /// Info for XTI/ATM connections. - Param_Info *info_; - - /// R/W flag for XTI/ATM connections. - int rw_flag_; - - /// User data for XTI/ATM connections. - Param_Udata *udata_; - - /// Open flag for XTI/ATM connections. - int oflag_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/ATM_Params.inl" -#endif /* __ACE_INLINE__ */ - -#endif /* ACE_HAS_ATM */ -#include /**/ "ace/post.h" -#endif /* ACE_ATM_PARAMS_H */ diff --git a/ACE/ace/ATM_Params.inl b/ACE/ace/ATM_Params.inl deleted file mode 100644 index 5d60f6ba920..00000000000 --- a/ACE/ace/ATM_Params.inl +++ /dev/null @@ -1,235 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE void -ACE_ATM_Params::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_ATM_Params::dump"); -#endif /* ACE_HAS_DUMP */ -} - -ACE_INLINE -ACE_ATM_Params::ACE_ATM_Params (int rw_flag, - const char device[], - Param_Info *info, - Param_Udata *udata, - int oflag, - int protocol_family, - int protocol, - int type, - ACE_Protocol_Info *protocol_info, - ACE_SOCK_GROUP g, - u_long flags, - int reuse_addr) - : protocol_family_(protocol_family), - protocol_(protocol), - type_(type), - protocol_info_(protocol_info), - group_(g), - flags_(flags), - reuse_addr_(reuse_addr), - device_(device), - info_(info), - rw_flag_(rw_flag), - udata_(udata), - oflag_(oflag) -{ - ACE_TRACE ("ACE_ATM_Params::ACE_ATM_Params"); -} - -// Default dtor. -ACE_INLINE -ACE_ATM_Params::~ACE_ATM_Params (void) -{ - ACE_TRACE ("ACE_ATM_Params::~ACE_ATM_Params"); -} - -ACE_INLINE -int -ACE_ATM_Params::get_protocol_family (void) const -{ - ACE_TRACE ("ACE_ATM_Params::get_protocol_family"); - return protocol_family_; -} - -ACE_INLINE -void -ACE_ATM_Params::set_protocol_family (int family) -{ - ACE_TRACE ("ACE_ATM_Params::set_protocol_family"); - protocol_family_ = family; -} - -ACE_INLINE -int -ACE_ATM_Params::get_protocol (void) const -{ - ACE_TRACE ("ACE_ATM_Params::get_protocol"); - return protocol_; -} - -ACE_INLINE -void -ACE_ATM_Params::set_protocol (int protocol) -{ - ACE_TRACE ("ACE_ATM_Params::set_protocol"); - protocol_ = protocol; -} - -ACE_INLINE -int -ACE_ATM_Params::get_type (void) const -{ - ACE_TRACE ("ACE_ATM_Params::get_type"); - return type_; -} - -ACE_INLINE -void -ACE_ATM_Params::set_type (int type) -{ - ACE_TRACE ("ACE_ATM_Params::set_type"); - type_ = type; -} - -ACE_INLINE -ACE_Protocol_Info* -ACE_ATM_Params::get_protocol_info( void ) -{ - ACE_TRACE ("ACE_ATM_Params::get_protocol_info"); - return protocol_info_; -} - -ACE_INLINE -void -ACE_ATM_Params::set_protocol_info( ACE_Protocol_Info *protocol_info ) -{ - ACE_TRACE ("ACE_ATM_Params::set_protocol_info"); - protocol_info_ = protocol_info; -} - -ACE_INLINE -ACE_SOCK_GROUP -ACE_ATM_Params::get_sock_group( void ) -{ - ACE_TRACE ("ACE_ATM_Params::get_sock_group"); - return group_; -} - -ACE_INLINE -void -ACE_ATM_Params::set_sock_group( ACE_SOCK_GROUP g ) -{ - ACE_TRACE ("ACE_ATM_Params::set_sock_group"); - group_ = g; -} - -ACE_INLINE -u_long -ACE_ATM_Params::get_flags( void ) -{ - ACE_TRACE ("ACE_ATM_Params::get_flags"); - return flags_; -} - -ACE_INLINE -void -ACE_ATM_Params::set_flags( u_long flags) -{ - ACE_TRACE ("ACE_ATM_Params::set_flags"); - flags_ = flags; -} - -ACE_INLINE -int -ACE_ATM_Params::get_reuse_addr (void) const -{ - ACE_TRACE ("ACE_ATM_Params::get_reuse_addr"); - return reuse_addr_; -} - -ACE_INLINE -void -ACE_ATM_Params::set_reuse_addr (int reuse_addr) -{ - ACE_TRACE ("ACE_ATM_Params::set_reuse_addr"); - reuse_addr_ = reuse_addr; -} - -ACE_INLINE -const char* -ACE_ATM_Params::get_device (void) const -{ - ACE_TRACE ("ACE_ATM_Params::get_device"); - return device_; -} - -ACE_INLINE -Param_Info* -ACE_ATM_Params::get_info (void) const -{ - ACE_TRACE ("ACE_ATM_Params::get_info"); - return info_; -} - -ACE_INLINE -void -ACE_ATM_Params::set_info (Param_Info* info) -{ - ACE_TRACE ("ACE_ATM_Params::set_info"); - info_ = info; -} - -ACE_INLINE -int -ACE_ATM_Params::get_rw_flag (void) const -{ - ACE_TRACE ("ACE_ATM_Params::get_rw_flag"); - return rw_flag_; -} - -ACE_INLINE -void -ACE_ATM_Params::set_rw_flag (int rw_flag) -{ - ACE_TRACE ("ACE_ATM_Params::set_rw_flag"); - rw_flag_ = rw_flag; -} - -ACE_INLINE -Param_Udata* -ACE_ATM_Params::get_user_data (void) const -{ - ACE_TRACE ("ACE_ATM_Params::get_user_data"); - return udata_; -} - -ACE_INLINE -void -ACE_ATM_Params::set_user_data (Param_Udata *udata) -{ - ACE_TRACE ("ACE_ATM_Params::set_user_data"); - udata_ = udata; -} - -ACE_INLINE -int -ACE_ATM_Params::get_oflag (void) const -{ - ACE_TRACE ("ACE_ATM_Params::get_oflag"); - return oflag_; -} - -ACE_INLINE -void -ACE_ATM_Params::set_oflag (int oflag) -{ - ACE_TRACE ("ACE_ATM_Params::set_oflag"); - oflag_ = oflag; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/ATM_QoS.cpp b/ACE/ace/ATM_QoS.cpp deleted file mode 100644 index 6a7e6d4f463..00000000000 --- a/ACE/ace/ATM_QoS.cpp +++ /dev/null @@ -1,631 +0,0 @@ -// $Id$ - -#include "ace/ATM_QoS.h" - -ACE_RCSID(ace, ATM_QoS, "$Id$") - -#if defined (ACE_HAS_ATM) - -#if !defined (__ACE_INLINE__) -#include "ace/ATM_QoS.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) -#define BHLI_MAGIC "FORE_ATM" -// This is line rate in cells/s for an OC-3 MM interface. -const long ACE_ATM_QoS::LINE_RATE = 353207; -const int ACE_ATM_QoS::OPT_FLAGS_CPID = 0x1; -const int ACE_ATM_QoS::OPT_FLAGS_PMP = 0x2; -const int ACE_ATM_QoS::DEFAULT_SELECTOR = 0x99; -const int ACE_ATM_QoS::DEFAULT_PKT_SIZE = 8192; -#elif defined (ACE_HAS_LINUX_ATM) -//pbrandao:for Linux: -//pbrandao:for now stick with current definitions -//pbrandao:see if later need to change -const long ACE_ATM_QoS::LINE_RATE = 353207; -const int ACE_ATM_QoS::OPT_FLAGS_CPID = 0x1; -const int ACE_ATM_QoS::OPT_FLAGS_PMP = 0x2; -const int ACE_ATM_QoS::DEFAULT_SELECTOR = 0x99; -const int ACE_ATM_QoS::DEFAULT_PKT_SIZE = 8192; -#else -const long ACE_ATM_QoS::LINE_RATE = 0L; -const int ACE_ATM_QoS::OPT_FLAGS_CPID = 0; -const int ACE_ATM_QoS::OPT_FLAGS_PMP = 0; -const int ACE_ATM_QoS::DEFAULT_SELECTOR = 0x0; -const int ACE_ATM_QoS::DEFAULT_PKT_SIZE = 0; -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ - -ACE_ALLOC_HOOK_DEFINE(ACE_ATM_QoS) - -ACE_ATM_QoS::ACE_ATM_QoS (int pktSize) -{ - ACE_TRACE ("ACE_ATM_QoS::ACE_ATM_QoS"); -#if defined (ACE_HAS_LINUX_ATM) - ACE_OS::memset(&qos_, 0, sizeof(qos_)); - qos_.aal = ATM_PROTOCOL_DEFAULT; - qos_.rxtp.traffic_class = ATM_ANYCLASS; - qos_.rxtp.max_sdu = pktSize; - qos_.txtp.traffic_class = ATM_ANYCLASS; - qos_.txtp.max_sdu = pktSize; -#else - ACE_UNUSED_ARG (pktSize); -#endif /* ACE_HAS_LINUX_ATM */ -} - -ACE_ATM_QoS::ACE_ATM_QoS(int rate, - int pktSize) -{ - ACE_TRACE( "ACE_ATM_QoS::ACE_ATM_QoS" ); -#if defined (ACE_HAS_FORE_ATM_WS2) - AAL_PARAMETERS_IE ie_aalparams; - ATM_TRAFFIC_DESCRIPTOR_IE ie_td; - ATM_BROADBAND_BEARER_CAPABILITY_IE ie_bbc; - ATM_QOS_CLASS_IE ie_qos; - Q2931_IE *ie_ptr; - int size; - - // Setting up cbr parameters ... - ie_aalparams.AALType = AALTYPE_5; - ie_aalparams.AALSpecificParameters.AAL5Parameters.ForwardMaxCPCSSDUSize - = pktSize; // was 1516; - ie_aalparams.AALSpecificParameters.AAL5Parameters.BackwardMaxCPCSSDUSize - = pktSize; // was 1516; - ie_aalparams.AALSpecificParameters.AAL5Parameters.Mode = AAL5_MODE_MESSAGE; - ie_aalparams.AALSpecificParameters.AAL5Parameters.SSCSType = AAL5_SSCS_NULL; - - size = sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(AAL_PARAMETERS_IE); - - ie_td.Forward.PeakCellRate_CLP0 = SAP_FIELD_ABSENT; - ie_td.Forward.PeakCellRate_CLP01 = rate; - ie_td.Forward.SustainableCellRate_CLP0 = SAP_FIELD_ABSENT; - ie_td.Forward.SustainableCellRate_CLP01 = SAP_FIELD_ABSENT; - ie_td.Forward.MaxBurstSize_CLP0 = SAP_FIELD_ABSENT; - ie_td.Forward.MaxBurstSize_CLP01 = SAP_FIELD_ABSENT; - ie_td.Forward.Tagging = SAP_FIELD_ABSENT; - - ie_td.Backward.PeakCellRate_CLP0 = SAP_FIELD_ABSENT; - ie_td.Backward.PeakCellRate_CLP01 = rate; - ie_td.Backward.SustainableCellRate_CLP0 = SAP_FIELD_ABSENT; - ie_td.Backward.SustainableCellRate_CLP01 = SAP_FIELD_ABSENT; - ie_td.Backward.MaxBurstSize_CLP0 = SAP_FIELD_ABSENT; - ie_td.Backward.MaxBurstSize_CLP01 = SAP_FIELD_ABSENT; - ie_td.Backward.Tagging = SAP_FIELD_ABSENT; - - ie_td.BestEffort = 0; // Note: this must be set to zero for CBR. - - size += sizeof( Q2931_IE_TYPE ) - + sizeof( ULONG ) - + sizeof( ATM_TRAFFIC_DESCRIPTOR_IE ); - - ie_bbc.BearerClass = BCOB_X; - ie_bbc.TrafficType = TT_CBR; - ie_bbc.TimingRequirements = TR_END_TO_END; - ie_bbc.ClippingSusceptability = CLIP_NOT; - ie_bbc.UserPlaneConnectionConfig = UP_P2P; - - size += sizeof( Q2931_IE_TYPE ) - + sizeof( ULONG ) - + sizeof( ATM_BROADBAND_BEARER_CAPABILITY_IE ); - - ie_qos.QOSClassForward = QOS_CLASS1; - ie_qos.QOSClassBackward = QOS_CLASS1; // This may not be really used - // since we do only simplex data xfer. - - size += sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(ATM_QOS_CLASS_IE); - - qos_.ProviderSpecific.buf = (char *) ACE_OS::malloc(size); - if (qos_.ProviderSpecific.buf == 0) { - ACE_ERROR((LM_ERROR, - ACE_TEXT ("ACE_ATM_QoS::ACE_ATM_QoS: Unable to allocate %d bytes for qos_.ProviderSpecific.buf\n"), - size)); - return; - } - qos_.ProviderSpecific.len = size; - ACE_OS::memset(qos_.ProviderSpecific.buf, 0, size); - - ie_ptr = (Q2931_IE *) qos_.ProviderSpecific.buf; - ie_ptr->IEType = IE_AALParameters; - ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) - + sizeof( ULONG ) - + sizeof( AAL_PARAMETERS_IE ); - ACE_OS::memcpy(ie_ptr->IE, &ie_aalparams, sizeof(AAL_PARAMETERS_IE)); - - ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength); - ie_ptr->IEType = IE_TrafficDescriptor; - ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) - + sizeof( ULONG ) - + sizeof( ATM_TRAFFIC_DESCRIPTOR_IE ); - ACE_OS::memcpy(ie_ptr->IE, &ie_td, sizeof(ATM_TRAFFIC_DESCRIPTOR_IE)); - - ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength); - ie_ptr->IEType = IE_BroadbandBearerCapability; - ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) - + sizeof( ULONG ) - + sizeof( ATM_BROADBAND_BEARER_CAPABILITY_IE ); - ACE_OS::memcpy(ie_ptr->IE, - &ie_bbc, - sizeof(ATM_BROADBAND_BEARER_CAPABILITY_IE)); - - ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength); - ie_ptr->IEType = IE_QOSClass; - ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) - + sizeof( ULONG ) - + sizeof( ATM_QOS_CLASS_IE ); - ACE_OS::memcpy(ie_ptr->IE, &ie_qos, sizeof(ATM_QOS_CLASS_IE)); - - // qos_.SendingFlowspec.TokenRate = 0xffffffff; - // qos_.SendingFlowspec.TokenBucketSize = 0xffffffff; - // qos_.SendingFlowspec.PeakBandwidth = 0xffffffff; - // qos_.SendingFlowspec.Latency = 0xffffffff; - // qos_.SendingFlowspec.DelayVariation = 0xffffffff; - // qos_.SendingFlowspec.ServiceType = SERVICETYPE_BESTEFFORT; - // This will most probably be ignored by the service provider. - // qos_.SendingFlowspec.MaxSduSize = 0xffffffff; - // qos_.SendingFlowspec.MinimumPolicedSize = 0xffffffff; - - // qos_.ReceivingFlowspec.TokenRate = 0xffffffff; - // qos_.ReceivingFlowspec.TokenBucketSize = 0xffffffff; - // qos_.ReceivingFlowspec.PeakBandwidth = 0xffffffff; - // qos_.ReceivingFlowspec.Latency = 0xffffffff; - // qos_.ReceivingFlowspec.DelayVariation = 0xffffffff; - // qos_.ReceivingFlowspec.ServiceType = SERVICETYPE_BESTEFFORT; - // This will most probably be ignored by the service provider. - // qos_.ReceivingFlowspec.MaxSduSize = 0xffffffff; - // qos_.ReceivingFlowspec.MinimumPolicedSize = 0; - - ACE_Flow_Spec send_fspec( 0xffffffff, - 0xffffffff, - 0xffffffff, - 0xffffffff, - 0xffffffff, - SERVICETYPE_BESTEFFORT, - // This will most probably ignored by SP. - 0xffffffff, - 0xffffffff, - 15, - ACE_DEFAULT_THREAD_PRIORITY ), - recv_fspec( 0xffffffff, - 0xffffffff, - 0xffffffff, - 0xffffffff, - 0xffffffff, - SERVICETYPE_BESTEFFORT, - // This will most probably ignored by SP. - 0xffffffff, - 0, - 15, - ACE_DEFAULT_THREAD_PRIORITY ); - - qos_.sending_flowspec (send_fspec); - qos_.receiving_flowspec (recv_fspec); -#elif defined (ACE_HAS_FORE_ATM_XTI) - ACE_UNUSED_ARG (rate); - ACE_UNUSED_ARG (pktSize); -#elif defined (ACE_HAS_LINUX_ATM) - ACE_OS::memset(&qos_, - 0, - sizeof(qos_)); - qos_.aal = ATM_PROTOCOL_DEFAULT; - qos_.rxtp.max_sdu = pktSize; - - if (rate > 0) { - qos_.rxtp.pcr = rate; - qos_.rxtp.traffic_class = ATM_CBR; - qos_.txtp.traffic_class = ATM_CBR; - qos_.txtp.pcr = rate; - } - else { - qos_.rxtp.traffic_class = ATM_UBR; - qos_.txtp.traffic_class = ATM_UBR; - } - - qos_.txtp.max_sdu = pktSize; -#else - ACE_UNUSED_ARG (rate); -#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_FORE_ATM_XTI || ACE_HAS_LINUX_ATM */ -} - -void -ACE_ATM_QoS::set_cbr_rate (int rate, - int pktSize) -{ - ACE_TRACE ("ACE_ATM_QoS::set_cbr_rate"); -#if defined (ACE_HAS_FORE_ATM_WS2) - /* - AAL_PARAMETERS_IE ie_aalparams; - ATM_TRAFFIC_DESCRIPTOR_IE ie_td; - ATM_BROADBAND_BEARER_CAPABILITY_IE ie_bbc; - ATM_QOS_CLASS_IE ie_qos; - Q2931_IE *ie_ptr; - int size; - */ - - ACE_OS::printf( "ATM_QoS(set_cbr_rate): set rate to %d c/s\n", rate ); - - // Setting up cbr parameters ... - /* - FORE has changed this - we no longer specify QoS this way - ie_aalparams.AALType = AALTYPE_5; - ie_aalparams.AALSpecificParameters.AAL5Parameters.ForwardMaxCPCSSDUSize - = pktSize; // was 1516; - ie_aalparams.AALSpecificParameters.AAL5Parameters.BackwardMaxCPCSSDUSize - = pktSize; // was 1516; - ie_aalparams.AALSpecificParameters.AAL5Parameters.Mode = AAL5_MODE_MESSAGE; - ie_aalparams.AALSpecificParameters.AAL5Parameters.SSCSType = AAL5_SSCS_NULL; - - size = sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(AAL_PARAMETERS_IE); - - ie_td.Forward.PeakCellRate_CLP0 = SAP_FIELD_ABSENT; - ie_td.Forward.PeakCellRate_CLP01 = rate; - ie_td.Forward.SustainableCellRate_CLP0 = SAP_FIELD_ABSENT; - ie_td.Forward.SustainableCellRate_CLP01 = SAP_FIELD_ABSENT; - ie_td.Forward.MaxBurstSize_CLP0 = SAP_FIELD_ABSENT; - ie_td.Forward.MaxBurstSize_CLP01 = SAP_FIELD_ABSENT; - ie_td.Forward.Tagging = SAP_FIELD_ABSENT; - - ie_td.Backward.PeakCellRate_CLP0 = SAP_FIELD_ABSENT; - ie_td.Backward.PeakCellRate_CLP01 = rate; - ie_td.Backward.SustainableCellRate_CLP0 = SAP_FIELD_ABSENT; - ie_td.Backward.SustainableCellRate_CLP01 = SAP_FIELD_ABSENT; - ie_td.Backward.MaxBurstSize_CLP0 = SAP_FIELD_ABSENT; - ie_td.Backward.MaxBurstSize_CLP01 = SAP_FIELD_ABSENT; - ie_td.Backward.Tagging = SAP_FIELD_ABSENT; - - ie_td.BestEffort = 0; // Note: this must be set to zero for CBR. - - size += sizeof( Q2931_IE_TYPE ) + - sizeof( ULONG ) + - sizeof( ATM_TRAFFIC_DESCRIPTOR_IE ); - - ie_bbc.BearerClass = BCOB_X; - ie_bbc.TrafficType = TT_CBR; - ie_bbc.TimingRequirements = TR_END_TO_END; - ie_bbc.ClippingSusceptability = CLIP_NOT; - ie_bbc.UserPlaneConnectionConfig = UP_P2P; - - size += sizeof(Q2931_IE_TYPE) + - sizeof(ULONG) + - sizeof(ATM_BROADBAND_BEARER_CAPABILITY_IE); - - ie_qos.QOSClassForward = QOS_CLASS1; - ie_qos.QOSClassBackward = QOS_CLASS1; // This may not be really used - // since we only simplex data xfer. - - size += sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(ATM_QOS_CLASS_IE); - - qos_.ProviderSpecific.buf = (char *) ACE_OS::malloc(size); - if (qos_.ProviderSpecific.buf == 0) { - ACE_ERROR((LM_ERROR, - ACE_TEXT ("ACE_ATM_QoS::ACE_ATM_QoS: Unable to allocate %d bytes for qos_.ProviderSpecific.buf\n"), - size)); - return; - } - qos_.ProviderSpecific.len = size; - ACE_OS::memset(qos_.ProviderSpecific.buf, 0, size); - - ie_ptr = (Q2931_IE *) qos_.ProviderSpecific.buf; - ie_ptr->IEType = IE_AALParameters; - ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) + - sizeof( ULONG ) + - sizeof( AAL_PARAMETERS_IE ); - ACE_OS::memcpy(ie_ptr->IE, &ie_aalparams, sizeof(AAL_PARAMETERS_IE)); - - ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength); - ie_ptr->IEType = IE_TrafficDescriptor; - ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) + - sizeof( ULONG ) + - sizeof( ATM_TRAFFIC_DESCRIPTOR_IE ); - ACE_OS::memcpy(ie_ptr->IE, &ie_td, sizeof(ATM_TRAFFIC_DESCRIPTOR_IE)); - - ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength); - ie_ptr->IEType = IE_BroadbandBearerCapability; - ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) + - sizeof( ULONG ) + - sizeof( ATM_BROADBAND_BEARER_CAPABILITY_IE ); - ACE_OS::memcpy( ie_ptr->IE, - &ie_bbc, - sizeof( ATM_BROADBAND_BEARER_CAPABILITY_IE )); - - ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength); - ie_ptr->IEType = IE_QOSClass; - ie_ptr->IELength = sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + - sizeof(ATM_QOS_CLASS_IE); - ACE_OS::memcpy(ie_ptr->IE, &ie_qos, sizeof(ATM_QOS_CLASS_IE)); - */ - - const int BYTES_PER_ATM_CELL = 53; - ACE_OS::memset(&qos_, 0, sizeof(ATM_QoS)); - // Setting the token rate sets the minimum rate. 3 Mbits/sec seems too high. - // Certainly for Vaudeville audio, we only need about 1000 c/s which is - // 424000 bits/sec which is 53000 bytes/sec. - //qos_.SendingFlowspec.TokenRate = 3*(1024*128); // 3Mbits/sec - qos_.SendingFlowspec.TokenRate = 53000; // 1000 cells/sec - qos_.SendingFlowspec.TokenBucketSize = 32*1024; // our block size - //ourQos.SendingFlowspec.PeakBandwidth = ourQos.SendingFlowspec.TokenRate; - qos_.SendingFlowspec.ServiceType = SERVICETYPE_GUARANTEED; - // Peak bandwidth is in bytes/sec. The rate is specified in cells/sec so - // we need to convert from cells/sec to bytes/sec (i.e., multiply by 53). - qos_.SendingFlowspec.PeakBandwidth = rate * BYTES_PER_ATM_CELL; - qos_.SendingFlowspec.Latency = -1; // we don't care too much - qos_.SendingFlowspec.DelayVariation = -1; // we don't care too much - // no provider-specific data allowed on ATM - qos_.ProviderSpecific.buf=0; - qos_.ProviderSpecific.len=0; - // unidirectional P2MP; we don't need to setup the Receiving flowspec - - //qos_.SendingFlowspec.TokenRate = 0xffffffff; - //qos_.SendingFlowspec.TokenBucketSize = 0xffffffff; - //qos_.SendingFlowspec.PeakBandwidth = 0xffffffff; - //qos_.SendingFlowspec.Latency = 0xffffffff; - //qos_.SendingFlowspec.DelayVariation = 0xffffffff; - //qos_.SendingFlowspec.ServiceType = SERVICETYPE_BESTEFFORT; - // This will most probably be ignored by the service provider. - //qos_.SendingFlowspec.MaxSduSize = 0xffffffff; - //qos_.SendingFlowspec.MinimumPolicedSize = 0xffffffff; - - //qos_.ReceivingFlowspec.TokenRate = 0xffffffff; - //qos_.ReceivingFlowspec.TokenBucketSize = 0xffffffff; - //qos_.ReceivingFlowspec.PeakBandwidth = 0xffffffff; - //qos_.ReceivingFlowspec.Latency = 0xffffffff; - //qos_.ReceivingFlowspec.DelayVariation = 0xffffffff; - //qos_.ReceivingFlowspec.ServiceType = SERVICETYPE_BESTEFFORT; - // This will most probably be ignored by the service provider. - //qos_.ReceivingFlowspec.MaxSduSize = 0xffffffff; - //qos_.ReceivingFlowspec.MinimumPolicedSize = 0; - - /* - ACE_Flow_Spec send_fspec( 0xffffffff, - 0xffffffff, - 0xffffffff, - 0xffffffff, - 0xffffffff, - SERVICETYPE_BESTEFFORT, - // This will most probably ignored by SP. - 0xffffffff, - 0xffffffff, - 15, - ACE_DEFAULT_THREAD_PRIORITY ), - recv_fspec( 0xffffffff, - 0xffffffff, - 0xffffffff, - 0xffffffff, - 0xffffffff, - SERVICETYPE_BESTEFFORT, - // This will most probably ignored by SP. - 0xffffffff, - 0, - 15, - ACE_DEFAULT_THREAD_PRIORITY ); - - qos_.sending_flowspec( send_fspec ); - qos_.receiving_flowspec( recv_fspec ); - */ -#elif defined (ACE_HAS_FORE_ATM_XTI) - ACE_UNUSED_ARG (rate); - ACE_UNUSED_ARG (pktSize); -#elif defined (ACE_HAS_LINUX_ATM) - ACE_UNUSED_ARG (pktSize); - - qos_.rxtp.traffic_class = ATM_CBR; - qos_.rxtp.pcr = rate; - qos_.txtp.traffic_class = ATM_CBR; - qos_.txtp.pcr = rate; -#else - ACE_UNUSED_ARG (rate); -#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_FORE_ATM_XTI || ACE_HAS_LINUX_ATM */ -} - -void -ACE_ATM_QoS::set_rate (ACE_HANDLE fd, - int rate, - int flags) -{ - ACE_TRACE ("ACE_ATM_QoS::set_rate"); -#if defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM) - set_cbr_rate( rate ); - - ACE_UNUSED_ARG( fd ); - ACE_UNUSED_ARG( flags ); -#elif defined (ACE_HAS_FORE_ATM_XTI) - long optlen = 0; - qos_.buf = construct_options(fd, - rate, - flags, - &optlen); - qos_.len = optlen; -#else - ACE_UNUSED_ARG (rate); -#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM || ACE_HAS_FORE_ATM_XTI */ -} - -char* -ACE_ATM_QoS::construct_options (ACE_HANDLE fd, - int rate, - int flags, - long *len) -{ -#if defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM) - ACE_UNUSED_ARG (fd); - ACE_UNUSED_ARG (rate); - ACE_UNUSED_ARG (flags); - ACE_UNUSED_ARG (len); - return (0); -#elif defined (ACE_HAS_FORE_ATM_XTI) - struct t_opthdr *popt; - char *buf; - int qos_cells; - struct t_info info; - - if (ACE_OS::t_getinfo (fd, &info) == -1) - { - ACE_OS::t_error ("t_getinfo"); - return 0; - } - - buf = (char *) ACE_OS::malloc (info.options); - - if (buf == 0) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("Unable to allocate %d bytes for options\n"), - info.options), - 0); - - popt = (struct t_opthdr *) buf; - - if (flags & OPT_FLAGS_CPID) - { - // This constructs the T_ATM_ORIG_ADDR option, which is used to - // signal the UNI 3.1 Calling Party ID Information Element. - t_atm_addr *source_addr; - - popt->len = sizeof (struct t_opthdr) + sizeof (t_atm_addr); - popt->level = T_ATM_SIGNALING; - popt->name = T_ATM_ORIG_ADDR; - popt->status = 0; - - source_addr = - (t_atm_addr *)((char *) popt + sizeof (struct t_opthdr)); - - source_addr->address_format = T_ATM_ENDSYS_ADDR; - source_addr->address_length = ATMNSAP_ADDR_LEN; - - ATMSAPAddress local_addr; - struct t_bind boundaddr; - - boundaddr.addr.maxlen = sizeof(local_addr); - boundaddr.addr.buf = (char *) &local_addr; - - //if (ACE_OS::t_getprotaddr(fd, &boundaddr, 0) < 0) { - if (ACE_OS::t_getname(fd, - &boundaddr.addr, - LOCALNAME) < 0) - { - ACE_OS::t_error("t_getname (local_address)"); - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("Can't get local address!\n"))); - ACE_OS::free (buf); - return 0; - } - - ACE_OS::memcpy(source_addr->address, - local_addr.sap.t_atm_sap_addr.address, - ATMNSAP_ADDR_LEN); - - popt = T_OPT_NEXTHDR (buf, info.options , popt); - } - - // This constructs all options necessary (bearer cap., QoS, and - // Traffic Descriptor) to signal for a CBR connection with the - // specified QoS in kbit/sec., and/or specify a PMP connection. - - // For FORE 200e cards, the adapter shapes traffic to CBR with rate - // equal to PCR CLP=0+1 (traffic.forward.PCR_all_traffic) - - qos_cells = (rate * 1000) / (48*8); - - if ((qos_cells > 0 && qos_cells < LINE_RATE) - || (ACE_BIT_ENABLED (flags, OPT_FLAGS_PMP))) - { - struct t_atm_bearer *bearer; - struct t_atm_traffic *traffic; - - // T_ATM_BEARER_CAP: Broadband bearer capability - popt->len = sizeof (struct t_opthdr) + sizeof (struct t_atm_bearer); - popt->level = T_ATM_SIGNALING; - popt->name = T_ATM_BEARER_CAP; - popt->status = 0; - - bearer = (struct t_atm_bearer *)((char *) popt + - sizeof (struct t_opthdr)); - bearer->bearer_class = T_ATM_CLASS_X; - - if (qos_cells) - { - bearer->traffic_type = T_ATM_CBR; - bearer->timing_requirements = T_ATM_END_TO_END; - } - else - { - bearer->traffic_type = 0; // UBR - bearer->timing_requirements = 0; - } - bearer->clipping_susceptibility = T_ATM_NULL; - - if (ACE_BIT_ENABLED (flags, OPT_FLAGS_PMP)) - bearer->connection_configuration = T_ATM_1_TO_MANY; - else - bearer->connection_configuration = T_ATM_1_TO_1; - - popt = T_OPT_NEXTHDR (buf, info.options, popt); - - // T_ATM_TRAFFIC: traffic descriptor - popt->len = sizeof (struct t_opthdr) + sizeof (struct t_atm_traffic); - popt->level = T_ATM_SIGNALING; - popt->name = T_ATM_TRAFFIC; - popt->status = 0; - - traffic = (struct t_atm_traffic *)((char *) popt + - sizeof (struct t_opthdr)); - - traffic->forward.PCR_high_priority = T_ATM_ABSENT; - traffic->forward.PCR_all_traffic = qos_cells ? qos_cells : LINE_RATE; - traffic->forward.SCR_high_priority = T_ATM_ABSENT; - traffic->forward.SCR_all_traffic = T_ATM_ABSENT; - traffic->forward.MBS_high_priority = T_ATM_ABSENT; - traffic->forward.MBS_all_traffic = T_ATM_ABSENT; - traffic->forward.tagging = T_NO; - - traffic->backward.PCR_high_priority = T_ATM_ABSENT; - traffic->backward.PCR_all_traffic = - (ACE_BIT_ENABLED (flags, OPT_FLAGS_PMP)) - ? 0 : qos_cells ? qos_cells : LINE_RATE; - traffic->backward.SCR_high_priority = T_ATM_ABSENT; - traffic->backward.SCR_all_traffic = T_ATM_ABSENT; - traffic->backward.MBS_high_priority = T_ATM_ABSENT; - traffic->backward.MBS_all_traffic = T_ATM_ABSENT; - traffic->backward.tagging = T_NO; - - traffic->best_effort = qos_cells ? T_NO : T_YES; - - popt = T_OPT_NEXTHDR (buf, - info.options, - popt); - } - - if (qos_cells > 0 && qos_cells < LINE_RATE) - { - struct t_atm_qos *qos; - - // T_ATM_QOS: Quality of Service - popt->len = sizeof (struct t_opthdr) + sizeof (struct t_atm_qos); - popt->level = T_ATM_SIGNALING; - popt->name = T_ATM_QOS; - popt->status = 0; - - qos = (struct t_atm_qos *)((char *) popt + sizeof (struct t_opthdr)); - qos->coding_standard = T_ATM_ITU_CODING; - qos->forward.qos_class = T_ATM_QOS_CLASS_1; - qos->backward.qos_class = T_ATM_QOS_CLASS_1; - - popt = T_OPT_NEXTHDR (buf, info.options, popt); - } - - // Return actual size of options and option buffer to user. - *len = (char *) popt - buf; - - return buf; -#else - ACE_UNUSED_ARG (fd); - ACE_UNUSED_ARG (rate); - ACE_UNUSED_ARG (flag); - ACE_UNUSED_ARG (len); - return (0); -#endif /* ACE_HAS_FORE_ATM_WS2 */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_ATM */ - diff --git a/ACE/ace/ATM_QoS.h b/ACE/ace/ATM_QoS.h deleted file mode 100644 index f548da3033d..00000000000 --- a/ACE/ace/ATM_QoS.h +++ /dev/null @@ -1,115 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file ATM_QoS.h - * - * $Id$ - * - * @author Joe Hoffert - */ -//========================================================================== - - -#ifndef ACE_ATM_QoS_H -#define ACE_ATM_QoS_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined(ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_ATM) - -#if defined (ACE_HAS_FORE_ATM_WS2) -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -// just map to WS2 GQOS struct -typedef ACE_QoS ATM_QoS; -ACE_END_VERSIONED_NAMESPACE_DECL -#elif defined (ACE_HAS_FORE_ATM_XTI) -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -typedef struct netbuf ATM_QoS; -ACE_END_VERSIONED_NAMESPACE_DECL -#elif defined (ACE_HAS_LINUX_ATM) -#include /**/ "atm.h" -#include "ace/ATM_Params.h" -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -typedef struct atm_qos ATM_QoS; -ACE_END_VERSIONED_NAMESPACE_DECL -#else -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -typedef int ATM_QoS; -ACE_END_VERSIONED_NAMESPACE_DECL -#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_FORE_ATM_XTI || ACE_HAS_LINUX_ATM */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_ATM_QoS - * - * @brief Define the QoS parameters for ATM - * - * This class wraps up QoS parameters for both ATM/XTI and - * ATM/WinSock2 to make the mechanism for the ATM protocol - * transparent. - */ -class ACE_Export ACE_ATM_QoS -{ -public: - // Constants used for ATM options - static const long LINE_RATE; - static const int OPT_FLAGS_CPID; - static const int OPT_FLAGS_PMP; - static const int DEFAULT_SELECTOR; - static const int DEFAULT_PKT_SIZE; - - // = Initializattion and termination methods. - /// Default constructor. - ACE_ATM_QoS(int = DEFAULT_PKT_SIZE); - - /// Constructor with a CBR rate. - ACE_ATM_QoS(int, - int = DEFAULT_PKT_SIZE); - - ~ACE_ATM_QoS (); - - /// Set the rate. - void set_rate (ACE_HANDLE, - int, - int); - - /// Set CBR rate in cells per second. - void set_cbr_rate (int, - int = DEFAULT_PKT_SIZE); - - /// Get ATM_QoS struct. - ATM_QoS get_qos (void); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - /// Construct QoS options. - char* construct_options(ACE_HANDLE, - int, - int, - long*); - -private: - ATM_QoS qos_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/ATM_QoS.inl" -#endif /* __ACE_INLINE__ */ - -#endif /* ACE_HAS_ATM */ -#include /**/ "ace/post.h" -#endif /* ACE_ATM_QoS_H */ diff --git a/ACE/ace/ATM_QoS.inl b/ACE/ace/ATM_QoS.inl deleted file mode 100644 index 283baa3f560..00000000000 --- a/ACE/ace/ATM_QoS.inl +++ /dev/null @@ -1,29 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE void -ACE_ATM_QoS::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_ATM_QoS::dump"); -#endif /* ACE_HAS_DUMP */ -} - -ACE_INLINE -ACE_ATM_QoS::~ACE_ATM_QoS () -{ - ACE_TRACE ("ACE_ATM_QoS::~ACE_ATM_QoS"); -} - -ACE_INLINE -ATM_QoS -ACE_ATM_QoS::get_qos (void) -{ - ACE_TRACE ("ACE_ATM_QoS::get_qos"); - return qos_; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/ATM_Stream.cpp b/ACE/ace/ATM_Stream.cpp deleted file mode 100644 index 21035b97f52..00000000000 --- a/ACE/ace/ATM_Stream.cpp +++ /dev/null @@ -1,290 +0,0 @@ -// $Id$ - -#include "ace/ATM_Stream.h" - -ACE_RCSID (ace, ATM_Stream, "$Id$") - -#if defined (ACE_HAS_ATM) - -#if !defined (__ACE_INLINE__) -#include "ace/ATM_Stream.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE (ACE_ATM_Stream) - -char* -ACE_ATM_Stream::get_peer_name (void) const -{ - ACE_TRACE ("ACE_ATM_Stream::get_peer_name"); -#if defined (ACE_HAS_FORE_ATM_XTI) - // // Use t_getprotaddr for XTI/ATM - // struct t_bind *localaddr - // = (struct t_bind *) ACE_OS::t_alloc (get_handle (), - // T_BIND, - // T_ADDR); - // struct t_bind *peeraddr - // = (struct t_bind *) ACE_OS::t_alloc (get_handle (), - // T_BIND, - // T_ADDR); - // ::t_getprotaddr (get_handle (), - // localaddr, - // peeraddr); - - // char* connected_name = (char*) ACE_OS::malloc (peeraddr->addr.len + 1); - // ACE_OS::strcpy (connected_name, - // peeraddr->addr.buf); - // ACE_OS::t_free ((char *) localaddr, - // T_BIND); - // ACE_OS::t_free ((char *) peeraddr, - // T_BIND); - // return (connected_name); - -#error "This doesn't seem to work. May need to jimmy-rig something with the" -#error "/etc/xti_hosts file - Ugh!" - - ACE_ATM_Addr sa; - struct netbuf name; - name.maxlen = sa.get_size (); - name.buf = (char *) sa.get_addr (); - ACE_OS::t_getname (this->get_handle (), &name, REMOTENAME); - // ACE_OS::ioctl (this->get_handle (), - // TI_GETPEERNAME, - // &name); - return (name.buf); - -#elif defined (ACE_HAS_FORE_ATM_WS2) - // Use getpeername for WinSock2. - struct sockaddr_atm name; - ACE_OS::memset (&name, 0, sizeof (name)); - int nameSize = sizeof (name); - - if (ACE_OS::getpeername (this->get_handle (), - (struct sockaddr *) &name, - &nameSize) != 0) { - return 0; - } - - char buffer[256]; - for (unsigned int index = 0; index < ATM_ADDR_SIZE - 1; index++) { - buffer[ index * 3 ] = '\0'; - ACE_OS::sprintf (buffer, "%s%02x.", buffer, name.satm_number.Addr[ index ]); - } - buffer[ (ATM_ADDR_SIZE - 1) * 3 ] = '\0'; - ACE_OS::sprintf (buffer, "%s%02x.", buffer, 0); - buffer[ ATM_ADDR_SIZE * 3 - 1 ] = '\0'; - for (index = 0; index < ACE_OS::strlen (buffer); ++index) - buffer[index] = ACE_OS::ace_tolower (buffer[index]); - - ifstream atm_hosts ("C:/WINNT/atmhosts"); - assert (atm_hosts.is_open ()); - - // Find the host address in the ATM hosts file and return the - // host name - char line[256]; - char *host_ptr, *host_name = 0; - ACE_NEW_RETURN (host_name, char[256], 0); - while (!atm_hosts.eof ()) { - atm_hosts.getline (line, 256); - // Convert the line to lower case to ease comparison - for (index = 0; index < ACE_OS::strlen (line); ++index) - line[index] = ACE_OS::ace_tolower (line[index]); - if (ACE_OS::strstr (line, buffer) != 0) - { - char *strtok_p; - // Grab the second token which is the host name - ACE_OS::strtok_r (line, " \t", &strtok_p); - host_ptr = ACE_OS::strtok (0, " \t", &strtok_p); - ACE_OS::strcpy (host_name, host_ptr); - break; - } - } - - return host_name; -#elif defined (ACE_HAS_LINUX_ATM) - ATM_Addr name; - int nameSize = sizeof (name.sockaddratmsvc); - - if (ACE_OS::getpeername (this->get_handle (), - (struct sockaddr *) & (name.sockaddratmsvc), - &nameSize) < 0) { - ACE_OS::perror ("ACE_ATM_Stream (get_peer_name) : "); - return 0; - } - - static ACE_TCHAR buffer[MAX_ATM_ADDR_LEN + 1]; - int total_len; - if ((total_len = atm2text (buffer,sizeof buffer, - (struct sockaddr *) & (name.sockaddratmsvc), - A2T_PRETTY|A2T_NAME)) < 0) { - ACE_DEBUG ((LM_DEBUG,ACE_TEXT ("ACE_ATM_Stream (get_peer_name) :%d"),errno)); - return 0; - } - - return (char*) buffer; -#else - return 0; -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ -} - -ACE_HANDLE -ACE_ATM_Stream::get_handle (void) const -{ - ACE_TRACE ("ACE_ATM_Stream::get_handle"); -#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM) - return stream_.get_handle (); -#else - return 0; -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ -} - -int -ACE_ATM_Stream::get_vpi_vci (ACE_UINT16 &vpi, - ACE_UINT16 &vci) const -{ - ACE_TRACE ("ACE_ATM_Stream::get_vpi_vci"); -#if defined (ACE_HAS_FORE_ATM_XTI) - struct t_atm_conn_prop conn_prop; - char* connect_opts = (char *) &conn_prop; - int opt_size = sizeof (t_atm_conn_prop); - struct t_info info; - struct t_optmgmt opt_req, opt_ret; - - if (ACE_OS::t_getinfo (stream_.get_handle (), - &info) < 0) - { - ACE_OS::t_error ("t_getinfo"); - return -1; - } - - char *buf_req = (char *) ACE_OS::malloc (info.options); - if (buf_req == 0) - { - ACE_OS::fprintf (stderr, - "Unable to allocate %ld bytes for options\n", - info.options); - return -1; - } - - char *buf_ret = (char *) ACE_OS::malloc (info.options); - if (buf_ret == 0) - { - ACE_OS::fprintf (stderr, - "Unable to allocate %ld bytes for options\n", - info.options); - return -1; - } - - ACE_OS::memset (&opt_req, 0, sizeof (opt_req)); - ACE_OS::memset (&opt_ret, 0, sizeof (opt_ret)); - - struct t_opthdr *popt = (struct t_opthdr *) buf_req; - struct t_opthdr *popt_ret = (struct t_opthdr *) buf_ret; - - popt->len= sizeof (struct t_opthdr) + opt_size; - - // We are only concerned with SVCs so no other check or values are needed - // here. - popt->level = T_ATM_SIGNALING; - popt->name = T_ATM_CONN_PROP; - popt->status = 0; - - opt_req.opt.len = popt->len; - opt_req.opt.buf = (char *) popt; - opt_req.flags = T_CURRENT; - - popt = T_OPT_NEXTHDR (buf_req, - info.options, - popt); - opt_ret.opt.maxlen = info.options; - opt_ret.opt.buf = (char *) popt_ret; - - if (ACE_OS::t_optmgmt (stream_.get_handle (), - &opt_req, - &opt_ret) < 0) { - ACE_OS::t_error ("t_optmgmt"); - return -1; - } - - ACE_OS::memcpy (connect_opts, - (char *) popt_ret + sizeof (struct t_opthdr), - opt_size); - - ACE_OS::free (buf_ret); - ACE_OS::free (buf_req); - - vpi = conn_prop.vpi; - vci = conn_prop.vci; - return (0); -#elif defined (ACE_HAS_FORE_ATM_WS2) - ATM_CONNECTION_ID connID; - DWORD bytes = 0; - - if (::WSAIoctl ((int) this -> get_handle (), - SIO_GET_ATM_CONNECTION_ID, - 0, - 0, - (LPVOID) &connID, - sizeof (ATM_CONNECTION_ID), - &bytes, - 0, - 0) - == SOCKET_ERROR) { - ACE_OS::printf ("Error: WSAIoctl %d\n", WSAGetLastError ()); - } - - vpi = (ACE_UINT16) connID.VPI; - vci = (ACE_UINT16) connID.VCI; - - return 0; -#elif defined (ACE_HAS_LINUX_ATM) -#if defined (SO_ATMPVC) /* atm version>=0.62 */ - struct sockaddr_atmpvc mypvcaddr; - int addrpvclen = sizeof (mypvcaddr); - if (ACE_OS::getsockopt (stream_.get_handle (), - SOL_ATM, - SO_ATMPVC, - reinterpret_cast (&mypvcaddr), - &addrpvclen) < 0) { - ACE_DEBUG (LM_DEBUG, - ACE_TEXT ("ACE_ATM_Stream::get_vpi_vci: getsockopt %d\n"), - errno); - return -1; - } - vpi = (ACE_UINT16) mypvcaddr.sap_addr.vpi; - vci = (ACE_UINT16) mypvcaddr.sap_addr.vci; - - return 0; -#elif defined (SO_VCID) /* patch for atm version 0.59 */ - struct atm_vcid mypvcid; - int pvcidlen = sizeof (mypvcid); - if (ACE_OS::getsockopt (stream_.get_handle (), - SOL_ATM,SO_VCID, - reinterpret_cast (&mypvcid), - &pvcidlen) < 0) { - ACE_DEBUG (LM_DEBUG, - ACE_TEXT ("ACE_ATM_Stream::get_vpi_vci: getsockopt %d\n"), - errno); - return -1; - } - vpi = (ACE_UINT16) mypvcid.vpi; - vci = (ACE_UINT16) mypvcid.vci; - - return 0; -#else - ACE_DEBUG (LM_DEBUG, - ACE_TEXT ("ACE_ATM_Stream::get_vpi_vci: Not implemented in this ATM version. Update to >= 0.62\n Or patch 0.59")); - ACE_UNUSED_ARG (vci); - ACE_UNUSED_ARG (vpi); - - return (-1); -#endif /* SO_ATMPVC || SO_VCID */ -#else - return (-1); -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_ATM */ diff --git a/ACE/ace/ATM_Stream.h b/ACE/ace/ATM_Stream.h deleted file mode 100644 index fde1294e1e3..00000000000 --- a/ACE/ace/ATM_Stream.h +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file ATM_Stream.h - * - * $Id$ - * - * @author Joe Hoffert - */ -//============================================================================= - - -#ifndef ACE_ATM_STREAM_H -#define ACE_ATM_STREAM_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_ATM) - -#include "ace/ATM_Addr.h" -#include "ace/ATM_Params.h" - -#if defined (ACE_WIN32) -#include "ace/SOCK_Stream.h" -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -typedef ACE_SOCK_Stream ATM_Stream; -ACE_END_VERSIONED_NAMESPACE_DECL -#else -#include "ace/TLI_Stream.h" -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -typedef ACE_TLI_Stream ATM_Stream; -ACE_END_VERSIONED_NAMESPACE_DECL -#endif - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_ATM_Stream - * - * @brief Defines the member functions for ACE_ATM_Stream abstraction. - */ -class ACE_Export ACE_ATM_Stream -{ -public: - // = Initialization and termination methods. - /// Default constructor. - ACE_ATM_Stream (void); - - // = ATM-specific open and shutdown operations. - /// open the stream. - int open (ACE_ATM_Params params = ACE_ATM_Params()); - - /// Close down and release resources. - int close (void); - - /// Get the underlying handle. - ACE_HANDLE get_handle (void) const; - - /// Get the underlying stream. - ATM_Stream& get_stream (void); - - /// Get the name of the connected host. - char* get_peer_name (void) const; - - /// Get the VPI and VCI of the stream. - int get_vpi_vci (ACE_UINT16 &vpi, - ACE_UINT16 &vci) const; - - /// Recv an n byte buffer from the connected transport mechanism. - ssize_t recv (void *buf, - size_t n, - int *flags = 0) const; - - /// Send exactly n bytes to the connected transport mechanism. - ssize_t send_n (const void *buf, - size_t n, - int flags) const; - - // = Meta-type info - typedef ACE_ATM_Addr PEER_ADDR; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - /// Typedef'd to the appropriate stream mechanism above. - ATM_Stream stream_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/ATM_Stream.inl" -#endif /* __ACE_INLINE__ */ - -#endif /* ACE_HAS_ATM */ -#include /**/ "ace/post.h" -#endif /* ACE_ATM_STREAM_H */ diff --git a/ACE/ace/ATM_Stream.inl b/ACE/ace/ATM_Stream.inl deleted file mode 100644 index b796af474e7..00000000000 --- a/ACE/ace/ATM_Stream.inl +++ /dev/null @@ -1,133 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE void -ACE_ATM_Stream::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_ATM_Stream::dump"); -#endif /* ACE_HAS_DUMP */ -} - -ACE_INLINE -ACE_ATM_Stream::ACE_ATM_Stream (void) -{ - ACE_TRACE ("ACE_ATM_Stream::ACE_ATM_Stream"); -} - -ACE_INLINE -int -ACE_ATM_Stream::open (ACE_ATM_Params params) -{ - ACE_TRACE ("ACE_ATM_Stream::open"); -#if defined (ACE_HAS_FORE_ATM_XTI) - ACE_HANDLE handle = stream_.open (params.get_device(), - params.get_oflag(), - params.get_info()); - return (handle == ACE_INVALID_HANDLE ? -1 : 0); -#elif defined (ACE_HAS_FORE_ATM_WS2) - params.set_flags( ACE_FLAG_MULTIPOINT_C_ROOT | ACE_FLAG_MULTIPOINT_D_ROOT ); - - int retval = stream_.open (params.get_type(), - params.get_protocol_family(), - params.get_protocol(), - params.get_protocol_info(), - params.get_sock_group(), - params.get_flags(), - params.get_reuse_addr()); - if (retval == -1) - return -1; - - struct sockaddr_atm sock_addr; - - ACE_OS::memset(&sock_addr, 0, sizeof(struct sockaddr_atm)); - sock_addr.satm_family = AF_ATM; - sock_addr.satm_number.AddressType=ADDR_ANY; - sock_addr.satm_number.NumofDigits = ATM_ADDR_SIZE; - sock_addr.satm_blli.Layer2Protocol = SAP_FIELD_ABSENT; - sock_addr.satm_blli.Layer3Protocol = SAP_FIELD_ABSENT; - sock_addr.satm_bhli.HighLayerInfoType = SAP_FIELD_ABSENT; - if (ACE_OS::bind(get_handle(), - (struct sockaddr FAR *)&sock_addr, - sizeof(struct sockaddr_atm)) < 0) - { - ACE_OS::printf("Error binding local address: %d",WSAGetLastError()); - return -1; - } - - return 0; -#else - ACE_UNUSED_ARG(params); - return 0; -#endif /* ACE_HAS_FORE_ATM_XTI */ -} - -ACE_INLINE -int -ACE_ATM_Stream::close (void) -{ - ACE_TRACE ("ACE_ATM_Stream::close"); -#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) - return stream_.close (); -#else - return 0; -#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */ -} - -ACE_INLINE -ATM_Stream& -ACE_ATM_Stream::get_stream (void) -{ - ACE_TRACE ("ACE_ATM_Stream::get_stream"); - return stream_; -} - -ACE_INLINE -ssize_t -ACE_ATM_Stream::recv (void *buf, - size_t n, - int *flags) const -{ - ACE_TRACE ("ACE_ATM_Stream::recv"); -#if defined (ACE_HAS_FORE_ATM_XTI) - return stream_.recv (buf, - n, - flags); -#elif defined (ACE_HAS_FORE_ATM_WS2) - return stream_.recv (buf, - n); -#else - ACE_UNUSED_ARG(buf); - ACE_UNUSED_ARG(n); - ACE_UNUSED_ARG(flags); - return (0); -#endif /* ACE_HAS_FORE_ATM_XTI */ -} - -ACE_INLINE -ssize_t -ACE_ATM_Stream::send_n (const void *buf, - size_t n, - int flags) const -{ - ACE_TRACE ("ACE_ATM_Stream::send_n"); -#if defined (ACE_HAS_FORE_ATM_XTI) - return stream_.send_n (buf, - n, - flags); -#elif defined (ACE_HAS_FORE_ATM_WS2) - return stream_.send_n (buf, - n, - flags); -#else - ACE_UNUSED_ARG(buf); - ACE_UNUSED_ARG(n); - ACE_UNUSED_ARG(flags); - return (0); -#endif /* ACE_HAS_FORE_ATM_XTI */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Acceptor.cpp b/ACE/ace/Acceptor.cpp deleted file mode 100644 index 2dd5b52d926..00000000000 --- a/ACE/ace/Acceptor.cpp +++ /dev/null @@ -1,1226 +0,0 @@ -#ifndef ACE_ACCEPTOR_CPP -#define ACE_ACCEPTOR_CPP - -#include "ace/ACE.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Acceptor.h" -#include "ace/Handle_Set.h" -#include "ace/Svc_Handler.h" -#include "ace/WFMO_Reactor.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_sys_select.h" - -ACE_RCSID (ace, - Acceptor, - "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_Acceptor) - -template void -ACE_Acceptor::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Acceptor::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - this->peer_acceptor_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -template -ACE_Acceptor::operator ACE_PEER_ACCEPTOR & () const -{ - ACE_TRACE ("ACE_Acceptor::operator ACE_PEER_ACCEPTOR &"); - return (ACE_PEER_ACCEPTOR &) this->peer_acceptor_; -} - -template ACE_PEER_ACCEPTOR & -ACE_Acceptor::acceptor (void) const -{ - ACE_TRACE ("ACE_Acceptor::acceptor"); - return const_cast (this->peer_acceptor_); -} - -// Returns ACE_HANDLE of the underlying Acceptor_Strategy. - -template ACE_HANDLE -ACE_Acceptor::get_handle (void) const -{ - ACE_TRACE ("ACE_Acceptor::get_handle"); - return this->peer_acceptor_.get_handle (); -} - -// Initialize the appropriate strategies for creation, passive -// connection acceptance, and concurrency, and then register -// with the Reactor and listen for connection requests at the -// designated . - -template int -ACE_Acceptor::open - (const ACE_PEER_ACCEPTOR_ADDR &local_addr, - ACE_Reactor *reactor, - int flags, - int use_select, - int reuse_addr) -{ - ACE_TRACE ("ACE_Acceptor::open"); - this->flags_ = flags; - this->use_select_ = use_select; - this->reuse_addr_ = reuse_addr; - this->peer_acceptor_addr_ = local_addr; - - // Must supply a valid Reactor to Acceptor::open()... - - if (reactor == 0) - { - errno = EINVAL; - return -1; - } - - if (this->peer_acceptor_.open (local_addr, reuse_addr) == -1) - return -1; - - // Set the peer acceptor's handle into non-blocking mode. This is a - // safe-guard against the race condition that can otherwise occur - // between the time when indicates that a passive-mode - // socket handle is "ready" and when we call . During this - // interval, the client can shutdown the connection, in which case, - // the call can hang! - if (this->accept_strategy_->acceptor ().enable (ACE_NONBLOCK) != 0) - return -1; - - // Initialize the concurrency strategy. - - if (con_s == 0) - { - ACE_NEW_RETURN (con_s, - CONCURRENCY_STRATEGY, - -1); - this->delete_concurrency_strategy_ = true; - } - this->concurrency_strategy_ = con_s; - - // Initialize the scheduling strategy. - - if (sch_s == 0) - { - ACE_NEW_RETURN (sch_s, - SCHEDULING_STRATEGY, - -1); - this->delete_scheduling_strategy_ = true; - } - this->scheduling_strategy_ = sch_s; - - this->use_select_ = use_select; - - return this->reactor ()->register_handler - (this, - ACE_Event_Handler::ACCEPT_MASK); -} - -// Simple constructor. - -template -ACE_Strategy_Acceptor::ACE_Strategy_Acceptor - (const ACE_TCHAR service_name[], - const ACE_TCHAR service_description[], - int use_select, - int reuse_addr) - : creation_strategy_ (0), - delete_creation_strategy_ (false), - accept_strategy_ (0), - delete_accept_strategy_ (false), - concurrency_strategy_ (0), - delete_concurrency_strategy_ (false), - scheduling_strategy_ (0), - delete_scheduling_strategy_ (false), - service_name_ (0), - service_description_ (0) -{ - ACE_TRACE ("ACE_Strategy_Acceptor::ACE_Strategy_Acceptor"); - - if (service_name != 0) - ACE_ALLOCATOR (this->service_name_, - ACE_OS::strdup (service_name)); - if (service_description != 0) - ACE_ALLOCATOR (this->service_description_, - ACE_OS::strdup (service_description)); - this->use_select_ = use_select; - this->reuse_addr_ = reuse_addr; -} - -template -ACE_Strategy_Acceptor::ACE_Strategy_Acceptor - (const ACE_PEER_ACCEPTOR_ADDR &addr, - ACE_Reactor *reactor, - ACE_Creation_Strategy *cre_s, - ACE_Accept_Strategy *acc_s, - ACE_Concurrency_Strategy *con_s, - ACE_Scheduling_Strategy *sch_s, - const ACE_TCHAR service_name[], - const ACE_TCHAR service_description[], - int use_select, - int reuse_addr) - : creation_strategy_ (0), - delete_creation_strategy_ (false), - accept_strategy_ (0), - delete_accept_strategy_ (false), - concurrency_strategy_ (0), - delete_concurrency_strategy_ (false), - scheduling_strategy_ (0), - delete_scheduling_strategy_ (false), - service_name_ (0), - service_description_ (0) -{ - ACE_TRACE ("ACE_Strategy_Acceptor::ACE_Strategy_Acceptor"); - - if (this->open (addr, - reactor, - cre_s, - acc_s, - con_s, - sch_s, - service_name, - service_description, - use_select, - reuse_addr) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Strategy_Acceptor::ACE_Strategy_Acceptor"))); -} - -// Perform termination activities when is removed from the -// . - -template int -ACE_Strategy_Acceptor::handle_close (ACE_HANDLE, - ACE_Reactor_Mask) -{ - ACE_TRACE ("ACE_Strategy_Acceptor::handle_close"); - // Guard against multiple closes. - if (this->reactor () != 0) - { - ACE_HANDLE handle = this->get_handle (); - - if (this->delete_creation_strategy_) - delete this->creation_strategy_; - this->delete_creation_strategy_ = false; - this->creation_strategy_ = 0; - - if (this->delete_accept_strategy_) - delete this->accept_strategy_; - this->delete_accept_strategy_ = false; - this->accept_strategy_ = 0; - - if (this->delete_concurrency_strategy_) - delete this->concurrency_strategy_; - this->delete_concurrency_strategy_ = false; - this->concurrency_strategy_ = 0; - - if (this->delete_scheduling_strategy_) - delete this->scheduling_strategy_; - this->delete_scheduling_strategy_ = false; - this->scheduling_strategy_ = 0; - - // We must use the obtained *before* we deleted the - // accept_strategy_... - - this->reactor ()->remove_handler - (handle, - ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL); - - // Set the Reactor to 0 so that we don't try to close down - // again. - this->reactor (0); - } - return 0; -} - -// Bridge method for creating a . The strategy for -// creating a are configured into the Acceptor via it's -// . The default is to create a new -// . However, subclasses can override this strategy to -// perform creation in any way that they like (such as -// creating subclass instances of , using a singleton, -// dynamically linking the handler, etc.). - -template int -ACE_Strategy_Acceptor::make_svc_handler (SVC_HANDLER *&sh) -{ - ACE_TRACE ("ACE_Strategy_Acceptor::make_svc_handler"); - return this->creation_strategy_->make_svc_handler (sh); -} - -// Bridge method for accepting the new connection into the -// . The default behavior delegates to the -// in the Acceptor_Strategy. - -template int -ACE_Strategy_Acceptor::accept_svc_handler - (SVC_HANDLER *svc_handler) -{ - ACE_TRACE ("ACE_Strategy_Acceptor::accept_svc_handler"); - return this->accept_strategy_->accept_svc_handler (svc_handler); -} - -// Bridge method for activating a with the appropriate -// concurrency strategy. The default behavior of this method is to -// activate the SVC_HANDLER by calling its open() method (which allows -// the SVC_HANDLER to define its own concurrency strategy). However, -// subclasses can override this strategy to do more sophisticated -// concurrency activations (such as creating the SVC_HANDLER as an -// "active object" via multi-threading or multi-processing). - -template int -ACE_Strategy_Acceptor::activate_svc_handler - (SVC_HANDLER *svc_handler) -{ - ACE_TRACE ("ACE_Strategy_Acceptor::activate_svc_handler"); - return this->concurrency_strategy_->activate_svc_handler - (svc_handler, - (void *) this); -} - -template -ACE_Strategy_Acceptor::~ACE_Strategy_Acceptor (void) -{ - ACE_TRACE ("ACE_Strategy_Acceptor::~ACE_Strategy_Acceptor"); - ACE_OS::free ((void *) this->service_name_); - ACE_OS::free ((void *) this->service_description_); - this->handle_close (); -} - -// Signal the server to shutdown gracefully. - -template int -ACE_Strategy_Acceptor::handle_signal (int, siginfo_t *, ucontext_t *) -{ - ACE_Reactor::instance()->end_reactor_event_loop (); - return 0; -} - -template int -ACE_Strategy_Acceptor::info (ACE_TCHAR **strp, - size_t length) const -{ - ACE_TRACE ("ACE_Strategy_Acceptor::info"); - - ACE_TCHAR buf[BUFSIZ]; - ACE_TCHAR service_addr_str[BUFSIZ]; - ACE_PEER_ACCEPTOR_ADDR addr; - - if (this->acceptor ().get_local_addr (addr) == -1) - return -1; - else if (addr.addr_to_string (service_addr_str, - sizeof service_addr_str) == -1) - return -1; - - // @@ Should add the protocol in... - ACE_OS::sprintf (buf, - ACE_TEXT ("%s\t %s #%s\n"), - this->service_name_ == 0 - ? ACE_TEXT ("") - : this->service_name_, - service_addr_str, - this->service_description_ == 0 - ? ACE_TEXT ("") - : this->service_description_); - - if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) - return -1; - else - ACE_OS::strsncpy (*strp, buf, length); - return static_cast (ACE_OS::strlen (buf)); -} - -template int -ACE_Strategy_Acceptor::fini (void) -{ - ACE_TRACE ("ACE_Strategy_Acceptor::fini"); - return this->ACE_Strategy_Acceptor::handle_close (); -} - -ACE_ALLOC_HOOK_DEFINE(ACE_Oneshot_Acceptor) - -template void -ACE_Oneshot_Acceptor::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Oneshot_Acceptor::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nsvc_handler_ = %x"), this->svc_handler_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nrestart_ = %d"), this->restart_)); - this->peer_acceptor_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_concurrency_strategy_ = %d"), - delete_concurrency_strategy_)); - this->concurrency_strategy_->dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -template int -ACE_Oneshot_Acceptor::open - (const ACE_PEER_ACCEPTOR_ADDR &local_addr, - ACE_Reactor *reactor, - ACE_Concurrency_Strategy *con_s) -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::open"); - this->reactor (reactor); - - // Initialize the concurrency strategy. - - if (con_s == 0) - { - ACE_NEW_RETURN (con_s, - ACE_Concurrency_Strategy, - -1); - this->delete_concurrency_strategy_ = true; - } - this->concurrency_strategy_ = con_s; - - // Reuse the addr, even if it is already in use...! - return this->peer_acceptor_.open (local_addr, 1); -} - -template -ACE_Oneshot_Acceptor::ACE_Oneshot_Acceptor (void) - : delete_concurrency_strategy_ (false) -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::ACE_Oneshot_Acceptor"); - this->reactor (0); -} - -template -ACE_Oneshot_Acceptor::ACE_Oneshot_Acceptor - (const ACE_PEER_ACCEPTOR_ADDR &local_addr, - ACE_Reactor *reactor, - ACE_Concurrency_Strategy *cs) - : delete_concurrency_strategy_ (false) -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::ACE_Oneshot_Acceptor"); - if (this->open (local_addr, reactor, cs) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Oneshot_Acceptor::ACE_Oneshot_Acceptor"))); -} - -template -ACE_Oneshot_Acceptor::~ACE_Oneshot_Acceptor (void) -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::~ACE_Oneshot_Acceptor"); - this->handle_close (); -} - -template int -ACE_Oneshot_Acceptor::close (void) -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::close"); - return this->handle_close (); -} - -template int -ACE_Oneshot_Acceptor::handle_close (ACE_HANDLE, - ACE_Reactor_Mask) -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::handle_close"); - - // Guard against multiple closes. - if (this->delete_concurrency_strategy_) - { - delete this->concurrency_strategy_; - this->delete_concurrency_strategy_ = false; - this->concurrency_strategy_ = 0; - } - // Note that if we aren't actually registered with the - // ACE_Reactor then it's ok for this call to fail... - - if (this->reactor ()) - this->reactor ()->remove_handler - (this, - ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL); - - if (this->peer_acceptor_.close () == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("close\n"))); - return 0; -} - -template int -ACE_Oneshot_Acceptor::handle_timeout - (const ACE_Time_Value &tv, - const void *arg) -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::handle_timeout"); - errno = ETIME; - - if (this->svc_handler_->handle_timeout (tv, arg) == -1) - this->svc_handler_->handle_close (this->svc_handler_->get_handle (), - ACE_Event_Handler::TIMER_MASK); - - // Since we aren't necessarily registered with the Reactor, don't - // bother to check the return value here... - if (this->reactor ()) - this->reactor ()->remove_handler (this, - ACE_Event_Handler::ACCEPT_MASK); - return 0; -} - -template int -ACE_Oneshot_Acceptor::cancel (void) -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::cancel"); - return this->reactor () && this->reactor ()->cancel_timer (this); -} - -template int -ACE_Oneshot_Acceptor::register_handler - (SVC_HANDLER *svc_handler, - const ACE_Synch_Options &synch_options, - int restart) -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::register_handler"); - // Can't do this if we don't have a Reactor. - if (this->reactor () == 0) - { - errno = EINVAL; - return -1; - } - else - { - this->svc_handler_ = svc_handler; - this->restart_ = restart; - ACE_Time_Value *tv = (ACE_Time_Value *) synch_options.time_value (); - - if (tv != 0 - && this->reactor ()->schedule_timer (this, - synch_options.arg (), - *tv) == 0) - return -1; - else - return this->reactor ()->register_handler - (this, - ACE_Event_Handler::ACCEPT_MASK); - } -} - -// Bridge method for activating a with the appropriate -// concurrency strategy. The default behavior of this method is to -// activate the SVC_HANDLER by calling its open() method (which allows -// the SVC_HANDLER to define its own concurrency strategy). However, -// subclasses can override this strategy to do more sophisticated -// concurrency activations (such as creating the SVC_HANDLER as an -// "active object" via multi-threading or multi-processing). - -template int -ACE_Oneshot_Acceptor::activate_svc_handler - (SVC_HANDLER *svc_handler) -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::activate_svc_handler"); - return this->concurrency_strategy_->activate_svc_handler - (svc_handler, - (void *) this); -} - -// Factors out the code shared between the and -// methods. - -template int -ACE_Oneshot_Acceptor::shared_accept - (SVC_HANDLER *svc_handler, - ACE_PEER_ACCEPTOR_ADDR *remote_addr, - ACE_Time_Value *timeout, - int restart, - int reset_new_handle) -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::shared_accept"); - if (svc_handler == 0) - return -1; - - // Accept connection into the Svc_Handler. - else if (this->peer_acceptor_.accept (svc_handler->peer (), // stream - remote_addr, // remote address - timeout, // timeout - restart, // restart - reset_new_handle // reset new handle - ) == -1) - { - // Check whether we just timed out or whether we failed... - if (!(errno == EWOULDBLOCK || errno == ETIME)) - // Close down handler to avoid memory leaks. - svc_handler->close (0); - return -1; - } - // Activate the using the designated concurrency - // strategy (note that this method becomes responsible for handling - // errors and freeing up the memory if things go awry...) - else - return this->activate_svc_handler (svc_handler); -} - -// Make a SVC_HANDLER, accept the connection into the SVC_HANDLER, and -// then activate the SVC_HANDLER. Note that SVC_HANDLER::open() -// decides what type of concurrency strategy to use. - -template int -ACE_Oneshot_Acceptor::accept - (SVC_HANDLER *svc_handler, - ACE_PEER_ACCEPTOR_ADDR *remote_addr, - const ACE_Synch_Options &synch_options, - int restart, - int reset_new_handle) -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::accept"); - // Note that if timeout == ACE_Time_Value (x, y) where (x > 0 || y > - // 0) then this->connector_.connect() will block synchronously. If - // is set then we don't want this to happen (since we - // want the ACE_Reactor to do the timeout asynchronously). - // Therefore, we'll force this->connector_ to use ACE_Time_Value (0, - // 0) in this case... - - ACE_Time_Value *timeout; - int use_reactor = synch_options[ACE_Synch_Options::USE_REACTOR]; - - if (use_reactor) - timeout = (ACE_Time_Value *) &ACE_Time_Value::zero; - else - timeout = (ACE_Time_Value *) synch_options.time_value (); - - if (this->shared_accept (svc_handler, // stream - remote_addr, // remote address - timeout, // timeout - restart, // restart - reset_new_handle // reset new handler - ) == -1) - { - if (use_reactor && errno == EWOULDBLOCK) - // We couldn't accept right away, so let's wait in the - // . - this->register_handler (svc_handler, - synch_options, - restart); - return -1; - } - return 0; -} - -// Accepts one pending connection from a client (since we're the -// "oneshot" Acceptor). - -template int -ACE_Oneshot_Acceptor::handle_input (ACE_HANDLE) -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::handle_input"); - int result = 0; - - // Cancel any timer that might be pending. - this->cancel (); - - // Try to find out if the implementation of the reactor that we are - // using requires us to reset the event association for the newly - // created handle. This is because the newly created handle will - // inherit the properties of the listen handle, including its event - // associations. - int reset_new_handle = this->reactor ()->uses_event_associations (); - - // There is a use-case whereby this object will be gone upon return - // from shared_accept - if the Svc_Handler deletes this Oneshot_Acceptor - // during the shared_accept/activation steps. So, do whatever we need - // to do with this object before calling shared_accept. - if (this->reactor ()) - this->reactor ()->remove_handler - (this, - ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL); - - if (this->shared_accept (this->svc_handler_, // stream - 0, // remote address - 0, // timeout - this->restart_, // restart - reset_new_handle // reset new handle - ) == -1) - result = -1; - - return result; -} - -// Hook called by the explicit dynamic linking facility. - -template int -ACE_Oneshot_Acceptor::init (int, ACE_TCHAR *[]) -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::init"); - return -1; -} - -template int -ACE_Oneshot_Acceptor::fini (void) -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::fini"); - return this->handle_close (); -} - -template int -ACE_Oneshot_Acceptor::info (ACE_TCHAR **strp, - size_t length) const -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::info"); - ACE_TCHAR buf[BUFSIZ]; - ACE_TCHAR addr_str[BUFSIZ]; - ACE_PEER_ACCEPTOR_ADDR addr; - - if (this->peer_acceptor_.get_local_addr (addr) == -1) - return -1; - else if (addr.addr_to_string (addr_str, sizeof addr_str) == -1) - return -1; - - ACE_OS::sprintf (buf, - ACE_TEXT ("%s\t %s %s"), - ACE_TEXT ("ACE_Oneshot_Acceptor"), - addr_str, - ACE_TEXT ("#oneshot acceptor factory\n")); - - if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) - return -1; - else - ACE_OS::strsncpy (*strp, buf, length); - return static_cast (ACE_OS::strlen (buf)); -} - -template int -ACE_Oneshot_Acceptor::suspend (void) -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::suspend"); - return this->reactor () && this->reactor ()->suspend_handler (this); -} - -template int -ACE_Oneshot_Acceptor::resume (void) -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::resume"); - return this->reactor () && this->reactor ()->resume_handler (this); -} - -// Returns ACE_HANDLE of the underlying peer_acceptor. - -template ACE_HANDLE -ACE_Oneshot_Acceptor::get_handle (void) const -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::get_handle"); - return this->peer_acceptor_.get_handle (); -} - -template ACE_PEER_ACCEPTOR & -ACE_Oneshot_Acceptor::acceptor (void) const -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::acceptor"); - return (ACE_PEER_ACCEPTOR &) this->peer_acceptor_; -} - -template -ACE_Oneshot_Acceptor::operator ACE_PEER_ACCEPTOR & () const -{ - ACE_TRACE ("ACE_Oneshot_Acceptor::operator ACE_PEER_ACCEPTOR &"); - return (ACE_PEER_ACCEPTOR &) this->peer_acceptor_; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_ACCEPTOR_CPP */ diff --git a/ACE/ace/Acceptor.h b/ACE/ace/Acceptor.h deleted file mode 100644 index 741dca098e1..00000000000 --- a/ACE/ace/Acceptor.h +++ /dev/null @@ -1,684 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Acceptor.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_ACCEPTOR_H -#define ACE_ACCEPTOR_H - -#include /**/ "ace/pre.h" - -#include "ace/Service_Object.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Strategies_T.h" -#include "ace/Synch_Options.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Acceptor - * - * @brief Abstract factory for creating a service handler - * (SVC_HANDLER), accepting into the SVC_HANDLER, and - * activating the SVC_HANDLER. - * - * Implements the basic strategy for passively establishing - * connections with clients. An ACE_Acceptor is parameterized - * by concrete types that conform to the interfaces of - * PEER_ACCEPTOR and SVC_HANDLER. The PEER_ACCEPTOR is - * instantiated with a transport mechanism that passively - * establishes connections. The SVC_HANDLER is instantiated - * with a concrete type that performs the application-specific - * service. An ACE_Acceptor inherits from ACE_Service_Object, - * which in turn inherits from ACE_Event_Handler. This enables - * the ACE_Reactor to dispatch the ACE_Acceptor's handle_input - * method when connection events occur. The handle_input method - * performs the ACE_Acceptor's default creation, connection - * establishment, and service activation strategies. These - * strategies can be overridden by subclasses individually or as - * a group. - */ -template -class ACE_Acceptor : public ACE_Service_Object -{ -public: - - // Useful STL-style traits. - typedef ACE_PEER_ACCEPTOR_ADDR addr_type; - typedef ACE_PEER_ACCEPTOR acceptor_type; - typedef SVC_HANDLER handler_type; - typedef typename SVC_HANDLER::stream_type stream_type; - - /// "Do-nothing" constructor. - ACE_Acceptor (ACE_Reactor * = 0, - int use_select = 1); - - /** - * Open the contained @c PEER_ACCEPTOR object to begin listening, and - * register with the specified reactor for accept events. An - * acceptor can only listen to one port at a time, so make sure to - * @c close() the acceptor before calling @c open() again. - * - * The @c PEER_ACCEPTOR handle is put into non-blocking mode as a - * safeguard against the race condition that can otherwise occur - * between the time when the passive-mode socket handle is "ready" - * and when the actual @c accept() call is made. During this - * interval, the client can shutdown the connection, in which case, - * the @c accept() call can hang. - * - * @param local_addr The address to listen at. - * @param reactor Pointer to the ACE_Reactor instance to register - * this object with. The default is the singleton. - * @param flags Flags to control what mode an accepted socket - * will be put into after it is accepted. The only - * legal value for this argument is @c ACE_NONBLOCK, - * which enables non-blocking mode on the accepted - * peer stream object in @c SVC_HANDLER. The default - * is 0. - * @param use_select Affects behavior when called back by the reactor - * when a connection can be accepted. If non-zero, - * this object will accept all pending connections, - * intead of just the one that triggered the reactor - * callback. Uses ACE_OS::select() internally to - * detect any remaining acceptable connections. - * The default is 1. - * @param reuse_addr Passed to the @c PEER_ACCEPTOR::open() method with - * @p local_addr. Generally used to request that the - * OS allow reuse of the listen port. The default is 1. - */ - ACE_Acceptor (const ACE_PEER_ACCEPTOR_ADDR &local_addr, - ACE_Reactor *reactor = ACE_Reactor::instance (), - int flags = 0, - int use_select = 1, - int reuse_addr = 1); - - /** - * Open the contained @c PEER_ACCEPTOR object to begin listening, and - * register with the specified reactor for accept events. An - * acceptor can only listen to one port at a time, so make sure to - * @c close() the acceptor before calling @c open() again. - * - * The @c PEER_ACCEPTOR handle is put into non-blocking mode as a - * safeguard against the race condition that can otherwise occur - * between the time when the passive-mode socket handle is "ready" - * and when the actual @c accept() call is made. During this - * interval, the client can shutdown the connection, in which case, - * the @c accept() call can hang. - * - * @param local_addr The address to listen at. - * @param reactor Pointer to the ACE_Reactor instance to register - * this object with. The default is the singleton. - * @param flags Flags to control what mode an accepted socket - * will be put into after it is accepted. The only - * legal value for this argument is @c ACE_NONBLOCK, - * which enables non-blocking mode on the accepted - * peer stream object in @c SVC_HANDLER. The default - * is 0. - * @param use_select Affects behavior when called back by the reactor - * when a connection can be accepted. If non-zero, - * this object will accept all pending connections, - * intead of just the one that triggered the reactor - * callback. Uses ACE_OS::select() internally to - * detect any remaining acceptable connections. - * The default is 1. - * @param reuse_addr Passed to the @c PEER_ACCEPTOR::open() method with - * @p local_addr. Generally used to request that the - * OS allow reuse of the listen port. The default is 1. - * - * @retval 0 Success - * @retval -1 Failure, @c errno contains an error code. - */ - virtual int open (const ACE_PEER_ACCEPTOR_ADDR &local_addr, - ACE_Reactor *reactor = ACE_Reactor::instance (), - int flags = 0, - int use_select = 1, - int reuse_addr = 1); - - /// Close down the Acceptor's resources. - virtual ~ACE_Acceptor (void); - - /// Return the underlying PEER_ACCEPTOR object. - virtual operator ACE_PEER_ACCEPTOR &() const; - - /// Return the underlying PEER_ACCEPTOR object. - virtual ACE_PEER_ACCEPTOR &acceptor (void) const; - - /// Returns the listening acceptor's {ACE_HANDLE}. - virtual ACE_HANDLE get_handle (void) const; - - /// Close down the Acceptor - virtual int close (void); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - // = The following three methods define the Acceptor's strategies - // for creating, accepting, and activating SVC_HANDLER's, - // respectively. - - /** - * Bridge method for creating a SVC_HANDLER. The default is to - * create a new {SVC_HANDLER} if {sh} == 0, else {sh} is unchanged. - * However, subclasses can override this policy to perform - * SVC_HANDLER creation in any way that they like (such as creating - * subclass instances of SVC_HANDLER, using a singleton, dynamically - * linking the handler, etc.). Returns -1 on failure, else 0. - */ - virtual int make_svc_handler (SVC_HANDLER *&sh); - - /** - * Bridge method for accepting the new connection into the - * . The default behavior delegates to the - * PEER_ACCEPTOR::accept. - */ - virtual int accept_svc_handler (SVC_HANDLER *svc_handler); - - /** - * Bridge method for activating a {svc_handler} with the appropriate - * concurrency strategy. The default behavior of this method is to - * activate the SVC_HANDLER by calling its {open} method (which - * allows the SVC_HANDLER to define its own concurrency strategy). - * However, subclasses can override this strategy to do more - * sophisticated concurrency activations (such as making the - * SVC_HANDLER as an "active object" via multi-threading or - * multi-processing). - */ - virtual int activate_svc_handler (SVC_HANDLER *svc_handler); - - // = Demultiplexing hooks. - /// Perform termination activities when {this} is removed from the - /// {reactor}. - virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE, - ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK); - - /// Accepts all pending connections from clients, and creates and - /// activates SVC_HANDLERs. - virtual int handle_input (ACE_HANDLE); - - // = Dynamic linking hooks. - /// Default version does no work and returns -1. Must be overloaded - /// by application developer to do anything meaningful. - virtual int init (int argc, ACE_TCHAR *argv[]); - - /// Calls {handle_close}. - virtual int fini (void); - - /// Default version returns address info in {buf}. - virtual int info (ACE_TCHAR **buf, size_t) const; - -public: - // = Service management hooks. - /// This method calls {Reactor::suspend}. - virtual int suspend (void); - - /// This method calls {Reactor::resume}. - virtual int resume (void); - -protected: - /// Concrete factory for accepting connections from clients... - ACE_PEER_ACCEPTOR peer_acceptor_; - - /// Needed to reopen the socket if {accept} fails. - ACE_PEER_ACCEPTOR_ADDR peer_acceptor_addr_; - - /** - * Flags that indicate how {SVC_HANDLER}'s should be initialized - * prior to being activated. Right now, the only flag that is - * processed is {ACE_NONBLOCK}, which enabled non-blocking I/O on - * the {SVC_HANDLER} when it is opened. - */ - int flags_; - - /// Flag that indicates whether it shall use {select} in the - /// {accept}-loop. - int use_select_; - - /// Needed to reopen the socket if {accept} fails. - int reuse_addr_; -}; - -/** - * @class ACE_Strategy_Acceptor - * - * @brief Abstract factory for creating a service handler - * (SVC_HANDLER), accepting into the SVC_HANDLER, and activating - * the SVC_HANDLER. - * - * Implements a flexible and extensible set of strategies for - * passively establishing connections with clients. There are - * three main strategies: (1) creating a SVC_HANDLER, (2) - * passively accepting a new connection from a client into the - * SVC_HANDLER, and (3) activating the SVC_HANDLER with a - * particular concurrency mechanism. - */ -template -class ACE_Strategy_Acceptor - : public ACE_Acceptor -{ -public: - - // Useful STL-style traits. - typedef ACE_Creation_Strategy - creation_strategy_type; - typedef ACE_Accept_Strategy - accept_strategy_type; - typedef ACE_Concurrency_Strategy - concurrency_strategy_type; - typedef ACE_Scheduling_Strategy scheduling_strategy_type; - typedef ACE_Acceptor - base_type; - - // = Define some useful (old style) traits. - typedef ACE_Creation_Strategy CREATION_STRATEGY; - typedef ACE_Accept_Strategy ACCEPT_STRATEGY; - typedef ACE_Concurrency_Strategy CONCURRENCY_STRATEGY; - typedef ACE_Scheduling_Strategy SCHEDULING_STRATEGY; - - - - /// Default constructor. - ACE_Strategy_Acceptor (const ACE_TCHAR service_name[] = 0, - const ACE_TCHAR service_description[] = 0, - int use_select = 1, - int reuse_addr = 1); - - /** - * Initialize the appropriate strategies for creation, passive - * connection acceptance, and concurrency, and then register {this} - * with the Reactor and listen for connection requests at the - * designated {local_addr}. - */ - ACE_Strategy_Acceptor (const ACE_PEER_ACCEPTOR_ADDR &local_addr, - ACE_Reactor * = ACE_Reactor::instance (), - ACE_Creation_Strategy * = 0, - ACE_Accept_Strategy * = 0, - ACE_Concurrency_Strategy * = 0, - ACE_Scheduling_Strategy * = 0, - const ACE_TCHAR service_name[] = 0, - const ACE_TCHAR service_description[] = 0, - int use_select = 1, - int reuse_addr = 1); - - /** - * Open the contained @c PEER_ACCEPTOR object to begin listening, and - * register with the specified reactor for accept events. - * - * The @c PEER_ACCEPTOR handle is put into non-blocking mode as a - * safeguard against the race condition that can otherwise occur - * between the time when the passive-mode socket handle is "ready" - * and when the actual @c accept call is made. During this - * interval, the client can shutdown the connection, in which case, - * the {accept} call can hang. - * - * @param local_addr The address to listen at. - * @param reactor Pointer to the ACE_Reactor instance to register - * this object with. The default is the singleton. - * @param flags Flags to control what mode an accepted socket - * will be put into after it is accepted. The only - * legal value for this argument is @c ACE_NONBLOCK, - * which enables non-blocking mode on the accepted - * peer stream object in @c SVC_HANDLER. The default - * is 0. - * @param use_select Affects behavior when called back by the reactor - * when a connection can be accepted. If non-zero, - * this object will accept all pending connections, - * intead of just the one that triggered the reactor - * callback. Uses ACE_OS::select() internally to - * detect any remaining acceptable connections. - * The default is 1. - * @param reuse_addr Passed to the @c PEER_ACCEPTOR::open() method with - * @p local_addr. Generally used to request that the - * OS allow reuse of the listen port. The default is 1. - * - * @retval 0 Success - * @retval -1 Failure, @c errno contains an error code. - */ - virtual int open (const ACE_PEER_ACCEPTOR_ADDR &local_addr, - ACE_Reactor *reactor, - int flags = 0, - int use_select = 1, - int reuse_addr = 1); - - /** - * Initialize the appropriate strategies for creation, passive - * connection acceptance, and concurrency, and then register {this} - * with the Reactor and listen for connection requests at the - * designated {local_addr}. - */ - virtual int open (const ACE_PEER_ACCEPTOR_ADDR &, - ACE_Reactor * = ACE_Reactor::instance (), - ACE_Creation_Strategy * = 0, - ACE_Accept_Strategy * =0, - ACE_Concurrency_Strategy * = 0, - ACE_Scheduling_Strategy * = 0, - const ACE_TCHAR *service_name = 0, - const ACE_TCHAR *service_description = 0, - int use_select = 1, - int reuse_addr = 1); - - /// Close down the Strategy_Acceptor's resources. - virtual ~ACE_Strategy_Acceptor (void); - - /// Return the underlying PEER_ACCEPTOR object. - virtual operator ACE_PEER_ACCEPTOR &() const; - - /// Return the underlying PEER_ACCEPTOR object. - virtual ACE_PEER_ACCEPTOR &acceptor (void) const; - - /// Returns the listening acceptor's {ACE_HANDLE}. - virtual ACE_HANDLE get_handle (void) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - - // = Service management hooks. - - /// This method delegates to the {Scheduling_Strategy}'s {suspend} - /// method. - virtual int suspend (void); - - /// This method delegates to the {Scheduling_Strategy}'s {resume} - /// method. - virtual int resume (void); - -protected: - - /// Calls {handle_close} when dynamically unlinked. - virtual int fini (void); - - /// Default version returns address info in {buf}. - virtual int info (ACE_TCHAR **buf, size_t) const; - - // = The following three methods define the {Acceptor}'s strategies - // for creating, accepting, and activating {SVC_HANDLER}'s, - // respectively. - - /** - * Bridge method for creating a {SVC_HANDLER}. The strategy for - * creating a {SVC_HANDLER} are configured into the Acceptor via - * it's {creation_strategy_}. The default is to create a new - * {SVC_HANDLER} if {sh} == 0, else {sh} is unchanged. However, - * subclasses can override this policy to perform {SVC_HANDLER} - * creation in any way that they like (such as creating subclass - * instances of {SVC_HANDLER}, using a singleton, dynamically - * linking the handler, etc.). Returns -1 on failure, else 0. - */ - virtual int make_svc_handler (SVC_HANDLER *&); - - /** - * Bridge method for accepting the new connection into the - * {SVC_HANDLER}. The default behavior delegates to the - * {PEER_ACCEPTOR::accept} in the {Acceptor_Strategy}. - */ - virtual int accept_svc_handler (SVC_HANDLER *svc_handler); - - /** - * Bridge method for activating a {SVC_HANDLER} with the appropriate - * concurrency strategy. The default behavior of this method is to - * activate the {SVC_HANDLER} by calling its {open} method (which - * allows the {SVC_HANDLER} to define its own concurrency strategy). - * However, subclasses can override this strategy to do more - * sophisticated concurrency activations (such as creating the - * {SVC_HANDLER} as an "active object" via multi-threading or - * multi-processing). - */ - virtual int activate_svc_handler (SVC_HANDLER *svc_handler); - - // = Demultiplexing hooks. - /// Perform termination activities when {this} is removed from the - /// {Reactor}. - virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE, - ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK); - - /// Handle SIGINT. - virtual int handle_signal (int signum, siginfo_t *, ucontext_t *); - - // = These data members are "logically private" but are put in the - // protected part in case subclasses want to access them. - - // = Strategy objects. - - /// Creation strategy for an Acceptor. - CREATION_STRATEGY *creation_strategy_; - - /// true if {Acceptor} created the creation strategy and thus should - /// delete it, else false. - bool delete_creation_strategy_; - - /// Accept strategy for an {Acceptor}. - ACCEPT_STRATEGY *accept_strategy_; - - /// true if {Acceptor} created the accept strategy and thus should delete - /// it, else false. - bool delete_accept_strategy_; - - /// Concurrency strategy for an {Acceptor}. - CONCURRENCY_STRATEGY *concurrency_strategy_; - - /// true if {Acceptor} created the concurrency strategy and thus should - /// delete it, else false. - bool delete_concurrency_strategy_; - - /// Scheduling strategy for an {Acceptor}. - SCHEDULING_STRATEGY *scheduling_strategy_; - - /// true if {Acceptor} created the scheduling strategy and thus should - /// delete it, else false. - bool delete_scheduling_strategy_; - - // = Service information objects. - - /// Name of the service. - ACE_TCHAR *service_name_; - - /// Description of the service. - ACE_TCHAR *service_description_; - - /// Address that the {Strategy_Acceptor} uses to listen for - /// connections. - ACE_PEER_ACCEPTOR_ADDR service_addr_; -}; - -/** - * @class ACE_Oneshot_Acceptor - * - * @brief Generic factory for passively connecting clients and creating - * exactly one service handler (SVC_HANDLER). - * - * This class works similarly to the regular {ACE_Acceptor}, - * with the following differences: - * 1. This class doesn't automagically register {this} with the - * {ACE_Reactor} since it expects to have its {accept} method - * called directly. However, it stashes the {ACE_Reactor} - * pointer away in case it's needed later to finish accepting - * a connection asynchronously. - * 2. The class doesn't need an {ACE_Creation_Strategy} (since - * the user supplies the SVC_HANDLER) or an - * {ACE_Accept_Strategy} (since this class only accepts one - * connection and then removes all traces of itself from the - * {ACE_Reactor} if it was registered for asynchronous - * accepts). - */ -template -class ACE_Oneshot_Acceptor : public ACE_Service_Object -{ -public: - - // Useful STL-style traits. - typedef ACE_PEER_ACCEPTOR_ADDR addr_type; - typedef ACE_PEER_ACCEPTOR acceptor_type; - typedef SVC_HANDLER handler_type; - typedef typename SVC_HANDLER::stream_type stream_type; - - /// Constructor. - ACE_Oneshot_Acceptor (void); - - /** - * Initialize the appropriate strategies for concurrency and then - * open the {peer_acceptor} at the designated {local_addr}. Note - * that unlike the {ACE_Acceptor} and {ACE_Strategy_Acceptor}, this - * method does NOT register {this} acceptor with the {reactor} at - * this point -- it just stashes the {reactor} away in case it's - * needed later. - */ - ACE_Oneshot_Acceptor (const ACE_PEER_ACCEPTOR_ADDR &local_addr, - ACE_Reactor *reactor = ACE_Reactor::instance (), - ACE_Concurrency_Strategy * = 0); - - /** - * Initialize the appropriate strategies for concurrency and then - * open the {peer_acceptor} at the designated {local_addr}. Note - * that unlike the {ACE_Acceptor} and {ACE_Strategy_Acceptor}, this - * method does NOT register {this} acceptor with the {reactor} at - * this point -- it just stashes the {reactor} away in case it's - * needed later. - */ - int open (const ACE_PEER_ACCEPTOR_ADDR &, - ACE_Reactor *reactor = ACE_Reactor::instance (), - ACE_Concurrency_Strategy * = 0); - - /// Close down the {Oneshot_Acceptor}. - virtual ~ACE_Oneshot_Acceptor (void); - - // = Explicit factory operation. - /// Create a {SVC_HANDLER}, accept the connection into the - /// {SVC_HANDLER}, and activate the {SVC_HANDLER}. - virtual int accept (SVC_HANDLER * = 0, - ACE_PEER_ACCEPTOR_ADDR *remote_addr = 0, - const ACE_Synch_Options &synch_options = ACE_Synch_Options::defaults, - int restart = 1, - int reset_new_handle = 0); - - /// Cancel a oneshot acceptor that was started asynchronously. - virtual int cancel (void); - - /// Return the underlying {PEER_ACCEPTOR} object. - virtual operator ACE_PEER_ACCEPTOR &() const; - - /// Return the underlying {PEER_ACCEPTOR} object. - virtual ACE_PEER_ACCEPTOR &acceptor (void) const; - - /// Close down the {Oneshot_Acceptor}. - virtual int close (void); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - /** - * Bridge method for activating a {svc_handler} with the appropriate - * concurrency strategy. Default behavior is to activate the - * {SVC_HANDLER} as a "passive object." However, subclasses can - * override this strategy to do more sophisticated concurrency - * activations (such as creating the {SVC_HANDLER} as an "active - * object" via multi-threading or multi-processing). - */ - virtual int activate_svc_handler (SVC_HANDLER *svc_handler); - - /// Factors out the code shared between the {accept} and - /// {handle_input} methods. - int shared_accept (SVC_HANDLER *svc_handler, - ACE_PEER_ACCEPTOR_ADDR *remote_addr, - ACE_Time_Value *timeout, - int restart, - int reset_new_handle); - - // = Demultiplexing hooks. - /// Returns the listening acceptor's {ACE_HANDLE}. - virtual ACE_HANDLE get_handle (void) const; - - /// Perform termination activities when {this} is removed from the - /// {reactor}. - virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE, - ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK); - - /// Accept one connection from a client and activates the - /// SVC_HANDLER. - virtual int handle_input (ACE_HANDLE); - - /// Called when an acceptor times out... - virtual int handle_timeout (const ACE_Time_Value &tv, - const void *arg); - - // = Dynamic linking hooks. - /// Default version does no work and returns -1. Must be overloaded - /// by application developer to do anything meaningful. - virtual int init (int argc, ACE_TCHAR *argv[]); - - /// Default version does no work and returns -1. Must be overloaded - /// by application developer to do anything meaningful. - virtual int fini (void); - - /// Default version returns address info in {buf}. - virtual int info (ACE_TCHAR **, size_t) const; - - // = Service management hooks. - /// Default version does no work and returns -1. Must be overloaded - /// by application developer to do anything meaningful. - virtual int suspend (void); - - /// Default version does no work and returns -1. Must be overloaded - /// by application developer to do anything meaningful. - virtual int resume (void); - -private: - /** - * Insert ourselves into the {ACE_Reactor} so that we can continue - * accepting this connection asynchronously. This method should NOT - * be called by developers directly. - */ - int register_handler (SVC_HANDLER *svc_handler, - const ACE_Synch_Options &options, - int restart); - - /// Hold the svc_handler_ across asynchrony boundaries. - SVC_HANDLER *svc_handler_; - - /// Hold the restart flag across asynchrony boundaries. - int restart_; - - /// Factory that establishes connections passively. - ACE_PEER_ACCEPTOR peer_acceptor_; - - /// Concurrency strategy for an Acceptor. - ACE_Concurrency_Strategy *concurrency_strategy_; - - /// true if Acceptor created the concurrency strategy and thus should - /// delete it, else false. - bool delete_concurrency_strategy_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Acceptor.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Acceptor.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" - -#endif /* ACE_ACCEPTOR_H */ diff --git a/ACE/ace/Activation_Queue.cpp b/ACE/ace/Activation_Queue.cpp deleted file mode 100644 index aef17d05e7a..00000000000 --- a/ACE/ace/Activation_Queue.cpp +++ /dev/null @@ -1,138 +0,0 @@ -#include "ace/Activation_Queue.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Activation_Queue.inl" -#endif /* __ACE_INLINE__ */ - -#include "ace/Log_Msg.h" -#include "ace/Method_Request.h" -#include "ace/Malloc_Base.h" -#include "ace/Time_Value.h" - -ACE_RCSID (ace, - Activation_Queue, - "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -void -ACE_Activation_Queue::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("delete_queue_ = %d\n"), - this->delete_queue_)); - ACE_DEBUG ((LM_INFO, ACE_TEXT ("queue_: \n"))); - if (this->queue_) - this->queue_->dump(); - else - //FUZZ: disable check_for_NULL - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(NULL)\n"))); - //FUZZ: enable check_for_NULL - - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_Activation_Queue::ACE_Activation_Queue (ACE_Message_Queue *new_queue, - ACE_Allocator *alloc, - ACE_Allocator *db_alloc) - : delete_queue_ (false) - , allocator_(alloc) - , data_block_allocator_(db_alloc) -{ - if (this->allocator_ == 0) - this->allocator_ = ACE_Allocator::instance (); - - if (new_queue) - this->queue_ = new_queue; - else - { - ACE_NEW (this->queue_, - ACE_Message_Queue); - this->delete_queue_ = true; - } -} - -void -ACE_Activation_Queue::queue (ACE_Message_Queue *q) -{ - // Destroy the internal queue if one exist. - if (this->delete_queue_) - { - // Destroy the current queue. - delete this->queue_; - - // Set the flag to false. NOTE that the delete_queue_ flag is a - // flag used to only indicate whether or not if an internal - // ACE_Message_Queue has been created, therefore, it will not - // affect the user if the user decided to replace the queue with - // their own queue no matter how many time they call on this - // function. - this->delete_queue_ = false; - } - - queue_ = q; -} - -ACE_Activation_Queue::~ACE_Activation_Queue (void) -{ - if (this->delete_queue_) - delete this->queue_; -} - -ACE_Method_Request * -ACE_Activation_Queue::dequeue (ACE_Time_Value *tv) -{ - ACE_Message_Block *mb = 0; - - // Dequeue the message. - if (this->queue_->dequeue_head (mb, tv) != -1) - { - // Get the next . - ACE_Method_Request *mr = - reinterpret_cast (mb->base ()); - // Delete the message block. - mb->release (); - return mr; - } - else - return 0; -} - -int -ACE_Activation_Queue::enqueue (ACE_Method_Request *mr, - ACE_Time_Value *tv) -{ - ACE_Message_Block *mb = 0; - - // We pass sizeof (*mr) here so that flow control will work - // correctly. Since we also pass note that no unnecessary - // memory is actually allocated -- just the size field is set. - ACE_NEW_MALLOC_RETURN (mb, - static_cast (this->allocator_->malloc (sizeof (ACE_Message_Block))), - ACE_Message_Block (sizeof (*mr), // size - ACE_Message_Block::MB_DATA, // type - 0, // cont - (char *) mr, // data - 0, // allocator - 0, // locking strategy - mr->priority (), // priority - ACE_Time_Value::zero, // execution time - ACE_Time_Value::max_time, // absolute time of deadline - this->data_block_allocator_, // data_block allocator - this->allocator_), // message_block allocator - -1); - - // Enqueue in priority order. - int const result = this->queue_->enqueue_prio (mb, tv); - - // Free ACE_Message_Block if enqueue_prio failed. - if (result == -1) - ACE_DES_FREE (mb, this->allocator_->free, ACE_Message_Block); - - return result; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Activation_Queue.h b/ACE/ace/Activation_Queue.h deleted file mode 100644 index 87fffc0f73d..00000000000 --- a/ACE/ace/Activation_Queue.h +++ /dev/null @@ -1,173 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Activation_Queue.h - * - * $Id$ - * - * @author Andres Kruse - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_ACTIVATION_QUEUE_H -#define ACE_ACTIVATION_QUEUE_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Message_Queue.h" -#include "ace/Condition_Thread_Mutex.h" - -/// Define to be compatible with the terminology in the POSA2 book! -#define ACE_Activation_List ACE_Activation_Queue - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -class ACE_Method_Request; - -/** - * @class ACE_Activation_Queue - * - * @brief Reifies a method into a request. Subclasses typically - * represent necessary state and behavior. - * - * Maintains a priority-ordered queue of ACE_Method_Request objects. - * A scheduler class (often derived from ACE_Task) subsequently removes - * each method request and invokes its @c call() method. - * - * This class is discussed in depth in the Active Object chapter - * of POSA2. In that book, it is referred to as an Activation List. - * - * @sa ACE_Method_Request - */ -class ACE_Export ACE_Activation_Queue -{ -public: - // = Initialization and termination methods. - /// Constructor. - /** - * Initializes a new activation queue. - * - * @param new_queue The activation queue uses an ACE_Message_Queue to - * queue and order the method requests. If this argument - * is 0, a new ACE_Message_Queue is created for this - * object's use and will be deleted when this object is - * destroyed. If a non-zero pointer is supplied, the - * passed object will be used and will not be deleted when - * this object is destroyed. If an ACE_Task is being created - * to act as the scheduler, for instance, its - * ACE_Message_Queue pointer can be passed to this object. - * @param alloc Optional, the allocator to use when allocating - * ACE_Message_Block instances that wrap the method requests - * queued to this activation queue. Defaults to - * ACE_Allocator::instance(). - * @param db_alloc Optional, the allocator to use when allocating - * data blocks for the ACE_Message_Block instances that - * wrap the method requests queued to this activation queue. - * Defaults to ACE_Allocator::instance(). - */ - ACE_Activation_Queue (ACE_Message_Queue *new_queue = 0, - ACE_Allocator *alloc = 0, - ACE_Allocator *db_alloc = 0); - - /// Destructor. - virtual ~ACE_Activation_Queue (void); - - // = Activate Queue operations. - - /// Dequeue the next available ACE_Method_Request. - /** - * @param tv If 0, the method will block until a method request is - * available, else will wait until the absolute time specified - * in the referenced ACE_Time_Value. This method will return, - * earlier, however, if queue is closed, deactivated, or when - * a signal occurs. - * - * @retval Pointer to the dequeued ACE_Method_Request object. - * @retval 0 an error occurs; errno contains further information. If - * the specified timeout elapses, errno will be @c EWOULDBLOCK. - */ - ACE_Method_Request *dequeue (ACE_Time_Value *tv = 0); - - /// Enqueue the ACE_Method_Request in priority order. - /** - * The priority of the method request is obtained via the @c priority() - * method of the queued method request. Priority ordering is determined - * by the ACE_Message_Queue class; 0 is the lowest priority. - * - * @param new_method_request Pointer to the ACE_Method_Request object to - * queue. This object's @c priority() method is called to obtain - * the priority. - * @param tv If 0, the method will block until the method request can - * be queued, else will wait until the absolute time specified - * in the referenced ACE_Time_Value. This method will return, - * earlier, however, if queue is closed, deactivated, or when - * a signal occurs. - * - * @retval >0 The number of method requests on the queue after adding - * the specified request. - * @retval -1 if an error occurs; errno contains further information. If - * the specified timeout elapses, errno will be @c EWOULDBLOCK. - */ - int enqueue (ACE_Method_Request *new_method_request, ACE_Time_Value *tv = 0); - - /// Get the current number of method objects in the queue. - size_t method_count (void) const; - - /// Returns 1 if the queue is empty, 0 otherwise. - int is_empty (void) const; - - /// Returns 1 if the queue is full, 0 otherwise. - int is_full (void) const; - - /// Dump the state of an request. - void dump (void) const; - - /// Get a pointer to the underlying queue. - ACE_Message_Queue *queue (void) const; - - /// Set the pointer to the underlying queue. - void queue (ACE_Message_Queue *q); - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - - // = Prevent copying and assignment. - ACE_Activation_Queue (const ACE_Activation_Queue &); - void operator= (const ACE_Activation_Queue &); - -protected: - - /// Stores the Method_Requests. - ACE_Message_Queue *queue_; - - /// Keeps track of whether we need to delete the queue. - bool delete_queue_; - -private: - - /// Allocation strategy of the queue. - ACE_Allocator *allocator_; - - /// Allocation strategy of the message blocks. - ACE_Allocator *data_block_allocator_; - -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Activation_Queue.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_ACTIVATION_QUEUE_H */ diff --git a/ACE/ace/Activation_Queue.inl b/ACE/ace/Activation_Queue.inl deleted file mode 100644 index 50127f607d1..00000000000 --- a/ACE/ace/Activation_Queue.inl +++ /dev/null @@ -1,31 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE size_t -ACE_Activation_Queue::method_count (void) const -{ - return queue_->message_count (); -} - -ACE_INLINE int -ACE_Activation_Queue::is_full (void) const -{ - return queue_->is_full (); -} - -ACE_INLINE int -ACE_Activation_Queue::is_empty (void) const -{ - return queue_->is_empty (); -} - -ACE_INLINE ACE_Message_Queue * -ACE_Activation_Queue::queue (void) const -{ - return queue_; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Active_Map_Manager.cpp b/ACE/ace/Active_Map_Manager.cpp deleted file mode 100644 index 6f4b66191c7..00000000000 --- a/ACE/ace/Active_Map_Manager.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// $Id$ - -#include "ace/Active_Map_Manager.h" - -ACE_RCSID(ace, Active_Map_Manager, "$Id$") - -#if !defined (__ACE_INLINE__) -#include "ace/Active_Map_Manager.inl" -#endif /* __ACE_INLINE__ */ diff --git a/ACE/ace/Active_Map_Manager.h b/ACE/ace/Active_Map_Manager.h deleted file mode 100644 index 1281302fdf8..00000000000 --- a/ACE/ace/Active_Map_Manager.h +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file Active_Map_Manager.h - * - * $Id$ - * - * @author Irfan Pyarali - */ -//============================================================================= - - -#ifndef ACE_ACTIVE_MAP_MANAGER_H -#define ACE_ACTIVE_MAP_MANAGER_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Basic_Types.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Active_Map_Manager_Key - * - * @brief Key used in the Active Object Map. - * - * This key keeps information of the index and the generation - * count of the slot it represents. Since the index information - * is part of the key, lookups are super fast and predictable, - */ -class ACE_Export ACE_Active_Map_Manager_Key -{ -public: - /// Default constructor. - ACE_Active_Map_Manager_Key (void); - - /** - * Constructor given the @a slot_index and @a slot_generation number. - * This is useful once the user has somehow recovered the - * @a slot_index and @a slot_generation number from the client. - */ - ACE_Active_Map_Manager_Key (ACE_UINT32 slot_index, - ACE_UINT32 slot_generation); - - /// Get the slot_index. - ACE_UINT32 slot_index (void) const; - - /// Set the slot_index. - void slot_index (ACE_UINT32 i); - - /// Get the slot_generation number. - ACE_UINT32 slot_generation (void) const; - - /// Set the slot_generation number. - void slot_generation (ACE_UINT32 g); - - /// Size required to store information about active key. - static size_t size (void); - - /// Recover state of active key from @a data. User must make sure - /// that @a data encoded using the encode() method. - void decode (const void *data); - - /// Encode state of the active key into @a data. @a data must be as - /// big as the value returned from . - void encode (void *data) const; - - /// Compare keys. - bool operator== (const ACE_Active_Map_Manager_Key &rhs) const; - bool operator!= (const ACE_Active_Map_Manager_Key &rhs) const; - - // = This really should be protected but because of template - // friends, they are not. - - /// Increment the number. - void increment_slot_generation_count (void); - -private: - - /** - * @brief Data for the Active Object Map Key. - * - * This separate structure makes it easier to manage copying - * the index and the generation to and from the user buffer. - * - */ - struct key_data - { - /// Slot index in the active map. - ACE_UINT32 slot_index_; - - /// Slot generation number of slot in the active map. - ACE_UINT32 slot_generation_; - }; - - /// Data for the Active Object Map Key. - key_data key_data_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Active_Map_Manager.inl" -#endif /* __ACE_INLINE__ */ - -// Include the templates here. -#include "ace/Active_Map_Manager_T.h" - -#include /**/ "ace/post.h" -#endif /* ACE_ACTIVE_MAP_MANAGER_H */ diff --git a/ACE/ace/Active_Map_Manager.inl b/ACE/ace/Active_Map_Manager.inl deleted file mode 100644 index 652cf7c1f71..00000000000 --- a/ACE/ace/Active_Map_Manager.inl +++ /dev/null @@ -1,95 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/OS_NS_string.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_Active_Map_Manager_Key::ACE_Active_Map_Manager_Key (void) -{ - // If you change ~0, please change ACE_Map_Manager::free_list_id() - // accordingly. - this->key_data_.slot_index_ = (ACE_UINT32) ~0; - this->key_data_.slot_generation_ = 0; -} - -ACE_INLINE -ACE_Active_Map_Manager_Key::ACE_Active_Map_Manager_Key (ACE_UINT32 slot_index, - ACE_UINT32 slot_generation) -{ - this->key_data_.slot_index_ = slot_index; - this->key_data_.slot_generation_ = slot_generation; -} - -ACE_INLINE ACE_UINT32 -ACE_Active_Map_Manager_Key::slot_index (void) const -{ - return this->key_data_.slot_index_; -} - -ACE_INLINE ACE_UINT32 -ACE_Active_Map_Manager_Key::slot_generation (void) const -{ - return this->key_data_.slot_generation_; -} - -ACE_INLINE bool -ACE_Active_Map_Manager_Key::operator== (const ACE_Active_Map_Manager_Key &rhs) const -{ - return - this->key_data_.slot_index_ == rhs.key_data_.slot_index_ && - this->key_data_.slot_generation_ == rhs.key_data_.slot_generation_; -} - -ACE_INLINE bool -ACE_Active_Map_Manager_Key::operator!= (const ACE_Active_Map_Manager_Key &rhs) const -{ - return !this->operator== (rhs); -} - -ACE_INLINE void -ACE_Active_Map_Manager_Key::slot_index (ACE_UINT32 i) -{ - this->key_data_.slot_index_ = i; -} - -ACE_INLINE void -ACE_Active_Map_Manager_Key::slot_generation (ACE_UINT32 g) -{ - this->key_data_.slot_generation_ = g; -} - -ACE_INLINE void -ACE_Active_Map_Manager_Key::increment_slot_generation_count (void) -{ - ++this->key_data_.slot_generation_; -} - -/* static */ -ACE_INLINE size_t -ACE_Active_Map_Manager_Key::size (void) -{ - return sizeof (ACE_UINT32) + sizeof (ACE_UINT32); -} - -ACE_INLINE void -ACE_Active_Map_Manager_Key::decode (const void *data) -{ - // Copy the information from the user buffer into the key. - ACE_OS::memcpy (&this->key_data_, - data, - sizeof this->key_data_); -} - -ACE_INLINE void -ACE_Active_Map_Manager_Key::encode (void *data) const -{ - // Copy the key data to the user buffer. - ACE_OS::memcpy (data, - &this->key_data_, - sizeof this->key_data_); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Active_Map_Manager_T.cpp b/ACE/ace/Active_Map_Manager_T.cpp deleted file mode 100644 index b8cd14446ac..00000000000 --- a/ACE/ace/Active_Map_Manager_T.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// $Id$ - -#ifndef ACE_ACTIVE_MAP_MANAGER_T_CPP -#define ACE_ACTIVE_MAP_MANAGER_T_CPP - -#include "ace/Active_Map_Manager_T.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (__ACE_INLINE__) -#include "ace/Active_Map_Manager_T.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_Active_Map_Manager) - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_ACTIVE_MAP_MANAGER_T_CPP */ diff --git a/ACE/ace/Active_Map_Manager_T.h b/ACE/ace/Active_Map_Manager_T.h deleted file mode 100644 index 34b5a475652..00000000000 --- a/ACE/ace/Active_Map_Manager_T.h +++ /dev/null @@ -1,211 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file Active_Map_Manager_T.h - * - * $Id$ - * - * @author Irfan Pyarali - */ -//============================================================================= - - -#ifndef ACE_ACTIVE_MAP_MANAGER_T_H -#define ACE_ACTIVE_MAP_MANAGER_T_H -#include /**/ "ace/pre.h" - -#include "ace/Map_Manager.h" -#include "ace/Active_Map_Manager.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Null_Mutex.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Active_Map_Manager - * - * @brief Define a map abstraction that associates system generated - * keys with user specified values. - * - * Since the key is system generated, searches are very fast and - * take a constant amount of time. - */ -template -class ACE_Active_Map_Manager : public ACE_Map_Manager -{ -public: - - // = Traits. - typedef ACE_Active_Map_Manager_Key key_type; - typedef T mapped_type; - - typedef ACE_Map_Entry ENTRY; - typedef ACE_Map_Iterator ITERATOR; - typedef ACE_Map_Reverse_Iterator REVERSE_ITERATOR; - - typedef ENTRY entry; - typedef ITERATOR iterator; - typedef REVERSE_ITERATOR reverse_iterator; - - // = Initialization and termination methods. - /// Initialize a with the ACE_DEFAULT_MAP_SIZE. - ACE_Active_Map_Manager (ACE_Allocator *alloc = 0); - - /// Initialize a with @a size entries. - ACE_Active_Map_Manager (size_t size, - ACE_Allocator *alloc = 0); - - /// Close down a and release dynamically - /// allocated resources. - ~ACE_Active_Map_Manager (void); - - /// Initialize a with size @a length. - int open (size_t length = ACE_DEFAULT_MAP_SIZE, - ACE_Allocator *alloc = 0); - - /// Close down a and release dynamically - /// allocated resources. - int close (void); - - /// Add @a value to the map, and the corresponding key produced by the - /// Active_Map_Manager is returned through @a key. - int bind (const T &value, - ACE_Active_Map_Manager_Key &key); - - /// Add @a value to the map. The user does not care about the - /// corresponding key produced by the Active_Map_Manager. - int bind (const T &value); - - /** - * Reserves a slot in the internal structure and returns the key and - * a pointer to the value. User should place their @a value into - * <*internal_value>. This method is useful in reducing the number - * of copies required in some cases. Note that is - * only a temporary pointer and will change when the map resizes. - * Therefore, the user should use the pointer immediately and not - * hold on to it. - */ - int bind (ACE_Active_Map_Manager_Key &key, - T *&internal_value); - - /// Reassociate @a key with @a value. The function fails if @a key is - /// not in the map. - int rebind (const ACE_Active_Map_Manager_Key &key, - const T &value); - - /** - * Reassociate @a key with @a value, storing the old value into the - * "out" parameter @a old_value. The function fails if @a key is not - * in the map. - */ - int rebind (const ACE_Active_Map_Manager_Key &key, - const T &value, - T &old_value); - - /** - * Reassociate @a key with @a value, storing the old key and value - * into the "out" parameter @a old_key and @a old_value. The function - * fails if @a key is not in the map. - */ - int rebind (const ACE_Active_Map_Manager_Key &key, - const T &value, - ACE_Active_Map_Manager_Key &old_key, - T &old_value); - - /// Locate @a value associated with @a key. - int find (const ACE_Active_Map_Manager_Key &key, - T &value) const; - - /// Is @a key in the map? - int find (const ACE_Active_Map_Manager_Key &key) const; - - /** - * Locate @a value associated with @a key. The value is returned via - * and hence a copy is saved. Note that - * is only a temporary pointer and will change when - * the map resizes. Therefore, the user should use the pointer - * immediately and not hold on to it. - */ - int find (const ACE_Active_Map_Manager_Key &key, - T *&internal_value) const; - - // Creates a key. User should place their @a value into - // <*internal_value>. This method is useful in reducing the number - // of copies required in some cases. - - /// Remove @a key from the map. - int unbind (const ACE_Active_Map_Manager_Key &key); - - /// Remove @a key from the map, and return the @a value associated with - /// @a key. - int unbind (const ACE_Active_Map_Manager_Key &key, - T &value); - - /** - * Locate @a value associated with @a key. The value is returned via - * and hence a copy is saved. Note that - * is only a temporary pointer and will change when - * the map resizes or when this slot is reused. Therefore, the user - * should use the pointer immediately and not hold on to it. - */ - int unbind (const ACE_Active_Map_Manager_Key &key, - T *&internal_value); - - /// Return the current size of the map. - size_t current_size (void) const; - - /// Return the total size of the map. - size_t total_size (void) const; - - /// Returns a key that cannot be found in the map. - static const ACE_Active_Map_Manager_Key npos (void); - - /// Dump the state of an object. - void dump (void) const; - - // = STL styled iterator factory functions. - - /// Return forward iterator. - ACE_Map_Iterator begin (void); - ACE_Map_Iterator end (void); - - /// Return reverse iterator. - ACE_Map_Reverse_Iterator rbegin (void); - ACE_Map_Reverse_Iterator rend (void); - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - - /// Private base class - typedef ACE_Map_Manager ACE_AMM_BASE; - -private: - - // = Disallow these operations. - ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Active_Map_Manager &)) - ACE_UNIMPLEMENTED_FUNC (ACE_Active_Map_Manager (const ACE_Active_Map_Manager &)) -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Active_Map_Manager_T.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Active_Map_Manager_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Active_Map_Manager_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" -#endif /* ACE_ACTIVE_MAP_MANAGER_T_H */ diff --git a/ACE/ace/Active_Map_Manager_T.inl b/ACE/ace/Active_Map_Manager_T.inl deleted file mode 100644 index 124f76c48c4..00000000000 --- a/ACE/ace/Active_Map_Manager_T.inl +++ /dev/null @@ -1,311 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template ACE_INLINE int -ACE_Active_Map_Manager::bind (ACE_Active_Map_Manager_Key &key, - T *&internal_value) -{ - ACE_UINT32 slot_index; - int result = this->next_free (slot_index); - - if (result == 0) - { - // Move from free list to occupied list - this->move_from_free_list_to_occupied_list (slot_index); - - // Reset the key. - this->search_structure_[slot_index].ext_id_.increment_slot_generation_count (); - this->search_structure_[slot_index].ext_id_.slot_index (slot_index); - - // Copy the key for the user. - key = this->search_structure_[slot_index].ext_id_; - - // This is where the user should place the value. - internal_value = &this->search_structure_[slot_index].int_id_; - - // Update the current size. - ++this->cur_size_; - } - - return result; -} - -template ACE_INLINE int -ACE_Active_Map_Manager::bind (const T &value, - ACE_Active_Map_Manager_Key &key) -{ - T *internal_value = 0; - int result = this->bind (key, - internal_value); - - if (result == 0) - { - // Store new value. - *internal_value = value; - } - - return result; -} - -template ACE_INLINE int -ACE_Active_Map_Manager::bind (const T &value) -{ - ACE_Active_Map_Manager_Key key; - return this->bind (value, key); -} - -template ACE_INLINE int -ACE_Active_Map_Manager::find (const ACE_Active_Map_Manager_Key &key, - T *&internal_value) const -{ - ACE_UINT32 slot_index = key.slot_index (); - ACE_UINT32 slot_generation = key.slot_generation (); - - if (slot_index > this->total_size_ || -#if defined (ACE_HAS_LAZY_MAP_MANAGER) - this->search_structure_[slot_index].free_ || -#endif /* ACE_HAS_LAZY_MAP_MANAGER */ - this->search_structure_[slot_index].ext_id_.slot_generation () != slot_generation || - this->search_structure_[slot_index].ext_id_.slot_index () == - (ACE_UINT32)this->free_list_id ()) - { - return -1; - } - else - { - // This is where the user value is. - internal_value = &this->search_structure_[slot_index].int_id_; - } - - return 0; -} - -template ACE_INLINE int -ACE_Active_Map_Manager::find (const ACE_Active_Map_Manager_Key &key) const -{ - T *internal_value = 0; - return this->find (key, - internal_value); -} - -template ACE_INLINE int -ACE_Active_Map_Manager::find (const ACE_Active_Map_Manager_Key &key, - T &value) const -{ - T *internal_value = 0; - int result = this->find (key, - internal_value); - - if (result == 0) - value = *internal_value; - - return result; -} - -template ACE_INLINE int -ACE_Active_Map_Manager::rebind (const ACE_Active_Map_Manager_Key &key, - const T &value) -{ - int result = this->find (key); - - if (result == 0) - { - // Store new value. - this->search_structure_[key.slot_index ()].int_id_ = value; - } - - return result; -} - -template ACE_INLINE int -ACE_Active_Map_Manager::rebind (const ACE_Active_Map_Manager_Key &key, - const T &value, - T &old_value) -{ - int result = this->find (key); - - if (result == 0) - { - // Copy old value. - old_value = this->search_structure_[key.slot_index ()].int_id_; - - // Store new value. - this->search_structure_[key.slot_index ()].int_id_ = value; - } - - return result; -} - -template ACE_INLINE int -ACE_Active_Map_Manager::rebind (const ACE_Active_Map_Manager_Key &key, - const T &value, - ACE_Active_Map_Manager_Key &old_key, - T &old_value) -{ - int result = this->find (key); - - if (result == 0) - { - // Copy old key. - old_key = this->search_structure_[key.slot_index ()].ext_id_; - - // Copy old value. - old_value = this->search_structure_[key.slot_index ()].int_id_; - - // Store new value. - this->search_structure_[key.slot_index ()].int_id_ = value; - } - - return result; -} - -template ACE_INLINE int -ACE_Active_Map_Manager::unbind (const ACE_Active_Map_Manager_Key &key, - T *&internal_value) -{ - int result = this->find (key, - internal_value); - - if (result == 0) - { - ACE_UINT32 slot_index = key.slot_index (); - -#if defined (ACE_HAS_LAZY_MAP_MANAGER) - - // - // In the case of lazy map managers, the movement of free slots - // from the occupied list to the free list is delayed until we - // run out of free slots in the free list. - // - - this->search_structure_[slot_index].free_ = 1; - -#else - - // Move from occupied list to free list. - this->move_from_occupied_list_to_free_list (slot_index); - -#endif /* ACE_HAS_LAZY_MAP_MANAGER */ - - // Reset the slot_index. This will tell us that this entry is free. - this->search_structure_[slot_index].ext_id_.slot_index (this->free_list_id ()); - - // Update the current size. - --this->cur_size_; - } - - return result; -} - -template ACE_INLINE int -ACE_Active_Map_Manager::unbind (const ACE_Active_Map_Manager_Key &key, - T &value) -{ - T *internal_value; - int result = this->unbind (key, - internal_value); - - if (result == 0) - { - // Copy old value. - value = *internal_value; - } - - return result; -} - -template ACE_INLINE int -ACE_Active_Map_Manager::unbind (const ACE_Active_Map_Manager_Key &key) -{ - T *internal_value; - return this->unbind (key, - internal_value); -} - -template ACE_INLINE -ACE_Active_Map_Manager::ACE_Active_Map_Manager (ACE_Allocator *alloc) - : ACE_AMM_BASE (alloc) -{ -} - -template ACE_INLINE -ACE_Active_Map_Manager::ACE_Active_Map_Manager (size_t size, - ACE_Allocator *alloc) - : ACE_AMM_BASE (size, - alloc) -{ -} - -template ACE_INLINE -ACE_Active_Map_Manager::~ACE_Active_Map_Manager (void) -{ -} - -template ACE_INLINE int -ACE_Active_Map_Manager::open (size_t length, - ACE_Allocator *alloc) -{ - return ACE_AMM_BASE::open (length, alloc); -} - -template ACE_INLINE int -ACE_Active_Map_Manager::close (void) -{ - return ACE_AMM_BASE::close (); -} - -template ACE_INLINE size_t -ACE_Active_Map_Manager::current_size (void) const -{ - return ACE_AMM_BASE::current_size (); -} - -template ACE_INLINE size_t -ACE_Active_Map_Manager::total_size (void) const -{ - return ACE_AMM_BASE::total_size (); -} - -/* static */ -template ACE_INLINE const ACE_Active_Map_Manager_Key -ACE_Active_Map_Manager::npos (void) -{ - return ACE_Active_Map_Manager_Key (~0, ~0); -} - -template ACE_INLINE void -ACE_Active_Map_Manager::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_AMM_BASE::dump (); -#endif /* ACE_HAS_DUMP */ -} - -template ACE_Map_Iterator -ACE_Active_Map_Manager::begin (void) -{ - return ACE_AMM_BASE::begin (); -} - -template ACE_INLINE ACE_Map_Iterator -ACE_Active_Map_Manager::end (void) -{ - return ACE_AMM_BASE::end (); -} - -template ACE_INLINE ACE_Map_Reverse_Iterator -ACE_Active_Map_Manager::rbegin (void) -{ - return ACE_AMM_BASE::rbegin (); -} - -template ACE_INLINE ACE_Map_Reverse_Iterator -ACE_Active_Map_Manager::rend (void) -{ - return ACE_AMM_BASE::rend (); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Addr.cpp b/ACE/ace/Addr.cpp deleted file mode 100644 index f458e018eef..00000000000 --- a/ACE/ace/Addr.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// $Id$ - -#include "ace/Addr.h" - - -ACE_RCSID (ace, - Addr, - "$Id$") - - -#if !defined (__ACE_INLINE__) -#include "ace/Addr.inl" -#endif /* __ACE_INLINE__ */ - -#include "ace/Log_Msg.h" -#include "ace/os_include/sys/os_socket.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Note: this object requires static construction and destruction. -/* static */ -const ACE_Addr ACE_Addr::sap_any (AF_ANY, -1); - -ACE_ALLOC_HOOK_DEFINE(ACE_Addr) - - -// Initializes instance variables. Note that 0 is an unspecified -// protocol family type... - -ACE_Addr::ACE_Addr (int type, int size) : - addr_type_ (type), - addr_size_ (size) -{ -} - -ACE_Addr::~ACE_Addr (void) -{ -} - -void * -ACE_Addr::get_addr (void) const -{ - return 0; -} - -void -ACE_Addr::set_addr (void *, int) -{ -} - -// Initializes instance variables. - -void -ACE_Addr::base_set (int type, int size) -{ - this->addr_type_ = type; - this->addr_size_ = size; -} - -void -ACE_Addr::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Addr::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("addr_type_ = %d"), this->addr_type_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\naddr_size_ = %d"), this->addr_size_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Addr.h b/ACE/ace/Addr.h deleted file mode 100644 index 530fb87c17f..00000000000 --- a/ACE/ace/Addr.h +++ /dev/null @@ -1,104 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Addr.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_ADDR_H -#define ACE_ADDR_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Addr - * - * @brief Defines the base class for the "address family independent" - * address format. - */ -class ACE_Export ACE_Addr -{ -public: - // = Initialization and termination methods. - /// Initializes instance variables. - ACE_Addr (int type = -1, - int size = -1); - - /// Destructor. - virtual ~ACE_Addr (void); - - // = Get/set the size of the address. - - /// Return the size of the address. - int get_size (void) const; - - /// Sets the size of the address. - void set_size (int size); - - // = Get/set the type of the address. - - /// Get the type of the address. - int get_type (void) const; - - /// Set the type of the address. - void set_type (int type); - - /// Return a pointer to the address. - virtual void *get_addr (void) const; - - /// Set a pointer to the address. - virtual void set_addr (void *, int len); - - // = Equality/inequality tests - /// Check for address equality. - bool operator == (const ACE_Addr &sap) const; - - /// Check for address inequality. - bool operator != (const ACE_Addr &sap) const; - - /// Initializes instance variables. - void base_set (int type, int size); - - /// Wild-card address. - static const ACE_Addr sap_any; - - /// Returns a hash value. This should be overwritten by a subclass - /// that can produce a better hash value. - virtual unsigned long hash (void) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - /// e.g., AF_UNIX, AF_INET, AF_SPIPE, etc. - int addr_type_; - - /// Number of bytes in the address. - int addr_size_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Addr.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" - -#endif /* ACE_ADDR_H */ diff --git a/ACE/ace/Addr.inl b/ACE/ace/Addr.inl deleted file mode 100644 index 3780e04b6aa..00000000000 --- a/ACE/ace/Addr.inl +++ /dev/null @@ -1,61 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -// Return the address of the address. - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE bool -ACE_Addr::operator == (const ACE_Addr &sap) const -{ - return (sap.addr_type_ == this->addr_type_ && - sap.addr_size_ == this->addr_size_ ); -} - -ACE_INLINE bool -ACE_Addr::operator != (const ACE_Addr &sap) const -{ - return (sap.addr_type_ != this->addr_type_ || - sap.addr_size_ != this->addr_size_ ); -} - -// Return the size of the address. - -ACE_INLINE int -ACE_Addr::get_size (void) const -{ - return this->addr_size_; -} - -// Sets the size of the address. - -ACE_INLINE void -ACE_Addr::set_size (int size) -{ - this->addr_size_ = size; -} - -// Return the type of the address. - -ACE_INLINE int -ACE_Addr::get_type (void) const -{ - return this->addr_type_; -} - -// Set the type of the address. - -ACE_INLINE void -ACE_Addr::set_type (int type) -{ - this->addr_type_ = type; -} - -ACE_INLINE unsigned long -ACE_Addr::hash (void) const -{ - return 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Arg_Shifter.cpp b/ACE/ace/Arg_Shifter.cpp deleted file mode 100644 index 36c265c6d5a..00000000000 --- a/ACE/ace/Arg_Shifter.cpp +++ /dev/null @@ -1,230 +0,0 @@ -#ifndef ACE_ARG_SHIFTER_T_CPP -#define ACE_ARG_SHIFTER_T_CPP - -#include "ace/Arg_Shifter.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_strings.h" -#include "ace/OS_Errno.h" -#include "ace/OS_Memory.h" - -ACE_RCSID (ace, - Arg_Shifter, - "$Id$") - - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template -ACE_Arg_Shifter_T::ACE_Arg_Shifter_T (int& argc, - const CHAR_TYPE** argv, - const CHAR_TYPE** temp) - : argc_ (argc), - total_size_ (argc), - temp_ (temp), - argv_ (argv), - current_index_ (0), - back_ (argc - 1), - front_ (0) -{ - this->init (); -} - -template -ACE_Arg_Shifter_T::ACE_Arg_Shifter_T (int& argc, - CHAR_TYPE** argv, - CHAR_TYPE** temp) - : argc_ (argc), - total_size_ (argc), - temp_ ((const CHAR_TYPE **) temp), - argv_ ((const CHAR_TYPE **) argv), - current_index_ (0), - back_ (argc - 1), - front_ (0) -{ - this->init (); -} - -template -void -ACE_Arg_Shifter_T::init (void) -{ - // If not provided with one, allocate a temporary array. - if (this->temp_ == 0) - ACE_NEW (this->temp_, - const CHAR_TYPE *[this->total_size_]); - - if (this->temp_ != 0) - { - // Fill the temporary array. - this->argc_ = 0; - for (int i = 0; i < this->total_size_; i++) - { - this->temp_[i] = this->argv_[i]; - this->argv_[i] = 0; - } - } - else - { - // Allocation failed, prohibit iteration. - this->current_index_ = this->argc_; - this->front_ = this->argc_; - } -} - -template -ACE_Arg_Shifter_T::~ACE_Arg_Shifter_T (void) -{ - // Delete the temporary vector. - delete [] temp_; -} - -template -const CHAR_TYPE * -ACE_Arg_Shifter_T::get_current (void) const -{ - const CHAR_TYPE * retval = 0; - - if (this->is_anything_left ()) - retval = this->temp_[current_index_]; - - return retval; -} - -template -const CHAR_TYPE * -ACE_Arg_Shifter_T::get_the_parameter (const CHAR_TYPE *flag) -{ - // the return 0's abound because this method - // would otherwise be a deep if { } else { } - - // check to see if any arguments still exist - if (!this->is_anything_left()) - return 0; - - // check to see if the flag is the argument - int const offset = this->cur_arg_strncasecmp (flag); - if (offset == -1) - return 0; - - if (offset == 0) - { - this->consume_arg (); - - if (!this->is_parameter_next()) - { - return 0; - } - } - // the parameter is in the middle somewhere... - return this->temp_[current_index_] + offset; -} - -template -int -ACE_Arg_Shifter_T::cur_arg_strncasecmp (const CHAR_TYPE *flag) -{ - // Check for a current argument - if (this->is_anything_left()) - { - size_t const flag_length = ACE_OS::strlen (flag); - - // Check for presence of the flag - if (ACE_OS::strncasecmp(this->temp_[current_index_], - flag, - flag_length) == 0) - { - if (ACE_OS::strlen(temp_[current_index_]) == - flag_length) - { - // match and lengths are equal - return 0; - } - else - { - // matches, with more info to boot! - size_t const remaining = ACE_OS::strspn - (this->temp_[current_index_] + flag_length, - ACE_TEXT (" ")) + flag_length; - return static_cast (remaining); - } - } - } - // failure - return -1; -} - -template -int -ACE_Arg_Shifter_T::consume_arg (int number) -{ - int retval = 0; - - // Stick knowns at the end of the vector (consumed). - if (this->is_anything_left() >= number) - { - for (int i = 0, j = this->back_ - (number - 1); - i < number; - ++i, ++j, ++this->current_index_) - this->argv_[j] = this->temp_[this->current_index_]; - - this->back_ -= number; - retval = 1; - } - - return retval; -} - -template -int -ACE_Arg_Shifter_T::ignore_arg (int number) -{ - int retval = 0; - - // Keep unknowns at the head of the vector. - if (this->is_anything_left () >= number) - { - for (int i = 0; - i < number; - i++, this->current_index_++, this->front_++) - this->argv_[this->front_] = this->temp_[this->current_index_]; - - retval = 1; - this->argc_ += number; - } - - return retval; -} - -template -int -ACE_Arg_Shifter_T::is_anything_left (void) const -{ - return this->total_size_ - this->current_index_; -} - -template -int -ACE_Arg_Shifter_T::is_option_next (void) const -{ - return this->is_anything_left () && - this->temp_[this->current_index_][0] == '-'; -} - -template -int -ACE_Arg_Shifter_T::is_parameter_next (void) const -{ - return this->is_anything_left () - && this->temp_[this->current_index_][0] != '-'; -} - -template -int -ACE_Arg_Shifter_T::num_ignored_args (void) const -{ - return this->front_; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_ATOMIC_OP_T_CPP */ diff --git a/ACE/ace/Arg_Shifter.h b/ACE/ace/Arg_Shifter.h deleted file mode 100644 index 409ffa03a88..00000000000 --- a/ACE/ace/Arg_Shifter.h +++ /dev/null @@ -1,221 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Arg_Shifter.h - * - * $Id$ - * - * @author Seth Widoff - */ -//============================================================================= - -#ifndef ACE_ARG_SHIFTER_H -#define ACE_ARG_SHIFTER_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Global_Macros.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Arg_Shifter_T - * - * @brief This ADT operates on a specified set of arguments (@a argv). - * As known arguments are scanned, they are shifted to the back of the - * @a argv vector, so deeper levels of argument parsing can locate the yet - * unprocessed arguments at the beginning of the vector. - * - * The @c ACE_Arg_Shifter copies the pointers of the @a argv vector - * into a temporary array. As the @c ACE_Arg_Shifter iterates over - * the copied vector, it places known arguments in the rear of the - * vector, leaving the unknown ones in the beginning. So, after having - * visited all the arguments in the temporary vector, @c ACE_Arg_Shifter - * has placed all the unknown arguments in their original order at - * the front of original @a argv. - */ -template -class ACE_Arg_Shifter_T -{ -public: - // = Initialization and termination methods. - /** - * Initialize the ACE_Arg_Shifter to the vector over which to - * iterate. Optionally, also provide the temporary array for - * use in shifting the arguments. If ACE_Arg_Shifter must allocate - * the temporary vector internally and dynamic allocation fails, the - * ACE_Arg_Shifter will set all indicators to end of the vector, - * forbidding iteration. Following iteration over @a argv, the - * @a argc value will be updated to contain the number of - * unconsumed arguments. - * @param argc The number of strings in @a argv. @a argc will be - * updated to reflect the number of unconsumed arguments. - * @param argv The argument vector to shift. The string pointers in - * the vector will be reordered to place the @a argc unconsumed - * arguments at the front of the vector. - * @param temp A vector of @c CHAR_TYPE pointers at least @a argc - * elements long. The vector will be used for argument shifting as - * the specified @a argv vector is consumed. The vector must not - * be modified while this object exists. If this argument is 0 - * (the default) the object will allocate and free the temporary - * vector transparently. - */ - ACE_Arg_Shifter_T (int& argc, - const CHAR_TYPE **argv, - const CHAR_TYPE **temp = 0); - - /// Same behavior as the preceding constructor, but without the - /// "const" qualifier. - ACE_Arg_Shifter_T (int& argc, - CHAR_TYPE **argv, - CHAR_TYPE **temp = 0); - - /// Destructor. - ~ACE_Arg_Shifter_T (void); - - /// Get the current head of the vector. - const CHAR_TYPE *get_current (void) const; - - /** - * If the @a flag matches the current_arg of arg shifter - * this method will attempt to return the associated - * parameter value - * - * Safe to call without checking that a current arg exists - * - * In the following examples, a pointer to the char* "value" is ret - * - * eg: main -foobar value, main -FooBar value - * main -FOOBARvalue - * - * all of the above will all match the @a flag == -FooBar - * and will return a char* to "value" - * - * main -foobar 4 would succeed and return a char* to "4" - * main -foobar -4 does not succeed (-4 is not a parameter) - * but instead, would return 0 - * - * 0 is returned: - * If the current argument does not match flag - * If there is no parameter found after a 'matched' flag - * - * If the flag is matched and the flag and paramter DO NOT RUN - * together, the flag is consumed, the parameter is returned, - * and the new current argument is the parameter value. - * ie '-foobarflag VALUE' leaves the new cur arg == "VALUE" - * - * If the flag is matched and the flag and parameter RUN - * together '-foobarflagVALUE', the flag is NOT consumed - * and the cur arg is left pointing to the entire flag/value pair - */ - const CHAR_TYPE *get_the_parameter (const CHAR_TYPE* flag); - - /** - * Check if the current argument matches (case insensitive) - * - * ------------------------------------------------------------ - * - * Case A: Perfect Match (case insensitive) - * 0 is returned. - * - * ie: when current_arg = "-foobar" or "-FOOBAR" or "-fooBAR" - * this->cur_arg_strncasecmp ("-FooBar); - * will return 0 - * - * ------------------------------------------------------------ - * - * Case B: Perfect Match (case insensitive) but the current_arg - * is longer than the flag. Returns a number equal to the index - * in the char* indicating the start of the extra characters - * - * ie: when current_arg = "-foobar98023" - * this->cur_arg_strncasecmp ("-FooBar); - * will return 7 - * - * Notice: this number will always be > 0 - * - * ------------------------------------------------------------ - * - * Case C: If neither of Case A or B is met (no match) - * then -1 is returned - */ - int cur_arg_strncasecmp (const CHAR_TYPE *flag); - - /// Consume @a number argument(s) by sticking them/it on the end of - /// the vector. - int consume_arg (int number = 1); - - /// Place @a number arguments in the same relative order ahead of the - /// known arguments in the vector. - int ignore_arg (int number = 1); - - /// Returns the number of args left to see in the vector. - int is_anything_left (void) const; - - /// Returns 1 if there's a next item in the vector and it begins with - /// '-'. - int is_option_next (void) const; - - /// Returns 1 if there's a next item in the vector and it doesn't - /// begin with '-'. - int is_parameter_next (void) const; - - /// Returns the number of irrelevant args seen. - int num_ignored_args (void) const; - -private: - /// Copy Constructor should not be used. - ACE_UNIMPLEMENTED_FUNC (ACE_Arg_Shifter_T (const ACE_Arg_Shifter_T&)) - - /// Assignment '=' operator should not be used. - ACE_UNIMPLEMENTED_FUNC (ACE_Arg_Shifter_T operator= (const ACE_Arg_Shifter_T&)) - - /// Refactor the constructor logic. - void init (void); - - /// The size of the argument vector. - int& argc_; - - /// The size of argv_. - int total_size_; - - /// The temporary array over which we traverse. - const CHAR_TYPE **temp_; - - /// The array in which the arguments are reordered. - const CHAR_TYPE **argv_; - - /// The element in we're currently examining. - int current_index_; - - /// The index of in which we'll stick the next unknown - /// argument. - int back_; - - /// The index of in which we'll stick the next known - /// argument. - int front_; -}; - -typedef ACE_Arg_Shifter_T ACE_Arg_Shifter; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Arg_Shifter.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Arg_Shifter.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" - -#endif /* ACE_ARG_SHIFTER_H */ diff --git a/ACE/ace/Argv_Type_Converter.cpp b/ACE/ace/Argv_Type_Converter.cpp deleted file mode 100644 index e16076818a4..00000000000 --- a/ACE/ace/Argv_Type_Converter.cpp +++ /dev/null @@ -1,204 +0,0 @@ -// $Id$ - -#include "ace/Argv_Type_Converter.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Argv_Type_Converter.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID (ace, - Argv_Type_Converter, - "$Id$") - -#include "ace/OS_NS_string.h" -#include "ace/OS_Errno.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -#if defined (ACE_USES_WCHAR) -ACE_Argv_Type_Converter::ACE_Argv_Type_Converter (int &argc, wchar_t** argv) - : saved_argc_ (argc), - char_argv_ (0), - wchar_argv_ (argv), - before_pass_argc_ (argc), - original_type_ (true), - wchar_passed_ (false), - char_passed_ (false) -{ - this->initialize (); - - for (int i = 0; i < argc; ++i) - this->char_argv_[i] = ACE_OS::strdup (ACE_TEXT_ALWAYS_CHAR (argv[i])); -} -#endif // ACE_USES_WCHAR - - -ACE_Argv_Type_Converter::ACE_Argv_Type_Converter (int &argc, char **argv) - : saved_argc_(argc), - char_argv_(argv) -#if defined (ACE_USES_WCHAR) - , wchar_argv_(0), - before_pass_argc_(argc), - original_type_(false), - wchar_passed_(false), - char_passed_(false) -{ - this->initialize(); - - for (int i = 0; i < argc; ++i) - this->wchar_argv_[i] = ACE_OS::strdup (ACE_TEXT_ANTI_TO_TCHAR (argv[i])); -} -#else -{ -} -#endif // ACE_USES_WCHAR - -ACE_Argv_Type_Converter::~ACE_Argv_Type_Converter (void) -{ -#if defined (ACE_USES_WCHAR) - // selectively delete the 'copy' of argv - if (this->original_type_) - { - // if original type is wchar_t - if (this->char_passed_) - this->align_wchar_with_char (); - - for (int i = 0; i < this->before_pass_argc_; ++i) - ACE_OS::free (this->char_argv_[i]); - - delete [] this->char_argv_; - } - else - { - // if original type is char - if (this->wchar_passed_) - this->align_char_with_wchar (); - - for (int i = 0; i < this->before_pass_argc_; ++i) - ACE_OS::free (this->wchar_argv_[i]); - - delete [] this->wchar_argv_; - } -#endif // ACE_USES_WCHAR -} - -#if defined (ACE_USES_WCHAR) -void -ACE_Argv_Type_Converter::initialize (void) -{ - if (this->original_type_) - { - // Make a copy of argv in 'char'. type Create one more argv entry - // than original argc for the NULL. - ACE_NEW (char_argv_, - char *[this->saved_argc_ + 1]); - this->char_argv_[saved_argc_] = 0; // last entry of argv is - // always a NULL - } - else - { - // make a copy of argv in 'wchar_t' type - ACE_NEW (this->wchar_argv_, - wchar_t*[this->saved_argc_ + 1]); - this->wchar_argv_[saved_argc_] = 0; - } -} - - -void -ACE_Argv_Type_Converter::align_char_with_wchar (void) -{ - int wchar_argv_index = 0; - wchar_t* match_argv = this->wchar_argv_[0]; // pick the initial entry - - while (wchar_argv_index < this->saved_argc_) - { - // if n'th entries of both argv lists are different - if (ACE_OS::strcmp (this->char_argv_[wchar_argv_index], - ACE_TEXT_ALWAYS_CHAR (match_argv)) != 0) - { - // loop through the wchar argv list entries that are after - // wchar_argv_index - for (int i = wchar_argv_index + 1; i < before_pass_argc_; ++i) - { - if (ACE_OS::strcmp (this->char_argv_[i], - ACE_TEXT_ALWAYS_CHAR (match_argv)) == 0) - { - // swap the pointers in the char argv list - char *temp = this->char_argv_[wchar_argv_index]; - this->char_argv_[wchar_argv_index] = this->char_argv_[i]; - this->char_argv_[i] = temp; - break; - } - } - } - - // move to the next wchar argv list entry - match_argv = this->wchar_argv_[++wchar_argv_index]; - } - - this->cleanup (); -} - -void -ACE_Argv_Type_Converter::align_wchar_with_char (void) -{ - int char_argv_index = 0; - char* match_argv = this->char_argv_[0]; // pick the initial entry - - while (char_argv_index < saved_argc_) - { - // if n'th entries of both argv lists are different - if (ACE_OS::strcmp ( - ACE_TEXT_ALWAYS_CHAR (this->wchar_argv_[char_argv_index]), - match_argv) != 0) - { - // loop through the wchar argv list entries that are after - // wchar_argv_index - for (int i = char_argv_index + 1; i < this->before_pass_argc_; ++i) - { - if (ACE_OS::strcmp ( - ACE_TEXT_ALWAYS_CHAR(this->wchar_argv_[i]), - match_argv) == 0) { - // swap the pointers in the char argv list - wchar_t* temp = this->wchar_argv_[char_argv_index]; - this->wchar_argv_[char_argv_index] = this->wchar_argv_[i]; - this->wchar_argv_[i] = temp; - break; - } - } - } - - // move to the next wchar argv list entry - match_argv = this->char_argv_[++char_argv_index]; - } - - this->cleanup(); -} - -void -ACE_Argv_Type_Converter::cleanup (void) -{ - for (int i = this->saved_argc_; i < this->before_pass_argc_; ++i) - { - // Check whether it's ours to delete. - if (original_type_) - { - ACE_OS::free (this->char_argv_[i]); - this->char_argv_[i] = 0; - } - else - { - ACE_OS::free (this->wchar_argv_[i]); - this->wchar_argv_[i] = 0; - } - } - - this->before_pass_argc_ = this->saved_argc_; - - this->wchar_passed_ = false; - this->char_passed_ = false; -} -#endif // ACE_USES_WCHAR - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Argv_Type_Converter.h b/ACE/ace/Argv_Type_Converter.h deleted file mode 100644 index 205fa10c983..00000000000 --- a/ACE/ace/Argv_Type_Converter.h +++ /dev/null @@ -1,119 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Argv_Type_Converter.h - * - * $Id$ - * - * @author Si Mong Park - */ -//============================================================================= - -#ifndef ACE_ARGV_TYPE_CONVERTER_H -#define ACE_ARGV_TYPE_CONVERTER_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" -#include "ace/OS_Memory.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Argv_Type_Converter - * - * @brief To convert 'char' input/command line parameter to 'wchar_t'. - * - * This class is to convert 'char' type command line paramter to - * wide-character (wchar_t) format and stores the copy of it. - * This is useful for all classes that use 'char**' argv but cannot - * be converted into 'ACE_TCHAR**' version. - * Note that the converted data will be lost upon destruction, so - * classes should use this class as their data member. - */ -class ACE_Export ACE_Argv_Type_Converter -{ -public: - - ACE_Argv_Type_Converter (int &argc, char** argv); - -#if defined (ACE_USES_WCHAR) - ACE_Argv_Type_Converter (int &argc, wchar_t** argv); -#endif // ACE_USES_WCHAR - - ~ACE_Argv_Type_Converter (void); - - /// Returns the pointer of converted command line. - ACE_TCHAR** get_TCHAR_argv (void); - - /// Returns the pointer of ASCII (char) command line. - char** get_ASCII_argv (void); - - /// Returns the number of sub paramters (argc). - int& get_argc (void); - -private: - - /// Copy Constructor should not be used. - ACE_Argv_Type_Converter (const ACE_Argv_Type_Converter&); - - /// Assignment '=' operator should not be used. - ACE_Argv_Type_Converter operator= (const ACE_Argv_Type_Converter&); - -#if defined (ACE_USES_WCHAR) - - /// Perform common initialization for two Ctor's. - void initialize (void); - - /// Align all entries in the char type argv list with wchar_t type - /// argv list. - void align_char_with_wchar (void); - - /// Align all entries in the wchar_t type argv list with char type - /// argv list. - void align_wchar_with_char (void); - - /// Clean up removed (comsumed) argv entries and reset the pass flags. - void cleanup (void); -#endif // ACE_USES_WCHAR - -private: - /// Original number of input paramter, same as 'argc'. - int &saved_argc_; - - /// Data member pointer that contains converted argv in ACE_ANTI_TCHAR. - char** char_argv_; - -#if defined (ACE_USES_WCHAR) - /// Data member pointer that contains converted argv in ACE_TCHAR. - wchar_t** wchar_argv_; - - /// argc value before any argv has been passed. - int before_pass_argc_; - - /// false represents original argv passed in is char, and true - /// represents wchar_t. - bool const original_type_; - - /// true indicates wchar_t type argv has been passed. - bool wchar_passed_; - - /// true indicates char type argv has been passed. - bool char_passed_; -#endif /* ACE_USES_WCHAR */ -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Argv_Type_Converter.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" - -#endif /* ACE_ARGV_TYPE_CONVERTER_H */ diff --git a/ACE/ace/Argv_Type_Converter.inl b/ACE/ace/Argv_Type_Converter.inl deleted file mode 100644 index 5bb0bafd2db..00000000000 --- a/ACE/ace/Argv_Type_Converter.inl +++ /dev/null @@ -1,44 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE ACE_TCHAR** -ACE_Argv_Type_Converter::get_TCHAR_argv (void) -{ -#if defined (ACE_USES_WCHAR) - if (this->char_passed_) - { - this->align_wchar_with_char (); - } - - this->wchar_passed_ = true; - return this->wchar_argv_; -#else - return this->char_argv_; -#endif // ACE_USES_WCHAR -} - -ACE_INLINE char** -ACE_Argv_Type_Converter::get_ASCII_argv (void) -{ -#if defined (ACE_USES_WCHAR) - if (this->wchar_passed_) - { - this->align_char_with_wchar (); - } - - this->char_passed_ = true; -#endif // ACE_USES_WCHAR - - return this->char_argv_; -} - -ACE_INLINE int& -ACE_Argv_Type_Converter::get_argc (void) -{ - return this->saved_argc_; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Array.h b/ACE/ace/Array.h deleted file mode 100644 index c3159cd7a89..00000000000 --- a/ACE/ace/Array.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file Array.h - * - * $Id$ - * - * @deprecated - * - * @note This file has been deprecated and will soon go away. You - * should directly include "Containers_T.h" instead. - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_ARRAY_H -#define ACE_ARRAY_H -#include /**/ "ace/pre.h" - -#include "ace/Containers_T.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include /**/ "ace/post.h" -#endif /* ACE_ARRAY_H */ diff --git a/ACE/ace/Array_Base.cpp b/ACE/ace/Array_Base.cpp deleted file mode 100644 index 280a12d8e17..00000000000 --- a/ACE/ace/Array_Base.cpp +++ /dev/null @@ -1,235 +0,0 @@ -// $Id$ - -#ifndef ACE_ARRAY_BASE_CPP -#define ACE_ARRAY_BASE_CPP - -#include "ace/Array_Base.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (__ACE_INLINE__) -#include "ace/Array_Base.inl" -#endif /* __ACE_INLINE__ */ - -#include "ace/Malloc_Base.h" -#include "ace/os_include/os_errno.h" - -#include - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Dynamically initialize an array. -template -ACE_Array_Base::ACE_Array_Base (typename ACE_Array_Base::size_type size, - ACE_Allocator *alloc) - : max_size_ (size), - cur_size_ (size), - allocator_ (alloc) -{ - if (this->allocator_ == 0) - this->allocator_ = ACE_Allocator::instance (); - - if (size != 0) - { - ACE_ALLOCATOR (this->array_, - (T *) this->allocator_->malloc (size * sizeof (T))); - for (size_type i = 0; i < size; ++i) - new (&array_[i]) T; - } - else - this->array_ = 0; -} - -template -ACE_Array_Base::ACE_Array_Base (typename ACE_Array_Base::size_type size, - const T &default_value, - ACE_Allocator *alloc) - : max_size_ (size), - cur_size_ (size), - allocator_ (alloc) -{ - if (this->allocator_ == 0) - this->allocator_ = ACE_Allocator::instance (); - - if (size != 0) - { - ACE_ALLOCATOR (this->array_, - (T *) this->allocator_->malloc (size * sizeof (T))); - for (size_type i = 0; i < size; ++i) - new (&array_[i]) T (default_value); - } - else - this->array_ = 0; -} - -// The copy constructor (performs initialization). - -template -ACE_Array_Base::ACE_Array_Base (const ACE_Array_Base &s) - : max_size_ (s.size ()), - cur_size_ (s.size ()), - allocator_ (s.allocator_) -{ - if (this->allocator_ == 0) - this->allocator_ = ACE_Allocator::instance (); - - ACE_ALLOCATOR (this->array_, - (T *) this->allocator_->malloc (s.size () * sizeof (T))); - for (size_type i = 0; i < this->size (); ++i) - new (&this->array_[i]) T (s.array_[i]); -} - -// Assignment operator (performs assignment). - -template void -ACE_Array_Base::operator= (const ACE_Array_Base &s) -{ - // Check for "self-assignment". - - if (this != &s) - { - if (this->max_size_ < s.size ()) - { - // Need to reallocate memory. - - // Strongly exception-safe assignment. - // - // Note that we're swapping the allocators here, too. - // Should we? Probably. "*this" should be a duplicate of - // the "right hand side". - ACE_Array_Base tmp (s); - this->swap (tmp); - } - else - { - // Underlying array is large enough. No need to reallocate - // memory. - // - // "*this" still owns the memory for the underlying array. - // Do not swap out the allocator. - // - // @@ Why don't we just drop the explicit destructor and - // placement operator new() calls with a straight - // element-by-element assignment? Is the existing - // approach more efficient? - // -Ossama - - ACE_DES_ARRAY_NOFREE (this->array_, - s.size (), - T); - - this->cur_size_ = s.size (); - - for (size_type i = 0; i < this->size (); ++i) - new (&this->array_[i]) T (s.array_[i]); - } - } -} - -// Set an item in the array at location slot. - -template int -ACE_Array_Base::set (const T &new_item, - typename ACE_Array_Base::size_type slot) -{ - if (this->in_range (slot)) - { - this->array_[slot] = new_item; - return 0; - } - else - return -1; -} - -// Get an item in the array at location slot. - -template int -ACE_Array_Base::get (T &item, - typename ACE_Array_Base::size_type slot) const -{ - if (this->in_range (slot)) - { - // Copies the item. If you don't want to copy, use operator [] - // instead (but then you'll be responsible for range checking). - item = this->array_[slot]; - return 0; - } - else - return -1; -} - -template int -ACE_Array_Base::max_size (typename ACE_Array_Base::size_type new_size) -{ - if (new_size > this->max_size_) - { - T *tmp = 0; - - ACE_ALLOCATOR_RETURN (tmp, - (T *) this->allocator_->malloc (new_size * sizeof (T)), - -1); - for (size_type i = 0; i < this->cur_size_; ++i) - new (&tmp[i]) T (this->array_[i]); - - // Initialize the new portion of the array that exceeds the - // previously allocated section. - for (size_type j = this->cur_size_; j < new_size; ++j) - new (&tmp[j]) T; - - ACE_DES_ARRAY_FREE (this->array_, - this->max_size_, - this->allocator_->free, - T); - this->array_ = tmp; - this->max_size_ = new_size; - this->cur_size_ = new_size; - } - - return 0; -} - -template int -ACE_Array_Base::size (typename ACE_Array_Base::size_type new_size) -{ - int const r = this->max_size (new_size); - - if (r == 0) - this->cur_size_ = new_size; - - return r; -} - -template -void -ACE_Array_Base::swap (ACE_Array_Base & rhs) -{ - std::swap (this->max_size_ , rhs.max_size_); - std::swap (this->cur_size_ , rhs.cur_size_); - std::swap (this->array_ , rhs.array_); - std::swap (this->allocator_, rhs.allocator_); -} - -// **************************************************************** - -template int -ACE_Array_Iterator::next (T *&item) -{ - // ACE_TRACE ("ACE_Array_Iterator::next"); - - if (this->done ()) - { - item = 0; - return 0; - } - else - { - item = &array_[current_]; - return 1; - } -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_ARRAY_BASE_CPP */ diff --git a/ACE/ace/Array_Base.h b/ACE/ace/Array_Base.h deleted file mode 100644 index 210bab6d46d..00000000000 --- a/ACE/ace/Array_Base.h +++ /dev/null @@ -1,256 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Array_Base.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_ARRAY_BASE_H -#define ACE_ARRAY_BASE_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Global_Macros.h" -#include "ace/Malloc_Base.h" -#include /* For reverse_iterator adapters */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Forward declaration. -template class ACE_Array_Iterator; - -/** - * @class ACE_Array_Base - * - * @brief Implement a simple dynamic array - * - * This parametric class implements a simple dynamic array; - * resizing must be controlled by the user. No comparison or find - * operations are implemented. - */ -template -class ACE_Array_Base -{ -public: - - // Old/ACE-style traits. - typedef T TYPE; - typedef ACE_Array_Iterator ITERATOR; - - // STL-style typedefs/traits. - typedef T value_type; - typedef value_type * iterator; - typedef value_type const * const_iterator; - typedef value_type & reference; - typedef value_type const & const_reference; - typedef value_type * pointer; - typedef value_type const * const_pointer; - typedef ptrdiff_t difference_type; - typedef ACE_Allocator::size_type size_type; - - ACE_DECLARE_STL_REVERSE_ITERATORS - - // = Initialization and termination methods. - - /// Dynamically create an uninitialized array. - ACE_Array_Base (size_type size = 0, - ACE_Allocator * the_allocator = 0); - - /// Dynamically initialize the entire array to the . - ACE_Array_Base (size_type size, - T const & default_value, - ACE_Allocator * the_allocator = 0); - - /** - * The copy constructor performs initialization by making an exact - * copy of the contents of parameter , i.e., *this == s will - * return true. - */ - ACE_Array_Base (ACE_Array_Base const & s); - - /** - * Assignment operator performs an assignment by making an exact - * copy of the contents of parameter , i.e., *this == s will - * return true. Note that if the of is >= than - * we can copy it without reallocating. However, if - * is < we must delete the , - * reallocate a new , and then copy the contents of . - */ - void operator= (ACE_Array_Base const & s); - - /// Clean up the array (e.g., delete dynamically allocated memory). - ~ACE_Array_Base (void); - - // = Set/get methods. - - /// Set item in the array at location @a slot. Doesn't - /// perform range checking. - T & operator[] (size_type slot); - - /// Get item in the array at location @a slot. Doesn't - /// perform range checking. - T const & operator[] (size_type slot) const; - - /// Set an item in the array at location @a slot. Returns - /// -1 if @a slot is not in range, else returns 0. - int set (T const & new_item, size_type slot); - - /** - * Get an item in the array at location @a slot. Returns -1 if - * @a slot is not in range, else returns 0. Note that this function - * copies the item. If you want to avoid the copy, you can use - * the const operator [], but then you'll be responsible for range checking. - */ - int get (T & item, size_type slot) const; - - /// Returns the of the array. - size_type size (void) const; - - /** - * Changes the size of the array to match . - * It copies the old contents into the new array. - * Return -1 on failure. - */ - int size (size_type new_size); - - /// Returns the of the array. - size_type max_size (void) const; - - /** - * Changes the size of the array to match . - * It copies the old contents into the new array. - * Return -1 on failure. - * It does not affect new_size - */ - int max_size (size_type new_size); - - /** - * @name Forward Iterator Accessors - * - * Forward iterator accessors. - */ - //@{ - iterator begin (void); - iterator end (void); - const_iterator begin (void) const; - const_iterator end (void) const; - //@} - - /** - * @name Reverse Iterator Accessors - * - * Reverse iterator accessors. - */ - //@{ - reverse_iterator rbegin (void); - reverse_iterator rend (void); - const_reverse_iterator rbegin (void) const; - const_reverse_iterator rend (void) const; - //@} - - /// Swap the contents of this array with the given @a array in - /// an exception-safe manner. - void swap (ACE_Array_Base & array); - -protected: - - /// Returns 1 if @a slot is within range, i.e., 0 >= @a slot < - /// , else returns 0. - bool in_range (size_type slot) const; - - /// Maximum size of the array, i.e., the total number of elements - /// in . - size_type max_size_; - - /** - * Current size of the array. This starts out being == to - * . However, if we are assigned a smaller array, then - * will become less than . The purpose of - * keeping track of both sizes is to avoid reallocating memory if we - * don't have to. - */ - size_type cur_size_; - - /// Pointer to the array's storage buffer. - value_type * array_; - - /// Allocation strategy of the ACE_Array_Base. - ACE_Allocator * allocator_; - - friend class ACE_Array_Iterator; -}; - -// **************************************************************** - -/** - * @class ACE_Array_Iterator - * - * @brief Implement an iterator over an ACE_Array. - * - * This iterator is safe in the face of array element deletions. - * But it is NOT safe if the array is resized (via the ACE_Array - * assignment operator) during iteration. That would be very - * odd, and dangerous. - */ -template -class ACE_Array_Iterator -{ -public: - // = Initialization method. - ACE_Array_Iterator (ACE_Array_Base &); - - // = Iteration methods. - - /// Pass back the that hasn't been seen in the Array. - /// Returns 0 when all items have been seen, else 1. - int next (T *&next_item); - - /// Move forward by one element in the Array. Returns 0 when all the - /// items in the Array have been seen, else 1. - int advance (void); - - /// Returns 1 when all items have been seen, else 0. - int done (void) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - /// Pointer to the current item in the iteration. - size_t current_; - - /// Pointer to the Array we're iterating over. - ACE_Array_Base &array_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Array_Base.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Array_Base.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Array_Base.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" - -#endif /* ACE_ARRAY_BASE_H */ diff --git a/ACE/ace/Array_Base.inl b/ACE/ace/Array_Base.inl deleted file mode 100644 index 849bcc18de2..00000000000 --- a/ACE/ace/Array_Base.inl +++ /dev/null @@ -1,146 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Clean up the array (e.g., delete dynamically allocated memory). -template ACE_INLINE -ACE_Array_Base::~ACE_Array_Base (void) -{ - ACE_DES_ARRAY_FREE (this->array_, - this->max_size_, - this->allocator_->free, - T); -} - -template -ACE_INLINE typename ACE_Array_Base::iterator -ACE_Array_Base::begin (void) -{ - return this->array_; -} - -template -ACE_INLINE typename ACE_Array_Base::iterator -ACE_Array_Base::end (void) -{ - return this->array_ + this->cur_size_; -} - -template -ACE_INLINE typename ACE_Array_Base::const_iterator -ACE_Array_Base::begin (void) const -{ - return this->array_; -} - -template -ACE_INLINE typename ACE_Array_Base::const_iterator -ACE_Array_Base::end (void) const -{ - return this->array_ + this->cur_size_; -} - -template -ACE_INLINE typename ACE_Array_Base::reverse_iterator -ACE_Array_Base::rbegin (void) -{ - return reverse_iterator (this->end ()); -} - -template -ACE_INLINE typename ACE_Array_Base::reverse_iterator -ACE_Array_Base::rend (void) -{ - return reverse_iterator (this->begin ()); -} - -template -ACE_INLINE typename ACE_Array_Base::const_reverse_iterator -ACE_Array_Base::rbegin (void) const -{ - return const_reverse_iterator (this->end ()); -} - -template -ACE_INLINE typename ACE_Array_Base::const_reverse_iterator -ACE_Array_Base::rend (void) const -{ - return const_reverse_iterator (this->begin ()); -} - -template ACE_INLINE typename ACE_Array_Base::size_type -ACE_Array_Base::size (void) const -{ - return this->cur_size_; -} - -template ACE_INLINE typename ACE_Array_Base::size_type -ACE_Array_Base::max_size (void) const -{ - return this->max_size_; -} - -template ACE_INLINE bool -ACE_Array_Base::in_range (typename ACE_Array_Base::size_type index) const -{ - return index < this->cur_size_; -} - -template ACE_INLINE T & -ACE_Array_Base::operator[] (typename ACE_Array_Base::size_type index) -{ - return this->array_[index]; -} - -template ACE_INLINE const T & -ACE_Array_Base::operator[] (typename ACE_Array_Base::size_type index) const -{ - return this->array_[index]; -} - -// **************************************************************** - -template ACE_INLINE void -ACE_Array_Iterator::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - // ACE_TRACE ("ACE_Array_Iterator::dump"); -#endif /* ACE_HAS_DUMP */ -} - -template ACE_INLINE -ACE_Array_Iterator::ACE_Array_Iterator (ACE_Array_Base &a) - : current_ (0), - array_ (a) -{ - // ACE_TRACE ("ACE_Array_Iterator::ACE_Array_Iterator"); -} - -template ACE_INLINE int -ACE_Array_Iterator::advance (void) -{ - // ACE_TRACE ("ACE_Array_Iterator::advance"); - - if (this->current_ < array_.size ()) - { - ++this->current_; - return 1; - } - else - { - // Already finished iterating. - return 0; - } -} - -template ACE_INLINE int -ACE_Array_Iterator::done (void) const -{ - ACE_TRACE ("ACE_Array_Iterator::done"); - - return this->current_ >= array_.size (); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Array_Map.cpp b/ACE/ace/Array_Map.cpp deleted file mode 100644 index 62c6f553292..00000000000 --- a/ACE/ace/Array_Map.cpp +++ /dev/null @@ -1,299 +0,0 @@ -// $Id$ - -#ifndef ACE_ARRAY_MAP_CPP -#define ACE_ARRAY_MAP_CPP - -#include "ace/Array_Map.h" - -#ifndef __ACE_INLINE__ -# include "ace/Array_Map.inl" -#endif /* !__ACE_INLINE__ */ - -#include "ace/checked_iterator.h" - -#include - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -#ifndef ACE_LACKS_MEMBER_TEMPLATES -template -template -ACE_Array_Map::ACE_Array_Map (InputIterator f, - InputIterator l) - : size_ (l - f) - , capacity_ (size_) - , nodes_ (size_ == 0 ? 0 : new value_type[size_]) -{ - (void) std::copy (f, - l, - ACE_make_checked_array_iterator (this->begin (), - this->size_)); - -// iterator n = this->begin (); - -// for (InputIterator i = f; i != l; ++i, ++n) -// *n = *i; -} -#else -template -ACE_Array_Map::ACE_Array_Map ( - typename ACE_Array_Map::const_iterator f, - typename ACE_Array_Map::const_iterator l) - : size_ (l - f) - , capacity_ (size_) - , nodes_ (size_ == 0 ? 0 : new value_type[size_]) -{ - (void) std::copy (f, - l, - ACE_make_checked_array_iterator (this->begin (), - this->size_)); - -// iterator n = this->begin (); - -// for (const_iterator i = f; i != l; ++i, ++n) -// *n = *i; -} -#endif /* !ACE_LACKS_MEMBER_TEMPLATES */ - -template -ACE_Array_Map::ACE_Array_Map ( - ACE_Array_Map const & map) - : size_ (map.size_) - , capacity_ (map.size_) - , nodes_ (size_ == 0 ? 0 : new value_type[size_]) -{ - std::copy (map.begin (), - map.end (), - ACE_make_checked_array_iterator (this->begin (), - this->size_)); - -// iterator f = map.begin (); -// iterator l = map.end (); -// iterator n = this->begin (); - -// for (iterator i = f; i != l; ++i, ++n) -// *n = *i; -} - -template -ACE_Array_Map::~ACE_Array_Map (void) -{ - delete[] this->nodes_; -} - -template -void -ACE_Array_Map::swap ( - ACE_Array_Map & map) -{ - std::swap (this->size_, map.size_); - std::swap (this->capacity_, map.capacity_); - std::swap (this->nodes_, map.nodes_); -} - -template -std::pair::iterator, bool> -ACE_Array_Map::insert ( - typename ACE_Array_Map::value_type const & x) -{ - // Linear insertion due to linear duplicate key search. - - bool inserted = false; - iterator i = this->find (x.first); - - if (i == this->end ()) - { - // Add the element to the array. - - size_type const old_size = this->size (); - this->grow (1); // Increase size by at least one. - - i = this->begin () + old_size; - *i = x; - - ++this->size_; - - inserted = true; - } - - return std::make_pair (i, inserted); -} - -#ifndef ACE_LACKS_MEMBER_TEMPLATES -template -template -void -ACE_Array_Map::insert (InputIterator f, InputIterator l) -{ - this->grow (l - f); // Preallocate storage. - - for (InputIterator i = f; i != l; ++i) - { - (void) this->insert (*i); - } -} -#else -template -void -ACE_Array_Map::insert ( - typename ACE_Array_Map::const_iterator f, - typename ACE_Array_Map::const_iterator l) -{ - this->grow (l - f); // Preallocate storage. - - for (const_iterator i = f; i != l; ++i) - { - (void) this->insert (*i); - } -} -#endif /* ACE_LACKS_MEMBER_TEMPLATES */ - -template -void -ACE_Array_Map::erase ( - typename ACE_Array_Map::iterator pos) -{ - iterator const first = this->begin (); - iterator const last = this->end (); - - if (pos >= first && pos < last) - { - if (pos != last - 1) - { - // Relocate the tail element to the location of the erased - // element to prevent introduction of "holes" in the - // underlying array. - *pos = *(last - 1); - } - - // Explicitly destroy the tail element by assigning a default - // constructed instance to it. Note that this also works for - // the case of a map of size 1. - *(last - 1) = value_type (); - - --this->size_; - } -} - -template -typename ACE_Array_Map::size_type -ACE_Array_Map::erase ( - typename ACE_Array_Map::key_type const & k) -{ - iterator pos = this->find (k); - - size_type const old_size = this->size_; - - this->erase (pos); - - return old_size - this->size_; -} - -template -void -ACE_Array_Map::erase ( - typename ACE_Array_Map::iterator first, - typename ACE_Array_Map::iterator last) -{ - if (this->begin () <= first && first < last && last < this->end ()) - for (iterator i = first; i != last; ++i) - this->erase (i); -} - -template -void -ACE_Array_Map::clear (void) -{ - this->size_ = 0; // No need to deallocate array nor destroy elements. -} - -template -typename ACE_Array_Map::iterator -ACE_Array_Map::find ( - typename ACE_Array_Map::key_type const & k) -{ - iterator const the_end = this->end (); - - EqualTo eq; - - for (iterator i = this->begin (); i != the_end; ++i) - if (eq (k, i->first)) - return i; - - return this->end (); -} - -template -typename ACE_Array_Map::const_iterator -ACE_Array_Map::find ( - typename ACE_Array_Map::key_type const & k) const -{ - const_iterator const the_end = this->end (); - - EqualTo eq; - - for (const_iterator i = this->begin (); i != the_end; ++i) - if (eq (k, i->first)) - return i; - - return this->end (); -} - -template -void -ACE_Array_Map::grow ( - typename ACE_Array_Map::size_type s) -{ - if (this->size () + s > this->capacity_) - { - // This implementation focuses more on static footprint than - // speed. - - // Strongly exception safe. - - ACE_Array_Map temp (this->size () + s); - - std::copy (this->begin (), - this->end (), - ACE_make_checked_array_iterator (temp.begin (), - temp.capacity_)); - - size_type const n = this->size (); // Do not swap out the size - // since we bypassed the - // temporary map's element - // counting code. - this->swap (temp); - - this->size_ = n; - } -} - -// --------------------------------------------------------------- - -template -bool -operator== (ACE_Array_Map const & lhs, - ACE_Array_Map const & rhs) -{ - // Do not include Array_Map capacity in comparison. It isn't useful - // in this case. - - return (lhs.size () == rhs.size () - && std::equal (lhs.begin (), - lhs.end (), - ACE_make_checked_array_iterator (rhs.begin (), - rhs.size ()))); -} - -template -bool -operator< (ACE_Array_Map const & lhs, - ACE_Array_Map const & rhs) -{ - return std::lexicographical_compare (lhs.begin (), lhs.end (), - rhs.begin (), rhs.end ()); -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_ARRAY_MAP_CPP */ diff --git a/ACE/ace/Array_Map.h b/ACE/ace/Array_Map.h deleted file mode 100644 index cd0ae3efea6..00000000000 --- a/ACE/ace/Array_Map.h +++ /dev/null @@ -1,300 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Array_Map.h - * - * $Id$ - * - * Light weight array-based map with fast iteration but linear - * (i.e. O(n)) search times. STL-style interface is exposed. - * - * @note This class requires the STL generic algorithms and - * reverse_iterator adapter. - * - * @author Ossama Othman - */ -//============================================================================= - - -#ifndef ACE_ARRAY_MAP_H -#define ACE_ARRAY_MAP_H - -#include /**/ "ace/pre.h" - -#include "ace/config-lite.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include -#include -#include - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Array_Map - * - * @brief Light weight array-based map with fast iteration, but linear - * (i.e. O(n)) search times. - * - * Map implementation that focuses on small footprint and fast - * iteration. Search times are, however, linear (O(n)) meaning that - * this map isn't suitable for large data sets that will be searched - * in performance critical areas of code. Iteration over large data - * sets, however, is faster than linked list-based maps, for example, - * since spatial locality is maximized through the use of contiguous - * arrays as the underlying storage. - * @par - * An @c ACE_Array_Map is a unique associative container, meaning that - * duplicate values may not be added to the map. It is also pair - * associative (value_type is a std::pair<>). It is not a sorted - * container. - * @par - * An STL @c std::map -like interface is exposed by this class - * portability. Furthermore, this map's iterators are compatible with - * STL algorithms. - * @par - * Requirements and Performance Characteristics - * - Internal Structure - * Array - * - Duplicates allowed? - * No - * - Random access allowed? - * Yes - * - Search speed - * O(n) - * - Insert/replace speed - * O(n), can be longer if the map has to resize - * - Iterator still valid after change to container? - * No - * - Frees memory for removed elements? - * Yes - * - Items inserted by - * Value - * - Requirements for key type - * -# Default constructor - * -# Copy constructor - * -# operator= - * -# operator== - * - Requirements for object type - * -# Default constructor - * -# Copy constructor - * -# operator= - */ -template > -class ACE_Array_Map -{ -public: - - // STL-style typedefs/traits. - typedef Key key_type; - typedef Value data_type; - typedef std::pair value_type; - typedef value_type * iterator; - typedef value_type const * const_iterator; - typedef value_type & reference; - typedef value_type const & const_reference; - typedef value_type * pointer; - typedef value_type const * const_pointer; - typedef ptrdiff_t difference_type; - typedef size_t size_type; - - ACE_DECLARE_STL_REVERSE_ITERATORS - - /// Default Constructor. - /** - * Create an empty map with a preallocated buffer of size @a s. - */ - ACE_Array_Map (size_type s = 0); - -#ifndef ACE_LACKS_MEMBER_TEMPLATES - template - ACE_Array_Map (InputIterator f, InputIterator l); -#else - ACE_Array_Map (const_iterator f, const_iterator l); -#endif /* !ACE_LACKS_MEMBER_TEMPLATES */ - - ACE_Array_Map (ACE_Array_Map const & map); - ACE_Array_Map & operator= (ACE_Array_Map const & map); - - /// Destructor. - ~ACE_Array_Map (void); - - /** - * @name Forward Iterator Accessors - * - * Forward iterator accessors. - */ - //@{ - iterator begin (void); - iterator end (void); - const_iterator begin (void) const; - const_iterator end (void) const; - //@} - - /** - * @name Reverse Iterator Accessors - * - * Reverse iterator accessors. - */ - //@{ - reverse_iterator rbegin (void); - reverse_iterator rend (void); - const_reverse_iterator rbegin (void) const; - const_reverse_iterator rend (void) const; - //@} - - /// Return current size of map. - /** - * @return The number of elements in the map. - */ - size_type size (void) const; - - /// Maximum number of elements the map can hold. - size_type max_size (void) const; - - /// Return @c true if the map is empty, else @c false. - bool is_empty (void) const; // ACE style - - /** - * Return @c true if the map is empty, else @c false. We recommend - * using @c is_empty() instead since it's more consistent with the - * ACE container naming conventions. - */ - bool empty (void) const; // STL style - - /// Swap the contents of this map with the given @a map in an - /// exception-safe manner. - void swap (ACE_Array_Map & map); - - /// Insert the value @a x into the map. - /** - * STL-style map insertion method. - * - * @param x @c std::pair containing key and datum. - * - * @return @c std::pair::second will be @c false if the map already - * contains a value with the same key as @a x. - */ - std::pair insert (value_type const & x); - -#ifndef ACE_LACKS_MEMBER_TEMPLATES - /// Insert range of elements into map. - template - void insert (InputIterator f, InputIterator l); -#else - /// Insert range of elements into map. - void insert (const_iterator f, const_iterator l); -#endif /* ACE_LACKS_MEMBER_TEMPLATES */ - - /// Remove element at position @a pos from the map. - void erase (iterator pos); - - /// Remove element corresponding to key @a k from the map. - /** - * @return Number of elements that were erased. - */ - size_type erase (key_type const & k); - - /// Remove range of elements [@a first, @a last) from the map. - /** - * @note [@a first, @a last) must be valid range within the map. - */ - void erase (iterator first, iterator last); - - /// Clear contents of map. - /** - * @note This a constant time (O(1)) operation. - */ - void clear (void); - - /** - * @name Search Operations - * - * Search the map for data corresponding to key @a k. - */ - //@{ - /** - * @return @c end() if data corresponding to key @a k is not in the - * map. - */ - iterator find (key_type const & k); - - /** - * @return @c end() if data corresponding to key @a k is not in the - * map. - */ - const_iterator find (key_type const & k) const; - //@} - - /// Count the number of elements corresponding to key @a k. - /** - * @return In the case of this map, the count will always be one if - * such exists in the map. - */ - size_type count (key_type const & k); - - /// Convenience array index operator. - /** - * Array index operator that allows insertion and retrieval of - * elements using an array index syntax, such as: - * @par - * map["Foo"] = 12; - */ - data_type & operator[] (key_type const & k); - -private: - - /// Increase size of underlying buffer by @a s. - void grow (size_type s); - -private: - - /// Number of elements in the map. - size_type size_; - - /// Current size of underlying array. - /** - * @note @c capacity_ is always greater than or equal to @c size_; - */ - size_type capacity_; - - /// Underlying array containing keys and data. - value_type * nodes_; - -}; - -// -------------------------------------------------------------- - -/// @c ACE_Array_Map equality operator. -template -bool operator== (ACE_Array_Map const & lhs, - ACE_Array_Map const & rhs); - -/// @c ACE_Array_Map lexicographical comparison operator. -template -bool operator< (ACE_Array_Map const & lhs, - ACE_Array_Map const & rhs); - -// -------------------------------------------------------------- - -ACE_END_VERSIONED_NAMESPACE_DECL - -#ifdef __ACE_INLINE__ -# include "ace/Array_Map.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -# include "ace/Array_Map.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Array_Map.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" - -#endif /* ACE_ARRAY_MAP_H */ diff --git a/ACE/ace/Array_Map.inl b/ACE/ace/Array_Map.inl deleted file mode 100644 index 86a26d3f3aa..00000000000 --- a/ACE/ace/Array_Map.inl +++ /dev/null @@ -1,133 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template -ACE_INLINE -ACE_Array_Map::ACE_Array_Map ( - typename ACE_Array_Map::size_type s) - : size_ (0) - , capacity_ (s) - , nodes_ (s == 0 ? 0 : new value_type[s]) -{ -} - -template -ACE_INLINE ACE_Array_Map & -ACE_Array_Map::operator= ( - ACE_Array_Map const & map) -{ - // Strongly exception-safe assignment. - - ACE_Array_Map temp (map); - this->swap (temp); - return *this; -} - -template -ACE_INLINE typename ACE_Array_Map::iterator -ACE_Array_Map::begin (void) -{ - return this->nodes_; -} - -template -ACE_INLINE typename ACE_Array_Map::iterator -ACE_Array_Map::end (void) -{ - return this->nodes_ + this->size_; -} - -template -ACE_INLINE typename ACE_Array_Map::const_iterator -ACE_Array_Map::begin (void) const -{ - return this->nodes_; -} - -template -ACE_INLINE typename ACE_Array_Map::const_iterator -ACE_Array_Map::end (void) const -{ - return this->nodes_ + this->size_; -} - -template -ACE_INLINE typename ACE_Array_Map::reverse_iterator -ACE_Array_Map::rbegin (void) -{ - return reverse_iterator (this->end ()); -} - -template -ACE_INLINE typename ACE_Array_Map::reverse_iterator -ACE_Array_Map::rend (void) -{ - return reverse_iterator (this->begin ()); -} - -template -ACE_INLINE typename ACE_Array_Map::const_reverse_iterator -ACE_Array_Map::rbegin (void) const -{ - return const_reverse_iterator (this->end ()); -} - -template -ACE_INLINE typename ACE_Array_Map::const_reverse_iterator -ACE_Array_Map::rend (void) const -{ - return const_reverse_iterator (this->begin ()); -} - -template -ACE_INLINE typename ACE_Array_Map::size_type -ACE_Array_Map::size (void) const -{ - return this->size_; -} - -template -ACE_INLINE typename ACE_Array_Map::size_type -ACE_Array_Map::max_size (void) const -{ - return size_type (-1) / sizeof (value_type); -} - -template -ACE_INLINE bool -ACE_Array_Map::is_empty (void) const -{ - return this->size_ == 0; -} - -// The following method is deprecated. - -template -ACE_INLINE bool -ACE_Array_Map::empty (void) const -{ - return this->is_empty (); -} - -template -ACE_INLINE typename ACE_Array_Map::size_type -ACE_Array_Map::count ( - typename ACE_Array_Map::key_type const & k) -{ - return - (this->find (k) == this->end () ? 0 : 1); // Only one datum per key. -} - -template -ACE_INLINE typename ACE_Array_Map::data_type & -ACE_Array_Map::operator[] ( - typename ACE_Array_Map::key_type const & k) -{ - iterator i = (this->insert (value_type (k, data_type ()))).first; - return (*i).second; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Assert.cpp b/ACE/ace/Assert.cpp deleted file mode 100644 index 06e4f34d2ea..00000000000 --- a/ACE/ace/Assert.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// $Id$ - -#include "ace/Assert.h" -#include "ace/Log_Msg.h" - -ACE_RCSID(ace, Assert, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// The following ASSERT macro is courtesy of Alexandre Karev -// . -void -__ace_assert(const char *file, int line, const ACE_TCHAR *expression) -{ - int error = ACE_Log_Msg::last_error_adapter (); - ACE_Log_Msg *log = ACE_Log_Msg::instance (); - - log->set (file, line, -1, error, log->restart (), - log->msg_ostream (), log->msg_callback ()); - - log->log (LM_ERROR, ACE_TEXT ("ACE_ASSERT: file %N, line %l assertion failed for '%s'.%a\n"), expression, -1); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Assert.h b/ACE/ace/Assert.h deleted file mode 100644 index 70e9b0060c4..00000000000 --- a/ACE/ace/Assert.h +++ /dev/null @@ -1,38 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Assert.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_ASSERT_H -#define ACE_ASSERT_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#include /**/ "ace/config-all.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_Export void __ace_assert(const char *file, int line, const ACE_TCHAR *expression); -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (ACE_NDEBUG) -#define ACE_ASSERT(x) \ - (static_cast(0)) -#else -#define ACE_ASSERT(X) \ - ((X) \ - ? static_cast(0) \ - : ACE_VERSIONED_NAMESPACE_NAME::__ace_assert(__FILE__, __LINE__, ACE_TEXT_CHAR_TO_TCHAR (#X))) -#endif /* ACE_NDEBUG */ - -#include /**/ "ace/post.h" - -#endif /* ACE_ASSERT */ diff --git a/ACE/ace/Asynch_Acceptor.cpp b/ACE/ace/Asynch_Acceptor.cpp deleted file mode 100644 index 7ded341609f..00000000000 --- a/ACE/ace/Asynch_Acceptor.cpp +++ /dev/null @@ -1,516 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -#ifndef ACE_ASYNCH_ACCEPTOR_C -#define ACE_ASYNCH_ACCEPTOR_C - -#include "ace/Asynch_Acceptor.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_RCSID(ace, Asynch_Acceptor, "$Id$") - -#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) -// This only works on platforms that support async i/o. - -#include "ace/OS_Errno.h" -#include "ace/OS_Memory.h" -#include "ace/OS_NS_sys_socket.h" -#include "ace/Log_Msg.h" -#include "ace/Message_Block.h" -#include "ace/INET_Addr.h" -#include "ace/SOCK_Stream.h" -#include "ace/Sock_Connect.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template -ACE_Asynch_Acceptor::ACE_Asynch_Acceptor (void) - : listen_handle_ (ACE_INVALID_HANDLE), - pass_addresses_ (false), - validate_new_connection_ (false), - reissue_accept_ (1), - bytes_to_read_ (0) -{ -} - -template -ACE_Asynch_Acceptor::~ACE_Asynch_Acceptor (void) -{ - // Close down the listen socket - if (this->listen_handle_ != ACE_INVALID_HANDLE) - { - ACE_OS::closesocket (this->listen_handle_); - this->listen_handle_ = ACE_INVALID_HANDLE; - } -} - -template int -ACE_Asynch_Acceptor::open (const ACE_INET_Addr &address, - size_t bytes_to_read, - bool pass_addresses, - int backlog, - int reuse_addr, - ACE_Proactor *proactor, - bool validate_new_connection, - int reissue_accept, - int number_of_initial_accepts) -{ - ACE_TRACE ("ACE_Asynch_Acceptor<>::open"); - - this->proactor (proactor); - this->pass_addresses_ = pass_addresses; - this->bytes_to_read_ = bytes_to_read; - this->validate_new_connection_ = validate_new_connection; - this->reissue_accept_ = reissue_accept; - this->addr_family_ = address.get_type (); - - // Create the listener socket - this->listen_handle_ = ACE_OS::socket (address.get_type (), SOCK_STREAM, 0); - if (this->listen_handle_ == ACE_INVALID_HANDLE) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_OS::socket")), - -1); - // Initialize the ACE_Asynch_Accept - if (this->asynch_accept_.open (*this, - this->listen_handle_, - 0, - this->proactor ()) == -1) - { - ACE_Errno_Guard g (errno); - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Asynch_Accept::open"))); - ACE_OS::closesocket (this->listen_handle_); - this->listen_handle_ = ACE_INVALID_HANDLE; - return -1; - } - - if (reuse_addr) - { - // Reuse the address - int one = 1; - if (ACE_OS::setsockopt (this->listen_handle_, - SOL_SOCKET, - SO_REUSEADDR, - (const char*) &one, - sizeof one) == -1) - { - ACE_Errno_Guard g (errno); - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_OS::setsockopt"))); - ACE_OS::closesocket (this->listen_handle_); - this->listen_handle_ = ACE_INVALID_HANDLE; - return -1; - } - } - - // If port is not specified, bind to any port. - static ACE_INET_Addr sa (ACE_sap_any_cast (const ACE_INET_Addr &)); - - if (address == sa && - ACE::bind_port (this->listen_handle_, - INADDR_ANY, - address.get_type()) == -1) - { - ACE_Errno_Guard g (errno); - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE::bind_port"))); - ACE_OS::closesocket (this->listen_handle_); - this->listen_handle_ = ACE_INVALID_HANDLE; - return -1; - } - - // Bind to the specified port. - if (ACE_OS::bind (this->listen_handle_, - reinterpret_cast (address.get_addr ()), - address.get_size ()) == -1) - { - ACE_Errno_Guard g (errno); - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_OS::bind"))); - ACE_OS::closesocket (this->listen_handle_); - this->listen_handle_ = ACE_INVALID_HANDLE; - return -1; - } - - // Start listening. - if (ACE_OS::listen (this->listen_handle_, backlog) == -1) - { - ACE_Errno_Guard g (errno); - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_OS::listen"))); - ACE_OS::closesocket (this->listen_handle_); - this->listen_handle_ = ACE_INVALID_HANDLE; - return -1; - } - - // For the number of . - if (number_of_initial_accepts == -1) - number_of_initial_accepts = backlog; - - for (int i = 0; i < number_of_initial_accepts; i++) - { - // Initiate accepts. - if (this->accept (bytes_to_read) == -1) - { - ACE_Errno_Guard g (errno); - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Asynch_Acceptor::accept"))); - ACE_OS::closesocket (this->listen_handle_); - this->listen_handle_ = ACE_INVALID_HANDLE; - return -1; - } - } - - return 0; -} - -template int -ACE_Asynch_Acceptor::set_handle (ACE_HANDLE listen_handle) -{ - ACE_TRACE ("ACE_Asynch_Acceptor<>::set_handle"); - - // Take ownership of the - this->listen_handle_ = listen_handle; - - // Reinitialize the ACE_Asynch_Accept - if (this->asynch_accept_.open (*this, - this->listen_handle_, - 0, - this->proactor ()) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Asynch_Accept::open")), - -1); - return 0; -} - -template ACE_HANDLE -ACE_Asynch_Acceptor::get_handle (void) const -{ - return this->listen_handle_; -} - -template int -ACE_Asynch_Acceptor::accept (size_t bytes_to_read, const void *act) -{ - ACE_TRACE ("ACE_Asynch_Acceptor<>::accept"); - - ACE_Message_Block *message_block = 0; - // The space_needed calculation is drive by needs of Windows. POSIX doesn't - // need to extra 16 bytes, but it doesn't hurt. - size_t space_needed = sizeof (sockaddr_in) + 16; -#if defined (ACE_HAS_IPV6) - if (PF_INET6 == this->addr_family_) - space_needed = sizeof (sockaddr_in6) + 16; -#endif /* ACE_HAS_IPV6 */ - space_needed = (2 * space_needed) + bytes_to_read; - - // Create a new message block big enough for the addresses and data - ACE_NEW_RETURN (message_block, - ACE_Message_Block (space_needed), - -1); - - // Initiate asynchronous accepts - if (this->asynch_accept_.accept (*message_block, - bytes_to_read, - ACE_INVALID_HANDLE, - act, - 0, - ACE_SIGRTMIN, - this->addr_family_) == -1) - { - // Cleanup on error - message_block->release (); - return -1; - } - return 0; -} - -template void -ACE_Asynch_Acceptor::handle_accept (const ACE_Asynch_Accept::Result &result) -{ - ACE_TRACE ("ACE_Asynch_Acceptor<>::handle_accept"); - - // Variable for error tracking - int error = 0; - - // If the asynchronous accept fails. - if (!result.success () || result.accept_handle () == ACE_INVALID_HANDLE) - { - error = 1; - } - -#if defined (ACE_WIN32) - // In order to use accept handle with other Window Sockets 1.1 - // functions, we call the setsockopt function with the - // SO_UPDATE_ACCEPT_CONTEXT option. This option initializes the - // socket so that other Windows Sockets routines to access the - // socket correctly. - if (!error && - ACE_OS::setsockopt (result.accept_handle (), - SOL_SOCKET, - SO_UPDATE_ACCEPT_CONTEXT, - (char *) &this->listen_handle_, - sizeof (this->listen_handle_)) == -1) - { - error = 1; - } -#endif /* ACE_WIN32 */ - - // Parse address. - ACE_INET_Addr local_address; - ACE_INET_Addr remote_address; - if (!error && - (this->validate_new_connection_ || this->pass_addresses_)) - // Parse the addresses. - this->parse_address (result, - remote_address, - local_address); - - // Validate remote address - if (!error && - this->validate_new_connection_ && - (this->validate_connection (result, remote_address, local_address) == -1)) - { - error = 1; - } - - HANDLER *new_handler = 0; - if (!error) - { - // The Template method - new_handler = this->make_handler (); - if (new_handler == 0) - { - error = 1; - } - } - - // If no errors - if (!error) - { - // Update the Proactor. - new_handler->proactor (this->proactor ()); - - // Pass the addresses - if (this->pass_addresses_) - new_handler->addresses (remote_address, - local_address); - - // Pass the ACT - if (result.act () != 0) - new_handler->act (result.act ()); - - // Set up the handler's new handle value - new_handler->handle (result.accept_handle ()); - - // Initiate the handler - new_handler->open (result.accept_handle (), - result.message_block ()); - } - - // On failure, no choice but to close the socket - if (error && - result.accept_handle() != ACE_INVALID_HANDLE ) - ACE_OS::closesocket (result.accept_handle ()); - - // Delete the dynamically allocated message_block - result.message_block ().release (); - - // Start off another asynchronous accept to keep the backlog going, - // unless we closed the listen socket already (from the destructor), - // or this callback is the result of a canceled/aborted accept. - if (this->should_reissue_accept () && - this->listen_handle_ != ACE_INVALID_HANDLE -#if defined (ACE_WIN32) - && result.error () != ERROR_OPERATION_ABORTED -#else - && result.error () != ECANCELED -#endif - ) - this->accept (this->bytes_to_read_); -} - -template int -ACE_Asynch_Acceptor::validate_connection - (const ACE_Asynch_Accept::Result& /* result */, - const ACE_INET_Addr& /* remote */, - const ACE_INET_Addr& /* local */) -{ - // Default implementation always validates the remote address. - return 0; -} - -template int -ACE_Asynch_Acceptor::cancel (void) -{ - ACE_TRACE ("ACE_Asynch_Acceptor<>::cancel"); - - // All I/O operations that are canceled will complete with the error - // ERROR_OPERATION_ABORTED. All completion notifications for the I/O - // operations will occur normally. -#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) && \ - (defined (_MSC_VER) || defined (__BORLANDC__)) - return (int) ::CancelIo (this->listen_handle_); -#else - // Supported now - return this->asynch_accept_.cancel(); - -#endif /* defined (ACE_HAS_WIN32_OVERLAPPED_IO) && (defined (_MSC_VER)) || defined (__BORLANDC__)) */ -} - -template void -ACE_Asynch_Acceptor::parse_address (const - ACE_Asynch_Accept::Result &result, - ACE_INET_Addr &remote_address, - ACE_INET_Addr &local_address) -{ - ACE_TRACE ("ACE_Asynch_Acceptor<>::parse_address"); - -#if defined (ACE_HAS_AIO_CALLS) - - // Use an ACE_SOCK to get the addresses - it knows how to deal with - // ACE_INET_Addr objects and get IPv4/v6 addresses. - ACE_SOCK_Stream str (result.accept_handle ()); - str.get_local_addr (local_address); - str.get_remote_addr (remote_address); - -#elif defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) - - ACE_Message_Block &message_block = result.message_block (); - - sockaddr *local_addr = 0; - sockaddr *remote_addr = 0; - int local_size = 0; - int remote_size = 0; - // This matches setup in accept(). - size_t addr_size = sizeof (sockaddr_in) + 16; -#if defined (ACE_HAS_IPV6) - if (this->addr_family_ == PF_INET6) - addr_size = sizeof (sockaddr_in6) + 16; -#endif /* ACE_HAS_IPV6 */ - - ::GetAcceptExSockaddrs (message_block.rd_ptr (), - static_cast (this->bytes_to_read_), - static_cast (addr_size), - static_cast (addr_size), - &local_addr, - &local_size, - &remote_addr, - &remote_size); - - local_address.set (reinterpret_cast (local_addr), - local_size); - remote_address.set (reinterpret_cast (remote_addr), - remote_size); -#else - // just in case - errno = ENOTSUP; -#endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */ - return; -} - -template ACE_HANDLE -ACE_Asynch_Acceptor::handle (void) const -{ - return this->listen_handle_; -} - -template void -ACE_Asynch_Acceptor::handle (ACE_HANDLE h) -{ - ACE_Handler::handle (h); -} - -template ACE_Asynch_Accept & -ACE_Asynch_Acceptor::asynch_accept (void) -{ - return this->asynch_accept_; -} - -template HANDLER * -ACE_Asynch_Acceptor::make_handler (void) -{ - // Default behavior - HANDLER *handler = 0; - ACE_NEW_RETURN (handler, - HANDLER, - 0); - return handler; -} - -/* static */ -template size_t -ACE_Asynch_Acceptor::address_size (void) -{ - return sizeof (sockaddr) + sizeof (sockaddr_in); -} - -template bool -ACE_Asynch_Acceptor::pass_addresses (void) const -{ - return this->pass_addresses_; -} - -template void -ACE_Asynch_Acceptor::pass_addresses (bool new_value) -{ - this->pass_addresses_ = new_value; -} - -template bool -ACE_Asynch_Acceptor::validate_new_connection (void) const -{ - return this->validate_new_connection_; -} - -template void -ACE_Asynch_Acceptor::validate_new_connection (bool new_value) -{ - this->validate_new_connection_ = new_value; -} - -template int -ACE_Asynch_Acceptor::reissue_accept (void) const -{ - return this->reissue_accept_; -} - -template void -ACE_Asynch_Acceptor::reissue_accept (int new_value) -{ - this->reissue_accept_ = new_value; -} - -template size_t -ACE_Asynch_Acceptor::bytes_to_read (void) const -{ - return this->bytes_to_read_; -} - -template void -ACE_Asynch_Acceptor::bytes_to_read (size_t new_value) -{ - this->bytes_to_read_ = new_value; -} - -template int -ACE_Asynch_Acceptor::should_reissue_accept (void) -{ - return this->reissue_accept_; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_WIN32 || ACE_HAS_AIO_CALLS */ -#endif /* ACE_ASYNCH_ACCEPTOR_C */ diff --git a/ACE/ace/Asynch_Acceptor.h b/ACE/ace/Asynch_Acceptor.h deleted file mode 100644 index af7944e4b58..00000000000 --- a/ACE/ace/Asynch_Acceptor.h +++ /dev/null @@ -1,281 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file Asynch_Acceptor.h - * - * $Id$ - * - * @author Irfan Pyarali (irfan@cs.wustl.edu) - */ -//============================================================================= - -#ifndef ACE_ASYNCH_ACCEPTOR_H -#define ACE_ASYNCH_ACCEPTOR_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) -// This only works on platforms that support async i/o. - -#include "ace/Default_Constants.h" -#include "ace/Asynch_IO.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Forward declarations -class ACE_Message_Block; -class ACE_INET_Addr; - -/** - * @class ACE_Asynch_Acceptor - * - * @brief This class is an example of the Acceptor Pattern. This class - * will accept new connections and create new HANDLER to handle - * the new connections. - * - * Unlike the ACE_Acceptor, however, this class is designed to - * be used asynchronously. - */ -template -class ACE_Asynch_Acceptor : public ACE_Handler -{ -public: - /// A do nothing constructor. - ACE_Asynch_Acceptor (void); - - /// Virtual destruction - virtual ~ACE_Asynch_Acceptor (void); - - /** - * @c open starts one or more asynchronous accept requests on a - * @a address. Each accept operation may optionally read an - * initial buffer from the new connection when accepted. - * - * @param address The address to listen/accept connections on. - * If the address does not specify a port, a random - * port is selected and bound. - * @param bytes_to_read Optional, specifies the maximum number of bytes - * to read with the accept. The buffer for the initial - * data is allocated internally and passed to the - * @c ACE_Service_Handler::open() hook method. It is - * legitimate only during the @c open() method and must - * be copied if required after @c open() returns. - * This pre-read function works only on Windows. - * @param pass_addresses Optional, a non-zero value indicates that - * the local and peer addresses should be passed to the - * associated @c ACE_Service_Handler::addresses() method - * after any call to @c validate_new_connection() and prior - * to the @c open() hook method call. - * @param backlog Optional, defaulting to @c ACE_DEFAULT_ASYNCH_BACKLOG (which - * can be adjusted in your platform's @c config.h file). - * Specifies the listening backlog for the listening socket. - * @param reuse_addr Optional, indicates whether the @c SO_REUSEADDR - * option is set on the listening socket or not. - * @param proactor Optional, pointer to the @c ACE_Proactor to use for - * demultiplexing asynchronous accepts. If 0, the - * process's singleton @c ACE_Proactor is used. - * @param validate_new_connection Optional, if true, this object's - * @c validate_connection() method is called after - * the accept completes, but before the service handler's - * @c open() hook method is called. If @c - * validate_connection() returns -1, the newly-accepted - * socket is immediately closed, and the @c addresses() - * method is not called. - * @param reissue_accept Optional, if non-zero (the default), a new - * asynchronous accept operation is started after each - * completion, whether the completion is for success or - * failure, and whether or not a successfully-accepted - * connection is subsequently refused. - * @param number_of_initial_accepts Optional, the number of asynchronous - * accepts that are started immediately. If -1 (the - * default), the value of @a backlog is used. - * - * @note On Windows, the peer address is only available at the time - * the connection is accepted. Therefore, if you require the peer - * address on Windows, do not rely on the - * @c ACE_SOCK::get_remote_addr() method - it won't work. You must - * supply a non-zero value for @a pass_addresses and obtain the - * peer address in the @c ACE_Service_Handler::addresses() method. - * - * @see ACE_INET_Addr - * @see ACE_Service_Handler - */ - virtual int open (const ACE_INET_Addr &address, - size_t bytes_to_read = 0, - bool pass_addresses = false, - int backlog = ACE_DEFAULT_ASYNCH_BACKLOG, - int reuse_addr = 1, - ACE_Proactor *proactor = 0, - bool validate_new_connection = false, - int reissue_accept = 1, - int number_of_initial_accepts = -1); - - /// Get the underlying handle. - virtual ACE_HANDLE get_handle (void) const; - - /** - * Set the underlying listen handle. It is the user's responsibility - * to make sure that the old listen handle has been appropriately - * closed and the all outstanding asynchronous operations have - * either completed or have been canceled on the old listen handle. - */ - virtual int set_handle (ACE_HANDLE handle); - - /// This initiates a new asynchronous accept operation. - /** - * You need only call this method if the @a reissue_accept argument - * passed to @c open() was 0. - */ - virtual int accept (size_t bytes_to_read = 0, const void *act = 0); - - /** - * Cancels all pending accepts operations issued by this object. - * - * @note On Windows, only accept operations initiated by the calling thread - * are canceled. - */ - virtual int cancel (void); - - /** - * Template method to validate peer before service is opened. - * This method is called after a new connection is accepted if the - * @a validate_connection argument to @c open() was non-zero or - * the @c validate_new_connection() method is called to turn this - * feature on. The default implementation returns 0. Users can - * reimplement this method to perform validation of the peer - * using it's address, running an authentication procedure (such as - * SSL) or anything else necessary or desireable. The return value - * from this method determines whether or not ACE will continue - * opening the service or abort the connection. - * - * @param result Result of the connection acceptance. - * @param remote Peer's address. - * @param local Local address connection was accepted at. - * - * @retval -1 ACE_Asynch_Acceptor will close the connection, and - * the service will not be opened. - * @retval 0 Service opening will proceeed. - */ - virtual int validate_connection (const ACE_Asynch_Accept::Result& result, - const ACE_INET_Addr &remote, - const ACE_INET_Addr& local); - - /** - * Template method for deciding whether to reissue accept. - * - * This hook method is called after each accept completes to decide if - * another accept should be initiated. If the method returns a non-zero - * value, another accept is initiated. - * - * The default implemenation always returns the value passed as the - * @c open() method's @a reissue_accept argument. That value can also - * be changed using the @c reissue_accept() method. - */ - virtual int should_reissue_accept (void); - - // - // These are low level tweaking methods - // - - /// Get flag that indicates if parsing and passing of addresses to - /// the service_handler is necessary. - virtual bool pass_addresses (void) const; - - /// Set flag that indicates if parsing and passing of addresses to - /// the service_handler is necessary. - virtual void pass_addresses (bool new_value); - - /// Get flag that indicates if address validation is required. - virtual bool validate_new_connection (void) const; - - /// Set flag that indicates if address validation is required. - virtual void validate_new_connection (bool new_value); - - /// Get flag that indicates if a new accept should be reissued when a accept - /// completes. - virtual int reissue_accept (void) const; - - /// Set flag that indicates if a new accept should be reissued when a accept - /// completes. - virtual void reissue_accept (int new_value); - - /// Get bytes to be read with the call. - virtual size_t bytes_to_read (void) const; - - /// Set bytes to be read with the call. - virtual void bytes_to_read (size_t new_value); - - /// @deprecated address_size() assumes IPv4 use, so is not always valid. - /// This method will be removed after ACE 5.5. Internal uses have been - /// changes to base needed sizes on the addr_family_ member. - static size_t address_size (void); - -protected: - - /// This is called when an outstanding accept completes. - virtual void handle_accept (const ACE_Asynch_Accept::Result &result); - - /// Return the listen handle. - ACE_HANDLE handle (void) const; - /// Set the listen handle. - void handle (ACE_HANDLE h); - - /// This parses the address from read buffer. - void parse_address (const ACE_Asynch_Accept::Result &result, - ACE_INET_Addr &remote_address, - ACE_INET_Addr &local_address); - - /// Return the asynch accept object. - ACE_Asynch_Accept &asynch_accept (void); - - /** - * This is the template method used to create new handler. - * Subclasses must overwrite this method if a new handler creation - * strategy is required. - */ - virtual HANDLER *make_handler (void); - -private: - /// Handle used to listen for new connections. - ACE_HANDLE listen_handle_; - - /// Asynch_Accept used to make life easier :-) - ACE_Asynch_Accept asynch_accept_; - - /// Flag that indicates if parsing of addresses is necessary. - bool pass_addresses_; - - /// Flag that indicates if address validation is required. - bool validate_new_connection_; - - /// Flag that indicates if a new accept should be reissued when a - /// accept completes. - int reissue_accept_; - - /// Bytes to be read with the call. - size_t bytes_to_read_; - - /// Address family used to open this object. Obtained from @a address passed - /// to @c open(). - int addr_family_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Asynch_Acceptor.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Asynch_Acceptor.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ -#include /**/ "ace/post.h" -#endif /* ACE_ASYNCH_ACCEPTOR_H */ diff --git a/ACE/ace/Asynch_Connector.cpp b/ACE/ace/Asynch_Connector.cpp deleted file mode 100644 index fd61fcfdb8a..00000000000 --- a/ACE/ace/Asynch_Connector.cpp +++ /dev/null @@ -1,296 +0,0 @@ -// $Id$ - -#ifndef ACE_ASYNCH_CONNECTOR_CPP -#define ACE_ASYNCH_CONNECTOR_CPP - -#include "ace/Asynch_Connector.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if (defined (ACE_WIN32) || defined (ACE_HAS_AIO_CALLS)) && !defined(ACE_HAS_WINCE) -// This only works on platforms that support async I/O. - -#include "ace/OS_NS_sys_socket.h" -#include "ace/OS_Memory.h" -#include "ace/Flag_Manip.h" -#include "ace/Log_Msg.h" -#include "ace/Message_Block.h" -#include "ace/INET_Addr.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template -ACE_Asynch_Connector::ACE_Asynch_Connector (void) - : pass_addresses_ (false), - validate_new_connection_ (false) -{ -} - -template -ACE_Asynch_Connector::~ACE_Asynch_Connector (void) -{ - //this->asynch_connect_.close (); -} - -template int -ACE_Asynch_Connector::open (bool pass_addresses, - ACE_Proactor *proactor, - bool validate_new_connection) -{ - this->proactor (proactor); - this->pass_addresses_ = pass_addresses; - this->validate_new_connection_ = validate_new_connection; - - // Initialize the ACE_Asynch_Connect - if (this->asynch_connect_.open (*this, - ACE_INVALID_HANDLE, - 0, - this->proactor ()) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Asynch_Connect::open")), - -1); - return 0; -} - -template int -ACE_Asynch_Connector::connect (const ACE_INET_Addr & remote_sap, - const ACE_INET_Addr & local_sap, - int reuse_addr, - const void *act) -{ - // Initiate asynchronous connect - if (this->asynch_connect_.connect (ACE_INVALID_HANDLE, - remote_sap, - local_sap, - reuse_addr, - act) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Asynch_Connect::connect")), - -1); - return 0; -} - -template void -ACE_Asynch_Connector::handle_connect (const ACE_Asynch_Connect::Result &result) -{ - // Variable for error tracking - int error = 0; - - // If the asynchronous connect fails. - if (!result.success () || - result.connect_handle () == ACE_INVALID_HANDLE) - { - error = 1; - } - - if (result.error () != 0) - { - error = 1; - } - - // set blocking mode - if (!error && - ACE::clr_flags - (result.connect_handle (), ACE_NONBLOCK) != 0) - { - error = 1; - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Asynch_Connector::handle_connect : Set blocking mode"))); - } - - // Parse the addresses. - ACE_INET_Addr local_address; - ACE_INET_Addr remote_address; - if (!error && - (this->validate_new_connection_ || this->pass_addresses_)) - this->parse_address (result, - remote_address, - local_address); - - // Call validate_connection even if there was an error - it's the only - // way the application can learn the connect disposition. - if (this->validate_new_connection_ && - this->validate_connection (result, remote_address, local_address) == -1) - { - error = 1; - } - - HANDLER *new_handler = 0; - if (!error) - { - // The Template method - new_handler = this->make_handler (); - if (new_handler == 0) - { - error = 1; - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Asynch_Connector::handle_connect : Making of new handler failed"))); - } - } - - // If no errors - if (!error) - { - // Update the Proactor. - new_handler->proactor (this->proactor ()); - - // Pass the addresses - if (this->pass_addresses_) - new_handler->addresses (remote_address, - local_address); - - // Pass the ACT - if (result.act () != 0) - new_handler->act (result.act ()); - - // Set up the handler's new handle value - new_handler->handle (result.connect_handle ()); - - ACE_Message_Block mb; - - // Initiate the handler with empty message block; - new_handler->open (result.connect_handle (), mb); - } - - // On failure, no choice but to close the socket - if (error && - result.connect_handle() != ACE_INVALID_HANDLE) - ACE_OS::closesocket (result.connect_handle ()); -} - -template int -ACE_Asynch_Connector::validate_connection - (const ACE_Asynch_Connect::Result &, - const ACE_INET_Addr & /* remote_address */, - const ACE_INET_Addr & /* local_address */) -{ - // Default implementation always validates the remote address. - return 0; -} - -template int -ACE_Asynch_Connector::cancel (void) -{ - return this->asynch_connect_.cancel (); -} - -template void -ACE_Asynch_Connector::parse_address (const ACE_Asynch_Connect::Result &result, - ACE_INET_Addr &remote_address, - ACE_INET_Addr &local_address) -{ -#if defined (ACE_HAS_IPV6) - // Getting the addresses. - sockaddr_in6 local_addr; - sockaddr_in6 remote_addr; -#else - // Getting the addresses. - sockaddr_in local_addr; - sockaddr_in remote_addr; -#endif /* ACE_HAS_IPV6 */ - - // Get the length. - int local_size = sizeof (local_addr); - int remote_size = sizeof (remote_addr); - - // Get the local address. - if (ACE_OS::getsockname (result.connect_handle (), - reinterpret_cast (&local_addr), - &local_size) < 0) - ACE_ERROR ((LM_ERROR, - ACE_TEXT("%p\n"), - ACE_TEXT("ACE_Asynch_Connector:: failed"))); - - // Get the remote address. - if (ACE_OS::getpeername (result.connect_handle (), - reinterpret_cast (&remote_addr), - &remote_size) < 0) - ACE_ERROR ((LM_ERROR, - ACE_TEXT("%p\n"), - ACE_TEXT("ACE_Asynch_Connector:: failed"))); - - // Set the addresses. - local_address.set (reinterpret_cast (&local_addr), - local_size); - remote_address.set (reinterpret_cast (&remote_addr), - remote_size); - -#if 0 - // @@ Just debugging. - char local_address_buf [BUFSIZ]; - char remote_address_buf [BUFSIZ]; - - if (local_address.addr_to_string (local_address_buf, - sizeof local_address_buf) == -1) - ACE_ERROR ((LM_ERROR, - "Error:%m:can't obtain local_address's address string")); - - ACE_DEBUG ((LM_DEBUG, - "ACE_Asynch_Connector::parse_address : " - "Local address %s\n", - local_address_buf)); - - if (remote_address.addr_to_string (remote_address_buf, - sizeof remote_address_buf) == -1) - ACE_ERROR ((LM_ERROR, - "Error:%m:can't obtain remote_address's address string")); - - ACE_DEBUG ((LM_DEBUG, - "ACE_Asynch_Connector::parse_address : " - "Remote address %s\n", - remote_address_buf)); -#endif /* 0 */ - - return; -} - - -template ACE_Asynch_Connect & -ACE_Asynch_Connector::asynch_connect (void) -{ - return this->asynch_connect_; -} - -template HANDLER * -ACE_Asynch_Connector::make_handler (void) -{ - // Default behavior - HANDLER *handler = 0; - ACE_NEW_RETURN (handler, HANDLER, 0); - return handler; -} - -template bool -ACE_Asynch_Connector::pass_addresses (void) const -{ - return this->pass_addresses_; -} - -template void -ACE_Asynch_Connector::pass_addresses (bool new_value) -{ - this->pass_addresses_ = new_value; -} - -template bool -ACE_Asynch_Connector::validate_new_connection (void) const -{ - return this->validate_new_connection_; -} - -template void -ACE_Asynch_Connector::validate_new_connection (bool new_value) -{ - this->validate_new_connection_ = new_value; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_WIN32 || ACE_HAS_AIO_CALLS */ -#endif /* ACE_ASYNCH_CONNECTOR_CPP */ diff --git a/ACE/ace/Asynch_Connector.h b/ACE/ace/Asynch_Connector.h deleted file mode 100644 index 4e049584d77..00000000000 --- a/ACE/ace/Asynch_Connector.h +++ /dev/null @@ -1,171 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file Asynch_Connector.h - * - * $Id$ - * - * @author Alexander Libman - */ -//============================================================================= - -#ifndef ACE_ASYNCH_CONNECTOR_H -#define ACE_ASYNCH_CONNECTOR_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if (defined (ACE_WIN32) || defined (ACE_HAS_AIO_CALLS)) && !defined(ACE_HAS_WINCE) -// This only works on platforms that support async i/o. - -#include "ace/Asynch_IO.h" -#include "ace/INET_Addr.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Forward declarations -class ACE_Message_Block; - -/** - * @class ACE_Asynch_Connector - * - * @brief This class is an example of the Connector pattern. This class - * will establish new connections and create new HANDLER objects to handle - * the new connections. - * - * Unlike the ACE_Connector, however, this class is designed to - * be used asynchronously with the ACE Proactor framework. - */ - -template -class ACE_Asynch_Connector : public ACE_Handler -{ -public: - /// A do nothing constructor. - ACE_Asynch_Connector (void); - - /// Virtual destruction - virtual ~ACE_Asynch_Connector (void); - - /** - * This opens asynch connector - */ - virtual int open (bool pass_addresses = false, - ACE_Proactor *proactor = 0, - bool validate_new_connection = true); - - /// This initiates a new asynchronous connect - virtual int connect (const ACE_INET_Addr &remote_sap, - const ACE_INET_Addr &local_sap = - (const ACE_INET_Addr &)ACE_Addr::sap_any, - int reuse_addr = 1, - const void *act = 0); - - /** - * This cancels all pending accepts operations that were issued by - * the calling thread. - * - * @note On Windows, this method does not cancel connect operations - * issued by other threads. - * - * @note On POSIX, delegates cancelation to ACE_POSIX_Asynch_Connect. - */ - virtual int cancel (void); - - - /** - * Template method to validate peer before service is opened. - * This method is called when the connection attempt completes, - * whether it succeeded or failed, if the @a validate_connection - * argument to @c open() was non-zero or the @c validate_new_connection() - * method is called to turn this feature on. The default implementation - * returns 0. Users can (and probably should) reimplement this method - * to learn about the success or failure of the connection attempt. - * If the connection completed successfully, this method can be used to - * perform validation of the peer using it's address, running an - * authentication procedure (such as SSL) or anything else necessary or - * desireable. The return value from this method determines whether or - * not ACE will continue opening the service or abort the connection. - * - * @param result Result of the connection acceptance. Use - * result.success() to determine success or failure of - * the connection attempt. - * @param remote Peer's address. If the connection failed, this object - * is undefined. - * @param local Local address connection was completed from. If the - * connection failed, this object is undefined. - * - * @retval -1 ACE_Asynch_Connector will close the connection, and - * the service will not be opened. - * @retval 0 Service opening will proceeed. - * @return Return value is ignored if the connection attempt failed. - */ - virtual int validate_connection (const ACE_Asynch_Connect::Result& result, - const ACE_INET_Addr &remote, - const ACE_INET_Addr& local); - - // - // These are low level tweaking methods - // - - /// Set and get flag that indicates if parsing and passing of - /// addresses to the service_handler is necessary. - virtual bool pass_addresses (void) const; - virtual void pass_addresses (bool new_value); - - /// Set and get flag that indicates if address validation is - /// required. - virtual bool validate_new_connection (void) const; - virtual void validate_new_connection (bool new_value); - -protected: - - /// This is called when an outstanding accept completes. - virtual void handle_connect (const ACE_Asynch_Connect::Result &result); - - - /// This parses the address from read buffer. - void parse_address (const ACE_Asynch_Connect::Result &result, - ACE_INET_Addr &remote_address, - ACE_INET_Addr &local_address); - - /// Return the asynch Connect object. - ACE_Asynch_Connect & asynch_connect (void); - - /** - * This is the template method used to create new handler. - * Subclasses must overwrite this method if a new handler creation - * strategy is required. - */ - virtual HANDLER *make_handler (void); - -private: - - /// Asynch_Connect used to make life easier :-) - ACE_Asynch_Connect asynch_connect_; - - /// Flag that indicates if parsing of addresses is necessary. - bool pass_addresses_; - - /// Flag that indicates if address validation is required. - bool validate_new_connection_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Asynch_Connector.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Asynch_Connector.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#endif /* ACE_WIN32 || ACE_HAS_AIO_CALLS */ -#include /**/ "ace/post.h" -#endif /* ACE_ASYNCH_CONNECTOR_H */ diff --git a/ACE/ace/Asynch_IO.cpp b/ACE/ace/Asynch_IO.cpp deleted file mode 100644 index 3ebf11eff5c..00000000000 --- a/ACE/ace/Asynch_IO.cpp +++ /dev/null @@ -1,1411 +0,0 @@ -// $Id$ - -#include "ace/Asynch_IO.h" - -ACE_RCSID(ace, Asynch_IO, "$Id$") - -#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) -// This only works on platforms with Asynchronous IO - -#include "ace/Proactor.h" -#include "ace/Message_Block.h" -#include "ace/INET_Addr.h" -#include "ace/Asynch_IO_Impl.h" -#include "ace/os_include/os_errno.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -size_t -ACE_Asynch_Result::bytes_transferred (void) const -{ - return this->implementation ()->bytes_transferred (); -} - -const void * -ACE_Asynch_Result::act (void) const -{ - return this->implementation ()->act (); -} - -int -ACE_Asynch_Result::success (void) const -{ - return this->implementation ()->success (); -} - -const void * -ACE_Asynch_Result::completion_key (void) const -{ - return this->implementation ()->completion_key (); -} - -unsigned long -ACE_Asynch_Result::error (void) const -{ - return this->implementation ()->error (); -} - -ACE_HANDLE -ACE_Asynch_Result::event (void) const -{ - return this->implementation ()->event (); -} - -unsigned long -ACE_Asynch_Result::offset (void) const -{ - return this->implementation ()->offset (); -} - -unsigned long -ACE_Asynch_Result::offset_high (void) const -{ - return this->implementation ()->offset_high (); -} - -int -ACE_Asynch_Result::priority (void) const -{ - return this->implementation ()->priority (); -} - -int -ACE_Asynch_Result::signal_number (void) const -{ - return this->implementation ()->signal_number (); -} - -ACE_Asynch_Result::ACE_Asynch_Result (ACE_Asynch_Result_Impl *implementation) - : implementation_ (implementation) -{ -} - -ACE_Asynch_Result::~ACE_Asynch_Result (void) -{ - // Proactor deletes the implementation when the finishes. -} - -ACE_Asynch_Result_Impl * -ACE_Asynch_Result::implementation (void) const -{ - return this->implementation_; -} - -// ********************************************************************* - -int -ACE_Asynch_Operation::open (ACE_Handler &handler, - ACE_HANDLE handle, - const void *completion_key, - ACE_Proactor *proactor) -{ - return this->implementation ()->open (handler.proxy (), - handle, - completion_key, - proactor); -} - -int -ACE_Asynch_Operation::cancel (void) -{ - if (0 == this->implementation ()) - { - errno = EFAULT; - return -1; - } - return this->implementation ()->cancel (); -} - -ACE_Proactor * -ACE_Asynch_Operation::proactor (void) const -{ - if (0 == this->implementation ()) - { - errno = EFAULT; - return 0; - } - return this->implementation ()->proactor (); -} - -ACE_Asynch_Operation::ACE_Asynch_Operation (void) -{ -} - -ACE_Asynch_Operation::~ACE_Asynch_Operation (void) -{ -} - -ACE_Proactor * -ACE_Asynch_Operation::get_proactor (ACE_Proactor *user_proactor, - ACE_Handler &handler) const -{ - if (user_proactor == 0) - { - // Grab the singleton proactor if proactor> is zero - user_proactor = handler.proactor (); - if (user_proactor == 0) - user_proactor = ACE_Proactor::instance (); - } - - return user_proactor; -} - -// ************************************************************ - -ACE_Asynch_Read_Stream::ACE_Asynch_Read_Stream (void) - : implementation_ (0) -{ -} - -ACE_Asynch_Read_Stream::~ACE_Asynch_Read_Stream (void) -{ - // Delete the implementation. - delete this->implementation_; - this->implementation_ = 0; -} - -int -ACE_Asynch_Read_Stream::open (ACE_Handler &handler, - ACE_HANDLE handle, - const void *completion_key, - ACE_Proactor *proactor) -{ - // Get a proactor for/from the user. - proactor = this->get_proactor (proactor, handler); - - // Now let us get the implementation initialized. - if ((this->implementation_ = proactor->create_asynch_read_stream ()) == 0) - return -1; - - // Call the method of the base class. - return ACE_Asynch_Operation::open (handler, - handle, - completion_key, - proactor); -} - -int -ACE_Asynch_Read_Stream::read (ACE_Message_Block &message_block, - size_t bytes_to_read, - const void *act, - int priority, - int signal_number) -{ - if (0 == this->implementation_) - { - errno = EFAULT; - return -1; - } - return this->implementation_->read (message_block, - bytes_to_read, - act, - priority, - signal_number); -} - -#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) -int -ACE_Asynch_Read_Stream::readv (ACE_Message_Block &message_block, - size_t bytes_to_read, - const void *act, - int priority, - int signal_number) -{ - if (0 == this->implementation_) - { - errno = EFAULT; - return -1; - } - return this->implementation_->readv (message_block, - bytes_to_read, - act, - priority, - signal_number); -} -#endif /* ACE_HAS_WIN32_OVERLAPPED_IO */ - -ACE_Asynch_Operation_Impl * -ACE_Asynch_Read_Stream::implementation (void) const -{ - return this->implementation_; -} - -// ************************************************************ - -size_t -ACE_Asynch_Read_Stream::Result::bytes_to_read (void) const -{ - return this->implementation ()->bytes_to_read (); -} - -ACE_Message_Block & -ACE_Asynch_Read_Stream::Result::message_block (void) const -{ - return this->implementation ()->message_block (); -} - -ACE_HANDLE -ACE_Asynch_Read_Stream::Result::handle (void) const -{ - return this->implementation ()->handle (); -} - -ACE_Asynch_Read_Stream::Result::Result (ACE_Asynch_Read_Stream_Result_Impl *implementation) - : ACE_Asynch_Result (implementation), - implementation_ (implementation) -{ -} - -ACE_Asynch_Read_Stream::Result::~Result (void) -{ - // Proactor will delete the implementation after is - // finished. -} - -ACE_Asynch_Read_Stream_Result_Impl * -ACE_Asynch_Read_Stream::Result::implementation (void) const -{ - return this->implementation_; -} - -// *************************************************** - -ACE_Asynch_Write_Stream::ACE_Asynch_Write_Stream (void) - : implementation_ (0) -{ -} - -ACE_Asynch_Write_Stream::~ACE_Asynch_Write_Stream (void) -{ - // Delete the implementation. - delete this->implementation_; - this->implementation_ = 0; -} - -int -ACE_Asynch_Write_Stream::open (ACE_Handler &handler, - ACE_HANDLE handle, - const void *completion_key, - ACE_Proactor *proactor) -{ - // Get a proactor for/from the user. - proactor = this->get_proactor (proactor, handler); - - // Now let us get the implementation initialized. - if ((this->implementation_ = proactor->create_asynch_write_stream ()) == 0) - return -1; - - // Call the method of the base class. - return ACE_Asynch_Operation::open (handler, - handle, - completion_key, - proactor); -} - -int -ACE_Asynch_Write_Stream::write (ACE_Message_Block &message_block, - size_t bytes_to_write, - const void *act, - int priority, - int signal_number) -{ - if (0 == this->implementation_) - { - errno = EFAULT; - return -1; - } - return this->implementation_->write (message_block, - bytes_to_write, - act, - priority, - signal_number); -} - -#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) -int -ACE_Asynch_Write_Stream::writev (ACE_Message_Block &message_block, - size_t bytes_to_write, - const void *act, - int priority, - int signal_number) -{ - if (0 == this->implementation_) - { - errno = EFAULT; - return -1; - } - return this->implementation_->writev (message_block, - bytes_to_write, - act, - priority, - signal_number); -} -#endif /* ACE_HAS_WIN32_OVERLAPPED_IO */ - -ACE_Asynch_Operation_Impl * -ACE_Asynch_Write_Stream::implementation (void) const -{ - return this->implementation_; -} - -// ************************************************************ - -size_t -ACE_Asynch_Write_Stream::Result::bytes_to_write (void) const -{ - return this->implementation ()->bytes_to_write (); -} - -ACE_Message_Block & -ACE_Asynch_Write_Stream::Result::message_block (void) const -{ - return this->implementation ()->message_block (); -} - -ACE_HANDLE -ACE_Asynch_Write_Stream::Result::handle (void) const -{ - return this->implementation ()->handle (); -} - -ACE_Asynch_Write_Stream::Result::Result (ACE_Asynch_Write_Stream_Result_Impl *implementation) - : ACE_Asynch_Result (implementation), - implementation_ (implementation) -{ -} - -ACE_Asynch_Write_Stream::Result::~Result (void) -{ - // Proactor will delte the implementation when the call - // finishes. -} - -ACE_Asynch_Write_Stream_Result_Impl * -ACE_Asynch_Write_Stream::Result::implementation (void) const -{ - return this->implementation_; -} - -// ************************************************************ - -ACE_Asynch_Read_File::ACE_Asynch_Read_File (void) - : implementation_ (0) -{ -} - -ACE_Asynch_Read_File::~ACE_Asynch_Read_File (void) -{ - // Delete the implementation. - delete this->implementation_; - this->implementation_ = 0; -} - -int -ACE_Asynch_Read_File::open (ACE_Handler &handler, - ACE_HANDLE handle, - const void *completion_key, - ACE_Proactor *proactor) -{ - // Get a proactor for/from the user. - proactor = this->get_proactor (proactor, handler); - - // Now let us get the implementation initialized. - if ((this->implementation_ = proactor->create_asynch_read_file ()) == 0) - return -1; - - // Call the method of the base class. - return ACE_Asynch_Operation::open (handler, - handle, - completion_key, - proactor); -} - -int -ACE_Asynch_Read_File::read (ACE_Message_Block &message_block, - size_t bytes_to_read, - unsigned long offset, - unsigned long offset_high, - const void *act, - int priority, - int signal_number) -{ - if (0 == this->implementation_) - { - errno = EFAULT; - return -1; - } - return this->implementation_->read (message_block, - bytes_to_read, - offset, - offset_high, - act, - priority, - signal_number); -} - -#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) -int -ACE_Asynch_Read_File::readv (ACE_Message_Block &message_block, - size_t bytes_to_read, - unsigned long offset, - unsigned long offset_high, - const void *act, - int priority, - int signal_number) -{ - if (0 == this->implementation_) - { - errno = EFAULT; - return -1; - } - return this->implementation_->readv (message_block, - bytes_to_read, - offset, - offset_high, - act, - priority, - signal_number); -} -#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */ - -ACE_Asynch_Operation_Impl * -ACE_Asynch_Read_File::implementation (void) const -{ - return this->implementation_; -} - -// ************************************************************ - -ACE_Asynch_Read_File::Result::Result (ACE_Asynch_Read_File_Result_Impl *implementation) - : ACE_Asynch_Read_Stream::Result (implementation), - implementation_ (implementation) -{ -} - -ACE_Asynch_Read_File::Result::~Result (void) -{ - // Proactor will delete the implementation when call - // completes. -} - -ACE_Asynch_Read_File_Result_Impl * -ACE_Asynch_Read_File::Result::implementation (void) const -{ - return this->implementation_; -} - -// ************************************************************ - -ACE_Asynch_Write_File::ACE_Asynch_Write_File (void) - : implementation_ (0) -{ -} - -ACE_Asynch_Write_File::~ACE_Asynch_Write_File (void) -{ - // Delete the implementation. - delete this->implementation_; - this->implementation_ = 0; -} - -int -ACE_Asynch_Write_File::open (ACE_Handler &handler, - ACE_HANDLE handle, - const void *completion_key, - ACE_Proactor *proactor) -{ - // Get a proactor for/from the user. - proactor = this->get_proactor (proactor, handler); - - // Now let us get the implementation initialized. - if ((this->implementation_ = proactor->create_asynch_write_file ()) == 0) - return -1; - - // Call the method of the base class. - return ACE_Asynch_Operation::open (handler, - handle, - completion_key, - proactor); -} - -int -ACE_Asynch_Write_File::write (ACE_Message_Block &message_block, - size_t bytes_to_write, - unsigned long offset, - unsigned long offset_high, - const void *act, - int priority, - int signal_number) -{ - if (0 == this->implementation_) - { - errno = EFAULT; - return -1; - } - return this->implementation_->write (message_block, - bytes_to_write, - offset, - offset_high, - act, - priority, - signal_number); -} - -#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) -int -ACE_Asynch_Write_File::writev (ACE_Message_Block &message_block, - size_t bytes_to_write, - unsigned long offset, - unsigned long offset_high, - const void *act, - int priority, - int signal_number) -{ - if (0 == this->implementation_) - { - errno = EFAULT; - return -1; - } - return this->implementation_->writev (message_block, - bytes_to_write, - offset, - offset_high, - act, - priority, - signal_number); -} -#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */ - -ACE_Asynch_Operation_Impl * -ACE_Asynch_Write_File::implementation (void) const -{ - return this->implementation_; -} - -// ************************************************************ - -ACE_Asynch_Write_File::Result::Result (ACE_Asynch_Write_File_Result_Impl *implementation) - : ACE_Asynch_Write_Stream::Result (implementation), - implementation_ (implementation) -{ -} - -ACE_Asynch_Write_File::Result::~Result (void) -{ - // Proactor will delete the implementation when the call - // completes. -} - -ACE_Asynch_Write_File_Result_Impl * -ACE_Asynch_Write_File::Result::implementation (void) const -{ - return this->implementation_; -} - -// ********************************************************************* - -ACE_Asynch_Accept::ACE_Asynch_Accept (void) - : implementation_ (0) -{ -} - -ACE_Asynch_Accept::~ACE_Asynch_Accept (void) -{ - // Delete the implementation. - delete this->implementation_; - this->implementation_ = 0; -} - -int -ACE_Asynch_Accept::open (ACE_Handler &handler, - ACE_HANDLE handle, - const void *completion_key, - ACE_Proactor *proactor) -{ - // Get a proactor for/from the user. - proactor = this->get_proactor (proactor, handler); - - // Now let us get the implementation initialized. - if ((this->implementation_ = proactor->create_asynch_accept ()) == 0) - return -1; - - // Call the method of the base class. - return ACE_Asynch_Operation::open (handler, - handle, - completion_key, - proactor); -} - -int -ACE_Asynch_Accept::accept (ACE_Message_Block &message_block, - size_t bytes_to_read, - ACE_HANDLE accept_handle, - const void *act, - int priority, - int signal_number, - int addr_family) -{ - if (0 == this->implementation_) - { - errno = EFAULT; - return -1; - } - return this->implementation_->accept (message_block, - bytes_to_read, - accept_handle, - act, - priority, - signal_number, - addr_family); -} - -ACE_Asynch_Operation_Impl * -ACE_Asynch_Accept::implementation (void) const -{ - return this->implementation_; -} - -// ************************************************************ - -size_t -ACE_Asynch_Accept::Result::bytes_to_read (void) const -{ - return this->implementation ()->bytes_to_read (); -} - -ACE_Message_Block & -ACE_Asynch_Accept::Result::message_block (void) const -{ - return this->implementation ()->message_block (); -} - -ACE_HANDLE -ACE_Asynch_Accept::Result::listen_handle (void) const -{ - return this->implementation ()->listen_handle (); -} - -ACE_HANDLE -ACE_Asynch_Accept::Result::accept_handle (void) const -{ - return this->implementation ()->accept_handle (); -} - -ACE_Asynch_Accept::Result::Result (ACE_Asynch_Accept_Result_Impl *implementation) - : ACE_Asynch_Result (implementation), - implementation_ (implementation) -{ -} - -ACE_Asynch_Accept::Result::~Result (void) -{ - // Proactor will delete the implementation when the call - // completes. -} - -ACE_Asynch_Accept_Result_Impl * -ACE_Asynch_Accept::Result::implementation (void) const -{ - return this->implementation_; -} - - - -// ********************************************************************* - -ACE_Asynch_Connect::ACE_Asynch_Connect (void) - : implementation_ (0) -{ -} - -ACE_Asynch_Connect::~ACE_Asynch_Connect (void) -{ - // Delete the implementation. - delete this->implementation_; - this->implementation_ = 0; -} - -int -ACE_Asynch_Connect::open (ACE_Handler &handler, - ACE_HANDLE handle, - const void *completion_key, - ACE_Proactor *proactor) -{ - // Get a proactor for/from the user. - proactor = this->get_proactor (proactor, handler); - - // Now let us get the implementation initialized. - if ((this->implementation_ = proactor->create_asynch_connect ()) == 0) - return -1; - - // Call the method of the base class. - return ACE_Asynch_Operation::open (handler, - handle, - completion_key, - proactor); -} - -int -ACE_Asynch_Connect::connect (ACE_HANDLE connect_handle, - const ACE_Addr & remote_sap, - const ACE_Addr & local_sap, - int reuse_addr, - const void *act, - int priority, - int signal_number) -{ - if (0 == this->implementation_) - { - errno = EFAULT; - return -1; - } - return this->implementation_->connect (connect_handle, - remote_sap, - local_sap, - reuse_addr, - act, - priority, - signal_number); -} - -ACE_Asynch_Operation_Impl * -ACE_Asynch_Connect::implementation (void) const -{ - return this->implementation_; -} - -// ************************************************************ - -ACE_Asynch_Connect::Result::Result (ACE_Asynch_Connect_Result_Impl *implementation) - : ACE_Asynch_Result (implementation), - implementation_ (implementation) -{ -} - -ACE_Asynch_Connect::Result::~Result (void) -{ - // Proactor will delete the implementation when the call - // completes. -} - -ACE_HANDLE -ACE_Asynch_Connect::Result::connect_handle (void) const -{ - return this->implementation ()->connect_handle (); -} - - -ACE_Asynch_Connect_Result_Impl * -ACE_Asynch_Connect::Result::implementation (void) const -{ - return this->implementation_; -} - -// ************************************************************ - -ACE_Asynch_Transmit_File::ACE_Asynch_Transmit_File (void) - : implementation_ (0) -{ -} - -ACE_Asynch_Transmit_File::~ACE_Asynch_Transmit_File (void) -{ - // Delete the implementation. - delete this->implementation_; - this->implementation_ = 0; -} - -int -ACE_Asynch_Transmit_File::open (ACE_Handler &handler, - ACE_HANDLE handle, - const void *completion_key, - ACE_Proactor *proactor) -{ - // Get a proactor for/from the user. - proactor = this->get_proactor (proactor, handler); - - // Now let us get the implementation initialized. - if ((this->implementation_ = proactor->create_asynch_transmit_file ()) == 0) - return -1; - - // Call the method of the base class. - return ACE_Asynch_Operation::open (handler, - handle, - completion_key, - proactor); -} - -int -ACE_Asynch_Transmit_File::transmit_file (ACE_HANDLE file, - Header_And_Trailer *header_and_trailer, - size_t bytes_to_write, - unsigned long offset, - unsigned long offset_high, - size_t bytes_per_send, - unsigned long flags, - const void *act, - int priority, - int signal_number) -{ - if (0 == this->implementation_) - { - errno = EFAULT; - return -1; - } - return this->implementation_->transmit_file (file, - header_and_trailer, - bytes_to_write, - offset, - offset_high, - bytes_per_send, - flags, - act, - priority, - signal_number); -} - -ACE_Asynch_Operation_Impl * -ACE_Asynch_Transmit_File::implementation (void) const -{ - return this->implementation_; -} - -// **************************************************************************** - -ACE_HANDLE -ACE_Asynch_Transmit_File::Result::socket (void) const -{ - return this->implementation ()->socket (); -} - -ACE_HANDLE -ACE_Asynch_Transmit_File::Result::file (void) const -{ - return this->implementation ()->file (); -} - -ACE_Asynch_Transmit_File::Header_And_Trailer * -ACE_Asynch_Transmit_File::Result::header_and_trailer (void) const -{ - return this->implementation ()->header_and_trailer (); -} - -size_t -ACE_Asynch_Transmit_File::Result::bytes_to_write (void) const -{ - return this->implementation ()->bytes_to_write (); -} - -size_t -ACE_Asynch_Transmit_File::Result::bytes_per_send (void) const -{ - return this->implementation ()->bytes_per_send (); -} - -unsigned long -ACE_Asynch_Transmit_File::Result::flags (void) const -{ - return this->implementation ()->flags (); -} - -ACE_Asynch_Transmit_File::Result::Result (ACE_Asynch_Transmit_File_Result_Impl *implementation) - : ACE_Asynch_Result (implementation), - implementation_ (implementation) -{ -} - -ACE_Asynch_Transmit_File::Result::~Result (void) -{ -} - -ACE_Asynch_Transmit_File_Result_Impl * -ACE_Asynch_Transmit_File::Result::implementation (void) const -{ - return this->implementation_; -} - -// ************************************************************ - -ACE_Asynch_Transmit_File::Header_And_Trailer::Header_And_Trailer (ACE_Message_Block *header, - size_t header_bytes, - ACE_Message_Block *trailer, - size_t trailer_bytes) - : header_ (header), - header_bytes_ (header_bytes), - trailer_ (trailer), - trailer_bytes_ (trailer_bytes) -{ -} - -ACE_Asynch_Transmit_File::Header_And_Trailer::~Header_And_Trailer (void) -{ -} - -void -ACE_Asynch_Transmit_File::Header_And_Trailer::header_and_trailer (ACE_Message_Block *header, - size_t header_bytes, - ACE_Message_Block *trailer, - size_t trailer_bytes) -{ - this->header (header); - this->header_bytes (header_bytes); - this->trailer (trailer); - this->trailer_bytes (trailer_bytes); -} - -ACE_Message_Block * -ACE_Asynch_Transmit_File::Header_And_Trailer::header (void) const -{ - return this->header_; -} - -void -ACE_Asynch_Transmit_File::Header_And_Trailer::header (ACE_Message_Block *message_block) -{ - this->header_ = message_block; -} - -size_t -ACE_Asynch_Transmit_File::Header_And_Trailer::header_bytes (void) const -{ - return this->header_bytes_; -} - -void -ACE_Asynch_Transmit_File::Header_And_Trailer::header_bytes (size_t bytes) -{ - this->header_bytes_ = bytes; -} - -ACE_Message_Block * -ACE_Asynch_Transmit_File::Header_And_Trailer::trailer (void) const -{ - return this->trailer_; -} - -void -ACE_Asynch_Transmit_File::Header_And_Trailer::trailer (ACE_Message_Block *message_block) -{ - this->trailer_ = message_block; -} - -size_t -ACE_Asynch_Transmit_File::Header_And_Trailer::trailer_bytes (void) const -{ - return this->trailer_bytes_; -} - -void -ACE_Asynch_Transmit_File::Header_And_Trailer::trailer_bytes (size_t bytes) -{ - this->trailer_bytes_ = bytes; -} - -ACE_LPTRANSMIT_FILE_BUFFERS -ACE_Asynch_Transmit_File::Header_And_Trailer::transmit_buffers (void) -{ - // If both are zero, return zero - if (this->header_ == 0 && this->trailer_ == 0) - return 0; - else - { - // Something is valid - - // If header is valid, set the fields - if (this->header_ != 0) - { - this->transmit_buffers_.Head = this->header_->rd_ptr (); -#if defined(ACE_WIN64) - this->transmit_buffers_.HeadLength = - static_cast (this->header_bytes_); -#else - this->transmit_buffers_.HeadLength = this->header_bytes_; -#endif /* ACE_WIN64 */ - } - else - { - this->transmit_buffers_.Head = 0; - this->transmit_buffers_.HeadLength = 0; - } - - // If trailer is valid, set the fields - if (this->trailer_ != 0) - { - this->transmit_buffers_.Tail = this->trailer_->rd_ptr (); -#if defined(ACE_WIN64) - this->transmit_buffers_.TailLength = - static_cast (this->trailer_bytes_); -#else - this->transmit_buffers_.TailLength = this->trailer_bytes_; -#endif /* ACE_WIN64 */ - } - else - { - this->transmit_buffers_.Tail = 0; - this->transmit_buffers_.TailLength = 0; - } - - // Return the transmit buffers - return &this->transmit_buffers_; - } -} - -// ********************************************************************* - -ACE_Handler::ACE_Handler (void) - : proactor_ (0), handle_ (ACE_INVALID_HANDLE) -{ - ACE_Handler::Proxy *p; - ACE_NEW (p, ACE_Handler::Proxy (this)); - this->proxy_.reset (p); -} - -ACE_Handler::ACE_Handler (ACE_Proactor *d) - : proactor_ (d), handle_ (ACE_INVALID_HANDLE) -{ - ACE_Handler::Proxy *p; - ACE_NEW (p, ACE_Handler::Proxy (this)); - this->proxy_.reset (p); -} - -ACE_Handler::~ACE_Handler (void) -{ - ACE_Handler::Proxy *p = this->proxy_.get (); - if (p) - p->reset (); -} - -void -ACE_Handler::handle_read_stream (const ACE_Asynch_Read_Stream::Result & /* result */) -{ -} - -void -ACE_Handler::handle_write_stream (const ACE_Asynch_Write_Stream::Result & /* result */) -{ -} - -void -ACE_Handler::handle_write_dgram (const ACE_Asynch_Write_Dgram::Result & /* result */) -{ -} - -void -ACE_Handler::handle_read_dgram (const ACE_Asynch_Read_Dgram::Result & /* result */) -{ -} - -void -ACE_Handler::handle_accept (const ACE_Asynch_Accept::Result & /* result */) -{ -} - -void -ACE_Handler::handle_connect (const ACE_Asynch_Connect::Result & /* result */) -{ -} - -void -ACE_Handler::handle_transmit_file (const ACE_Asynch_Transmit_File::Result & /* result */) -{ -} - -void -ACE_Handler::handle_read_file (const ACE_Asynch_Read_File::Result & /* result */) -{ -} - -void -ACE_Handler::handle_write_file (const ACE_Asynch_Write_File::Result & /* result */) -{ -} - -void -ACE_Handler::handle_time_out (const ACE_Time_Value & /* tv */, - const void * /* act */) -{ -} - -void -ACE_Handler::handle_wakeup (void) -{ -} - -ACE_Proactor * -ACE_Handler::proactor (void) -{ - return this->proactor_; -} - -void -ACE_Handler::proactor (ACE_Proactor *p) -{ - this->proactor_ = p; -} - -ACE_HANDLE -ACE_Handler::handle (void) const -{ - return this->handle_; -} - -void -ACE_Handler::handle (ACE_HANDLE h) -{ - this->handle_ = h; -} - -ACE_Refcounted_Auto_Ptr & -ACE_Handler::proxy (void) -{ - return this->proxy_; -} - -// ************************************************************ - -ACE_Service_Handler::ACE_Service_Handler (void) -{ -} - -ACE_Service_Handler::~ACE_Service_Handler (void) -{ -} - -void -ACE_Service_Handler::addresses (const ACE_INET_Addr & /* remote_address */, - const ACE_INET_Addr & /* local_address */ ) -{ -} - -void -ACE_Service_Handler::act (const void *) -{ -} - -void -ACE_Service_Handler::open (ACE_HANDLE, - ACE_Message_Block &) -{ -} - - -// ************************************************************ - -ACE_Asynch_Read_Dgram::ACE_Asynch_Read_Dgram (void) - : implementation_ (0) -{ -} - -ACE_Asynch_Read_Dgram::~ACE_Asynch_Read_Dgram (void) -{ - // Delete the implementation. - delete this->implementation_; - this->implementation_ = 0; -} - -int -ACE_Asynch_Read_Dgram::open (ACE_Handler &handler, - ACE_HANDLE handle, - const void *completion_key, - ACE_Proactor *proactor) -{ - // Get a proactor for/from the user. - proactor = this->get_proactor (proactor, handler); - - // Now let us get the implementation initialized. - if ((this->implementation_ = proactor->create_asynch_read_dgram ()) == 0) - return -1; - - // Call the method of the base class. - return ACE_Asynch_Operation::open (handler, - handle, - completion_key, - proactor); -} - -ssize_t -ACE_Asynch_Read_Dgram::recv (ACE_Message_Block *message_block, - size_t &number_of_bytes_recvd, - int flags, - int protocol_family, - const void *act, - int priority, - int signal_number) -{ - if (0 == this->implementation_) - { - errno = EFAULT; - return -1; - } - return this->implementation_->recv (message_block, - number_of_bytes_recvd, - flags, - protocol_family, - act, - priority, - signal_number); -} - -ACE_Asynch_Operation_Impl * -ACE_Asynch_Read_Dgram::implementation (void) const -{ - return this->implementation_; -} - -// ************************************************************ - -int -ACE_Asynch_Read_Dgram::Result::remote_address (ACE_Addr& addr) const -{ - return this->implementation ()->remote_address (addr); -} - -ACE_Message_Block* -ACE_Asynch_Read_Dgram::Result::message_block (void) const -{ - return this->implementation ()->message_block (); -} - -int -ACE_Asynch_Read_Dgram::Result::flags (void) const -{ - return this->implementation ()->flags (); -} - -size_t -ACE_Asynch_Read_Dgram::Result::bytes_to_read (void) const -{ - return this->implementation ()->bytes_to_read (); -} - -ACE_HANDLE -ACE_Asynch_Read_Dgram::Result::handle (void) const -{ - return this->implementation ()->handle(); -} - -ACE_Asynch_Read_Dgram::Result::Result (ACE_Asynch_Read_Dgram_Result_Impl *implementation) -: ACE_Asynch_Result (implementation), - implementation_ (implementation) -{ -} - -ACE_Asynch_Read_Dgram::Result::~Result (void) -{ -} - -ACE_Asynch_Read_Dgram_Result_Impl * -ACE_Asynch_Read_Dgram::Result::implementation (void) const -{ - return this->implementation_; -} - -// ************************************************************ - - -ACE_Asynch_Write_Dgram::ACE_Asynch_Write_Dgram (void) - : implementation_ (0) -{ -} - -ACE_Asynch_Write_Dgram::~ACE_Asynch_Write_Dgram (void) -{ - // Delete the implementation. - delete this->implementation_; - this->implementation_ = 0; -} - -int -ACE_Asynch_Write_Dgram::open (ACE_Handler &handler, - ACE_HANDLE handle, - const void *completion_key, - ACE_Proactor *proactor) -{ - // Get a proactor for/from the user. - proactor = this->get_proactor (proactor, handler); - - // Now let us get the implementation initialized. - if ((this->implementation_ = proactor->create_asynch_write_dgram ()) == 0) - return -1; - - // Call the method of the base class. - return ACE_Asynch_Operation::open (handler, - handle, - completion_key, - proactor); -} - -ssize_t -ACE_Asynch_Write_Dgram::send (ACE_Message_Block *message_block, - size_t &number_of_bytes_sent, - int flags, - const ACE_Addr& remote_addr, - const void *act, - int priority, - int signal_number) -{ - if (0 == this->implementation_) - { - errno = EFAULT; - return -1; - } - return this->implementation_->send (message_block, - number_of_bytes_sent, - flags, - remote_addr, - act, - priority, - signal_number); -} - -ACE_Asynch_Operation_Impl * -ACE_Asynch_Write_Dgram::implementation (void) const -{ - return this->implementation_; -} - -// ************************************************************ - -size_t -ACE_Asynch_Write_Dgram::Result::bytes_to_write (void) const -{ - return this->implementation ()->bytes_to_write (); -} - -ACE_Message_Block* -ACE_Asynch_Write_Dgram::Result::message_block () const -{ - return this->implementation ()->message_block (); -} - -int -ACE_Asynch_Write_Dgram::Result::flags (void) const -{ - return this->implementation ()->flags (); -} - -ACE_HANDLE -ACE_Asynch_Write_Dgram::Result::handle (void) const -{ - return this->implementation ()->handle (); -} - -ACE_Asynch_Write_Dgram_Result_Impl * -ACE_Asynch_Write_Dgram::Result::implementation (void) const -{ - return this->implementation_; -} - -ACE_Asynch_Write_Dgram::Result::Result (ACE_Asynch_Write_Dgram_Result_Impl *implementation) -: ACE_Asynch_Result (implementation), - implementation_ (implementation) -{ -} - -ACE_Asynch_Write_Dgram::Result::~Result (void) -{ -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ diff --git a/ACE/ace/Asynch_IO.h b/ACE/ace/Asynch_IO.h deleted file mode 100644 index e71c16ca3ee..00000000000 --- a/ACE/ace/Asynch_IO.h +++ /dev/null @@ -1,1690 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file Asynch_IO.h - * - * $Id$ - * - * This works on Win32 (defined (ACE_WIN32) && !defined - * (ACE_HAS_WINCE)) platforms and on POSIX4 platforms with {aio_*} - * routines (defined (ACE_HAS_AIO_CALLS)) - * - * On Win32 platforms, the implementation of - * {ACE_Asynch_Transmit_File} and {ACE_Asynch_Accept} are only - * supported if ACE_HAS_WINSOCK2 is defined or you are on WinNT 4.0 - * or higher. - * - * @author Irfan Pyarali - * @author Tim Harrison - * @author Alexander Babu Arulanthu - * @author Roger Tragin - * @author Alexander Libman - */ -//============================================================================= - -#ifndef ACE_ASYNCH_IO_H -#define ACE_ASYNCH_IO_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) - -#include "ace/Synch_Traits.h" -#if defined (ACE_HAS_THREADS) -# include "ace/Thread_Mutex.h" -#else -# include "ace/Null_Mutex.h" -#endif /* ACE_HAS_THREADS */ -#include "ace/Refcounted_Auto_Ptr.h" - -#include "ace/os_include/os_signal.h" -#include "ace/os_include/sys/os_socket.h" -#include "ace/os_include/sys/os_types.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -# if defined (ACE_HAS_WIN32_OVERLAPPED_IO) -typedef TRANSMIT_FILE_BUFFERS ACE_TRANSMIT_FILE_BUFFERS; -typedef LPTRANSMIT_FILE_BUFFERS ACE_LPTRANSMIT_FILE_BUFFERS; -typedef PTRANSMIT_FILE_BUFFERS ACE_PTRANSMIT_FILE_BUFFERS; - -# define ACE_INFINITE INFINITE -# define ACE_STATUS_TIMEOUT STATUS_TIMEOUT -# define ACE_WAIT_FAILED WAIT_FAILED -# define ACE_WAIT_TIMEOUT WAIT_TIMEOUT -# else /* ACE_HAS_WIN32_OVERLAPPED_IO */ -struct ACE_TRANSMIT_FILE_BUFFERS -{ - void *Head; - size_t HeadLength; - void *Tail; - size_t TailLength; -}; -typedef ACE_TRANSMIT_FILE_BUFFERS* ACE_PTRANSMIT_FILE_BUFFERS; -typedef ACE_TRANSMIT_FILE_BUFFERS* ACE_LPTRANSMIT_FILE_BUFFERS; - -# if !defined (ACE_INFINITE) -# define ACE_INFINITE LONG_MAX -# endif /* ACE_INFINITE */ -# define ACE_STATUS_TIMEOUT LONG_MAX -# define ACE_WAIT_FAILED LONG_MAX -# define ACE_WAIT_TIMEOUT LONG_MAX -# endif /* ACE_HAS_WIN32_OVERLAPPED_IO */ - -// Forward declarations -class ACE_Proactor; -class ACE_Handler; -class ACE_Message_Block; -class ACE_INET_Addr; -class ACE_Addr; - -// Forward declarations -class ACE_Asynch_Result_Impl; -class ACE_Time_Value; - -/** - * @class ACE_Asynch_Result - * - * @brief An interface base class which allows users access to common - * information related to an asynchronous operation. - * - * An interface base class from which you can obtain some basic - * information like the number of bytes transferred, the ACT - * associated with the asynchronous operation, indication of - * success or failure, etc. Subclasses may want to store more - * information that is particular to the asynchronous operation - * it represents. - */ -class ACE_Export ACE_Asynch_Result -{ - -public: - /// Number of bytes transferred by the operation. - size_t bytes_transferred (void) const; - - /// ACT associated with the operation. - const void *act (void) const; - - /// Did the operation succeed? - int success (void) const; - - /** - * This is the ACT associated with the handle on which the - * Asynch_Operation takes place. - * - * On WIN32, this returns the ACT associated with the handle when it - * was registered with the I/O completion port. - * - * @@ This is not implemented for POSIX4 platforms. Returns 0. - */ - const void *completion_key (void) const; - - /// Error value if the operation fails. - unsigned long error (void) const; - - /** - * On WIN32, this returns the event associated with the OVERLAPPED - * structure. - * - * This returns ACE_INVALID_HANDLE on POSIX4-Unix platforms. - */ - ACE_HANDLE event (void) const; - - /** - * This really makes sense only when doing file I/O. - * - * On WIN32, these are represented in the OVERLAPPED datastructure. - * - * @@ On POSIX4-Unix, offset_high should be supported using - * aiocb64. - */ - unsigned long offset (void) const; - unsigned long offset_high (void) const; - - /** - * Priority of the operation. - * - * On POSIX4-Unix, this is supported. Priority works like {nice} in - * Unix. Negative values are not allowed. 0 means priority of the - * operation same as the process priority. 1 means priority of the - * operation is one less than process. And so forth. - * - * On Win32, this is a no-op. - */ - int priority (void) const; - - /** - * POSIX4 real-time signal number to be used for the - * operation. {signal_number} ranges from ACE_SIGRTMIN to ACE_SIGRTMAX. By - * default, ACE_SIGRTMIN is used to issue {aio_} calls. This is a no-op - * on non-POSIX4 systems and returns 0. - */ - int signal_number (void) const; - - - /// Destructor. - virtual ~ACE_Asynch_Result (void); - -protected: - /// Constructor. This implementation will not be deleted. The - /// implementation will be deleted by the Proactor. - ACE_Asynch_Result (ACE_Asynch_Result_Impl *implementation); - - /// Get the implementation class. - ACE_Asynch_Result_Impl *implementation (void) const; - - /// Implementation class. - ACE_Asynch_Result_Impl *implementation_; -}; - -// Forward declarations -class ACE_Asynch_Operation_Impl; - -/** - * @class ACE_Asynch_Operation - * - * @brief This is an interface base class for all asynch - * operations. The resposiblility of this class is to forward - * all methods to its delegation/implementation class, e.g., - * ACE_WIN32_Asynch_Operation or ACE_POSIX_Asynch_Operation. - * - * There are some attributes and functionality which is common - * to all asychronous operations. The delegation classes of this - * class will factor out this code. - */ -class ACE_Export ACE_Asynch_Operation -{ - -public: - /** - * Initializes the factory with information which will be used with - * each asynchronous call. If ({handle} == ACE_INVALID_HANDLE), - * {ACE_Handler::handle} will be called on the {handler} to get the - * correct handle. - */ - int open (ACE_Handler &handler, - ACE_HANDLE handle, - const void *completion_key, - ACE_Proactor *proactor); - - /** - * (Attempts to) cancel the asynchronous operation pending against - * the {handle} registered with this Operation. - * - * All completion notifications for the I/O operations will occur - * normally. - * - * = Return Values: - * - * -1 : Operation failed. (can get only in POSIX). - * 0 : All the operations were cancelled. - * 1 : All the operations were already finished in this - * handle. Unable to cancel them. - * 2 : Atleast one of the requested operations cannot be - * cancelled. - * - * There is slight difference in the semantics between NT and POSIX - * platforms which is given below. - * - * = Win32 : - * - * cancels all pending accepts operations that were issued by the - * calling thread. The function does not cancel asynchronous - * operations issued by other threads. - * All I/O operations that are canceled will complete with the - * error ERROR_OPERATION_ABORTED. - * - * = POSIX: - * - * Attempts to cancel one or more asynchronous I/O requests - * currently outstanding against the {handle} registered in this - * operation. - * For requested operations that are successfully canceled, the - * associated error status is set to ECANCELED. - */ - int cancel (void); - - - // = Access methods. - - /// Return the underlying proactor. - ACE_Proactor* proactor (void) const; - - /// Destructor. - virtual ~ACE_Asynch_Operation (void); - -protected: - /// Constructor. - ACE_Asynch_Operation (void); - - /// Return the underlying implementation class. - virtual ACE_Asynch_Operation_Impl *implementation (void) const = 0; - - /// Get a proactor for/from the user - ACE_Proactor *get_proactor (ACE_Proactor *user_proactor, - ACE_Handler &handler) const; -}; - -// Forward declarations -class ACE_Asynch_Read_Stream_Result_Impl; -class ACE_Asynch_Read_Stream_Impl; - -/** - * @class ACE_Asynch_Read_Stream - * - * @brief This class is a factory for starting off asynchronous reads - * on a stream. This class forwards all methods to its - * implementation class. - * - * Once {open} is called, multiple asynchronous {read}s can - * started using this class. An ACE_Asynch_Read_Stream::Result - * will be passed back to the {handler} when the asynchronous - * reads completes through the {ACE_Handler::handle_read_stream} - * callback. - */ -class ACE_Export ACE_Asynch_Read_Stream : public ACE_Asynch_Operation -{ - -public: - /// A do nothing constructor. - ACE_Asynch_Read_Stream (void); - - /// Destructor - virtual ~ACE_Asynch_Read_Stream (void); - - /** - * Initializes the factory with information which will be used with - * each asynchronous call. - * - * @arg handler The ACE_Handler that will be called to handle completions - * for operations initiated using this factory. - * @arg handle The handle that future read operations will use. - * If handle == @c ACE_INVALID_HANDLE, - * ACE_Handler::handle() will be called on @ handler - * to get the correct handle. - * - * @retval 0 for success. - * @retval -1 for failure; consult @c errno for further information. - */ - int open (ACE_Handler &handler, - ACE_HANDLE handle = ACE_INVALID_HANDLE, - const void *completion_key = 0, - ACE_Proactor *proactor = 0); - - /** - * Initiate an asynchronous read operation. - * - * @arg message_block The ACE_Message_Block to receive the data. - * Received bytes will be placed in the block - * beginning at its current write pointer. - * If data is read, the message block's write - * pointer will be advanced by the number of - * bytes read. - * @arg num_bytes_to_read The maximum number of bytes to read. - * @arg act Asynchronous Completion Token; passed through to - * the Result object corresponding to this operation. - * @arg priority Priority of the operation. On POSIX4-Unix, - * this is supported. Works like @c nice in Unix. - * Negative values are not allowed. 0 means - * priority of the operation same as the process - * priority. 1 means priority of the operation is - * one less than process priority, etc. - * @param is ignored on Windows. - * @arg signal_number The POSIX4 real-time signal number to be used - * to signal completion of the operation. Values - * range from ACE_SIGRTMIN to ACE_SIGRTMAX. - * This argument is ignored on non-POSIX4 systems. - */ - int read (ACE_Message_Block &message_block, - size_t num_bytes_to_read, - const void *act = 0, - int priority = 0, - int signal_number = ACE_SIGRTMIN); - -#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) - /** - * Same as above but with scatter support, through chaining of composite - * message blocks using the continuation field. - */ - int readv (ACE_Message_Block &message_block, - size_t num_bytes_to_read, - const void *act = 0, - int priority = 0, - int signal_number = ACE_SIGRTMIN); -#endif /* defined (ACE_HAS_WIN32_OVERLAPPED_IO) */ - - /// Return the underlying implementation class. - // (this should be protected...) - virtual ACE_Asynch_Operation_Impl *implementation (void) const; - -protected: - /// Implementation class that all methods will be forwarded to. - ACE_Asynch_Read_Stream_Impl *implementation_; - -public: -/** - * @class Result - * - * @brief This is the class which will be passed back to the - * {handler} when the asynchronous read completes. This class - * forwards all the methods to the implementation classes. - * - * This class has all the information necessary for the - * {handler} to uniquiely identify the completion of the - * asynchronous read. - */ - class ACE_Export Result : public ACE_Asynch_Result - { - - /// The concrete implementation result classes only construct this - /// class. - friend class ACE_POSIX_Asynch_Read_Stream_Result; - friend class ACE_WIN32_Asynch_Read_Stream_Result; - - public: - /// The number of bytes which were requested at the start of the - /// asynchronous read. - size_t bytes_to_read (void) const; - - /// Message block which contains the read data. - ACE_Message_Block &message_block (void) const; - - /// I/O handle used for reading. - ACE_HANDLE handle (void) const; - - /// Get the implementation class. - ACE_Asynch_Read_Stream_Result_Impl *implementation (void) const; - - protected: - /// Constructor. - Result (ACE_Asynch_Read_Stream_Result_Impl *implementation); - - /// Destructor. - virtual ~Result (void); - - /// The implementation class. - ACE_Asynch_Read_Stream_Result_Impl *implementation_; - }; -}; - -// Forward declarations -class ACE_Asynch_Write_Stream_Impl; -class ACE_Asynch_Write_Stream_Result_Impl; - -/** - * @class ACE_Asynch_Write_Stream - * - * @brief This class is a factory for starting off asynchronous writes - * on a stream. This class forwards all methods to its - * implementation class. - * - * Once {open} is called, multiple asynchronous {writes}s can - * started using this class. An ACE_Asynch_Write_Stream::Result - * will be passed back to the {handler} when the asynchronous - * write completes through the - * {ACE_Handler::handle_write_stream} callback. - */ -class ACE_Export ACE_Asynch_Write_Stream : public ACE_Asynch_Operation -{ - -public: - /// A do nothing constructor. - ACE_Asynch_Write_Stream (void); - - /// Destructor. - virtual ~ACE_Asynch_Write_Stream (void); - - /** - * Initializes the factory with information which will be used with - * each asynchronous call. If ({handle} == ACE_INVALID_HANDLE), - * {ACE_Handler::handle} will be called on the {handler} to get the - * correct handle. - */ - int open (ACE_Handler &handler, - ACE_HANDLE handle = ACE_INVALID_HANDLE, - const void *completion_key = 0, - ACE_Proactor *proactor = 0); - - /** - * This starts off an asynchronous write. Upto {bytes_to_write} - * will be written from the {message_block}. Upon successful completion - * of the write operation, {message_block}'s {rd_ptr} is updated to - * reflect the data that was written. Priority of the - * operation is specified by {priority}. On POSIX4-Unix, this is - * supported. Works like {nice} in Unix. Negative values are not - * allowed. 0 means priority of the operation same as the process - * priority. 1 means priority of the operation is one less than - * process. And so forth. On Win32, this argument is a no-op. - * {signal_number} is the POSIX4 real-time signal number to be used - * for the operation. {signal_number} ranges from ACE_SIGRTMIN to - * ACE_SIGRTMAX. This argument is a no-op on non-POSIX4 systems. - */ - int write (ACE_Message_Block &message_block, - size_t bytes_to_write, - const void *act = 0, - int priority = 0, - int signal_number = ACE_SIGRTMIN); - -#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) - /** - * Same as above but with gather support, through chaining of composite - * message blocks using the continuation field. - */ - int writev (ACE_Message_Block &message_block, - size_t bytes_to_write, - const void *act = 0, - int priority = 0, - int signal_number = ACE_SIGRTMIN); -#endif /* defined (ACE_HAS_WIN32_OVERLAPPED_IO) */ - - /// Return the underlying implementation class. - /// @todo (this should be protected...) - virtual ACE_Asynch_Operation_Impl *implementation (void) const; - -protected: - /// Implementation class that all methods will be forwarded to. - ACE_Asynch_Write_Stream_Impl *implementation_; - -public: -/** - * @class Result - * - * @brief This is that class which will be passed back to the - * {handler} when the asynchronous write completes. This class - * forwards all the methods to the implementation class. - * - * This class has all the information necessary for the - * {handler} to uniquiely identify the completion of the - * asynchronous write. - */ - class ACE_Export Result : public ACE_Asynch_Result - { - - /// The concrete implementation result classes only construct this - /// class. - friend class ACE_POSIX_Asynch_Write_Stream_Result; - friend class ACE_WIN32_Asynch_Write_Stream_Result; - - public: - /// The number of bytes which were requested at the start of the - /// asynchronous write. - size_t bytes_to_write (void) const; - - /// Message block that contains the data to be written. - ACE_Message_Block &message_block (void) const; - - /// I/O handle used for writing. - ACE_HANDLE handle (void) const; - - /// Get the implementation class. - ACE_Asynch_Write_Stream_Result_Impl *implementation (void) const; - - protected: - /// Constructor. - Result (ACE_Asynch_Write_Stream_Result_Impl *implementation); - - /// Destructor. - virtual ~Result (void); - - /// Implementation class. - ACE_Asynch_Write_Stream_Result_Impl *implementation_; - }; -}; - -// Forward declarations -class ACE_Asynch_Read_File_Impl; -class ACE_Asynch_Read_File_Result_Impl; - -/** - * @class ACE_Asynch_Read_File - * - * @brief This class is a factory for starting off asynchronous reads - * on a file. This class forwards all methods to its - * implementation class. - * - * Once {open} is called, multiple asynchronous {read}s can - * started using this class. An ACE_Asynch_Read_File::Result - * will be passed back to the {handler} when the asynchronous - * reads completes through the {ACE_Handler::handle_read_file} - * callback. - * This class differs slightly from ACE_Asynch_Read_Stream as it - * allows the user to specify an offset for the read. - */ -class ACE_Export ACE_Asynch_Read_File : public ACE_Asynch_Read_Stream -{ - -public: - /// A do nothing constructor. - ACE_Asynch_Read_File (void); - - /// Destructor. - virtual ~ACE_Asynch_Read_File (void); - - /** - * Initializes the factory with information which will be used with - * each asynchronous call. If ({handle} == ACE_INVALID_HANDLE), - * {ACE_Handler::handle} will be called on the {handler} to get the - * correct handle. - */ - int open (ACE_Handler &handler, - ACE_HANDLE handle = ACE_INVALID_HANDLE, - const void *completion_key = 0, - ACE_Proactor *proactor = 0); - - /** - * This starts off an asynchronous read. Upto {bytes_to_read} will - * be read and stored in the {message_block}. The read will start - * at {offset} from the beginning of the file. Priority of the - * operation is specified by {priority}. On POSIX4-Unix, this is - * supported. Works like {nice} in Unix. Negative values are not - * allowed. 0 means priority of the operation same as the process - * priority. 1 means priority of the operation is one less than - * process. And so forth. On Win32, this argument is a no-op. - * {signal_number} is the POSIX4 real-time signal number to be used - * for the operation. {signal_number} ranges from ACE_SIGRTMIN to - * ACE_SIGRTMAX. This argument is a no-op on non-POSIX4 systems. - */ - int read (ACE_Message_Block &message_block, - size_t bytes_to_read, - unsigned long offset = 0, - unsigned long offset_high = 0, - const void *act = 0, - int priority = 0, - int signal_number = ACE_SIGRTMIN); - -#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) - /** - * Same as above but with scatter support, through chaining of composite - * message blocks using the continuation field. - * @note In win32 Each data block payload must be at least the size of a system - * memory page and must be aligned on a system memory page size boundary - */ - int readv (ACE_Message_Block &message_block, - size_t bytes_to_read, - unsigned long offset = 0, - unsigned long offset_high = 0, - const void *act = 0, - int priority = 0, - int signal_number = ACE_SIGRTMIN); -#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */ - - /// Return the underlying implementation class. - // (this should be protected...) - virtual ACE_Asynch_Operation_Impl *implementation (void) const; - -protected: - /// Delegation/implementation class that all methods will be - /// forwarded to. - ACE_Asynch_Read_File_Impl *implementation_; - -public: -/** - * @class Result - * - * @brief This is that class which will be passed back to the - * {handler} when the asynchronous read completes. This class - * forwards all the methods to the implementation class. - * - * This class has all the information necessary for the - * {handler} to uniquiely identify the completion of the - * asynchronous read. - * This class differs slightly from - * ACE_Asynch_Read_Stream::Result as it calls back - * {ACE_Handler::handle_read_file} on the {handler} instead of - * {ACE_Handler::handle_read_stream}. No additional state is - * required by this class as ACE_Asynch_Result can store the - * {offset}. - */ - class ACE_Export Result : public ACE_Asynch_Read_Stream::Result - { - - /// The concrete implementation result classes only construct this - /// class. - friend class ACE_POSIX_Asynch_Read_File_Result; - friend class ACE_WIN32_Asynch_Read_File_Result; - - public: - /// Get the implementation class. - ACE_Asynch_Read_File_Result_Impl *implementation (void) const; - - protected: - /// Constructor. This implementation will not be deleted. - Result (ACE_Asynch_Read_File_Result_Impl *implementation); - - /// Destructor. - virtual ~Result (void); - - /// The implementation class. - ACE_Asynch_Read_File_Result_Impl *implementation_; - - private: - /// Here just to provide an dummpy implementation, since the - /// one auto generated by MSVC is flagged as infinitely recursive - void operator= (Result &) {} - }; -}; - -// Forward declarations -class ACE_Asynch_Write_File_Impl; -class ACE_Asynch_Write_File_Result_Impl; - -/** - * @class ACE_Asynch_Write_File - * - * @brief This class is a factory for starting off asynchronous writes - * on a file. This class forwards all methods to its - * implementation class. - * - * Once {open} is called, multiple asynchronous {write}s can be - * started using this class. A ACE_Asynch_Write_File::Result - * will be passed back to the {handler} when the asynchronous - * writes completes through the {ACE_Handler::handle_write_file} - * callback. - * This class differs slightly from ACE_Asynch_Write_Stream as - * it allows the user to specify an offset for the write. - */ -class ACE_Export ACE_Asynch_Write_File : public ACE_Asynch_Write_Stream -{ - -public: - /// A do nothing constructor. - ACE_Asynch_Write_File (void); - - /// Destructor. - virtual ~ACE_Asynch_Write_File (void); - - /** - * Initializes the factory with information which will be used with - * each asynchronous call. If ({handle} == ACE_INVALID_HANDLE), - * {ACE_Handler::handle} will be called on the {handler} to get the - * correct handle. - */ - int open (ACE_Handler &handler, - ACE_HANDLE handle = ACE_INVALID_HANDLE, - const void *completion_key = 0, - ACE_Proactor *proactor = 0); - - /** - * This starts off an asynchronous write. Upto {bytes_to_write} - * will be written from the {message_block}, starting at the - * block's {rd_ptr}. The write will go to the file, starting - * {offset} bytes from the beginning of the file. Priority of the - * operation is specified by {priority}. On POSIX4-Unix, this is - * supported. Works like {nice} in Unix. Negative values are not - * allowed. 0 means priority of the operation same as the process - * priority. 1 means priority of the operation is one less than - * process. And so forth. On Win32, this is a no-op. - * {signal_number} is the POSIX4 real-time signal number to be used - * for the operation. {signal_number} ranges from ACE_SIGRTMIN to - * ACE_SIGRTMAX. This argument is a no-op on non-POSIX4 systems. - */ - int write (ACE_Message_Block &message_block, - size_t bytes_to_write, - unsigned long offset = 0, - unsigned long offset_high = 0, - const void *act = 0, - int priority = 0, - int signal_number = ACE_SIGRTMIN); - -#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) - /** - * Same as above but with gather support, through chaining of composite - * message blocks using the continuation field. - * @note In win32 Each data block payload must be at least the size of a system - * memory page and must be aligned on a system memory page size boundary - */ - int writev (ACE_Message_Block &message_block, - size_t bytes_to_write, - unsigned long offset = 0, - unsigned long offset_high = 0, - const void *act = 0, - int priority = 0, - int signal_number = ACE_SIGRTMIN); -#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */ - - /// Return the underlying implementation class. - // (this should be protected...) - virtual ACE_Asynch_Operation_Impl *implementation (void) const; - -protected: - /// Implementation object. - ACE_Asynch_Write_File_Impl *implementation_; - -public: -/** - * @class Result - * - * @brief This is that class which will be passed back to the - * {handler} when the asynchronous write completes. This class - * forwards all the methods to the implementation class. - * - * This class has all the information necessary for the - * {handler} to uniquiely identify the completion of the - * asynchronous write. - * This class differs slightly from - * ACE_Asynch_Write_Stream::Result as it calls back - * {ACE_Handler::handle_write_file} on the {handler} instead - * of {ACE_Handler::handle_write_stream}. No additional state - * is required by this class as ACE_Asynch_Result can store - * the {offset}. - */ - class ACE_Export Result : public ACE_Asynch_Write_Stream::Result - { - - /// The concrete implementation result classes only construct this - /// class. - friend class ACE_POSIX_Asynch_Write_File_Result; - friend class ACE_WIN32_Asynch_Write_File_Result; - - public: - /// Get the implementation class. - ACE_Asynch_Write_File_Result_Impl *implementation (void) const; - - protected: - /// Constructor. This implementation will not be deleted. - Result (ACE_Asynch_Write_File_Result_Impl *implementation); - - /// Destructor. - virtual ~Result (void); - - /// The implementation class. - ACE_Asynch_Write_File_Result_Impl *implementation_; - - private: - /// Here just to provide an dummpy implementation, since the - /// one auto generated by MSVC is flagged as infinitely recursive - void operator= (Result &) {}; - }; -}; - -// Forward declarations -class ACE_Asynch_Accept_Result_Impl; -class ACE_Asynch_Accept_Impl; - -/** - * @class ACE_Asynch_Accept - * - * @brief This class is a factory for starting off asynchronous accepts - * on a listen handle. This class forwards all methods to its - * implementation class. - * - * Once {open} is called, multiple asynchronous {accept}s can - * started using this class. A ACE_Asynch_Accept::Result will - * be passed back to the {handler} when the asynchronous accept - * completes through the {ACE_Handler::handle_accept} - * callback. - */ -class ACE_Export ACE_Asynch_Accept : public ACE_Asynch_Operation -{ - -public: - /// A do nothing constructor. - ACE_Asynch_Accept (void); - - /// Destructor. - virtual ~ACE_Asynch_Accept (void); - - /** - * Initializes the factory with information which will be used with - * each asynchronous call. If ({handle} == ACE_INVALID_HANDLE), - * {ACE_Handler::handle} will be called on the {handler} to get the - * correct handle. - */ - int open (ACE_Handler &handler, - ACE_HANDLE handle = ACE_INVALID_HANDLE, - const void *completion_key = 0, - ACE_Proactor *proactor = 0); - - /** - * This starts off an asynchronous accept. The asynchronous accept - * call also allows any initial data to be returned to the - * handler specified to @c open(). - * @param message_block A message block to receive initial data, as well - * as the local and remote addresses when the - * connection is made. Since the block receives - * the addresses regardless of whether or not - * initial data is available or requested, the - * message block size must be at least - * @a bytes_to_read plus two times the size of - * the addresses used (IPv4 or IPv6). - * @param bytes_to_read The maximum number of bytes of initial data - * to read into @a message_block. - * @param accept_handle The handle that the new connection will be - * accepted on. If @c INVALID_HANDLE, a new - * handle will be created using @a addr_family. - * @param act Value to be passed in result when operation - * completes. - * @param priority Priority of the operation. On POSIX4-Unix, this - * is supported. Works like @c nice in Unix. - * Negative values are not allowed. 0 means - * priority of the operation same as the process - * priority. 1 means priority of the operation is - * one less than process. And so forth. - * On Win32, this argument is ignored. - * @param signal_number The POSIX4 real-time signal number to be used - * for the operation. Value range is from - * @c ACE_SIGRTMIN to @c ACE_SIGRTMAX. - * This argument is ignored on non-POSIX4 systems. - * @param addr_family The address family to use if @a accept_handle - * is @c ACE_INVALID_HANDLE and a new handle must - * be opened. Values are @c AF_INET and @c PF_INET6. - */ - int accept (ACE_Message_Block &message_block, - size_t bytes_to_read, - ACE_HANDLE accept_handle = ACE_INVALID_HANDLE, - const void *act = 0, - int priority = 0, - int signal_number = ACE_SIGRTMIN, - int addr_family = AF_INET); - - /// Return the underlying implementation class. - // (this should be protected...) - virtual ACE_Asynch_Operation_Impl *implementation (void) const; - -protected: - /// Delegation/implementation class that all methods will be - /// forwarded to. - ACE_Asynch_Accept_Impl *implementation_; - -public: -/** - * @class Result - * - * @brief This is that class which will be passed back to the - * {handler} when the asynchronous accept completes. - * - * This class has all the information necessary for the - * {handler} to uniquiely identify the completion of the - * asynchronous accept. - */ - class ACE_Export Result : public ACE_Asynch_Result - { - - /// The concrete implementation result classes only construct this - /// class. - friend class ACE_POSIX_Asynch_Accept_Result; - friend class ACE_WIN32_Asynch_Accept_Result; - - public: - /// The number of bytes which were requested at the start of the - /// asynchronous accept. - size_t bytes_to_read (void) const; - - /// Message block which contains the read data. - ACE_Message_Block &message_block (void) const; - - /// I/O handle used for accepting new connections. - ACE_HANDLE listen_handle (void) const; - - /// I/O handle for the new connection. - ACE_HANDLE accept_handle (void) const; - - /// Get the implementation. - ACE_Asynch_Accept_Result_Impl *implementation (void) const; - - protected: - /// Contructor. Implementation will not be deleted. - Result (ACE_Asynch_Accept_Result_Impl *implementation); - - /// Destructor. - virtual ~Result (void); - - /// Impelmentation class. - ACE_Asynch_Accept_Result_Impl *implementation_; - }; -}; -// Forward declarations -class ACE_Asynch_Connect_Result_Impl; -class ACE_Asynch_Connect_Impl; - -/** - * @class ACE_Asynch_Connect - * - * @brief This class is a factory for starting off asynchronous connects - * This class forwards all methods to its implementation class. - * - * Once @c open is called, multiple asynchronous connect operationss can - * started using this class. A ACE_Asynch_Connect::Result will - * be passed back to the associated ACE_Handler when the asynchronous connect - * completes through the ACE_Handler::handle_connect() callback. - */ -class ACE_Export ACE_Asynch_Connect : public ACE_Asynch_Operation -{ - -public: - /// A do nothing constructor. - ACE_Asynch_Connect (void); - - /// Destructor. - virtual ~ACE_Asynch_Connect (void); - - /** - * Initializes the factory with information which will be used with - * each asynchronous call. - * - * @note @arg handle is ignored and should be @c ACE_INVALID_HANDLE. - */ - int open (ACE_Handler &handler, - ACE_HANDLE handle = ACE_INVALID_HANDLE, - const void *completion_key = 0, - ACE_Proactor *proactor = 0); - - /** - * This starts off an asynchronous Connect. - */ - int connect (ACE_HANDLE connect_handle, - const ACE_Addr & remote_sap, - const ACE_Addr & local_sap, - int reuse_addr, - const void *act=0, - int priority = 0, - int signal_number = ACE_SIGRTMIN); - - /// Return the underlying implementation class. - // (this should be protected...) - virtual ACE_Asynch_Operation_Impl *implementation (void) const; - -protected: - /// Delegation/implementation class that all methods will be - /// forwarded to. - ACE_Asynch_Connect_Impl *implementation_; - -public: -/** - * @class Result - * - * @brief This is that class which will be passed back to the - * handler when the asynchronous connect completes. - * - * This class has all the information necessary for the - * handler to uniquely identify the completion of the - * asynchronous connect. - */ - class ACE_Export Result : public ACE_Asynch_Result - { - - /// The concrete implementation result classes only construct this - /// class. - friend class ACE_POSIX_Asynch_Connect_Result; - friend class ACE_WIN32_Asynch_Connect_Result; - - public: - - /// I/O handle for the connection. - ACE_HANDLE connect_handle (void) const; - - /// Get the implementation. - ACE_Asynch_Connect_Result_Impl *implementation (void) const; - - protected: - /// Contructor. Implementation will not be deleted. - Result (ACE_Asynch_Connect_Result_Impl *implementation); - - /// Destructor. - virtual ~Result (void); - - /// Impelmentation class. - ACE_Asynch_Connect_Result_Impl *implementation_; - }; -}; - -// Forward declarations -class ACE_Asynch_Transmit_File_Result_Impl; -class ACE_Asynch_Transmit_File_Impl; - -/** - * @class ACE_Asynch_Transmit_File - * - * @brief This class is a factory for starting off asynchronous - * transmit files on a stream. - * - * Once {open} is called, multiple asynchronous {transmit_file}s - * can started using this class. A - * ACE_Asynch_Transmit_File::Result will be passed back to the - * {handler} when the asynchronous transmit file completes - * through the {ACE_Handler::handle_transmit_file} callback. - * The transmit_file function transmits file data over a - * connected network connection. The function uses the operating - * system's cache manager to retrieve the file data. This - * function provides high-performance file data transfer over - * network connections. This function would be of great use in - * a Web Server, Image Server, etc. - */ -class ACE_Export ACE_Asynch_Transmit_File : public ACE_Asynch_Operation -{ - -public: - // Forward declarations - class Header_And_Trailer; - - /// A do nothing constructor. - ACE_Asynch_Transmit_File (void); - - /// Destructor. - virtual ~ACE_Asynch_Transmit_File (void); - - /** - * Initializes the factory with information which will be used with - * each asynchronous call. If ({handle} == ACE_INVALID_HANDLE), - * {ACE_Handler::handle} will be called on the {handler} to get the - * correct handle. - */ - int open (ACE_Handler &handler, - ACE_HANDLE handle = ACE_INVALID_HANDLE, - const void *completion_key = 0, - ACE_Proactor *proactor = 0); - - /** - * This starts off an asynchronous transmit file. The {file} is a - * handle to an open file. {header_and_trailer} is a pointer to a - * data structure that contains pointers to data to send before and - * after the file data is sent. Set this parameter to 0 if you only - * want to transmit the file data. Upto {bytes_to_write} will be - * written to the {socket}. If you want to send the entire file, - * let {bytes_to_write} = 0. {bytes_per_send} is the size of each - * block of data sent per send operation. Please read the Win32 - * documentation on what the flags should be. Priority of the - * operation is specified by {priority}. On POSIX4-Unix, this is - * supported. Works like {nice} in Unix. Negative values are not - * allowed. 0 means priority of the operation same as the process - * priority. 1 means priority of the operation is one less than - * process. And so forth. On Win32, this is a no-op. - * {signal_number} is the POSIX4 real-time signal number to be used - * for the operation. {signal_number} ranges from ACE_SIGRTMIN to - * ACE_SIGRTMAX. This argument is a no-op on non-POSIX4 systems. - */ - int transmit_file (ACE_HANDLE file, - Header_And_Trailer *header_and_trailer = 0, - size_t bytes_to_write = 0, - unsigned long offset = 0, - unsigned long offset_high = 0, - size_t bytes_per_send = 0, - unsigned long flags = 0, - const void *act = 0, - int priority = 0, - int signal_number = ACE_SIGRTMIN); - - /// Return the underlying implementation class. - // (this should be protected...) - virtual ACE_Asynch_Operation_Impl *implementation (void) const; - -protected: - /// The implementation class. - ACE_Asynch_Transmit_File_Impl *implementation_; - -public: -/** - * @class Result - * - * @brief This is that class which will be passed back to the - * {handler} when the asynchronous transmit file completes. - * - * This class has all the information necessary for the - * {handler} to uniquiely identify the completion of the - * asynchronous transmit file. - */ - class ACE_Export Result : public ACE_Asynch_Result - { - - /// The concrete implementation result classes only construct this - /// class. - friend class ACE_POSIX_Asynch_Transmit_File_Result; - friend class ACE_WIN32_Asynch_Transmit_File_Result; - - public: - /// Socket used for transmitting the file. - ACE_HANDLE socket (void) const; - - /// File from which the data is read. - ACE_HANDLE file (void) const; - - /// Header and trailer data associated with this transmit file. - Header_And_Trailer *header_and_trailer (void) const; - - /// The number of bytes which were requested at the start of the - /// asynchronous transmit file. - size_t bytes_to_write (void) const; - - /// Number of bytes per send requested at the start of the transmit - /// file. - size_t bytes_per_send (void) const; - - /// Flags which were passed into transmit file. - unsigned long flags (void) const; - - /// Get the implementation class. - ACE_Asynch_Transmit_File_Result_Impl *implementation (void) const; - - protected: - /// Constructor. - Result (ACE_Asynch_Transmit_File_Result_Impl *implementation); - - /// Destructor. - virtual ~Result (void); - - /// The implementation class. - ACE_Asynch_Transmit_File_Result_Impl *implementation_; - }; - -/** - * @class Header_And_Trailer - * - * @brief The class defines a data structure that contains pointers - * to data to send before and after the file data is sent. - * - * This class provides a wrapper over TRANSMIT_FILE_BUFFERS - * and provided a consistent use of ACE_Message_Blocks. - */ - class ACE_Export Header_And_Trailer - { - - public: - /// Constructor. - Header_And_Trailer (ACE_Message_Block *header = 0, - size_t header_bytes = 0, - ACE_Message_Block *trailer = 0, - size_t trailer_bytes = 0); - - /// Destructor - virtual ~Header_And_Trailer (void); - - /// This method allows all the member to be set in one fell swoop. - void header_and_trailer (ACE_Message_Block *header = 0, - size_t header_bytes = 0, - ACE_Message_Block *trailer = 0, - size_t trailer_bytes = 0); - - /// Get header which goes before the file data. - ACE_Message_Block *header (void) const; - - /// Set header which goes before the file data. - void header (ACE_Message_Block *message_block); - - /// Get size of the header data. - size_t header_bytes (void) const; - - /// Set size of the header data. - void header_bytes (size_t bytes); - - /// Get trailer which goes after the file data. - ACE_Message_Block *trailer (void) const; - - /// Set trailer which goes after the file data. - void trailer (ACE_Message_Block *message_block); - - /// Get size of the trailer data. - size_t trailer_bytes (void) const; - - /// Set size of the trailer data. - void trailer_bytes (size_t bytes); - - /// Conversion routine. - ACE_LPTRANSMIT_FILE_BUFFERS transmit_buffers (void); - - protected: - /// Header data. - ACE_Message_Block *header_; - - /// Size of header data. - size_t header_bytes_; - - /// Trailer data. - ACE_Message_Block *trailer_; - - /// Size of trailer data. - size_t trailer_bytes_; - - /// Target data structure. - ACE_TRANSMIT_FILE_BUFFERS transmit_buffers_; - }; -}; - - -// Forward declarations -class ACE_Asynch_Read_Dgram_Result_Impl; -class ACE_Asynch_Read_Dgram_Impl; -class ACE_Addr; - -/** - * @class ACE_Asynch_Read_Dgram - * - * @brief This class is a factory for starting off asynchronous reads - * on a UDP socket. This class forwards all methods to its - * implementation class. - * - * Once {open} is called, multiple asynchronous {read}s can be - * started using this class. An ACE_Asynch_Read_Dgram::Result - * will be passed back to the {handler} when the asynchronous - * reads completes through the {ACE_Handler::handle_read_dgram} - * callback. - */ -class ACE_Export ACE_Asynch_Read_Dgram : public ACE_Asynch_Operation -{ - -public: - /// A do nothing constructor. - ACE_Asynch_Read_Dgram (void); - - /// Destructor - virtual ~ACE_Asynch_Read_Dgram (void); - - /** - * Initializes the factory with information which will be used with - * each asynchronous call. If ({handle} == ACE_INVALID_HANDLE), - * {ACE_Handler::handle} will be called on the {handler} to get the - * correct handle. - */ - int open (ACE_Handler &handler, - ACE_HANDLE handle = ACE_INVALID_HANDLE, - const void *completion_key = 0, - ACE_Proactor *proactor = 0); - - /** This starts off an asynchronous read. Upto - * {message_block->total_size()} will be read and stored in the - * {message_block}. {message_block}'s {wr_ptr} will be updated to reflect - * the added bytes if the read operation is successfully completed. - * Return code of 1 means immediate success and {number_of_bytes_recvd} - * will contain number of bytes read. The {ACE_Handler::handle_read_dgram} - * method will still be called. Return code of 0 means the IO will - * complete proactively. Return code of -1 means there was an error, use - * errno to get the error code. - * - * Scatter/gather is supported on WIN32 by using the {message_block->cont()} - * method. Up to ACE_IOV_MAX {message_block}'s are supported. Upto - * {message_block->size()} bytes will be read into each {message block} for - * a total of {message_block->total_size()} bytes. All {message_block}'s - * {wr_ptr}'s will be updated to reflect the added bytes for each - * {message_block} - * - * Priority of the operation is specified by {priority}. On POSIX4-Unix, - * this is supported. Works like {nice} in Unix. Negative values are not - * allowed. 0 means priority of the operation same as the process - * priority. 1 means priority of the operation is one less than - * process. And so forth. On Win32, {priority} is a no-op. - * {signal_number} is the POSIX4 real-time signal number to be used - * for the operation. {signal_number} ranges from ACE_SIGRTMIN to - * ACE_SIGRTMAX. This argument is a no-op on non-POSIX4 systems. - */ - ssize_t recv (ACE_Message_Block *message_block, - size_t &number_of_bytes_recvd, - int flags, - int protocol_family = PF_INET, - const void *act = 0, - int priority = 0, - int signal_number = ACE_SIGRTMIN); - - /// Return the underlying implementation class. - // (this should be protected...) - virtual ACE_Asynch_Operation_Impl *implementation (void) const; - -protected: - /// Implementation class that all methods will be forwarded to. - ACE_Asynch_Read_Dgram_Impl *implementation_; - -public: -/** - * @class Result - * - * @brief This is the class which will be passed back to the - * {handler} when the asynchronous read completes. This class - * forwards all the methods to the implementation classes. - * - * This class has all the information necessary for the - * {handler} to uniquiely identify the completion of the - * asynchronous read. - */ - class ACE_Export Result : public ACE_Asynch_Result - { - - /// The concrete implementation result classes only construct this - /// class. - friend class ACE_POSIX_Asynch_Read_Dgram_Result; - friend class ACE_WIN32_Asynch_Read_Dgram_Result; - - public: - - /// The number of bytes which were requested at the start of the - /// asynchronous read. - size_t bytes_to_read (void) const; - - /// Message block which contains the read data - ACE_Message_Block *message_block (void) const; - - /// The flags used in the read - int flags (void) const; - - /// The address of where the packet came from - int remote_address (ACE_Addr& addr) const; - - /// I/O handle used for reading. - ACE_HANDLE handle (void) const; - - /// Get the implementation class. - ACE_Asynch_Read_Dgram_Result_Impl *implementation (void) const; - - protected: - /// Constructor. - Result (ACE_Asynch_Read_Dgram_Result_Impl *implementation); - - /// Destructor. - virtual ~Result (void); - - /// The implementation class. - ACE_Asynch_Read_Dgram_Result_Impl *implementation_; - }; -}; - -// Forward declarations -class ACE_Asynch_Write_Dgram_Impl; -class ACE_Asynch_Write_Dgram_Result_Impl; - -/** - * @class ACE_Asynch_Write_Dgram - * - * @brief This class is a factory for starting off asynchronous writes - * on a UDP socket. This class forwards all methods to its - * implementation class. - * - * Once {open} is called, multiple asynchronous {writes}s can - * started using this class. An ACE_Asynch_Write_Dgram::Result - * will be passed back to the {handler} when the asynchronous - * write completes through the - * {ACE_Handler::handle_write_dgram} callback. - */ -class ACE_Export ACE_Asynch_Write_Dgram : public ACE_Asynch_Operation -{ - -public: - /// A do nothing constructor. - ACE_Asynch_Write_Dgram (void); - - /// Destructor. - virtual ~ACE_Asynch_Write_Dgram (void); - - /** - * Initializes the factory with information which will be used with - * each asynchronous call. If ({handle} == ACE_INVALID_HANDLE), - * {ACE_Handler::handle} will be called on the {handler} to get the - * correct handle. - */ - int open (ACE_Handler &handler, - ACE_HANDLE handle = ACE_INVALID_HANDLE, - const void *completion_key = 0, - ACE_Proactor *proactor = 0); - - /** This starts off an asynchronous send. Upto - * {message_block->total_length()} will be sent. {message_block}'s - * {rd_ptr} will be updated to reflect the sent bytes if the send operation - * is successfully completed. - * Return code of 1 means immediate success and {number_of_bytes_sent} - * is updated to number of bytes sent. The {ACE_Handler::handle_write_dgram} - * method will still be called. Return code of 0 means the IO will - * complete proactively. Return code of -1 means there was an error, use - * errno to get the error code. - * - * Scatter/gather is supported on WIN32 by using the {message_block->cont()} - * method. Up to ACE_IOV_MAX {message_block}'s are supported. Upto - * {message_block->length()} bytes will be sent from each {message block} - * for a total of {message_block->total_length()} bytes. All - * {message_block}'s {rd_ptr}'s will be updated to reflect the bytes sent - * from each {message_block}. - * - * Priority of the operation is specified by {priority}. On POSIX4-Unix, - * this is supported. Works like {nice} in Unix. Negative values are not - * allowed. 0 means priority of the operation same as the process - * priority. 1 means priority of the operation is one less than - * process. And so forth. On Win32, this argument is a no-op. - * {signal_number} is the POSIX4 real-time signal number to be used - * for the operation. {signal_number} ranges from ACE_SIGRTMIN to - * ACE_SIGRTMAX. This argument is a no-op on non-POSIX4 systems. - */ - ssize_t send (ACE_Message_Block *message_block, - size_t &number_of_bytes_sent, - int flags, - const ACE_Addr& remote_addr, - const void *act = 0, - int priority = 0, - int signal_number = ACE_SIGRTMIN); - - /// Return the underlying implementation class. - // (this should be protected...) - virtual ACE_Asynch_Operation_Impl *implementation (void) const; - -protected: - /// Implementation class that all methods will be forwarded to. - ACE_Asynch_Write_Dgram_Impl *implementation_; - -public: -/** - * @class Result - * - * @brief This is that class which will be passed back to the - * {handler} when the asynchronous write completes. This class - * forwards all the methods to the implementation class. - * - * This class has all the information necessary for the - * {handler} to uniquiely identify the completion of the - * asynchronous write. - */ - class ACE_Export Result : public ACE_Asynch_Result - { - - /// The concrete implementation result classes only construct this - /// class. - friend class ACE_POSIX_Asynch_Write_Dgram_Result; - friend class ACE_WIN32_Asynch_Write_Dgram_Result; - - public: - - /// The number of bytes which were requested at the start of the - /// asynchronous write. - size_t bytes_to_write (void) const; - - /// Message block which contains the sent data - ACE_Message_Block *message_block (void) const; - - /// The flags using in the write - int flags (void) const; - - /// I/O handle used for writing. - ACE_HANDLE handle (void) const; - - /// Get the implementation class. - ACE_Asynch_Write_Dgram_Result_Impl *implementation (void) const; - - protected: - /// Constructor. - Result (ACE_Asynch_Write_Dgram_Result_Impl *implementation); - - /// Destructor. - virtual ~Result (void); - - /// Implementation class. - ACE_Asynch_Write_Dgram_Result_Impl *implementation_; - }; -}; - - -/** - * @class ACE_Handler - * - * @brief This base class defines the interface for receiving the - * results of asynchronous operations. - * - * Subclasses of this class will fill in appropriate methods. - */ -class ACE_Export ACE_Handler -{ -public: - /// A do nothing constructor. - ACE_Handler (void); - - /// A do nothing constructor which allows proactor to be set to \. - ACE_Handler (ACE_Proactor *p); - - /// Virtual destruction. - virtual ~ACE_Handler (void); - - /// This method will be called when an asynchronous read completes on - /// a stream. - virtual void handle_read_stream (const ACE_Asynch_Read_Stream::Result &result); - - /// This method will be called when an asynchronous write completes - /// on a UDP socket. - virtual void handle_write_dgram (const ACE_Asynch_Write_Dgram::Result &result); - - /// This method will be called when an asynchronous read completes on - /// a UDP socket. - virtual void handle_read_dgram (const ACE_Asynch_Read_Dgram::Result &result); - - /// This method will be called when an asynchronous write completes - /// on a stream. - virtual void handle_write_stream (const ACE_Asynch_Write_Stream::Result &result); - - /// This method will be called when an asynchronous read completes on - /// a file. - virtual void handle_read_file (const ACE_Asynch_Read_File::Result &result); - - /// This method will be called when an asynchronous write completes - /// on a file. - virtual void handle_write_file (const ACE_Asynch_Write_File::Result &result); - - /// This method will be called when an asynchronous accept completes. - virtual void handle_accept (const ACE_Asynch_Accept::Result &result); - - /// This method will be called when an asynchronous connect completes. - virtual void handle_connect (const ACE_Asynch_Connect::Result &result); - - /// This method will be called when an asynchronous transmit file - /// completes. - virtual void handle_transmit_file (const ACE_Asynch_Transmit_File::Result &result); - - /// Called when timer expires. {tv} was the requested time value and - /// {act} is the ACT passed when scheduling the timer. - virtual void handle_time_out (const ACE_Time_Value &tv, - const void *act = 0); - - /** - * This is method works with the {run_event_loop} of the - * ACE_Proactor. A special {Wake_Up_Completion} is used to wake up - * all the threads that are blocking for completions. - */ - virtual void handle_wakeup (void); - - /// Get the proactor associated with this handler. - ACE_Proactor *proactor (void); - - /// Set the proactor. - void proactor (ACE_Proactor *p); - - /** - * Get the I/O handle used by this {handler}. This method will be - * called by the ACE_Asynch_* classes when an ACE_INVALID_HANDLE is - * passed to {open}. - */ - virtual ACE_HANDLE handle (void) const; - - /// Set the ACE_HANDLE value for this Handler. - virtual void handle (ACE_HANDLE); - - /** - * @class Proxy - * - * @brief The Proxy class acts as a proxy for dispatch of completions - * to operations issued for the associated handler. It allows the handler - * to be deleted while operations are outstanding. The proxy must be used - * to get the ACE_Handler pointer for dispatching, and if it's 0, the - * handler is no longer valid and the result should not be dispatched. - */ - class ACE_Export Proxy - { - public: - Proxy (ACE_Handler *handler) : handler_ (handler) {}; - void reset (void) { this->handler_ = 0; }; - ACE_Handler *handler (void) { return this->handler_; }; - private: - ACE_Handler *handler_; - }; - typedef ACE_Refcounted_Auto_Ptr - Proxy_Ptr; - - Proxy_Ptr &proxy (void); - -protected: - /// The proactor associated with this handler. - ACE_Proactor *proactor_; - - /// The ACE_HANDLE in use with this handler. - ACE_HANDLE handle_; - - /// Refers to proxy for this handler. - ACE_Refcounted_Auto_Ptr proxy_; - - ACE_UNIMPLEMENTED_FUNC (ACE_Handler (const ACE_Handler &)) - ACE_UNIMPLEMENTED_FUNC (ACE_Handler operator= (const ACE_Handler &)) -}; - -// Forward declarations -class ACE_INET_Addr; - -// Forward declarations -template -class ACE_Asynch_Acceptor; - -/** - * @class ACE_Service_Handler - * - * @brief This base class defines the interface for the - * ACE_Asynch_Acceptor to call into when new connection are - * accepted. - * - * Subclasses of this class will fill in appropriate methods to - * define application specific behavior. - */ -class ACE_Export ACE_Service_Handler : public ACE_Handler -{ - - /// The Acceptor is the factory and therefore should have special - /// privileges. - friend class ACE_Asynch_Acceptor; - -public: - /// A do nothing constructor. - ACE_Service_Handler (void); - - /// Virtual destruction. - virtual ~ACE_Service_Handler (void); - - /** - * {open} is called by ACE_Asynch_Acceptor to initialize a new - * instance of ACE_Service_Handler that has been created after the - * new connection is accepted. The handle for the new connection is - * passed along with the initial data that may have shown up. - */ - virtual void open (ACE_HANDLE new_handle, - ACE_Message_Block &message_block); - - // protected: - // This should be corrected after the correct semantics of the - // friend has been figured out. - - /// Called by ACE_Asynch_Acceptor to pass the addresses of the new - /// connections. - virtual void addresses (const ACE_INET_Addr &remote_address, - const ACE_INET_Addr &local_address); - - /// Called by ACE_Asynch_Acceptor to pass the act. - virtual void act (const void *); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_WIN32 || ACE_HAS_AIO_CALLS*/ -#include /**/ "ace/post.h" -#endif /* ACE_ASYNCH_IO_H */ diff --git a/ACE/ace/Asynch_IO_Impl.cpp b/ACE/ace/Asynch_IO_Impl.cpp deleted file mode 100644 index 5349f5e7ca1..00000000000 --- a/ACE/ace/Asynch_IO_Impl.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// $Id$ - -#include "ace/Asynch_IO_Impl.h" - -#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) -// This only works on Win32 platforms and on Unix platforms supporting -// aio calls. - -#if !defined (__ACE_INLINE__) -#include "ace/Asynch_IO_Impl.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_Asynch_Result_Impl::~ACE_Asynch_Result_Impl (void) -{ -} - -ACE_Asynch_Operation_Impl::~ACE_Asynch_Operation_Impl (void) -{ -} - -ACE_Asynch_Read_Stream_Impl::~ACE_Asynch_Read_Stream_Impl (void) -{ -} - -ACE_Asynch_Read_Stream_Result_Impl::~ACE_Asynch_Read_Stream_Result_Impl (void) -{ -} - -ACE_Asynch_Write_Stream_Impl::~ACE_Asynch_Write_Stream_Impl (void) -{ -} - -ACE_Asynch_Write_Stream_Result_Impl::~ACE_Asynch_Write_Stream_Result_Impl (void) -{ -} - -ACE_Asynch_Read_File_Impl::~ACE_Asynch_Read_File_Impl (void) -{ -} - -ACE_Asynch_Write_File_Impl::~ACE_Asynch_Write_File_Impl (void) -{ -} - -ACE_Asynch_Read_File_Result_Impl::~ACE_Asynch_Read_File_Result_Impl (void) -{ -} - -ACE_Asynch_Write_File_Result_Impl::~ACE_Asynch_Write_File_Result_Impl (void) -{ -} - -ACE_Asynch_Accept_Result_Impl::~ACE_Asynch_Accept_Result_Impl (void) -{ -} - -ACE_Asynch_Connect_Result_Impl::~ACE_Asynch_Connect_Result_Impl (void) -{ -} - -ACE_Asynch_Accept_Impl::~ACE_Asynch_Accept_Impl (void) -{ -} - -ACE_Asynch_Connect_Impl::~ACE_Asynch_Connect_Impl (void) -{ -} - -ACE_Asynch_Transmit_File_Impl::~ACE_Asynch_Transmit_File_Impl (void) -{ -} - -ACE_Asynch_Transmit_File_Result_Impl::~ACE_Asynch_Transmit_File_Result_Impl (void) -{ -} - -ACE_Asynch_Read_Dgram_Impl::~ACE_Asynch_Read_Dgram_Impl (void) -{ -} - -ACE_Asynch_Read_Dgram_Impl::ACE_Asynch_Read_Dgram_Impl (void) -{ -} - -ACE_Asynch_Write_Dgram_Impl::~ACE_Asynch_Write_Dgram_Impl (void) -{ -} - -ACE_Asynch_Write_Dgram_Impl::ACE_Asynch_Write_Dgram_Impl (void) -{ -} - -//*********************************************** - -ACE_Asynch_Read_Dgram_Result_Impl::~ACE_Asynch_Read_Dgram_Result_Impl (void) -{ -} - -ACE_Asynch_Read_Dgram_Result_Impl::ACE_Asynch_Read_Dgram_Result_Impl (void) -{ -} - -//*********************************************** - -ACE_Asynch_Write_Dgram_Result_Impl::~ACE_Asynch_Write_Dgram_Result_Impl (void) -{ -} - -ACE_Asynch_Write_Dgram_Result_Impl::ACE_Asynch_Write_Dgram_Result_Impl (void) -{ -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ diff --git a/ACE/ace/Asynch_IO_Impl.h b/ACE/ace/Asynch_IO_Impl.h deleted file mode 100644 index b2a308a7565..00000000000 --- a/ACE/ace/Asynch_IO_Impl.h +++ /dev/null @@ -1,816 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file Asynch_IO_Impl.h - * - * $Id$ - * - * - * This class contains asbtract base classes for all the concrete - * implementation classes for the various asynchronous operations - * that are used with the Praoctor. - * - * - * @author Irfan Pyarali (irfan@cs.wustl.edu) - * @author Tim Harrison (harrison@cs.wustl.edu) - * @author Alexander Babu Arulanthu - * @author Roger Tragin - * @author Alexander Libman - */ -//============================================================================= - -#ifndef ACE_ASYNCH_IO_IMPL_H -#define ACE_ASYNCH_IO_IMPL_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) -// This only works on Win32 platforms and on Unix platforms supporting -// aio calls. - -#include "ace/Asynch_IO.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Forward declaration. -class ACE_Proactor_Impl; - -/** - * @class ACE_Asynch_Result_Impl - * - * @brief Abstract base class for the all the classes that provide - * concrete implementations for ACE_Asynch_Result. - * - */ -class ACE_Export ACE_Asynch_Result_Impl -{ -public: - virtual ~ACE_Asynch_Result_Impl (void); - - /// Number of bytes transferred by the operation. - virtual size_t bytes_transferred (void) const = 0; - - /// ACT associated with the operation. - virtual const void *act (void) const = 0; - - /// Did the operation succeed? - virtual int success (void) const = 0; - - /// This ACT is not the same as the ACT associated with the - /// asynchronous operation. - virtual const void *completion_key (void) const = 0; - - /// Error value if the operation fail. - virtual u_long error (void) const = 0; - - /// Event associated with the OVERLAPPED structure. - virtual ACE_HANDLE event (void) const = 0; - - /// This really make sense only when doing file I/O. - virtual u_long offset (void) const = 0; - virtual u_long offset_high (void) const = 0; - - /// Priority of the operation. - virtual int priority (void) const = 0; - - /** - * POSIX4 real-time signal number to be used for the - * operation. ranges from SIGRTMIN to SIGRTMAX. By - * default, SIGRTMIN is used to issue calls. This is a no-op - * on non-POSIX4 systems and returns 0. - */ - virtual int signal_number (void) const = 0; - - // protected: - // - // These two should really be protected. But sometimes it - // simplifies code to be able to "fake" a result. Use carefully. - /// This is called when the asynchronous operation completes. - virtual void complete (size_t bytes_transferred, - int success, - const void *completion_key, - u_long error = 0) = 0; - - /// Post @c this to the Proactor's completion port. - virtual int post_completion (ACE_Proactor_Impl *proactor) = 0; - -protected: - /// Do-nothing constructor. - ACE_Asynch_Result_Impl (void); -}; - -/** - * @class ACE_Asynch_Operation_Impl - * - * @brief Abstract base class for all the concrete implementation - * classes that provide different implementations for the - * ACE_Asynch_Operation. - */ -class ACE_Export ACE_Asynch_Operation_Impl -{ -public: - virtual ~ACE_Asynch_Operation_Impl (void); - - /** - * Initializes the factory with information which will be used with - * each asynchronous call. If @a handle == ACE_INVALID_HANDLE, - * ACE_Handler::handle() will be called on the proxied handler to get the - * correct handle. - */ - virtual int open (const ACE_Handler::Proxy_Ptr &handler_proxy, - ACE_HANDLE handle, - const void *completion_key, - ACE_Proactor *proactor) = 0; - - /** - * This cancels all pending accepts operations that were issued by - * the calling thread. The function does not cancel asynchronous - * operations issued by other threads. - */ - virtual int cancel (void) = 0; - - // = Access methods. - - /// Return the underlying proactor. - virtual ACE_Proactor* proactor (void) const = 0; - -protected: - /// Do-nothing constructor. - ACE_Asynch_Operation_Impl (void); -}; - -/** - * @class ACE_Asynch_Read_Stream_Impl - * - * @brief Abstract base class for all the concrete implementation - * classes that provide different implementations for the - * ACE_Asynch_Read_Stream - * - */ -class ACE_Export ACE_Asynch_Read_Stream_Impl : public virtual ACE_Asynch_Operation_Impl -{ -public: - virtual ~ACE_Asynch_Read_Stream_Impl (void); - - /// This starts off an asynchronous read. Upto @a bytes_to_read will - /// be read and stored in the @a message_block. - virtual int read (ACE_Message_Block &message_block, - size_t bytes_to_read, - const void *act, - int priority, - int signal_number) = 0; - -#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) - /** - * Same as above but with scatter support, through chaining of composite - * message blocks using the continuation field. - */ - virtual int readv (ACE_Message_Block &message_block, - size_t bytes_to_read, - const void *act, - int priority, - int signal_number) = 0; -#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */ - -protected: - /// Do-nothing constructor. - ACE_Asynch_Read_Stream_Impl (void); -}; - -/** - * @class ACE_Asynch_Read_Stream_Result_Impl - * - * @brief Abstract base class for all the concrete implementation - * classes that provide different implementations for the - * ACE_Asynch_Read_Stream::Result class. - * - */ -class ACE_Export ACE_Asynch_Read_Stream_Result_Impl : public virtual ACE_Asynch_Result_Impl -{ -public: - virtual ~ACE_Asynch_Read_Stream_Result_Impl (void); - - /// The number of bytes which were requested at the start of the - /// asynchronous read. - virtual size_t bytes_to_read (void) const = 0; - - /// Message block which contains the read data. - virtual ACE_Message_Block &message_block (void) const = 0; - - /// I/O handle used for reading. - virtual ACE_HANDLE handle (void) const = 0; - -protected: - /// Do-nothing constructor. - ACE_Asynch_Read_Stream_Result_Impl (void); -}; - -/** - * @class ACE_Asynch_Write_Stream_Impl - * - * @brief Abstract base class for all the concrete implementation - * classes that provide different implementations for the - * ACE_Asynch_Write_Stream class. - * - */ -class ACE_Export ACE_Asynch_Write_Stream_Impl : public virtual ACE_Asynch_Operation_Impl -{ -public: - virtual ~ACE_Asynch_Write_Stream_Impl (void); - - /// This starts off an asynchronous write. Upto @a bytes_to_write - /// will be written from the @a message_block. - virtual int write (ACE_Message_Block &message_block, - size_t bytes_to_write, - const void *act, - int priority, - int signal_number) = 0; - -#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) - /** - * Same as above but with gather support, through chaining of composite - * message blocks using the continuation field. - */ - virtual int writev (ACE_Message_Block &message_block, - size_t bytes_to_write, - const void *act, - int priority, - int signal_number) = 0; -#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */ - -protected: - /// Do-nothing constructor. - ACE_Asynch_Write_Stream_Impl (void); -}; - -/** - * @class ACE_Asynch_Write_Stream_Result_Impl - * - * @brief Abstract base class for all the concrete implementation - * classes that provide different implementations for the - * ACE_Asynch_Write_Stream::Result. - * - */ -class ACE_Export ACE_Asynch_Write_Stream_Result_Impl : public virtual ACE_Asynch_Result_Impl -{ -public: - virtual ~ACE_Asynch_Write_Stream_Result_Impl (void); - - /// The number of bytes which were requested at the start of the - /// asynchronous write. - virtual size_t bytes_to_write (void) const = 0; - - /// Message block that contains the data to be written. - virtual ACE_Message_Block &message_block (void) const = 0; - - /// I/O handle used for writing. - virtual ACE_HANDLE handle (void) const = 0; - -protected: - /// Do-nothing constructor. - ACE_Asynch_Write_Stream_Result_Impl (void); -}; - -/** - * @class ACE_Asynch_Read_File_Impl - * - * @brief Abstract base class for all the concrete implementation - * classes that provide different implementations for the - * ACE_Asynch_Read_File::Result. - * - */ -class ACE_Export ACE_Asynch_Read_File_Impl : public virtual ACE_Asynch_Read_Stream_Impl -{ -public: - virtual ~ACE_Asynch_Read_File_Impl (void); - - /** - * This starts off an asynchronous read. Upto @a bytes_to_read will - * be read and stored in the @a message_block. The read will start - * at @a offset from the beginning of the file. - */ - virtual int read (ACE_Message_Block &message_block, - size_t bytes_to_read, - u_long offset, - u_long offset_high, - const void *act, - int priority, - int signal_number) = 0; - -#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) - /** - * Same as above but with scatter support, through chaining of composite - * message blocks using the continuation field. - * @note In win32 Each data block payload must be at least the size of a system - * memory page and must be aligned on a system memory page size boundary - */ - virtual int readv (ACE_Message_Block &message_block, - size_t bytes_to_read, - u_long offset, - u_long offset_high, - const void *act, - int priority, - int signal_number) = 0; -#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */ - - /// This starts off an asynchronous read. Upto @a bytes_to_read will - /// be read and stored in the @a message_block. - virtual int read (ACE_Message_Block &message_block, - size_t bytes_to_read, - const void *act, - int priority, - int signal_number) = 0; - -#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) - /** - * Same as above but with scatter support, through chaining of composite - * message blocks using the continuation field. - */ - virtual int readv (ACE_Message_Block &message_block, - size_t bytes_to_read, - const void *act, - int priority, - int signal_number) = 0; -#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */ - -protected: - /// Do-nothing constructor. - ACE_Asynch_Read_File_Impl (void); -}; - -/** - * @class ACE_Asynch_Read_File_Result_Impl - * - * @brief This is the abstract base class for all the concrete - * implementation classes for ACE_Asynch_Read_File::Result. - * - */ -class ACE_Export ACE_Asynch_Read_File_Result_Impl : public virtual ACE_Asynch_Read_Stream_Result_Impl -{ -public: - /// Destructor. - virtual ~ACE_Asynch_Read_File_Result_Impl (void); - -protected: - /// Do-nothing constructor. - ACE_Asynch_Read_File_Result_Impl (void); -}; - -/** - * @class ACE_Asynch_Write_File_Impl - * - * @brief Abstract base class for all the concrete implementation - * classes that provide different implementations for the - * ACE_Asynch_Write_File. - * - */ -class ACE_Export ACE_Asynch_Write_File_Impl : public virtual ACE_Asynch_Write_Stream_Impl -{ -public: - virtual ~ACE_Asynch_Write_File_Impl (void); - - /** - * This starts off an asynchronous write. Upto @a bytes_to_write - * will be write and stored in the @a message_block. The write will - * start at @a offset from the beginning of the file. - */ - virtual int write (ACE_Message_Block &message_block, - size_t bytes_to_write, - u_long offset, - u_long offset_high, - const void *act, - int priority, - int signal_number) = 0; - -#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) - /** - * Same as above but with gather support, through chaining of composite - * message blocks using the continuation field. - * @note In win32 Each data block payload must be at least the size of a system - * memory page and must be aligned on a system memory page size boundary - */ - virtual int writev (ACE_Message_Block &message_block, - size_t bytes_to_write, - u_long offset, - u_long offset_high, - const void *act, - int priority, - int signal_number) = 0; -#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */ - - /// This starts off an asynchronous write. Upto @a bytes_to_write - /// will be written from the @a message_block. - virtual int write (ACE_Message_Block &message_block, - size_t bytes_to_write, - const void *act, - int priority, - int signal_number) = 0; - -#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) - /** - * Same as above but with gather support, through chaining of composite - * message blocks using the continuation field. - */ - virtual int writev (ACE_Message_Block &message_block, - size_t bytes_to_write, - const void *act, - int priority, - int signal_number) = 0; -#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */ - -protected: - /// Do-nothing constructor. - ACE_Asynch_Write_File_Impl (void); -}; - -/** - * @class ACE_Asynch_Write_File_Result_Impl - * - * @brief This is the abstract base class for all the concrete - * implementation classes that provide different implementations - * for the ACE_Asynch_Write_File::Result. - * - */ -class ACE_Export ACE_Asynch_Write_File_Result_Impl : public virtual ACE_Asynch_Write_Stream_Result_Impl -{ -public: - virtual ~ACE_Asynch_Write_File_Result_Impl (void); - -protected: - /// Do-nothing constructor. - ACE_Asynch_Write_File_Result_Impl (void); -}; - -/** - * @class ACE_Asynch_Accept_Impl - * - * @brief Abstract base class for all the concrete implementation - * classes that provide different implementations for the - * ACE_Asynch_Accept. - * - */ -class ACE_Export ACE_Asynch_Accept_Impl : public virtual ACE_Asynch_Operation_Impl -{ -public: - virtual ~ACE_Asynch_Accept_Impl (void); - - /** - * This starts off an asynchronous accept. The asynchronous accept - * call also allows any initial data to be returned to the - * . Upto @a bytes_to_read will be read and stored in the - * @a message_block. The @a accept_handle will be used for the - * call. If (@a accept_handle == INVALID_HANDLE), a new - * handle will be created. - * - * @a message_block must be specified. This is because the address of - * the new connection is placed at the end of this buffer. - */ - virtual int accept (ACE_Message_Block &message_block, - size_t bytes_to_read, - ACE_HANDLE accept_handle, - const void *act, - int priority, - int signal_number, - int addr_family) = 0; - -protected: - /// Do-nothing constructor. - ACE_Asynch_Accept_Impl (void); -}; - -/** - * @class ACE_Asynch_Accept_Result_Impl - * - * @brief Abstract base class for all the concrete implementation - * classes that provide different implementations for the - * ACE_Asynch_Accept. - * - */ -class ACE_Export ACE_Asynch_Accept_Result_Impl : public virtual ACE_Asynch_Result_Impl -{ -public: - virtual ~ACE_Asynch_Accept_Result_Impl (void); - - /// The number of bytes which were requested at the start of the - /// asynchronous accept. - virtual size_t bytes_to_read (void) const = 0; - - /// Message block which contains the read data. - virtual ACE_Message_Block &message_block (void) const = 0; - - /// I/O handle used for accepting new connections. - virtual ACE_HANDLE listen_handle (void) const = 0; - - /// I/O handle for the new connection. - virtual ACE_HANDLE accept_handle (void) const = 0; - -protected: - /// Do-nothing constructor. - ACE_Asynch_Accept_Result_Impl (void); -}; - - -/** - * @class ACE_Asynch_Connect_Impl - * - * @brief Abstract base class for all the concrete implementation - * classes that provide different implementations for the - * ACE_Asynch_Connect. - * - */ -class ACE_Export ACE_Asynch_Connect_Impl : public virtual ACE_Asynch_Operation_Impl -{ -public: - virtual ~ACE_Asynch_Connect_Impl (void); - - /** - * This starts off an asynchronous connect - */ - virtual int connect (ACE_HANDLE connect_handle, - const ACE_Addr & remote_sap, - const ACE_Addr & local_sap, - int reuse_addr, - const void *act, - int priority, - int signal_number) = 0; - -protected: - /// Do-nothing constructor. - ACE_Asynch_Connect_Impl (void); -}; - -/** - * @class ACE_Asynch_Connect_Result_Impl - * - * @brief Abstract base class for all the concrete implementation - * classes that provide different implementations for the - * ACE_Asynch_Connect. - * - */ -class ACE_Export ACE_Asynch_Connect_Result_Impl : public virtual ACE_Asynch_Result_Impl -{ -public: - virtual ~ACE_Asynch_Connect_Result_Impl (void); - - /// I/O handle for the connection. - virtual ACE_HANDLE connect_handle (void) const = 0; - -protected: - /// Do-nothing constructor. - ACE_Asynch_Connect_Result_Impl (void); -}; - - -/** - * @class ACE_Asynch_Transmit_File_Impl - * - * @brief Abstract base class for all the concrete implementation - * classes that provide different implementations for the - * ACE_Asynch_Transmit_File. - * - */ -class ACE_Asynch_Transmit_File_Impl : public virtual ACE_Asynch_Operation_Impl -{ -public: - virtual ~ACE_Asynch_Transmit_File_Impl (void); - - /// This starts off an asynchronous transmit file. - virtual int transmit_file (ACE_HANDLE file, - ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer, - size_t bytes_to_write, - u_long offset, - u_long offset_high, - size_t bytes_per_send, - u_long flags, - const void *act, - int priority, - int signal_number) = 0; - -protected: - /// Do-nothing constructor. - ACE_Asynch_Transmit_File_Impl (void); -}; - -/** - * @class ACE_Asynch_Transmit_File_Result_Impl - * - * @brief Abstract base class for all the concrete implementation - * classes that provide different implementations for the - * ACE_Asynch_Transmit_File::Result. - * - */ -class ACE_Export ACE_Asynch_Transmit_File_Result_Impl : public virtual ACE_Asynch_Result_Impl -{ -public: - virtual ~ACE_Asynch_Transmit_File_Result_Impl (void); - - /// Socket used for transmitting the file. - virtual ACE_HANDLE socket (void) const = 0; - - /// File from which the data is read. - virtual ACE_HANDLE file (void) const = 0; - - /// Header and trailer data associated with this transmit file. - virtual ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer (void) const = 0; - - /// The number of bytes which were requested at the start of the - /// asynchronous transmit file. - virtual size_t bytes_to_write (void) const = 0; - - /// Number of bytes per send requested at the start of the transmit - /// file. - virtual size_t bytes_per_send (void) const = 0; - - /// Flags which were passed into transmit file. - virtual u_long flags (void) const = 0; - -protected: - /// Do-nothing constructor. - ACE_Asynch_Transmit_File_Result_Impl (void); -}; - - -/** - * @class ACE_Asynch_Read_Dgram_Impl - * - * @brief Abstract base class for all the concrete implementation - * classes that provide different implementations for the - * ACE_Asynch_Read_Dgram - * - */ -class ACE_Export ACE_Asynch_Read_Dgram_Impl : public virtual ACE_Asynch_Operation_Impl -{ -public: - virtual ~ACE_Asynch_Read_Dgram_Impl (void); - - /** This starts off an asynchronous read. Upto - * total_size()> will be read and stored in the - * @a message_block. @a message_block's will be updated to reflect - * the added bytes if the read operation is successful completed. - * Return code of 1 means immediate success and - * will contain number of bytes read. The - * method will still be called. Return code of 0 means the IO will - * complete proactively. Return code of -1 means there was an error, use - * errno to get the error code. - * - * Scatter/gather is supported on WIN32 by using the cont()> - * method. Up to ACE_IOV_MAX @a message_block's are supported. Upto - * size()> bytes will be read into each for - * a total of total_size()> bytes. All @a message_block's - * 's will be updated to reflect the added bytes for each - * @a message_block - * - * Priority of the operation is specified by @a priority. On POSIX4-Unix, - * this is supported. Works like in Unix. Negative values are not - * allowed. 0 means priority of the operation same as the process - * priority. 1 means priority of the operation is one less than - * process. And so forth. On Win32, @a priority is a no-op. - * @a signal_number is the POSIX4 real-time signal number to be used - * for the operation. @a signal_number ranges from ACE_SIGRTMIN to - * ACE_SIGRTMAX. This argument is a no-op on non-POSIX4 systems. - */ - virtual ssize_t recv (ACE_Message_Block *message_block, - size_t &number_of_bytes_recvd, - int flags, - int protocol_family, - const void *act, - int priority, - int signal_number) = 0; - -protected: - /// Do-nothing constructor. - ACE_Asynch_Read_Dgram_Impl (void); -}; - -/** - * @class ACE_Asynch_Read_Dgram_Result_Impl - * - * @brief Abstract base class for all the concrete implementation - * classes that provide different implementations for the - * ACE_Asynch_Read_Dgram::Result class. - * - */ -class ACE_Export ACE_Asynch_Read_Dgram_Result_Impl : public virtual ACE_Asynch_Result_Impl -{ -public: - virtual ~ACE_Asynch_Read_Dgram_Result_Impl (void); - - /// Message block which contains the read data - virtual ACE_Message_Block *message_block (void) const = 0; - - /// The number of bytes which were requested at the start of the - /// asynchronous read. - virtual size_t bytes_to_read (void) const = 0; - - /// The address of where the packet came from - virtual int remote_address (ACE_Addr& addr) const = 0; - - /// The flags used in the read - virtual int flags (void) const = 0; - - /// I/O handle used for reading. - virtual ACE_HANDLE handle (void) const = 0; - -protected: - /// Do-nothing constructor. - ACE_Asynch_Read_Dgram_Result_Impl (void); -}; - -/** - * @class ACE_Asynch_Write_Dgram_Impl - * - * @brief Abstract base class for all the concrete implementation - * classes that provide different implementations for the - * ACE_Asynch_Write_Dgram class. - * - */ -class ACE_Export ACE_Asynch_Write_Dgram_Impl : public virtual ACE_Asynch_Operation_Impl -{ -public: - virtual ~ACE_Asynch_Write_Dgram_Impl (void); - - /** This starts off an asynchronous send. Upto - * total_length()> will be sent. @a message_block's - * will be updated to reflect the sent bytes if the send operation - * is successful completed. - * Return code of 1 means immediate success and - * is updated to number of bytes sent. The - * method will still be called. Return code of 0 means the IO will - * complete proactively. Return code of -1 means there was an error, use - * errno to get the error code. - * - * Scatter/gather is supported on WIN32 by using the cont()> - * method. Up to ACE_IOV_MAX @a message_block's are supported. Upto - * length()> bytes will be sent from each - * for a total of total_length()> bytes. All - * @a message_block's 's will be updated to reflect the bytes sent - * from each @a message_block. - * - * Priority of the operation is specified by @a priority. On POSIX4-Unix, - * this is supported. Works like in Unix. Negative values are not - * allowed. 0 means priority of the operation same as the process - * priority. 1 means priority of the operation is one less than - * process. And so forth. On Win32, this argument is a no-op. - * @a signal_number is the POSIX4 real-time signal number to be used - * for the operation. @a signal_number ranges from ACE_SIGRTMIN to - * ACE_SIGRTMAX. This argument is a no-op on non-POSIX4 systems. - */ - virtual ssize_t send (ACE_Message_Block *message_block, - size_t &number_of_bytes_sent, - int flags, - const ACE_Addr &addr, - const void *act, - int priority, - int signal_number) = 0; - -protected: - /// Do-nothing constructor. - ACE_Asynch_Write_Dgram_Impl (void); -}; - -/** - * @class ACE_Asynch_Write_Dgram_Result_Impl - * - * @brief Abstract base class for all the concrete implementation - * classes that provide different implementations for the - * ACE_Asynch_Write_Dgram::Result class. - * - */ -class ACE_Export ACE_Asynch_Write_Dgram_Result_Impl : public virtual ACE_Asynch_Result_Impl -{ -public: - virtual ~ACE_Asynch_Write_Dgram_Result_Impl (void); - - /// The number of bytes which were requested at the start of the - /// asynchronous write. - virtual size_t bytes_to_write (void) const = 0; - - /// Message block which contains the sent data - virtual ACE_Message_Block *message_block (void) const = 0; - - /// The flags using in the write - virtual int flags (void) const = 0; - - /// I/O handle used for writing. - virtual ACE_HANDLE handle (void) const = 0; - -protected: - /// Do-nothing constructor. - ACE_Asynch_Write_Dgram_Result_Impl (void); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Asynch_IO_Impl.inl" -#endif /* __ACE_INLINE__ */ - -#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ -#include /**/ "ace/post.h" -#endif /* ACE_ASYNCH_IO_IMPL_H */ diff --git a/ACE/ace/Asynch_IO_Impl.inl b/ACE/ace/Asynch_IO_Impl.inl deleted file mode 100644 index 495a768a972..00000000000 --- a/ACE/ace/Asynch_IO_Impl.inl +++ /dev/null @@ -1,106 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_Asynch_Result_Impl::ACE_Asynch_Result_Impl (void) -{ -} - -ACE_INLINE -ACE_Asynch_Operation_Impl::ACE_Asynch_Operation_Impl (void) -{ -} - -ACE_INLINE -ACE_Asynch_Read_Stream_Impl::ACE_Asynch_Read_Stream_Impl (void) - : ACE_Asynch_Operation_Impl () -{ -} - -ACE_INLINE -ACE_Asynch_Read_Stream_Result_Impl::ACE_Asynch_Read_Stream_Result_Impl (void) - : ACE_Asynch_Result_Impl () -{ -} - -ACE_INLINE -ACE_Asynch_Write_Stream_Impl::ACE_Asynch_Write_Stream_Impl (void) - : ACE_Asynch_Operation_Impl () -{ -} - -ACE_INLINE -ACE_Asynch_Write_Stream_Result_Impl::ACE_Asynch_Write_Stream_Result_Impl (void) - : ACE_Asynch_Result_Impl () -{ -} - -ACE_INLINE -ACE_Asynch_Read_File_Impl::ACE_Asynch_Read_File_Impl (void) - : ACE_Asynch_Operation_Impl (), - ACE_Asynch_Read_Stream_Impl () -{ -} - -ACE_INLINE -ACE_Asynch_Read_File_Result_Impl::ACE_Asynch_Read_File_Result_Impl (void) - : ACE_Asynch_Result_Impl (), - ACE_Asynch_Read_Stream_Result_Impl () -{ -} - -ACE_INLINE -ACE_Asynch_Write_File_Impl::ACE_Asynch_Write_File_Impl (void) - : ACE_Asynch_Operation_Impl (), - ACE_Asynch_Write_Stream_Impl () -{ -} - -ACE_INLINE -ACE_Asynch_Write_File_Result_Impl::ACE_Asynch_Write_File_Result_Impl (void) - : ACE_Asynch_Result_Impl (), - ACE_Asynch_Write_Stream_Result_Impl () -{ -} - -ACE_INLINE -ACE_Asynch_Accept_Impl::ACE_Asynch_Accept_Impl (void) - : ACE_Asynch_Operation_Impl () -{ -} - -ACE_INLINE -ACE_Asynch_Accept_Result_Impl::ACE_Asynch_Accept_Result_Impl (void) - : ACE_Asynch_Result_Impl () -{ -} - -ACE_INLINE -ACE_Asynch_Connect_Impl::ACE_Asynch_Connect_Impl (void) - : ACE_Asynch_Operation_Impl () -{ -} - -ACE_INLINE -ACE_Asynch_Connect_Result_Impl::ACE_Asynch_Connect_Result_Impl (void) - : ACE_Asynch_Result_Impl () -{ -} - - -ACE_INLINE -ACE_Asynch_Transmit_File_Impl::ACE_Asynch_Transmit_File_Impl (void) - : ACE_Asynch_Operation_Impl () -{ -} - -ACE_INLINE -ACE_Asynch_Transmit_File_Result_Impl::ACE_Asynch_Transmit_File_Result_Impl (void) - : ACE_Asynch_Result_Impl () -{ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Asynch_Pseudo_Task.cpp b/ACE/ace/Asynch_Pseudo_Task.cpp deleted file mode 100644 index 6bc47866b6f..00000000000 --- a/ACE/ace/Asynch_Pseudo_Task.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// $Id$ - -#include "ace/Asynch_Pseudo_Task.h" - -#include "ace/OS_NS_errno.h" -#include "ace/OS_NS_signal.h" - -ACE_RCSID(ace, Asynch_Pseudo_Task, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_Asynch_Pseudo_Task::ACE_Asynch_Pseudo_Task () - : select_reactor_ (), // should be initialized before reactor_ - reactor_ (&select_reactor_, 0) // don't delete implementation -{ -} - -ACE_Asynch_Pseudo_Task::~ACE_Asynch_Pseudo_Task () -{ - this->stop (); -} - -int -ACE_Asynch_Pseudo_Task::start (void) -{ - if (this->reactor_.initialized () == 0) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%N:%l:%p\n"), - ACE_TEXT ("start reactor is not initialized")), - -1); - - return this->activate () == -1 ? -1 : 0; // If started, return 0 -} - -int -ACE_Asynch_Pseudo_Task::stop (void) -{ - if (this->thr_count () == 0) // already stopped - return 0; - - if (this->reactor_.end_reactor_event_loop () == -1) - return -1; - - this->wait (); - this->reactor_.close (); - return 0; -} - -int -ACE_Asynch_Pseudo_Task::svc (void) -{ -#if !defined (ACE_WIN32) - - sigset_t RT_signals; - - sigemptyset (&RT_signals); - for (int si = ACE_SIGRTMIN; si <= ACE_SIGRTMAX; si++) - sigaddset (&RT_signals, si); - - if (ACE_OS::pthread_sigmask (SIG_BLOCK, &RT_signals, 0) != 0) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("Error:(%P | %t):%p\n"), - ACE_TEXT ("pthread_sigmask"))); -#endif - - reactor_.owner (ACE_Thread::self ()); - reactor_.run_reactor_event_loop (); - - return 0; -} - - - -int -ACE_Asynch_Pseudo_Task::register_io_handler (ACE_HANDLE handle, - ACE_Event_Handler *handler, - ACE_Reactor_Mask mask, - int flg_suspend) -{ - // Register the handler with the reactor. - if (-1 == this->reactor_.register_handler (handle, handler, mask)) - return -1; - - if (flg_suspend == 0) - return 0; - - // Suspend the handle now. Enable only when the accept is issued - // by the application. - if (this->reactor_.suspend_handler (handle) == -1) - { - ACE_ERROR - ((LM_ERROR, - ACE_TEXT ("%N:%l:%p\n"), - ACE_TEXT ("register_io_handler (suspended)"))); - this->reactor_.remove_handler (handle, ACE_Event_Handler::ALL_EVENTS_MASK - | ACE_Event_Handler::DONT_CALL); - return -1; - } - - return 0; -} - -int -ACE_Asynch_Pseudo_Task::remove_io_handler (ACE_HANDLE handle) -{ - return this->reactor_.remove_handler (handle, - ACE_Event_Handler::ALL_EVENTS_MASK - | ACE_Event_Handler::DONT_CALL); -} - -int -ACE_Asynch_Pseudo_Task::remove_io_handler (ACE_Handle_Set &set) -{ - return this->reactor_.remove_handler (set, ACE_Event_Handler::ALL_EVENTS_MASK - | ACE_Event_Handler::DONT_CALL); -} - -int -ACE_Asynch_Pseudo_Task::suspend_io_handler (ACE_HANDLE handle) -{ - return this->reactor_.suspend_handler (handle); -} - -int -ACE_Asynch_Pseudo_Task::resume_io_handler (ACE_HANDLE handle) -{ - return this->reactor_.resume_handler (handle); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Asynch_Pseudo_Task.h b/ACE/ace/Asynch_Pseudo_Task.h deleted file mode 100644 index 235d71411ba..00000000000 --- a/ACE/ace/Asynch_Pseudo_Task.h +++ /dev/null @@ -1,73 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Asynch_Pseudo_Task.h - * - * $Id$ - * - * @author Alexander Libman - */ -//============================================================================= - -#ifndef ACE_ASYNCH_PSEUDO_TASK_H -#define ACE_ASYNCH_PSEUDO_TASK_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Reactor.h" -#include "ace/Select_Reactor.h" -#include "ace/Task.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/* - * Specialization hook to replace the Reactor with the - * concrete Reactor implementation, e.g., select_st, - * select_mt etc. - */ -//@@ REACTOR_SPL_INCLUDE_FORWARD_DECL_ADD_HOOK - -/** - * @class ACE_Asynch_Pseudo_Task - * - */ -class ACE_Export ACE_Asynch_Pseudo_Task : public ACE_Task -{ -public: - ACE_Asynch_Pseudo_Task(); - virtual ~ACE_Asynch_Pseudo_Task(); - - int start (void); - int stop (void); - - int register_io_handler (ACE_HANDLE handle, - ACE_Event_Handler *handler, - ACE_Reactor_Mask mask, - int flg_suspend); - - int remove_io_handler (ACE_HANDLE handle); - int remove_io_handler (ACE_Handle_Set &set); - int resume_io_handler (ACE_HANDLE handle); - int suspend_io_handler (ACE_HANDLE handle); - -protected: - virtual int svc (void); - - /// Should be initialized before reactor_ - ACE_Select_Reactor select_reactor_; - - ACE_Reactor reactor_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#include /**/ "ace/post.h" - -#endif /* ACE_ASYNCH_PSEUDO_TASK_H */ diff --git a/ACE/ace/Atomic_Op.cpp b/ACE/ace/Atomic_Op.cpp deleted file mode 100644 index 9076b9f67ed..00000000000 --- a/ACE/ace/Atomic_Op.cpp +++ /dev/null @@ -1,310 +0,0 @@ -// $Id$ - -#include "ace/Atomic_Op.h" -#include "ace/OS_NS_unistd.h" - -ACE_RCSID (ace, - Atomic_Op, - "$Id$") - -#if !defined (__ACE_INLINE__) -#include "ace/Atomic_Op.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_HAS_BUILTIN_ATOMIC_OP) - -#if defined (ACE_INCLUDE_ATOMIC_OP_SPARC) -# include "ace/Atomic_Op_Sparc.h" -#endif /* ACE_INCLUDE_ATOMIC_OP_SPARC */ - -namespace { - -#if defined (_MSC_VER) -// Disable "no return value" warning, as we will be putting -// the return values directly into the EAX register. -#pragma warning (push) -#pragma warning (disable: 4035) -#endif /* _MSC_VER */ - -long -single_cpu_increment (volatile long *value) -{ -#if defined (ACE_HAS_INTEL_ASSEMBLY) - long tmp = 1; - unsigned long addr = reinterpret_cast (value); - asm( "xadd %0, (%1)" : "+r"(tmp) : "r"(addr) ); - return tmp + 1; -#elif defined (sun) || \ - (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64))) - return ace_atomic_add_long ( - reinterpret_cast (value), 1); -#elif defined(__GNUC__) && defined(PPC) - long tmp; - asm("lwz %0,%1" : "=r" (tmp) : "m" (*value) ); - asm("addi %0,%0,1" : "+r" (tmp) ); - asm("stw %0,%1" : "+r" (tmp), "=m" (*value) ); - return tmp; -#else /* ACE_HAS_INTEL_ASSEMBLY*/ - ACE_UNUSED_ARG (value); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_INTEL_ASSEMBLY*/ -} - -long -single_cpu_decrement (volatile long *value) -{ -#if defined (ACE_HAS_INTEL_ASSEMBLY) - long tmp = -1; - unsigned long addr = reinterpret_cast (value); - asm( "xadd %0, (%1)" : "+r"(tmp) : "r"(addr) ); - return tmp - 1; -#elif defined (sun) || \ - (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64))) - return ace_atomic_add_long ( - reinterpret_cast (value), -1); -#elif defined(__GNUC__) && defined(PPC) - long tmp; - asm("lwz %0,%1" : "=r" (tmp) : "m" (*value) ); - asm("addi %0,%0,-1" : "+r" (tmp) ); - asm("stw %0,%1" : "+r" (tmp), "=m" (*value) ); - return tmp; -#else /* ACE_HAS_INTEL_ASSEMBLY*/ - ACE_UNUSED_ARG (value); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_INTEL_ASSEMBLY*/ -} - -long -single_cpu_exchange (volatile long *value, long rhs) -{ -#if defined (ACE_HAS_INTEL_ASSEMBLY) - unsigned long addr = reinterpret_cast (value); - asm( "xchg %0, (%1)" : "+r"(rhs) : "r"(addr) ); - return rhs; -#elif defined (sun) || \ - (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64))) - return ace_atomic_swap_long ( - reinterpret_cast (value), rhs); -#elif defined(__GNUC__) && defined(PPC) - long tmp; - asm("lwz %0,%1" : "=r" (tmp) : "m" (rhs) ); - asm("stw %0,%1" : "+r" (tmp), "=m" (*value) ); - return tmp; -#else /* ACE_HAS_INTEL_ASSEMBLY*/ - ACE_UNUSED_ARG (value); - ACE_UNUSED_ARG (rhs); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_INTEL_ASSEMBLY*/ -} - -long -single_cpu_exchange_add (volatile long *value, long rhs) -{ -#if defined (ACE_HAS_INTEL_ASSEMBLY) - unsigned long addr = reinterpret_cast (value); - asm( "xadd %0, (%1)" : "+r"(rhs) : "r"(addr) ); - return rhs; -#elif defined (sun) || \ - (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64))) - return ace_atomic_swap_add_long ( - reinterpret_cast (value), rhs); -#elif defined(__GNUC__) && defined(PPC) - long tmp; - asm("add %0,%1,%2" : "=r" (tmp) : "r" (*value), "r" (rhs) ); - asm("stw %0,%1" : "+r" (tmp), "=m" (*value) ); - return tmp; -#elif defined (WIN32) && !defined (ACE_HAS_INTERLOCKED_EXCHANGEADD) -# if defined (_MSC_VER) - __asm - { - mov eax, rhs - mov edx, value - xadd [edx], eax - } - // Return value is already in EAX register. -# elif defined (__BORLANDC__) - _EAX = rhs; - _EDX = reinterpret_cast (value); - __emit__(0x0F, 0xC1, 0x02); // xadd [edx], eax - // Return value is already in EAX register. -# else /* _MSC_VER */ - ACE_UNUSED_ARG (value); - ACE_UNUSED_ARG (rhs); - ACE_NOTSUP_RETURN (-1); -# endif /* _MSC_VER */ -#else /* ACE_HAS_INTEL_ASSEMBLY*/ - ACE_UNUSED_ARG (value); - ACE_UNUSED_ARG (rhs); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_INTEL_ASSEMBLY*/ -} - -long -multi_cpu_increment (volatile long *value) -{ -#if defined (ACE_HAS_INTEL_ASSEMBLY) - long tmp = 1; - unsigned long addr = reinterpret_cast (value); - asm( "lock ; xadd %0, (%1)" : "+r"(tmp) : "r"(addr) ); - return tmp + 1; -#elif defined (sun) || \ - (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64))) - return ace_atomic_add_long ( - reinterpret_cast (value), 1); -#else /* ACE_HAS_INTEL_ASSEMBLY*/ - ACE_UNUSED_ARG (value); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_INTEL_ASSEMBLY*/ -} - -long -multi_cpu_decrement (volatile long *value) -{ -#if defined (ACE_HAS_INTEL_ASSEMBLY) - long tmp = -1; - unsigned long addr = reinterpret_cast (value); - asm( "lock ; xadd %0, (%1)" : "+r"(tmp) : "r"(addr) ); - return tmp - 1; -#elif defined (sun) || \ - (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64))) - return ace_atomic_add_long ( - reinterpret_cast (value), -1); -#else /* ACE_HAS_INTEL_ASSEMBLY*/ - ACE_UNUSED_ARG (value); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_INTEL_ASSEMBLY*/ -} - -long -multi_cpu_exchange (volatile long *value, long rhs) -{ -#if defined (ACE_HAS_INTEL_ASSEMBLY) - unsigned long addr = reinterpret_cast (value); - // The XCHG instruction automatically follows LOCK semantics - asm( "xchg %0, (%1)" : "+r"(rhs) : "r"(addr) ); - return rhs; -#elif defined (sun) || \ - (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64))) - return ace_atomic_swap_long ( - reinterpret_cast (value), rhs); -#else /* ACE_HAS_INTEL_ASSEMBLY*/ - ACE_UNUSED_ARG (value); - ACE_UNUSED_ARG (rhs); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_INTEL_ASSEMBLY*/ -} - -long -multi_cpu_exchange_add (volatile long *value, long rhs) -{ -#if defined (ACE_HAS_INTEL_ASSEMBLY) - unsigned long addr = reinterpret_cast (value); - asm( "lock ; xadd %0, (%1)" : "+r"(rhs) : "r"(addr) ); - return rhs; -#elif defined (sun) || \ - (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64))) - return ace_atomic_swap_add_long ( - reinterpret_cast (value), rhs); -#elif defined (WIN32) && !defined (ACE_HAS_INTERLOCKED_EXCHANGEADD) -# if defined (_MSC_VER) - __asm - { - mov eax, rhs - mov edx, value - lock xadd [edx], eax - } - // Return value is already in EAX register. -# elif defined (__BORLANDC__) - _EAX = rhs; - _EDX = reinterpret_cast (value); - __emit__(0xF0, 0x0F, 0xC1, 0x02); // lock xadd [edx], eax - // Return value is already in EAX register. -# else /* _MSC_VER */ - ACE_UNUSED_ARG (value); - ACE_UNUSED_ARG (rhs); - ACE_NOTSUP_RETURN (-1); -# endif /* _MSC_VER */ -#else /* ACE_HAS_INTEL_ASSEMBLY*/ - ACE_UNUSED_ARG (value); - ACE_UNUSED_ARG (rhs); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_INTEL_ASSEMBLY*/ -} - -#if defined (_MSC_VER) -#pragma warning (pop) -#endif /* _MSC_VER */ - -} // end namespace - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -long (*ACE_Atomic_Op::increment_fn_) (volatile long *) = multi_cpu_increment; -long (*ACE_Atomic_Op::decrement_fn_) (volatile long *) = multi_cpu_decrement; -long (*ACE_Atomic_Op::exchange_fn_) (volatile long *, long) = multi_cpu_exchange; -long (*ACE_Atomic_Op::exchange_add_fn_) (volatile long *, long) = multi_cpu_exchange_add; - -void -ACE_Atomic_Op::init_functions (void) -{ - if (ACE_OS::num_processors () == 1) - { - increment_fn_ = single_cpu_increment; - decrement_fn_ = single_cpu_decrement; - exchange_fn_ = single_cpu_exchange; - exchange_add_fn_ = single_cpu_exchange_add; - } - else - { - increment_fn_ = multi_cpu_increment; - decrement_fn_ = multi_cpu_decrement; - exchange_fn_ = multi_cpu_exchange; - exchange_add_fn_ = multi_cpu_exchange_add; - } -} - -void -ACE_Atomic_Op::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -long (*ACE_Atomic_Op::increment_fn_) (volatile long *) = multi_cpu_increment; -long (*ACE_Atomic_Op::decrement_fn_) (volatile long *) = multi_cpu_decrement; -long (*ACE_Atomic_Op::exchange_fn_) (volatile long *, long) = multi_cpu_exchange; -long (*ACE_Atomic_Op::exchange_add_fn_) (volatile long *, long) = multi_cpu_exchange_add; - -void -ACE_Atomic_Op::init_functions (void) -{ - if (ACE_OS::num_processors () == 1) - { - increment_fn_ = single_cpu_increment; - decrement_fn_ = single_cpu_decrement; - exchange_fn_ = single_cpu_exchange; - exchange_add_fn_ = single_cpu_exchange_add; - } - else - { - increment_fn_ = multi_cpu_increment; - decrement_fn_ = multi_cpu_decrement; - exchange_fn_ = multi_cpu_exchange; - exchange_add_fn_ = multi_cpu_exchange_add; - } -} - -void -ACE_Atomic_Op::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_BUILTIN_ATOMIC_OP */ diff --git a/ACE/ace/Atomic_Op.h b/ACE/ace/Atomic_Op.h deleted file mode 100644 index 24abb64ef1d..00000000000 --- a/ACE/ace/Atomic_Op.h +++ /dev/null @@ -1,260 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Atomic_Op.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_ATOMIC_OP_H -#define ACE_ATOMIC_OP_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Thread_Mutex.h" - -// Include the templates here. -#include "ace/Atomic_Op_T.h" - -// Determine whether builtin atomic op support is -// available on this platform. -#if defined (ACE_HAS_THREADS) -# if defined (WIN32) -# if defined (ACE_HAS_INTRINSIC_INTERLOCKED) -# define ACE_HAS_BUILTIN_ATOMIC_OP -# endif /* ACE_HAS_INTRINSIC_INTERLOCKED */ -# if defined (ACE_HAS_INTERLOCKED_EXCHANGEADD) -# define ACE_HAS_BUILTIN_ATOMIC_OP -# else /* ACE_HAS_INTERLOCKED_EXCHANGEADD */ - // Inline assembly emulation of InterlockedExchangeAdd - // is currently only implemented for MSVC (x86 only) and Borland. -# if (defined (_MSC_VER) && defined (_M_IX86)) || defined (__BORLANDC__) -# define ACE_HAS_BUILTIN_ATOMIC_OP -# endif /* _MSC_VER || __BORLANDC__ */ -# endif /* ACE_HAS_INTERLOCKED_EXCHANGEADD */ -# elif defined (ACE_HAS_INTEL_ASSEMBLY) -# define ACE_HAS_BUILTIN_ATOMIC_OP -# endif /* WIN32 */ -#endif /* ACE_HAS_THREADS */ - -#if defined (ACE_HAS_BUILTIN_ATOMIC_OP) - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Atomic_Op - * - * @brief Specialization of ACE_Atomic_Op for platforms that - * support atomic integer operations. - * - * Specialization of ACE_Atomic_Op for platforms that support atomic - * integer operations. - */ -template<> -class ACE_Export ACE_Atomic_Op -{ -public: - /// Initialize to 0. - ACE_Atomic_Op (void); - - /// Initialize to c. - ACE_Atomic_Op (long c); - - /// Manage copying... - ACE_Atomic_Op (const ACE_Atomic_Op &c); - - /// Atomically pre-increment . - long operator++ (void); - - /// Atomically post-increment . - long operator++ (int); - - /// Atomically increment by rhs. - long operator+= (long rhs); - - /// Atomically pre-decrement . - long operator-- (void); - - /// Atomically post-decrement . - long operator-- (int); - - /// Atomically decrement by rhs. - long operator-= (long rhs); - - /// Atomically compare with rhs. - bool operator== (long rhs) const; - - /// Atomically compare with rhs. - bool operator!= (long rhs) const; - - /// Atomically check if greater than or equal to rhs. - bool operator>= (long rhs) const; - - /// Atomically check if greater than rhs. - bool operator> (long rhs) const; - - /// Atomically check if less than or equal to rhs. - bool operator<= (long rhs) const; - - /// Atomically check if less than rhs. - bool operator< (long rhs) const; - - /// Atomically assign rhs to . - ACE_Atomic_Op &operator= (long rhs); - - /// Atomically assign to . - ACE_Atomic_Op &operator= (const ACE_Atomic_Op &rhs); - - /// Explicitly return . - long value (void) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Explicitly return (by reference). - volatile long &value_i (void); - - // ACE_ALLOC_HOOK_DECLARE; - // Declare the dynamic allocation hooks. - - /// Used during ACE object manager initialization to optimize the fast - /// atomic op implementation according to the number of CPUs. - static void init_functions (void); - -private: - - // This function cannot be supported by this template specialization. - // If you need access to an underlying lock, use the ACE_Atomic_Op_Ex - // template instead. - ACE_Thread_Mutex &mutex (void); - -private: - - /// Current object decorated by the atomic op. - volatile long value_; - - // Pointers to selected atomic op implementations. - static long (*increment_fn_) (volatile long *); - static long (*decrement_fn_) (volatile long *); - static long (*exchange_fn_) (volatile long *, long); - static long (*exchange_add_fn_) (volatile long *, long); -}; - -/** - * @class ACE_Atomic_Op - * - * @brief Specialization of ACE_Atomic_Op for platforms that - * support atomic integer operations. - * - * Specialization of ACE_Atomic_Op for platforms that support atomic - * integer operations. - */ -template<> -class ACE_Export ACE_Atomic_Op -{ -public: - /// Initialize to 0. - ACE_Atomic_Op (void); - - /// Initialize to c. - ACE_Atomic_Op (unsigned long c); - - /// Manage copying... - ACE_Atomic_Op (const ACE_Atomic_Op &c); - - /// Atomically pre-increment . - unsigned long operator++ (void); - - /// Atomically post-increment . - unsigned long operator++ (int); - - /// Atomically increment by rhs. - unsigned long operator+= (unsigned long rhs); - - /// Atomically pre-decrement . - unsigned long operator-- (void); - - /// Atomically post-decrement . - unsigned long operator-- (int); - - /// Atomically decrement by rhs. - unsigned long operator-= (unsigned long rhs); - - /// Atomically compare with rhs. - bool operator== (unsigned long rhs) const; - - /// Atomically compare with rhs. - bool operator!= (unsigned long rhs) const; - - /// Atomically check if greater than or equal to rhs. - bool operator>= (unsigned long rhs) const; - - /// Atomically check if greater than rhs. - bool operator> (unsigned long rhs) const; - - /// Atomically check if less than or equal to rhs. - bool operator<= (unsigned long rhs) const; - - /// Atomically check if less than rhs. - bool operator< (unsigned long rhs) const; - - /// Atomically assign rhs to . - ACE_Atomic_Op &operator= (unsigned long rhs); - - /// Atomically assign to . - ACE_Atomic_Op &operator= (const ACE_Atomic_Op &rhs); - - /// Explicitly return . - unsigned long value (void) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Explicitly return (by reference). - volatile unsigned long &value_i (void); - - // ACE_ALLOC_HOOK_DECLARE; - // Declare the dynamic allocation hooks. - - /// Used during ACE object manager initialization to optimize the fast - /// atomic op implementation according to the number of CPUs. - static void init_functions (void); - -private: - - // This function cannot be supported by this template specialization. - // If you need access to an underlying lock, use the ACE_Atomic_Op_Ex - // template instead. - ACE_Thread_Mutex &mutex (void); - -private: - - /// Current object decorated by the atomic op. - volatile unsigned long value_; - - // Pointers to selected atomic op implementations. - static long (*increment_fn_) (volatile long *); - static long (*decrement_fn_) (volatile long *); - static long (*exchange_fn_) (volatile long *, long); - static long (*exchange_add_fn_) (volatile long *, long); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_BUILTIN_ATOMIC_OP */ - -#if defined (__ACE_INLINE__) -#include "ace/Atomic_Op.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /*ACE_ATOMIC_OP_H*/ diff --git a/ACE/ace/Atomic_Op.inl b/ACE/ace/Atomic_Op.inl deleted file mode 100644 index 4d55f05b091..00000000000 --- a/ACE/ace/Atomic_Op.inl +++ /dev/null @@ -1,335 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#if defined (ACE_HAS_BUILTIN_ATOMIC_OP) - -#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) -# include "ace/os_include/os_intrin.h" - -#pragma intrinsic (_InterlockedExchange, _InterlockedExchangeAdd, _InterlockedIncrement, _InterlockedDecrement) -#endif /* ACE_HAS_INTRINSIC_INTERLOCKED */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_Atomic_Op::ACE_Atomic_Op (void) - : value_ (0) -{ -} - -ACE_INLINE -ACE_Atomic_Op::ACE_Atomic_Op (long c) - : value_ (c) -{ -} - -ACE_INLINE -ACE_Atomic_Op::ACE_Atomic_Op ( - const ACE_Atomic_Op &rhs) - : value_ (rhs.value_) -{ -} - -ACE_INLINE long -ACE_Atomic_Op::operator++ (void) -{ -#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) - return ::_InterlockedIncrement (const_cast (&this->value_)); -#elif defined (WIN32) - return ::InterlockedIncrement (const_cast (&this->value_)); -#else /* WIN32 */ - return (*increment_fn_) (&this->value_); -#endif /* WIN32 */ -} - -ACE_INLINE long -ACE_Atomic_Op::operator++ (int) -{ - return ++*this - 1; -} - -ACE_INLINE long -ACE_Atomic_Op::operator-- (void) -{ -#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) - return ::_InterlockedDecrement (const_cast (&this->value_)); -#elif defined (WIN32) - return ::InterlockedDecrement (const_cast (&this->value_)); -#else /* WIN32 */ - return (*decrement_fn_) (&this->value_); -#endif /* WIN32 */ -} - -ACE_INLINE long -ACE_Atomic_Op::operator-- (int) -{ - return --*this + 1; -} - -ACE_INLINE long -ACE_Atomic_Op::operator+= (long rhs) -{ -#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) - return ::_InterlockedExchangeAdd (const_cast (&this->value_), - rhs) + rhs; -#elif defined (WIN32) && defined (ACE_HAS_INTERLOCKED_EXCHANGEADD) - return ::InterlockedExchangeAdd (const_cast (&this->value_), - rhs) + rhs; -#else /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ - return (*exchange_add_fn_) (&this->value_, rhs) + rhs; -#endif /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ -} - -ACE_INLINE long -ACE_Atomic_Op::operator-= (long rhs) -{ -#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) - return ::_InterlockedExchangeAdd (const_cast (&this->value_), - -rhs) - rhs; -#elif defined (WIN32) && defined (ACE_HAS_INTERLOCKED_EXCHANGEADD) - return ::InterlockedExchangeAdd (const_cast (&this->value_), - -rhs) - rhs; -#else /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ - return (*exchange_add_fn_) (&this->value_, -rhs) - rhs; -#endif /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ -} - -ACE_INLINE bool -ACE_Atomic_Op::operator== (long rhs) const -{ - return (this->value_ == rhs); -} - -ACE_INLINE bool -ACE_Atomic_Op::operator!= (long rhs) const -{ - return (this->value_ != rhs); -} - -ACE_INLINE bool -ACE_Atomic_Op::operator>= (long rhs) const -{ - return (this->value_ >= rhs); -} - -ACE_INLINE bool -ACE_Atomic_Op::operator> (long rhs) const -{ - return (this->value_ > rhs); -} - -ACE_INLINE bool -ACE_Atomic_Op::operator<= (long rhs) const -{ - return (this->value_ <= rhs); -} - -ACE_INLINE bool -ACE_Atomic_Op::operator< (long rhs) const -{ - return (this->value_ < rhs); -} - -ACE_INLINE ACE_Atomic_Op & -ACE_Atomic_Op::operator= (long rhs) -{ -#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) - ::_InterlockedExchange (const_cast (&this->value_), rhs); -#elif defined (WIN32) - ::InterlockedExchange (const_cast (&this->value_), rhs); -#else /* WIN32 */ - (*exchange_fn_) (&this->value_, rhs); -#endif /* WIN32 */ - return *this; -} - -ACE_INLINE ACE_Atomic_Op & -ACE_Atomic_Op::operator= ( - const ACE_Atomic_Op &rhs) -{ -#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) - ::_InterlockedExchange (const_cast (&this->value_), rhs.value_); -#elif defined (WIN32) - ::InterlockedExchange (const_cast (&this->value_), rhs.value_); -#else /* WIN32 */ - (*exchange_fn_) (&this->value_, rhs.value_); -#endif /* WIN32 */ - return *this; -} - -ACE_INLINE long -ACE_Atomic_Op::value (void) const -{ - return this->value_; -} - -ACE_INLINE volatile long & -ACE_Atomic_Op::value_i (void) -{ - return this->value_; -} - - -ACE_INLINE -ACE_Atomic_Op::ACE_Atomic_Op (void) - : value_ (0) -{ -} - -ACE_INLINE -ACE_Atomic_Op::ACE_Atomic_Op (unsigned long c) - : value_ (c) -{ -} - -ACE_INLINE -ACE_Atomic_Op::ACE_Atomic_Op ( - const ACE_Atomic_Op &rhs) - : value_ (rhs.value_) -{ -} - -ACE_INLINE unsigned long -ACE_Atomic_Op::operator++ (void) -{ -#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) - return static_cast (::_InterlockedIncrement (const_cast (reinterpret_cast(&this->value_)))); -#elif defined (WIN32) - return static_cast (::InterlockedIncrement (const_cast (reinterpret_cast(&this->value_)))); -#else /* WIN32 */ - return static_cast ((*increment_fn_) (reinterpret_cast (&this->value_))); -#endif /* WIN32 */ -} - -ACE_INLINE unsigned long -ACE_Atomic_Op::operator++ (int) -{ - return ++*this - 1; -} - -ACE_INLINE unsigned long -ACE_Atomic_Op::operator-- (void) -{ -#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) - return static_cast (::_InterlockedDecrement (const_cast (reinterpret_cast(&this->value_)))); -#elif defined (WIN32) - return static_cast (::InterlockedDecrement (const_cast (reinterpret_cast(&this->value_)))); -#else /* WIN32 */ - return static_cast ((*decrement_fn_) (reinterpret_cast (&this->value_))); -#endif /* WIN32 */ -} - -ACE_INLINE unsigned long -ACE_Atomic_Op::operator-- (int) -{ - return --*this + 1; -} - -ACE_INLINE unsigned long -ACE_Atomic_Op::operator+= (unsigned long rhs) -{ -#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) - return static_cast (::_InterlockedExchangeAdd (const_cast (reinterpret_cast (&this->value_)), - rhs)) + rhs; -#elif defined (WIN32) && defined (ACE_HAS_INTERLOCKED_EXCHANGEADD) - return static_cast (::InterlockedExchangeAdd (const_cast (reinterpret_cast (&this->value_)), - rhs)) + rhs; -#else /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ - return static_cast ((*exchange_add_fn_) (reinterpret_cast (&this->value_), rhs)) + rhs; -#endif /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ -} - -ACE_INLINE unsigned long -ACE_Atomic_Op::operator-= (unsigned long rhs) -{ -#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) - return static_cast (::_InterlockedExchangeAdd (const_cast (reinterpret_cast(&this->value_)), - -static_cast(rhs))) - rhs; -#elif defined (WIN32) && defined (ACE_HAS_INTERLOCKED_EXCHANGEADD) - return static_cast (::InterlockedExchangeAdd (const_cast (reinterpret_cast(&this->value_)), - -static_cast(rhs))) - rhs; -#else /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ - long l_rhs = static_cast (rhs); - return static_cast ((*exchange_add_fn_) (reinterpret_cast (&this->value_), -l_rhs)) - rhs; -#endif /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ -} - -ACE_INLINE bool -ACE_Atomic_Op::operator== (unsigned long rhs) const -{ - return (this->value_ == rhs); -} - -ACE_INLINE bool -ACE_Atomic_Op::operator!= (unsigned long rhs) const -{ - return (this->value_ != rhs); -} - -ACE_INLINE bool -ACE_Atomic_Op::operator>= (unsigned long rhs) const -{ - return (this->value_ >= rhs); -} - -ACE_INLINE bool -ACE_Atomic_Op::operator> (unsigned long rhs) const -{ - return (this->value_ > rhs); -} - -ACE_INLINE bool -ACE_Atomic_Op::operator<= (unsigned long rhs) const -{ - return (this->value_ <= rhs); -} - -ACE_INLINE bool -ACE_Atomic_Op::operator< (unsigned long rhs) const -{ - return (this->value_ < rhs); -} - -ACE_INLINE ACE_Atomic_Op & -ACE_Atomic_Op::operator= (unsigned long rhs) -{ -#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) - ::_InterlockedExchange (const_cast (reinterpret_cast (&this->value_)), rhs); -#elif defined (WIN32) - ::InterlockedExchange (const_cast (reinterpret_cast (&this->value_)), rhs); -#else /* WIN32 */ - (*exchange_fn_) (reinterpret_cast (&this->value_), rhs); -#endif /* WIN32 */ - return *this; -} - -ACE_INLINE ACE_Atomic_Op & -ACE_Atomic_Op::operator= ( - const ACE_Atomic_Op &rhs) -{ -#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) - ::_InterlockedExchange (const_cast (reinterpret_cast (&this->value_)), rhs.value_); -#elif defined (WIN32) - ::InterlockedExchange (const_cast (reinterpret_cast (&this->value_)), rhs.value_); -#else /* WIN32 */ - (*exchange_fn_) (reinterpret_cast (&this->value_), rhs.value_); -#endif /* WIN32 */ - return *this; -} - -ACE_INLINE unsigned long -ACE_Atomic_Op::value (void) const -{ - return this->value_; -} - -ACE_INLINE volatile unsigned long & -ACE_Atomic_Op::value_i (void) -{ - return this->value_; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_BUILTIN_ATOMIC_OP */ diff --git a/ACE/ace/Atomic_Op_Sparc.c b/ACE/ace/Atomic_Op_Sparc.c deleted file mode 100644 index 75d64eb6ac5..00000000000 --- a/ACE/ace/Atomic_Op_Sparc.c +++ /dev/null @@ -1,187 +0,0 @@ -/* $Id$ - * - * This is a C file for a reason. The Sun C++ compiler does not accept - * inline assembler. - * - * Portions of this code are based on atomic operations found in the - * linux kernel source code. - */ - -#if defined (ACE_INCLUDE_ATOMIC_OP_SPARC) - -#if defined(__i386) && defined(__SUNPRO_C) -static void -__sunpro_asm_code() { - __asm("\n\ - .globl ace_atomic_add_long \n\ - .type ace_atomic_add_long,@function \n\ - .align 4 \n\ -ace_atomic_add_long: \n\ - movl 0x00000004(%esp), %edx \n\ - movl 0x00000008(%esp), %eax \n\ - lock; xadd %eax, (%edx) \n\ - addl 0x00000008(%esp), %eax \n\ - ret \n\ - "); - - __asm("\n\ - .globl ace_atomic_swap_long \n\ - .type ace_atomic_swap_long,@function \n\ - .align 4 \n\ -ace_atomic_swap_long: \n\ - movl 0x00000004(%esp), %edx \n\ - movl 0x00000008(%esp), %eax \n\ - xchg %eax, (%edx) \n\ - ret \n\ - "); - - __asm("\n\ - .globl ace_atomic_swap_add_long \n\ - .type ace_atomic_swap_add_long,@function \n\ - .align 4 \n\ -ace_atomic_swap_add_long: \n\ - movl 0x00000004(%esp), %edx \n\ - movl 0x00000008(%esp), %eax \n\ - lock; xadd %eax, (%edx) \n\ - ret \n\ - "); -} - -#elif defined(__x86_64) && defined(__SUNPRO_C) - -static void -__sunpro_asm_code() { - __asm("\n\ - .globl ace_atomic_add_long \n\ - .type ace_atomic_add_long,@function \n\ - .align 16 \n\ -ace_atomic_add_long: \n\ - movq %rsi, %rax \n\ - lock; xaddq %rax, (%rdi) \n\ - addq %rsi, %rax \n\ - ret \n\ - "); - - __asm("\n\ - .globl ace_atomic_swap_long \n\ - .type ace_atomic_swap_long,@function \n\ - .align 16 \n\ -ace_atomic_swap_long: \n\ - xchgq %rsi, (%rdi) \n\ - movq %rsi, %rax \n\ - ret \n\ - "); - - __asm("\n\ - .globl ace_atomic_swap_add_long \n\ - .type ace_atomic_swap_add_long,@function \n\ - .align 16 \n\ -ace_atomic_swap_add_long: \n\ - lock; xaddq %rsi, (%rdi) \n\ - movq %rsi, %rax \n\ - ret \n\ - "); -} - -#elif defined (__sparcv9) - -unsigned long -ace_atomic_add_long (volatile unsigned long *dest, long rhs) -{ - __asm ("restore\n" - "ldx [%o0], %o2\n" - ".again_add:\n" - "add %o2, %o1, %o3\n" - "casx [%o0], %o2, %o3\n" - "cmp %o2, %o3\n" - "bne,pn %xcc, .again_add\n" - "mov %o3, %o2\n" - "retl\n" - "add %o2, %o1, %o0\n"); -} - -unsigned long -ace_atomic_swap_long (volatile unsigned long *dest, unsigned long rhs) -{ - __asm ("restore\n" - "ldx [%o0], %o2\n" - ".again_swap:\n" - "mov %o1, %o3\n" - "casx [%o0], %o2, %o3\n" - "cmp %o2, %o3\n" - "bne,pn %xcc, .again_swap\n" - "mov %o3, %o2\n" - "retl\n" - "mov %o3, %o0\n"); -} - -unsigned long -ace_atomic_swap_add_long (volatile unsigned long *dest, long rhs) -{ - __asm ("restore\n" - "ldx [%o0], %o2\n" - ".again_swap_add:\n" - "mov %o2, %o4\n" - "add %o2, %o1, %o3\n" - "casx [%o0], %o2, %o3\n" - "cmp %o2, %o3\n" - "bne,pn %xcc, .again_swap_add\n" - "mov %o3, %o2\n" - "retl\n" - "mov %o4, %o0\n"); -} - -#else - -unsigned long -ace_atomic_add_long (volatile unsigned long *dest, long rhs) -{ - __asm ("restore\n" - "ld [%o0], %o2\n" - ".again_add:\n" - "add %o2, %o1, %o3\n" - "cas [%o0], %o2, %o3\n" - "cmp %o2, %o3\n" - "bne,pn %icc, .again_add\n" - "mov %o3, %o2\n" - "retl\n" - "add %o2, %o1, %o0\n"); -} - -unsigned long -ace_atomic_swap_long (volatile unsigned long *dest, unsigned long rhs) -{ - __asm ("restore\n" - "ld [%o0], %o2\n" - ".again_swap:\n" - "mov %o1, %o3\n" - "cas [%o0], %o2, %o3\n" - "cmp %o2, %o3\n" - "bne,pn %icc, .again_swap\n" - "mov %o3, %o2\n" - "retl\n" - "mov %o3, %o0\n"); -} - -unsigned long -ace_atomic_swap_add_long (volatile unsigned long *dest, long rhs) -{ - __asm ("restore\n" - "ld [%o0], %o2\n" - ".again_swap_add:\n" - "mov %o2, %o4\n" - "add %o2, %o1, %o3\n" - "cas [%o0], %o2, %o3\n" - "cmp %o2, %o3\n" - "bne,pn %icc, .again_swap_add\n" - "mov %o3, %o2\n" - "retl\n" - "mov %o4, %o0\n"); -} - -# endif /* __sparcv9 */ - -#elif !defined (__GNUC__) && !defined (__INTEL_COMPILER) -/* Make compilers stop complaining about an empty translation unit */ -static int shut_up_compiler = 0; -#endif /* ACE_INCLUDE_ATOMIC_OP_SPARC */ diff --git a/ACE/ace/Atomic_Op_Sparc.h b/ACE/ace/Atomic_Op_Sparc.h deleted file mode 100644 index 6e238e5e909..00000000000 --- a/ACE/ace/Atomic_Op_Sparc.h +++ /dev/null @@ -1,14 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -#ifndef ACE_ATOMIC_OP_SPARC_H -#define ACE_ATOMIC_OP_SPARC_H - -extern "C" -{ - unsigned long ace_atomic_add_long (volatile unsigned long *dest, long rhs); - unsigned long ace_atomic_swap_long (volatile unsigned long *dest, unsigned long rhs); - unsigned long ace_atomic_swap_add_long (volatile unsigned long *dest, long rhs); -} - -#endif /* ACE_ATOMIC_OP_SPARC_H */ diff --git a/ACE/ace/Atomic_Op_T.cpp b/ACE/ace/Atomic_Op_T.cpp deleted file mode 100644 index ad8f6b01059..00000000000 --- a/ACE/ace/Atomic_Op_T.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef ACE_ATOMIC_OP_T_CPP -#define ACE_ATOMIC_OP_T_CPP - -#include "ace/Atomic_Op_T.h" - -#ifdef ACE_HAS_DUMP -# include "ace/Log_Msg.h" -#endif /* ACE_HAS_DUMP */ - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (__ACE_INLINE__) -#include "ace/Atomic_Op_T.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_Atomic_Op_Ex) -ACE_ALLOC_HOOK_DEFINE(ACE_Atomic_Op) - -ACE_RCSID(ace, Atomic_Op_T, "$Id$") - -// ************************************************* -template ACE_LOCK & -ACE_Atomic_Op_Ex::mutex (void) -{ - // ACE_TRACE ("ACE_Atomic_Op_Ex::mutex"); - return this->mutex_; -} - -template -void -ACE_Atomic_Op_Ex::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - // ACE_TRACE ("ACE_Atomic_Op_Ex::dump"); - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - this->mutex_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -template -ACE_Atomic_Op_Ex::ACE_Atomic_Op_Ex (ACE_LOCK & mtx) - : mutex_ (mtx) - , value_ (0) -{ - // ACE_TRACE ("ACE_Atomic_Op_Ex::ACE_Atomic_Op_Ex"); -} - -template -ACE_Atomic_Op_Ex::ACE_Atomic_Op_Ex ( - ACE_LOCK & mtx, - typename ACE_Atomic_Op_Ex::arg_type c) - : mutex_ (mtx) - , value_ (c) -{ - // ACE_TRACE ("ACE_Atomic_Op_Ex::ACE_Atomic_Op_Ex"); -} - -// **************************************************************** - -template -ACE_Atomic_Op::ACE_Atomic_Op (void) - : impl_ (this->own_mutex_) -{ - // ACE_TRACE ("ACE_Atomic_Op::ACE_Atomic_Op"); -} - -template -ACE_Atomic_Op::ACE_Atomic_Op ( - typename ACE_Atomic_Op::arg_type c) - : impl_ (own_mutex_, c) -{ - // ACE_TRACE ("ACE_Atomic_Op::ACE_Atomic_Op"); -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_ATOMIC_OP_T_CPP */ diff --git a/ACE/ace/Atomic_Op_T.h b/ACE/ace/Atomic_Op_T.h deleted file mode 100644 index cf9fbda184d..00000000000 --- a/ACE/ace/Atomic_Op_T.h +++ /dev/null @@ -1,369 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Atomic_Op_T.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_ATOMIC_OP_T_H -#define ACE_ATOMIC_OP_T_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template -struct ACE_Type_Traits -{ - typedef TYPE const & parameter_type; -}; - -template<> -struct ACE_Type_Traits -{ - typedef bool parameter_type; -}; - -template<> -struct ACE_Type_Traits -{ - typedef char parameter_type; -}; - -template<> -struct ACE_Type_Traits -{ - typedef signed char parameter_type; -}; - -template<> -struct ACE_Type_Traits -{ - typedef unsigned char parameter_type; -}; - -template<> -struct ACE_Type_Traits -{ - typedef short parameter_type; -}; - -template<> -struct ACE_Type_Traits -{ - typedef unsigned short parameter_type; -}; - -template<> -struct ACE_Type_Traits -{ - typedef int parameter_type; -}; - -template<> -struct ACE_Type_Traits -{ - typedef unsigned int parameter_type; -}; - -template<> -struct ACE_Type_Traits -{ - typedef long parameter_type; -}; - -template<> -struct ACE_Type_Traits -{ - typedef unsigned long parameter_type; -}; - -#ifndef ACE_LACKS_LONGLONG_T -template<> -struct ACE_Type_Traits -{ - typedef long long parameter_type; -}; -#endif /* !ACE_LACKS_LONGLONG_T */ - -#if !defined (ACE_LACKS_LONGLONG_T) \ - && !defined (ACE_LACKS_UNSIGNEDLONGLONG_T) -template<> -struct ACE_Type_Traits -{ - typedef unsigned long long parameter_type; -}; -#endif /* !ACE_LACKS_LONGLONG_T && !ACE_LACKS_UNSIGNEDLONGLONG_T */ - -template<> -struct ACE_Type_Traits -{ - typedef float parameter_type; -}; - -template<> -struct ACE_Type_Traits -{ - typedef double parameter_type; -}; - -template<> -struct ACE_Type_Traits -{ - typedef long double parameter_type; -}; - -template -struct ACE_Type_Traits -{ - typedef TYPE* parameter_type; -}; - -/** - * @class ACE_Atomic_Op_Ex - * - * @brief Transparently parameterizes synchronization into basic - * arithmetic operations. - * - * This class is described in an article in the July/August 1994 - * issue of the C++ Report magazine. It implements a - * templatized version of the Decorator pattern from the GoF book. - * - * ACE_Atomic_Op_Ex objects must be constructed with a reference - * to an existing lock. A single lock can be shared between - * multiple ACE_Atomic_Op_Ex objects. If you do not require this - * ability consider using the ACE_Atomic_Op class instead, which - * may be able to take advantage of platform-specific - * optimisations to provide atomic operations without requiring a - * lock. - */ -template -class ACE_Atomic_Op_Ex -{ -public: - - typedef typename ACE_Type_Traits::parameter_type arg_type; - - // = Initialization methods. - - /// Initialize @c value_ to 0. - ACE_Atomic_Op_Ex (ACE_LOCK & mtx); - - /// Initialize @c value_ to c. - ACE_Atomic_Op_Ex (ACE_LOCK & mtx, arg_type c); - - // = Accessors. - - /// Atomically pre-increment @c value_. - TYPE operator++ (void); - - /// Atomically post-increment @c value_. - TYPE operator++ (int); - - /// Atomically increment @c value_ by rhs. - TYPE operator+= (arg_type rhs); - - /// Atomically pre-decrement @c value_. - TYPE operator-- (void); - - /// Atomically post-decrement @c value_. - TYPE operator-- (int); - - /// Atomically decrement @c value_ by rhs. - TYPE operator-= (arg_type rhs); - - /// Atomically compare @c value_ with rhs. - bool operator== (arg_type rhs) const; - - /// Atomically compare @c value_ with rhs. - bool operator!= (arg_type rhs) const; - - /// Atomically check if @c value_ greater than or equal to rhs. - bool operator>= (arg_type rhs) const; - - /// Atomically check if @c value_ greater than rhs. - bool operator> (arg_type rhs) const; - - /// Atomically check if @c value_ less than or equal to rhs. - bool operator<= (arg_type rhs) const; - - /// Atomically check if @c value_ less than rhs. - bool operator< (arg_type rhs) const; - - /// Atomically assign rhs to @c value_. - ACE_Atomic_Op_Ex &operator= (arg_type rhs); - - /// Atomically assign to @c value_. - ACE_Atomic_Op_Ex &operator= ( - ACE_Atomic_Op_Ex const & rhs); - - /// Explicitly return @c value_. - TYPE value (void) const; - - /// Dump the state of an object. - void dump (void) const; - - // ACE_ALLOC_HOOK_DECLARE; - // Declare the dynamic allocation hooks. - - /// Manage copying... - ACE_Atomic_Op_Ex (ACE_Atomic_Op_Ex const &); - - /** - * Returns a reference to the underlying . This makes it - * possible to acquire the lock explicitly, which can be useful in - * some cases if you instantiate the with an - * ACE_Recursive_Mutex or ACE_Process_Mutex. @note the right - * name would be lock_, but HP/C++ will choke on that! - */ - ACE_LOCK & mutex (void); - - /** - * Explicitly return @c value_ (by reference). This gives the user - * full, unrestricted access to the underlying value. This method - * will usually be used in conjunction with explicit access to the - * lock. Use with care ;-) - */ - TYPE & value_i (void); - -private: - /// Type of synchronization mechanism. - ACE_LOCK & mutex_; - - /// Current object decorated by the atomic op. - TYPE value_; -}; - -/** - * @class ACE_Atomic_Op - * - * @brief Transparently parameterizes synchronization into basic - * arithmetic operations. - * - * This class is described in an article in the July/August 1994 - * issue of the C++ Report magazine. It implements a - * templatized version of the Decorator pattern from the GoF book. - * - * Certain platforms may provide a template specialization for - * ACE_Atomic_Op that provides optimized - * atomic integer operations without actually requiring a mutex. - */ -template -class ACE_Atomic_Op -{ -public: - - typedef typename ACE_Type_Traits::parameter_type arg_type; - - /// Initialize @c value_ to 0. - ACE_Atomic_Op (void); - - /// Initialize @c value_ to c. - ACE_Atomic_Op (arg_type c); - - /// Manage copying... - ACE_Atomic_Op (ACE_Atomic_Op const & c); - - /// Atomically assign rhs to @c value_. - ACE_Atomic_Op & operator= (arg_type rhs); - - /// Atomically assign to @c value_. - ACE_Atomic_Op & operator= ( - ACE_Atomic_Op const & rhs); - - /// Atomically pre-increment @c value_. - TYPE operator++ (void); - - /// Atomically post-increment @c value_. - TYPE operator++ (int); - - /// Atomically increment @c value_ by rhs. - TYPE operator+= (arg_type rhs); - - /// Atomically pre-decrement @c value_. - TYPE operator-- (void); - - /// Atomically post-decrement @c value_. - TYPE operator-- (int); - - /// Atomically decrement @c value_ by rhs. - TYPE operator-= (arg_type rhs); - - /// Atomically compare @c value_ with rhs. - bool operator== (arg_type rhs) const; - - /// Atomically compare @c value_ with rhs. - bool operator!= (arg_type rhs) const; - - /// Atomically check if @c value_ greater than or equal to rhs. - bool operator>= (arg_type rhs) const; - - /// Atomically check if @c value_ greater than rhs. - bool operator> (arg_type rhs) const; - - /// Atomically check if @c value_ less than or equal to rhs. - bool operator<= (arg_type rhs) const; - - /// Atomically check if @c value_ less than rhs. - bool operator< (arg_type rhs) const; - - /// Explicitly return @c value_. - TYPE value (void) const; - - /// Dump the state of an object. - void dump (void) const; - - /** - * Returns a reference to the underlying . This makes it - * possible to acquire the lock explicitly, which can be useful in - * some cases if you instantiate the ACE_Atomic_Op with an - * ACE_Recursive_Mutex or ACE_Process_Mutex. - * - * @deprecated This member function is deprecated and so may go away in - * the future. If you need access to the underlying mutex, consider - * using the ACE_Atomic_Op_Ex template instead. - */ - ACE_LOCK & mutex (void); - - /** - * Explicitly return @c value_ (by reference). This gives the user - * full, unrestricted access to the underlying value. This method - * will usually be used in conjunction with explicit access to the - * lock. Use with care ;-) - */ - TYPE & value_i (void); - -private: - /// Type of synchronization mechanism. - ACE_LOCK own_mutex_; - - /// Underlying atomic op implementation. - ACE_Atomic_Op_Ex impl_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Atomic_Op_T.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Atomic_Op_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Atomic_Op_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" -#endif /*ACE_ATOMIC_OP_T_H*/ diff --git a/ACE/ace/Atomic_Op_T.inl b/ACE/ace/Atomic_Op_T.inl deleted file mode 100644 index 3d09ba304fe..00000000000 --- a/ACE/ace/Atomic_Op_T.inl +++ /dev/null @@ -1,340 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/Guard_T.h" - -#include - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// -// ACE_Atomic_Op_Ex inline functions -// - -template -ACE_INLINE TYPE -ACE_Atomic_Op_Ex::operator++ (void) -{ - // ACE_TRACE ("ACE_Atomic_Op_Ex::operator++"); - ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); - return ++this->value_; -} - -template -ACE_INLINE TYPE -ACE_Atomic_Op_Ex::operator+= ( - typename ACE_Atomic_Op_Ex::arg_type rhs) -{ - // ACE_TRACE ("ACE_Atomic_Op_Ex::operator+="); - ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); - return this->value_ += rhs; -} - -template -ACE_INLINE TYPE -ACE_Atomic_Op_Ex::operator-- (void) -{ - // ACE_TRACE ("ACE_Atomic_Op_Ex::operator--"); - ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); - return --this->value_; -} - -template -ACE_INLINE TYPE -ACE_Atomic_Op_Ex::operator-= ( - typename ACE_Atomic_Op_Ex::arg_type rhs) -{ - // ACE_TRACE ("ACE_Atomic_Op_Ex::operator-="); - ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); - return this->value_ -= rhs; -} - -template -ACE_INLINE -ACE_Atomic_Op_Ex::ACE_Atomic_Op_Ex ( - ACE_Atomic_Op_Ex const & rhs) - : mutex_ (rhs.mutex_) - , value_ (rhs.value ()) // rhs.value() returns atomically -{ - // ACE_TRACE ("ACE_Atomic_Op_Ex::ACE_Atomic_Op_Ex"); -} - -template -ACE_INLINE TYPE -ACE_Atomic_Op_Ex::operator++ (int) -{ - // ACE_TRACE ("ACE_Atomic_Op_Ex::operator++"); - ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); - return this->value_++; -} - -template -ACE_INLINE TYPE -ACE_Atomic_Op_Ex::operator-- (int) -{ - // ACE_TRACE ("ACE_Atomic_Op_Ex::operator--"); - ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); - return this->value_--; -} - -template -ACE_INLINE bool -ACE_Atomic_Op_Ex::operator== ( - typename ACE_Atomic_Op_Ex::arg_type rhs) const -{ - // ACE_TRACE ("ACE_Atomic_Op_Ex::operator=="); - ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, false); - return this->value_ == rhs; -} - -template -ACE_INLINE bool -ACE_Atomic_Op_Ex::operator!= ( - typename ACE_Atomic_Op_Ex::arg_type rhs) const -{ - // ACE_TRACE ("ACE_Atomic_Op_Ex::operator!="); - return !(*this == rhs); -} - -template -ACE_INLINE bool -ACE_Atomic_Op_Ex::operator>= ( - typename ACE_Atomic_Op_Ex::arg_type rhs) const -{ - // ACE_TRACE ("ACE_Atomic_Op_Ex::operator>="); - ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, false); - return this->value_ >= rhs; -} - -template -ACE_INLINE bool -ACE_Atomic_Op_Ex::operator> ( - typename ACE_Atomic_Op_Ex::arg_type rhs) const -{ - // ACE_TRACE ("ACE_Atomic_Op_Ex::operator>"); - ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, false); - return this->value_ > rhs; -} - -template -ACE_INLINE bool -ACE_Atomic_Op_Ex::operator<= ( - typename ACE_Atomic_Op_Ex::arg_type rhs) const -{ - // ACE_TRACE ("ACE_Atomic_Op_Ex::operator<="); - ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, false); - return this->value_ <= rhs; -} - -template -ACE_INLINE bool -ACE_Atomic_Op_Ex::operator< ( - typename ACE_Atomic_Op_Ex::arg_type rhs) const -{ - // ACE_TRACE ("ACE_Atomic_Op_Ex::operator<"); - ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, false); - return this->value_ < rhs; -} - -template -ACE_INLINE ACE_Atomic_Op_Ex & -ACE_Atomic_Op_Ex::operator= ( - ACE_Atomic_Op_Ex const & rhs) -{ - // ACE_TRACE ("ACE_Atomic_Op_Ex::operator="); - - ACE_Atomic_Op_Ex tmp (rhs); - - ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, *this); - std::swap (this->value_, tmp.value_); - - return *this; -} - -template -ACE_INLINE TYPE -ACE_Atomic_Op_Ex::value (void) const -{ - // ACE_TRACE ("ACE_Atomic_Op_Ex::value"); - ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); - return this->value_; -} - -template -ACE_INLINE TYPE & -ACE_Atomic_Op_Ex::value_i (void) -{ - // Explicitly return (by reference). This gives the user - // full, unrestricted access to the underlying value. This method - // will usually be used in conjunction with explicit access to the - // lock. Use with care ;-) - return this->value_; -} - -template -ACE_INLINE ACE_Atomic_Op_Ex & -ACE_Atomic_Op_Ex::operator= ( - typename ACE_Atomic_Op_Ex::arg_type rhs) -{ - // ACE_TRACE ("ACE_Atomic_Op_Ex::operator="); - ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, *this); - this->value_ = rhs; - return *this; -} - -// -// ACE_Atomic_Op inline functions -// - -template ACE_INLINE -ACE_Atomic_Op::ACE_Atomic_Op ( - ACE_Atomic_Op const & rhs) - : impl_ (own_mutex_, rhs.value ()) -{ - // ACE_TRACE ("ACE_Atomic_Op::ACE_Atomic_Op"); -} - - -template -ACE_INLINE ACE_Atomic_Op & -ACE_Atomic_Op::operator= ( - typename ACE_Atomic_Op::arg_type i) -{ - this->impl_ = i; - return *this; -} - -template -ACE_INLINE ACE_Atomic_Op & -ACE_Atomic_Op::operator= ( - ACE_Atomic_Op const & rhs) -{ - this->impl_ = rhs.impl_; - return *this; -} - -template -ACE_INLINE TYPE -ACE_Atomic_Op::operator++ (void) -{ - return ++this->impl_; -} - -template -ACE_INLINE TYPE -ACE_Atomic_Op::operator++ (int) -{ - return this->impl_++; -} - -template -ACE_INLINE TYPE -ACE_Atomic_Op::operator+= ( - typename ACE_Atomic_Op::arg_type rhs) -{ - return this->impl_ += rhs; -} - -template -ACE_INLINE TYPE -ACE_Atomic_Op::operator-- (void) -{ - return --this->impl_; -} - -template -ACE_INLINE TYPE -ACE_Atomic_Op::operator-- (int) -{ - return this->impl_--; -} - -template -ACE_INLINE TYPE -ACE_Atomic_Op::operator-= ( - typename ACE_Atomic_Op::arg_type rhs) -{ - return this->impl_ -= rhs; -} - -template -ACE_INLINE bool -ACE_Atomic_Op::operator== ( - typename ACE_Atomic_Op::arg_type rhs) const -{ - return this->impl_ == rhs; -} - -template -ACE_INLINE bool -ACE_Atomic_Op::operator!= ( - typename ACE_Atomic_Op::arg_type rhs) const -{ - return this->impl_ != rhs; -} - -template -ACE_INLINE bool -ACE_Atomic_Op::operator>= ( - typename ACE_Atomic_Op::arg_type rhs) const -{ - return this->impl_ >= rhs; -} - -template -ACE_INLINE bool -ACE_Atomic_Op::operator> ( - typename ACE_Atomic_Op::arg_type rhs) const -{ - return this->impl_ > rhs; -} - -template -ACE_INLINE bool -ACE_Atomic_Op::operator<= ( - typename ACE_Atomic_Op::arg_type rhs) const -{ - return this->impl_ <= rhs; -} - -template -ACE_INLINE bool -ACE_Atomic_Op::operator< ( - typename ACE_Atomic_Op::arg_type rhs) const -{ - return this->impl_ < rhs; -} - -template -ACE_INLINE TYPE -ACE_Atomic_Op::value (void) const -{ - return this->impl_.value (); -} - -template -ACE_INLINE void -ACE_Atomic_Op::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - this->impl_.dump (); -#endif /* ACE_HAS_DUMP */ - return; -} - -template -ACE_INLINE ACE_LOCK & -ACE_Atomic_Op::mutex (void) -{ - return this->own_mutex_; -} - -template -ACE_INLINE TYPE & -ACE_Atomic_Op::value_i (void) -{ - return this->impl_.value_i (); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Auto_Event.cpp b/ACE/ace/Auto_Event.cpp deleted file mode 100644 index 9e106ac8119..00000000000 --- a/ACE/ace/Auto_Event.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// $Id$ - -#include "ace/Auto_Event.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Auto_Event.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID (ace, - Auto_Event, - "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_Auto_Event::ACE_Auto_Event (int initial_state, - int type, - const char *name, - void *arg) - : ACE_Event (0, - initial_state, - type, - ACE_TEXT_CHAR_TO_TCHAR (name), - arg) -{ -} - -#if defined (ACE_HAS_WCHAR) -ACE_Auto_Event::ACE_Auto_Event (int initial_state, - int type, - const wchar_t *name, - void *arg) - : ACE_Event (0, - initial_state, - type, - ACE_TEXT_WCHAR_TO_TCHAR (name), - arg) -{ -} -#endif /* ACE_HAS_WCHAR */ - -void -ACE_Auto_Event::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_Event::dump (); -#endif /* ACE_HAS_DUMP */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Auto_Event.h b/ACE/ace/Auto_Event.h deleted file mode 100644 index c4ee11509bb..00000000000 --- a/ACE/ace/Auto_Event.h +++ /dev/null @@ -1,73 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file Auto_Event.h - * - * $Id$ - * - * Moved from Synch.h. - * - * @author Douglas C. Schmidt - */ -//========================================================================== - -#ifndef ACE_AUTO_EVENT_H -#define ACE_AUTO_EVENT_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Event.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Auto_Event - * - * @brief Auto Events. - * - * Specialization of Event mechanism which wakes up one waiting - * thread on . All platforms support process-scope locking - * support. However, only Win32 platforms support global naming and - * system-scope locking support. - */ -class ACE_Export ACE_Auto_Event : public ACE_Event -{ -public: - /// Constructor which will create auto event - ACE_Auto_Event (int initial_state = 0, - int type = USYNC_THREAD, - const char *name = 0, - void *arg = 0); - -#if defined (ACE_HAS_WCHAR) - /// Constructor which will create auto event (wchar_t version) - ACE_Auto_Event (int initial_state, - int type, - const wchar_t *name, - void *arg = 0); -#endif /* ACE_HAS_WCHAR */ - - /// Default dtor. - ~ACE_Auto_Event (void); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks - ACE_ALLOC_HOOK_DECLARE; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Auto_Event.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_AUTO_EVENT_H */ diff --git a/ACE/ace/Auto_Event.inl b/ACE/ace/Auto_Event.inl deleted file mode 100644 index 80048c29b99..00000000000 --- a/ACE/ace/Auto_Event.inl +++ /dev/null @@ -1,12 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_Auto_Event::~ACE_Auto_Event (void) -{ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Auto_Functor.cpp b/ACE/ace/Auto_Functor.cpp deleted file mode 100644 index 8d6e7f998bf..00000000000 --- a/ACE/ace/Auto_Functor.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// $Id$ - -#ifndef ACE_AUTO_FUNCTOR_CPP -#define ACE_AUTO_FUNCTOR_CPP - -#include "ace/Auto_Functor.h" - -#if !defined(__ACE_INLINE__) -# include "ace/Auto_Functor.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template -ACE_Utils::Auto_Functor::~Auto_Functor() -{ - reset(0); -} - -template void -ACE_Utils::Auto_Functor::reset(X * p) -{ - if(p_ != 0) - { - f_(p_); - } - p_ = p; -} - -templatevoid -ACE_Utils::Auto_Functor::reset(X * p, Functor f) -{ - reset(p); - f_ = f; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /*ACE_AUTO_FUNCTOR_CPP*/ diff --git a/ACE/ace/Auto_Functor.h b/ACE/ace/Auto_Functor.h deleted file mode 100644 index 4ca55184b9a..00000000000 --- a/ACE/ace/Auto_Functor.h +++ /dev/null @@ -1,127 +0,0 @@ -// -*- C++ -*- -//============================================================================= -/** - * @file Auto_Functor.h - * - * $Id$ - * - * @author Carlos O'Ryan - */ -//============================================================================= -#ifndef ACE_AUTO_FUNCTOR_H -#define ACE_AUTO_FUNCTOR_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Global_Macros.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -namespace ACE_Utils -{ -/** - * @class Auto_Functor_Ref - * - * @brief Helper class to implement assignment and copy-construction - * as expected - */ -template -struct Auto_Functor_Ref -{ - X * p_; - Functor f_; - - Auto_Functor_Ref(X * p, Functor f); -}; - -/** - * @class Auto_Functor - * - * @brief Helper template to implement auto_ptr<>-like classes, but - * executing a functor in the destructor, instead of always - * deleting things. - * - * The functor is called in the destructor, and it must implement: - * - * Functor() throw();
- * Functor(Functor const &) throw();
- * Functor & operator=(Functor const &) throw();
- * void operator()(X * p) throw();
- * - */ -template -class Auto_Functor -{ -public: - typedef X element_type; - typedef Functor functor_type; - - /// Constructor - explicit Auto_Functor (X * p = 0, - Functor functor = Functor()); // throw() - - Auto_Functor (Auto_Functor & rhs); // throw() - - Auto_Functor& operator= (Auto_Functor & rhs); // throw() - -#if !defined(ACE_LACKS_MEMBER_TEMPLATES) - template - Auto_Functor(Auto_Functor& rhs); // throw() - - template - Auto_Functor& operator= (Auto_Functor& rhs); // throw() -#endif /* ACE_LACKS_MEMBER_TEMPLATES */ - - ~Auto_Functor(); // throw() - - X & operator*() const; // throw() - - X * operator->() const; // throw() - - X * get(); // throw() - - X * release(); // throw() - - void reset (X * p = 0); // throw() - - void reset (X * p, Functor f); // throw() - - Functor const & functor() const; // throw() - - Auto_Functor(Auto_Functor_Ref rhs); // throw() - - Auto_Functor & operator=(Auto_Functor_Ref rhs); // throw() - -#if !defined(ACE_LACKS_MEMBER_TEMPLATES) - template operator Auto_Functor_Ref(); // throw() - - template operator Auto_Functor(); // throw() -#else - operator Auto_Functor_Ref(); // throw() -#endif /* ACE_LACKS_MEMBER_TEMPLATES */ - -private: - X * p_; - - Functor f_; -}; - -} // namespace ACE_Utils - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined(__ACE_INLINE__) -# include "ace/Auto_Functor.inl" -#endif /* __ACE_INLINE__ */ - -#if defined(ACE_TEMPLATES_REQUIRE_SOURCE) -# include "ace/Auto_Functor.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#include /**/ "ace/post.h" -#endif /* ACE_AUTO_FUNCTOR_H*/ diff --git a/ACE/ace/Auto_Functor.inl b/ACE/ace/Auto_Functor.inl deleted file mode 100644 index 01f35b87eb5..00000000000 --- a/ACE/ace/Auto_Functor.inl +++ /dev/null @@ -1,134 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template ACE_INLINE -ACE_Utils::Auto_Functor_Ref:: -Auto_Functor_Ref(X * p, Functor f) - : p_(p) - , f_(f) -{ -} - -template ACE_INLINE -ACE_Utils::Auto_Functor::Auto_Functor(X * p, Functor f) - : p_(p) - , f_(f) -{ -} - -template ACE_INLINE -ACE_Utils::Auto_Functor::Auto_Functor(Auto_Functor & rhs) - : p_(rhs.release()) - , f_(rhs.f_) -{ -} - -template -ACE_INLINE ACE_Utils::Auto_Functor& -ACE_Utils::Auto_Functor:: operator=(Auto_Functor & rhs) -{ - reset(rhs.release()); - f_ = rhs.f_; - return *this; -} - -#if !defined(ACE_LACKS_MEMBER_TEMPLATES) -template template ACE_INLINE -ACE_Utils::Auto_Functor::Auto_Functor(Auto_Functor& rhs) - : p_(rhs.release()) - , f_(rhs.f_) -{ -} - -template template -ACE_INLINE ACE_Utils::Auto_Functor& -ACE_Utils::Auto_Functor::operator=(Auto_Functor& rhs) -{ - reset(rhs.release()); - return *this; -} -#endif /* ACE_LACKS_MEMBER_TEMPLATES */ - -template ACE_INLINE X & -ACE_Utils::Auto_Functor::operator*() const -{ - return *p_; -} - -template -ACE_INLINE X * -ACE_Utils::Auto_Functor::operator->() const -{ - return p_; -} - -template -ACE_INLINE X * -ACE_Utils::Auto_Functor::get() -{ - return p_; -} - -template -ACE_INLINE X * -ACE_Utils::Auto_Functor::release() -{ - X * tmp = p_; - p_ = 0; - return tmp; -} - -template -ACE_INLINE Functor const & -ACE_Utils::Auto_Functor::functor() const -{ - return f_; -} - -template ACE_INLINE -ACE_Utils::Auto_Functor::Auto_Functor(Auto_Functor_Ref rhs) - : p_(rhs.p_) - , f_(rhs.f_) -{ -} - -template -ACE_INLINE ACE_Utils::Auto_Functor & -ACE_Utils::Auto_Functor::operator=(Auto_Functor_Ref rhs) -{ - if(rhs.p_ != p_) - { - reset(rhs.p_); - f_ = rhs.f_; - } - return *this; -} - -#if !defined(ACE_LACKS_MEMBER_TEMPLATES) - -template template ACE_INLINE -ACE_Utils::Auto_Functor::operator ACE_Utils::Auto_Functor_Ref() -{ - return ACE_Utils::Auto_Functor_Ref(release(), f_); -} - -template template ACE_INLINE -ACE_Utils::Auto_Functor::operator ACE_Utils::Auto_Functor() -{ - return ACE_Utils::Auto_Functor(release(), f_); -} - -#else - -templateACE_INLINE -ACE_Utils::Auto_Functor::operator ACE_Utils::Auto_Functor_Ref() -{ - return ACE_Utils::Auto_Functor_Ref(release(), f_); -} - -#endif /* ACE_LACKS_MEMBER_TEMPLATES */ - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Auto_IncDec_T.cpp b/ACE/ace/Auto_IncDec_T.cpp deleted file mode 100644 index cf33efd7d6e..00000000000 --- a/ACE/ace/Auto_IncDec_T.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// $Id$ - -#ifndef ACE_AUTO_INCDEC_T_CPP -#define ACE_AUTO_INCDEC_T_CPP - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Auto_IncDec_T.h" -#include "ace/Log_Msg.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Auto_IncDec_T.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_Auto_IncDec) - -template void -ACE_Auto_IncDec::dump (void) const -{ -#if defined (ACE_HAS_DUMP) -// ACE_TRACE ("ACE_Auto_IncDec::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_AUTO_INCDEC_T_CPP */ diff --git a/ACE/ace/Auto_IncDec_T.h b/ACE/ace/Auto_IncDec_T.h deleted file mode 100644 index 0f29f5c4f3f..00000000000 --- a/ACE/ace/Auto_IncDec_T.h +++ /dev/null @@ -1,91 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Auto_IncDec_T.h - * - * $Id$ - * - * @author Edan Ayal - */ -//============================================================================= - - -#ifndef ACE_AUTO_INCDEC_T_H -#define ACE_AUTO_INCDEC_T_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Global_Macros.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Auto_IncDec - * - * @brief This class automatically increments and decrements a - * parameterized counter. - * - * This data structure is meant to be used within a method, - * function, or scope. The actual parameter given for the - * template parameter - * must provide at least operators ++ and --. - */ -template -class ACE_Auto_IncDec -{ -public: - - /// Implicitly increment the counter. - ACE_Auto_IncDec (ACE_SAFELY_INCREMENTABLE_DECREMENTABLE &counter); - - /// Implicitly decrement the counter. - ~ACE_Auto_IncDec (void); - - /// Dump the state of an object. - void dump (void) const; - -protected: - /// Reference to the counter - /// we're incrementing/decrementing. - ACE_SAFELY_INCREMENTABLE_DECREMENTABLE &counter_; - -private: - // = Prevent assignment and initialization. - ACE_UNIMPLEMENTED_FUNC (void operator= (const - ACE_Auto_IncDec &)) - ACE_UNIMPLEMENTED_FUNC (ACE_Auto_IncDec (const - ACE_Auto_IncDec &)) -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Auto_IncDec_T.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Auto_IncDec_T.cpp" -// On Win32 platforms, this code will be included as template source -// code and will not be inlined. Therefore, we first turn off -// ACE_INLINE, set it to be nothing, include the code, and then turn -// ACE_INLINE back to its original setting. All this nonsense is -// necessary, since the generic template code that needs to be -// specialized cannot be inlined, else the compiler will ignore the -// specialization code. Also, the specialization code *must* be -// inlined or the compiler will ignore the specializations. -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Auto_IncDec_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" - -#endif /* ACE_AUTO_INCDEC_T_H */ diff --git a/ACE/ace/Auto_IncDec_T.inl b/ACE/ace/Auto_IncDec_T.inl deleted file mode 100644 index 51daac0e84d..00000000000 --- a/ACE/ace/Auto_IncDec_T.inl +++ /dev/null @@ -1,25 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Implicitly and automatically increment the counter. - -template ACE_INLINE -ACE_Auto_IncDec::ACE_Auto_IncDec - (ACE_SAFELY_INCREMENTABLE_DECREMENTABLE &counter) - : counter_ (counter) -{ - ++this->counter_; -} - -// Implicitly and automatically decrement the counter. - -template ACE_INLINE -ACE_Auto_IncDec::~ACE_Auto_IncDec (void) -{ - --this->counter_; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Auto_Ptr.cpp b/ACE/ace/Auto_Ptr.cpp deleted file mode 100644 index 081744ce316..00000000000 --- a/ACE/ace/Auto_Ptr.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// $Id$ - -#ifndef ACE_AUTO_PTR_CPP -#define ACE_AUTO_PTR_CPP - -#include "ace/Auto_Ptr.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Auto_Ptr.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, Auto_Ptr, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_Auto_Basic_Ptr) -ACE_ALLOC_HOOK_DEFINE(ACE_Auto_Basic_Array_Ptr) - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_AUTO_PTR_CPP */ diff --git a/ACE/ace/Auto_Ptr.h b/ACE/ace/Auto_Ptr.h deleted file mode 100644 index ec955d30b21..00000000000 --- a/ACE/ace/Auto_Ptr.h +++ /dev/null @@ -1,242 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file Auto_Ptr.h - * - * $Id$ - * - * @author Doug Schmidt - * @author Irfan Pyarali - * @author Jack Reeves - * @author Dr. Harald M. Mueller - */ -//============================================================================= - -#ifndef ACE_AUTO_PTR_H -#define ACE_AUTO_PTR_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (_MSC_VER) -// Suppress warning e.g. "return type for -// 'ACE_Auto_Array_Pointer::operator ->' is 'type *' (i.e., not a UDT -// or reference to a UDT. Will produce errors if applied using infix -// notation)" -# pragma warning(push) -# pragma warning(disable: 4284) -#endif /* _MSC_VER */ - - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Auto_Basic_Ptr - * - * @brief Implements the draft C++ standard auto_ptr abstraction. - * This class allows one to work on non-object (basic) types - */ -template -class ACE_Auto_Basic_Ptr -{ -public: - typedef X element_type; - - // = Initialization and termination methods - explicit ACE_Auto_Basic_Ptr (X * p = 0) : p_ (p) {} - - ACE_Auto_Basic_Ptr (ACE_Auto_Basic_Ptr & ap); - ACE_Auto_Basic_Ptr &operator= (ACE_Auto_Basic_Ptr & rhs); - ~ACE_Auto_Basic_Ptr (void); - - // = Accessor methods. - X &operator *() const; - X *get (void) const; - X *release (void); - void reset (X * p = 0); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - X *p_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if !defined (ACE_LACKS_AUTO_PTR) && \ - defined (ACE_HAS_STANDARD_CPP_LIBRARY) && \ - (ACE_HAS_STANDARD_CPP_LIBRARY != 0) -#include -#if defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) && \ - (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB != 0) -using std::auto_ptr; -#endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */ -#else /* ACE_HAS_STANDARD_CPP_LIBRARY */ - -/** - * @class auto_ptr - * - * @brief Implements the draft C++ standard auto_ptr abstraction. - */ -template -class auto_ptr : public ACE_Auto_Basic_Ptr -{ -public: - typedef X element_type; - - // = Initialization and termination methods - explicit auto_ptr (X * p = 0) : ACE_Auto_Basic_Ptr (p) {} - auto_ptr (auto_ptr & ap) : ACE_Auto_Basic_Ptr (ap.release ()) {} - - X *operator-> () const; -}; - -#endif /* ACE_HAS_STANDARD_CPP_LIBRARY */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @brief Implements the draft C++ standard auto_ptr abstraction. - * This version can be used instead of auto_ptr, and obviates - * the need for the ACE_AUTO_PTR_RESET macro on platforms like - * VC6 where the auto_ptr is broken. - */ -template -class ACE_Auto_Ptr : public ACE_Auto_Basic_Ptr -{ -public: - typedef X element_type; - - // = Initialization and termination methods - explicit ACE_Auto_Ptr (X * p = 0) : ACE_Auto_Basic_Ptr (p) {} - - X *operator-> () const; -}; - -/** - * @class ACE_Auto_Basic_Array_Ptr - * - * @brief Implements an extension to the draft C++ standard auto_ptr - * abstraction. This class allows one to work on non-object - * (basic) types that must be treated as an array, e.g., - * deallocated via "delete [] foo". - */ -template -class ACE_Auto_Basic_Array_Ptr -{ -public: - typedef X element_type; - - // = Initialization and termination methods. - explicit ACE_Auto_Basic_Array_Ptr (X * p = 0) : p_ (p) {} - - ACE_Auto_Basic_Array_Ptr (ACE_Auto_Basic_Array_Ptr & ap); - ACE_Auto_Basic_Array_Ptr &operator= (ACE_Auto_Basic_Array_Ptr & rhs); - ~ACE_Auto_Basic_Array_Ptr (void); - - // = Accessor methods. - X & operator* () const; - X & operator[] (int i) const; - X * get (void) const; - X * release (void); - void reset (X * p = 0); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - X * p_; -}; - -/** - * @class ACE_Auto_Array_Ptr - * - * @brief Implements an extension to the draft C++ standard auto_ptr - * abstraction. - */ -template -class ACE_Auto_Array_Ptr : public ACE_Auto_Basic_Array_Ptr -{ -public: - typedef X element_type; - - // = Initialization and termination methods. - explicit ACE_Auto_Array_Ptr (X *p = 0) - : ACE_Auto_Basic_Array_Ptr (p) {} - - X *operator-> () const; -}; - - -/** - * @brief Reset given @c auto_ptr element to new element. - * - * Some platforms have an older version of auto_ptr support, which - * lacks reset, and cannot be disabled easily. Portability to these - * platforms requires use of this function template. This function - * template also works for the @c ACE_Auto_{Basic_}Array_Ptr class - * template, as well. - */ -template -inline void -ACE_auto_ptr_reset (AUTO_PTR_TYPE & ap, - PTR_TYPE * p) -{ -#if defined (ACE_AUTO_PTR_LACKS_RESET) - // Allow compiler to adjust pointer to potential base class pointer - // of element type found in auto_ptr. - typename AUTO_PTR_TYPE::element_type * const tp = p; - if (tp != ap.get ()) - { - ap = AUTO_PTR_TYPE (tp); - } -#else - ap.reset (p); -#endif /* ACE_AUTO_PTR_LACKS_RESET */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -// Some platforms have an older version of auto_ptr -// support, which lacks reset, and cannot be disabled -// easily. Portability to these platforms requires -// use of the following ACE_AUTO_PTR_RESET macro. -// -// The TYPE macro parameter is no longer necessary but we leave it -// around for backward compatibility. This is also the reason why the -// ACE_auto_ptr_reset function template is not called -// ACE_AUTO_PTR_RESET. -# define ACE_AUTO_PTR_RESET(AUTOPTR,NEWPTR,TYPE) \ - ACE_auto_ptr_reset (AUTOPTR, NEWPTR); - -#if defined (__ACE_INLINE__) -#include "ace/Auto_Ptr.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Auto_Ptr.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Auto_Ptr.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#if defined (_MSC_VER) -// Restore the warning state to what it was before entry. -# pragma warning(pop) -#endif /* _MSC_VER */ - -#include /**/ "ace/post.h" -#endif /* ACE_AUTO_PTR_H */ diff --git a/ACE/ace/Auto_Ptr.inl b/ACE/ace/Auto_Ptr.inl deleted file mode 100644 index 57adb236261..00000000000 --- a/ACE/ace/Auto_Ptr.inl +++ /dev/null @@ -1,171 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/Global_Macros.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template ACE_INLINE void -ACE_Auto_Basic_Ptr::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Auto_Basic_Ptr::dump"); -#endif /* ACE_HAS_DUMP */ -} - -template ACE_INLINE void -ACE_Auto_Basic_Array_Ptr::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Auto_Basic_Array_Ptr::dump"); -#endif /* ACE_HAS_DUMP */ -} - -template ACE_INLINE -ACE_Auto_Basic_Ptr::ACE_Auto_Basic_Ptr (ACE_Auto_Basic_Ptr &rhs) - : p_ (rhs.release ()) -{ - ACE_TRACE ("ACE_Auto_Basic_Ptr::ACE_Auto_Basic_Ptr"); -} - -template ACE_INLINE X * -ACE_Auto_Basic_Ptr::get (void) const -{ - ACE_TRACE ("ACE_Auto_Basic_Ptr::get"); - return this->p_; -} - -template ACE_INLINE X * -ACE_Auto_Basic_Ptr::release (void) -{ - ACE_TRACE ("ACE_Auto_Basic_Ptr::release"); - X *old = this->p_; - this->p_ = 0; - return old; -} - -template ACE_INLINE void -ACE_Auto_Basic_Ptr::reset (X *p) -{ - ACE_TRACE ("ACE_Auto_Basic_Ptr::reset"); - if (this->get () != p) - delete this->get (); - this->p_ = p; -} - -template ACE_INLINE ACE_Auto_Basic_Ptr & -ACE_Auto_Basic_Ptr::operator= (ACE_Auto_Basic_Ptr &rhs) -{ - ACE_TRACE ("ACE_Auto_Basic_Ptr::operator="); - if (this != &rhs) - { - this->reset (rhs.release ()); - } - return *this; -} - -template ACE_INLINE -ACE_Auto_Basic_Ptr::~ACE_Auto_Basic_Ptr (void) -{ - ACE_TRACE ("ACE_Auto_Basic_Ptr::~ACE_Auto_Basic_Ptr"); - delete this->get (); -} - -template ACE_INLINE X & -ACE_Auto_Basic_Ptr::operator *() const -{ - ACE_TRACE ("ACE_Auto_Basic_Ptr::operator *()"); - return *this->get (); -} - -#if defined (ACE_LACKS_AUTO_PTR) || \ - !defined (ACE_HAS_STANDARD_CPP_LIBRARY) || \ - (ACE_HAS_STANDARD_CPP_LIBRARY == 0) - -template ACE_INLINE X * -auto_ptr::operator-> () const -{ - ACE_TRACE ("auto_ptr::operator->"); - return this->get (); -} - -#endif /* ACE_HAS_STANDARD_CPP_LIBRARY */ - -template ACE_INLINE X * -ACE_Auto_Ptr::operator-> () const -{ - ACE_TRACE ("ACE_Auto_Ptr::operator->"); - return this->get (); -} - -template ACE_INLINE X * -ACE_Auto_Basic_Array_Ptr::get (void) const -{ - ACE_TRACE ("ACE_Auto_Basic_Array_Ptr::get"); - return this->p_; -} - -template ACE_INLINE X * -ACE_Auto_Basic_Array_Ptr::release (void) -{ - ACE_TRACE ("ACE_Auto_Basic_Array_Ptr::release"); - X *old = this->p_; - this->p_ = 0; - return old; -} - -template ACE_INLINE void -ACE_Auto_Basic_Array_Ptr::reset (X *p) -{ - ACE_TRACE ("ACE_Auto_Basic_Array_Ptr::reset"); - if (this->get () != p) - delete [] this->get (); - this->p_ = p; -} - -template ACE_INLINE -ACE_Auto_Basic_Array_Ptr::ACE_Auto_Basic_Array_Ptr (ACE_Auto_Basic_Array_Ptr &rhs) - : p_ (rhs.release ()) -{ - ACE_TRACE ("ACE_Auto_Basic_Array_Ptr::ACE_Auto_Basic_Array_Ptr"); -} - -template ACE_INLINE ACE_Auto_Basic_Array_Ptr & -ACE_Auto_Basic_Array_Ptr::operator= (ACE_Auto_Basic_Array_Ptr &rhs) -{ - ACE_TRACE ("ACE_Auto_Basic_Array_Ptr::operator="); - if (this != &rhs) - { - this->reset (rhs.release ()); - } - return *this; -} - -template ACE_INLINE -ACE_Auto_Basic_Array_Ptr::~ACE_Auto_Basic_Array_Ptr (void) -{ - ACE_TRACE ("ACE_Auto_Basic_Array_Ptr::~ACE_Auto_Basic_Array_Ptr"); - delete [] this->get (); -} - -template ACE_INLINE X & -ACE_Auto_Basic_Array_Ptr::operator *() const -{ - return *this->get (); -} - -template ACE_INLINE X & -ACE_Auto_Basic_Array_Ptr::operator[](int i) const -{ - X *array = this->get (); - return array[i]; -} - -template ACE_INLINE X * -ACE_Auto_Array_Ptr::operator->() const -{ - return this->get (); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Barrier.cpp b/ACE/ace/Barrier.cpp deleted file mode 100644 index 2cb82dba5b6..00000000000 --- a/ACE/ace/Barrier.cpp +++ /dev/null @@ -1,197 +0,0 @@ -// $Id$ - -#include "ace/Barrier.h" - -#if defined (ACE_HAS_THREADS) - -#if !defined (__ACE_INLINE__) -#include "ace/Barrier.inl" -#endif /* __ACE_INLINE__ */ - -#include "ace/Guard_T.h" -#include "ace/OS_NS_errno.h" - -#if defined (ACE_HAS_DUMP) -# include "ace/Log_Msg.h" -#endif /* ACE_HAS_DUMP */ - -ACE_RCSID (ace, - Barrier, - "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_Sub_Barrier) - -void -ACE_Sub_Barrier::dump (void) const -{ -#if defined (ACE_HAS_DUMP) -// ACE_TRACE ("ACE_Sub_Barrier::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - this->barrier_finished_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("running_threads_ = %d"), this->running_threads_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_Sub_Barrier::ACE_Sub_Barrier (unsigned int count, - ACE_Thread_Mutex &lock, - const ACE_TCHAR *name, - void *arg) - : barrier_finished_ (lock, name, arg), - running_threads_ (count) -{ -// ACE_TRACE ("ACE_Sub_Barrier::ACE_Sub_Barrier"); -} - -ACE_ALLOC_HOOK_DEFINE(ACE_Barrier) - -void -ACE_Barrier::dump (void) const -{ -#if defined (ACE_HAS_DUMP) -// ACE_TRACE ("ACE_Barrier::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - this->lock_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("current_generation_ = %d"), this->current_generation_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncount_ = %d"), this->count_)); - this->sub_barrier_1_.dump (); - this->sub_barrier_2_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_Barrier::ACE_Barrier (unsigned int count, - const ACE_TCHAR *name, - void *arg) - : lock_ (name, (ACE_mutexattr_t *) arg), - current_generation_ (0), - count_ (count), - sub_barrier_1_ (count, lock_, name, arg), - sub_barrier_2_ (count, lock_, name, arg) -{ - ACE_TRACE ("ACE_Barrier::ACE_Barrier"); - this->sub_barrier_[0] = &this->sub_barrier_1_; - this->sub_barrier_[1] = &this->sub_barrier_2_; -} - -int -ACE_Barrier::wait (void) -{ - ACE_TRACE ("ACE_Barrier::wait"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); - - ACE_Sub_Barrier *sbp = - this->sub_barrier_[this->current_generation_]; - - // Check for shutdown... - if (sbp == 0) - { - errno = ESHUTDOWN; - return -1; - } - - int retval = 0; - - if (sbp->running_threads_ == 1) - { - // We're the last running thread, so swap generations and tell - // all the threads waiting on the barrier to continue on their - // way. - sbp->running_threads_ = this->count_; - // Swap generations. - this->current_generation_ = 1 - this->current_generation_; - sbp->barrier_finished_.broadcast (); - } - else - { - --sbp->running_threads_; - - // Block until all the other threads wait(). - while (sbp->running_threads_ != this->count_) - sbp->barrier_finished_.wait (); - - // We're awake and the count has completed. See if it completed - // because all threads hit the barrier, or because the barrier - // was shut down. - if (this->sub_barrier_[this->current_generation_] == 0) - { - errno = ESHUTDOWN; - retval = -1; - } - } - - return retval; -} - -int -ACE_Barrier::shutdown (void) -{ - ACE_TRACE ("ACE_Barrier::shutdown"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); - - ACE_Sub_Barrier *sbp = - this->sub_barrier_[this->current_generation_]; - - // Check for shutdown... - if (sbp == 0) - { - errno = ESHUTDOWN; - return -1; - } - - // Flag the shutdown - this->sub_barrier_[0] = 0; - this->sub_barrier_[1] = 0; - // Tell all the threads waiting on the barrier to continue on their way. - sbp->running_threads_ = this->count_; - sbp->barrier_finished_.broadcast (); - - return 0; -} - -ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Barrier) - -ACE_Thread_Barrier::ACE_Thread_Barrier (unsigned int count, - const ACE_TCHAR *name) - : ACE_Barrier (count, name) -{ -// ACE_TRACE ("ACE_Thread_Barrier::ACE_Thread_Barrier"); -} - -void -ACE_Thread_Barrier::dump (void) const -{ -#if defined (ACE_HAS_DUMP) -// ACE_TRACE ("ACE_Thread_Barrier::dump"); - ACE_Barrier::dump (); -#endif /* ACE_HAS_DUMP */ -} - -#if 0 -ACE_ALLOC_HOOK_DEFINE(ACE_Process_Barrier) - -ACE_Process_Barrier::ACE_Process_Barrier (u_int count, - const ACE_TCHAR *name) - : ACE_Barrier (count, USYNC_PROCESS, name) -{ -// ACE_TRACE ("ACE_Process_Barrier::ACE_Process_Barrier"); -} - -void -ACE_Process_Barrier::dump (void) const -{ -#if defined (ACE_HAS_DUMP) -// ACE_TRACE ("ACE_Process_Barrier::dump"); - ACE_Barrier::dump (); -#endif /* ACE_HAS_DUMP */ -} -#endif /* 0 */ - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_THREADS */ diff --git a/ACE/ace/Barrier.h b/ACE/ace/Barrier.h deleted file mode 100644 index 00e22ec19f5..00000000000 --- a/ACE/ace/Barrier.h +++ /dev/null @@ -1,215 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file Barrier.h - * - * $Id$ - * - * Moved from Synch.h. - * - * @author Douglas C. Schmidt - */ -//========================================================================== - -#ifndef ACE_BARRIER_H -#define ACE_BARRIER_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include /**/ "ace/config-all.h" - -// ACE platform supports some form of threading. -#if !defined (ACE_HAS_THREADS) - -#include "ace/OS_NS_errno.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Barrier - * - * @brief This is a no-op to make ACE "syntactically consistent." - */ -class ACE_Export ACE_Barrier -{ -public: - ACE_Barrier (unsigned int, const ACE_TCHAR * = 0, void * = 0) {} - ~ACE_Barrier (void) {} - int wait (void) { ACE_NOTSUP_RETURN (-1); } - void dump (void) const {} -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#else /* ACE_HAS_THREADS */ - -#include "ace/Condition_Thread_Mutex.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -struct ACE_Export ACE_Sub_Barrier -{ - // = Initialization. - ACE_Sub_Barrier (unsigned int count, - ACE_Thread_Mutex &lock, - const ACE_TCHAR *name = 0, - void *arg = 0); - - ~ACE_Sub_Barrier (void); - - /// True if this generation of the barrier is done. - ACE_Condition_Thread_Mutex barrier_finished_; - - /// Number of threads that are still running. - int running_threads_; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; -}; - -/** - * @class ACE_Barrier - * - * @brief Implements "barrier synchronization". - * - * This class allows number of threads to synchronize - * their completion of (one round of) a task, which is known as - * "barrier synchronization". After all the threads call - * on the barrier they are all atomically released and can begin a new - * round. - * - * This implementation uses a "sub-barrier generation numbering" - * scheme to avoid overhead and to ensure that all threads wait to - * leave the barrier correct. This code is based on an article from - * SunOpsis Vol. 4, No. 1 by Richard Marejka - * (Richard.Marejka@canada.sun.com). - */ -class ACE_Export ACE_Barrier -{ -public: - /// Initialize the barrier to synchronize @a count threads. - ACE_Barrier (unsigned int count, - const ACE_TCHAR *name = 0, - void *arg = 0); - - /// Default dtor. - ~ACE_Barrier (void); - - /// Block the caller until all @c count threads have called @c wait and - /// then allow all the caller threads to continue in parallel. - /// - /// @retval 0 after successfully waiting for all threads to wait. - /// @retval -1 if an error occurs or the barrier is shut - /// down (@sa shutdown ()). - int wait (void); - - /// Shut the barrier down, aborting the wait of all waiting threads. - /// Any threads waiting on the barrier when it is shut down will return with - /// value -1, errno ESHUTDOWN. - /// - /// @retval 0 for success, -1 if already shut down. - /// - /// @since ACE beta 5.4.9. - int shutdown (void); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - /// Serialize access to the barrier state. - ACE_Thread_Mutex lock_; - - /// Either 0 or 1, depending on whether we are the first generation - /// of waiters or the next generation of waiters. - int current_generation_; - - /// Total number of threads that can be waiting at any one time. - int count_; - - /** - * We keep two @c sub_barriers, one for the first "generation" of - * waiters, and one for the next "generation" of waiters. This - * efficiently solves the problem of what to do if all the first - * generation waiters don't leave the barrier before one of the - * threads calls wait() again (i.e., starts up the next generation - * barrier). - */ - ACE_Sub_Barrier sub_barrier_1_; - ACE_Sub_Barrier sub_barrier_2_; - ACE_Sub_Barrier *sub_barrier_[2]; - -private: - // = Prevent assignment and initialization. - void operator= (const ACE_Barrier &); - ACE_Barrier (const ACE_Barrier &); -}; - -#if 0 -/** - * @class ACE_Process_Barrier - * - * @brief Implements "barrier synchronization" using ACE_Process_Mutexes! - * - * This class is just a simple wrapper for ACE_Barrier that - * selects the USYNC_PROCESS variant for the locks. - */ -class ACE_Export ACE_Process_Barrier : public ACE_Barrier -{ -public: - /// Create a Process_Barrier, passing in the optional @a name. - ACE_Process_Barrier (unsigned int count, const ACE_TCHAR *name = 0); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; -}; -#endif /* 0 */ - -/** - * @class ACE_Thread_Barrier - * - * @brief Implements "barrier synchronization" using ACE_Thread_Mutexes! - * - * This class is just a simple wrapper for ACE_Barrier that - * selects the USYNC_THREAD variant for the locks. - */ -class ACE_Export ACE_Thread_Barrier : public ACE_Barrier -{ -public: - /// Create a Thread_Barrier, passing in the optional @a name. - ACE_Thread_Barrier (unsigned int count, const ACE_TCHAR *name = 0); - - /// Default dtor. - ~ACE_Thread_Barrier (void); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Barrier.inl" -#endif /* __ACE_INLINE__ */ - -#endif /* !ACE_HAS_THREADS */ - -#include /**/ "ace/post.h" -#endif /* ACE_BARRIER_H */ diff --git a/ACE/ace/Barrier.inl b/ACE/ace/Barrier.inl deleted file mode 100644 index 9ab5c9fb111..00000000000 --- a/ACE/ace/Barrier.inl +++ /dev/null @@ -1,22 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_Sub_Barrier::~ACE_Sub_Barrier (void) -{ -} - -ACE_INLINE -ACE_Barrier::~ACE_Barrier (void) -{ -} - -ACE_INLINE -ACE_Thread_Barrier::~ACE_Thread_Barrier (void) -{ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Base_Thread_Adapter.cpp b/ACE/ace/Base_Thread_Adapter.cpp deleted file mode 100644 index 2ba31a4328e..00000000000 --- a/ACE/ace/Base_Thread_Adapter.cpp +++ /dev/null @@ -1,120 +0,0 @@ -// $Id$ - -#include "ace/Base_Thread_Adapter.h" - -ACE_RCSID (ace, - Base_Thread_Adapter, - "$Id$") - -#if !defined (ACE_HAS_INLINED_OSCALLS) -# include "ace/Base_Thread_Adapter.inl" -#endif /* ACE_HAS_INLINED_OSCALLS */ - -#if defined (ACE_HAS_TSS_EMULATION) -# include "ace/OS_NS_Thread.h" -#endif /* ACE_HAS_TSS_EMULATION */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INIT_LOG_MSG_HOOK ACE_Base_Thread_Adapter::init_log_msg_hook_ = 0; -ACE_INHERIT_LOG_MSG_HOOK ACE_Base_Thread_Adapter::inherit_log_msg_hook_ = 0; -ACE_CLOSE_LOG_MSG_HOOK ACE_Base_Thread_Adapter::close_log_msg_hook_ = 0; -ACE_SYNC_LOG_MSG_HOOK ACE_Base_Thread_Adapter::sync_log_msg_hook_ = 0; -ACE_THR_DESC_LOG_MSG_HOOK ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ = 0; - -ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter ( - ACE_THR_FUNC user_func, - void *arg, - ACE_THR_C_FUNC entry_point, - ACE_OS_Thread_Descriptor *td -#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) - , ACE_SEH_EXCEPT_HANDLER selector - , ACE_SEH_EXCEPT_HANDLER handler -#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ - ) - : user_func_ (user_func) - , arg_ (arg) - , entry_point_ (entry_point) - , thr_desc_ (td) -{ - ACE_OS_TRACE ("ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter"); - - if (ACE_Base_Thread_Adapter::init_log_msg_hook_ != 0) - (*ACE_Base_Thread_Adapter::init_log_msg_hook_) ( - this->log_msg_attributes_ -# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) - , selector - , handler -# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ - ); -#ifdef ACE_USES_GPROF - getitimer (ITIMER_PROF, &itimer_); -#endif // ACE_USES_GPROF -} - -ACE_Base_Thread_Adapter::~ACE_Base_Thread_Adapter (void) -{ -} - -void -ACE_Base_Thread_Adapter::inherit_log_msg (void) -{ - if (ACE_Base_Thread_Adapter::inherit_log_msg_hook_ != 0) - (*ACE_Base_Thread_Adapter::inherit_log_msg_hook_)( - this->thr_desc_, - this->log_msg_attributes_); -} - -void -ACE_Base_Thread_Adapter::close_log_msg (void) -{ - if (ACE_Base_Thread_Adapter::close_log_msg_hook_ != 0) - (*ACE_Base_Thread_Adapter::close_log_msg_hook_) (); -} - -void -ACE_Base_Thread_Adapter::sync_log_msg (const ACE_TCHAR *prg) -{ - if (ACE_Base_Thread_Adapter::sync_log_msg_hook_ != 0) - (*ACE_Base_Thread_Adapter::sync_log_msg_hook_) (prg); -} - -ACE_OS_Thread_Descriptor * -ACE_Base_Thread_Adapter::thr_desc_log_msg (void) -{ - if (ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ != 0) - return (*ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_) (); - return 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -// Run the thread entry point for the . This must -// be an extern "C" to make certain compilers happy... - -extern "C" ACE_THR_FUNC_RETURN -ACE_THREAD_ADAPTER_NAME (void *args) -{ - ACE_OS_TRACE ("ACE_THREAD_ADAPTER_NAME"); - -#if defined (ACE_HAS_TSS_EMULATION) - // As early as we can in the execution of the new thread, allocate - // its local TS storage. Allocate it on the stack, to save dynamic - // allocation/dealloction. - void *ts_storage[ACE_TSS_Emulation::ACE_TSS_THREAD_KEYS_MAX]; - ACE_TSS_Emulation::tss_open (ts_storage); -#endif /* ACE_HAS_TSS_EMULATION */ - - ACE_Base_Thread_Adapter * const thread_args = - static_cast (args); - -#ifdef ACE_USES_GPROF - setitimer (ITIMER_PROF, thread_args->timerval (), 0); -#endif // ACE_USES_GPROF - - // Invoke the user-supplied function with the args. - ACE_THR_FUNC_RETURN status = thread_args->invoke (); - - return status; -} - diff --git a/ACE/ace/Base_Thread_Adapter.h b/ACE/ace/Base_Thread_Adapter.h deleted file mode 100644 index f33f0facd48..00000000000 --- a/ACE/ace/Base_Thread_Adapter.h +++ /dev/null @@ -1,186 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Base_Thread_Adapter.h - * - * $Id$ - * - * @author Nanbor Wang - */ -//============================================================================= - -#ifndef ACE_BASE_THREAD_ADAPTER_H -#define ACE_BASE_THREAD_ADAPTER_H -#include /**/ "ace/pre.h" - -#include "ace/OS_Log_Msg_Attributes.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include /**/ "ace/ACE_export.h" -#include "ace/OS_Log_Msg_Attributes.h" - -#ifdef ACE_USES_GPROF -#include "os_include/sys/os_time.h" -#endif // ACE_USES_GPROF - -#if (defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1) -# define ACE_THREAD_ADAPTER_NAME ACE_PREPROC_CONCATENATE(ACE_VERSIONED_NAMESPACE_NAME, _ace_thread_adapter) -#else -# define ACE_THREAD_ADAPTER_NAME ace_thread_adapter -#endif /* ACE_HAS_VERSIONED_NAMESPACE == 1 */ - -// Run the thread entry point for the ACE_Thread_Adapter. This must -// be an extern "C" to make certain compilers happy... - -extern "C" ACE_Export ACE_THR_FUNC_RETURN ACE_THREAD_ADAPTER_NAME (void *args); - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_OS_Thread_Descriptor - * - * @brief Parent class of all ACE_Thread_Descriptor classes. - * = - * Container for ACE_Thread_Descriptor members that are - * used in ACE_OS. - */ -class ACE_Export ACE_OS_Thread_Descriptor -{ -public: - /// Get the thread creation flags. - long flags (void) const; - -protected: - /// For use by ACE_Thread_Descriptor. - ACE_OS_Thread_Descriptor (long flags = 0); - - /** - * Keeps track of whether this thread was created "detached" or not. - * If a thread is *not* created detached then if someone calls - * , we need to join with that thread (and - * close down the handle). - */ - long flags_; -}; - -/** - * @class ACE_Base_Thread_Adapter - * - * @brief Base class for all the Thread_Adapters. - * - * Converts a C++ function into a function that can be - * called from a thread creation routine - * (e.g., pthread_create() or _beginthreadex()) that expects an - * extern "C" entry point. This class also makes it possible to - * transparently provide hooks to register a thread with an - * ACE_Thread_Manager. - * This class is used in ACE_OS::thr_create(). In general, the - * thread that creates an object of this class is different from - * the thread that calls @c invoke() on this object. Therefore, - * the @c invoke() method is responsible for deleting itself. - */ -class ACE_Export ACE_Base_Thread_Adapter -{ -public: - - virtual ~ACE_Base_Thread_Adapter (void); - - /// Virtual method invoked by the thread entry point. - virtual ACE_THR_FUNC_RETURN invoke (void) = 0; - - /// Accessor for the C entry point function to the OS thread creation - /// routine. - ACE_THR_C_FUNC entry_point (void); - -#ifdef ACE_USES_GPROF - /// Accessor to the itimer_ - /// followed http://sam.zoy.org/writings/programming/gprof.html - struct itimerval* timerval (void); -#endif // ACE_USES_PROF - - /// Invoke the close_log_msg_hook, if it is present - static void close_log_msg (void); - - /// Invoke the sync_log_msg_hook, if it is present - static void sync_log_msg (const ACE_TCHAR *prog_name); - - /// Invoke the thr_desc_log_msg_hook, if it is present - static ACE_OS_Thread_Descriptor *thr_desc_log_msg (void); - -protected: - /// Constructor. - ACE_Base_Thread_Adapter (ACE_THR_FUNC user_func, - void *arg, - ACE_THR_C_FUNC entry_point = (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME, - ACE_OS_Thread_Descriptor *td = 0 -# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) - , ACE_SEH_EXCEPT_HANDLER selector = 0 - , ACE_SEH_EXCEPT_HANDLER handler = 0 -# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ - ); - /// Inherit the logging features if the parent thread has an - /// ACE_Log_Msg. - void inherit_log_msg (void); - -private: - /// The hooks to inherit and cleanup the Log_Msg attributes - static ACE_INIT_LOG_MSG_HOOK init_log_msg_hook_; - static ACE_INHERIT_LOG_MSG_HOOK inherit_log_msg_hook_; - static ACE_CLOSE_LOG_MSG_HOOK close_log_msg_hook_; - static ACE_SYNC_LOG_MSG_HOOK sync_log_msg_hook_; - static ACE_THR_DESC_LOG_MSG_HOOK thr_desc_log_msg_hook_; - - /// Set the Log_Msg hooks - static void set_log_msg_hooks (ACE_INIT_LOG_MSG_HOOK init_hook, - ACE_INHERIT_LOG_MSG_HOOK inherit_hook, - ACE_CLOSE_LOG_MSG_HOOK close_hook, - ACE_SYNC_LOG_MSG_HOOK sync_hook, - ACE_THR_DESC_LOG_MSG_HOOK thr_desc); - - /// Allow the ACE_Log_Msg class to set its hooks. - friend class ACE_Log_Msg; - -protected: - /// Thread startup function passed in by the user (C++ linkage). - ACE_THR_FUNC user_func_; - - /// Argument to thread startup function. - void *arg_; - - /// Entry point to the underlying OS thread creation call (C - /// linkage). - ACE_THR_C_FUNC entry_point_; - - /** - * Optional thread descriptor. Passing this pointer in will force - * the spawned thread to cache this location in and wait - * until fills in all information in thread - * descriptor. - */ - ACE_OS_Thread_Descriptor *thr_desc_; - - /// The ACE_Log_Msg attributes. - ACE_OS_Log_Msg_Attributes log_msg_attributes_; - /// That is usefull for gprof, define itimerval -#ifdef ACE_USES_GPROF - struct itimerval itimer_; -#endif // ACE_USES_GPROF - -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -# if defined (ACE_HAS_INLINED_OSCALLS) -# if defined (ACE_INLINE) -# undef ACE_INLINE -# endif /* ACE_INLINE */ -# define ACE_INLINE inline -# include "ace/Base_Thread_Adapter.inl" -# endif /* ACE_HAS_INLINED_OSCALLS */ - -#include /**/ "ace/post.h" -#endif /* ACE_BASE_THREAD_ADAPTER_H */ diff --git a/ACE/ace/Base_Thread_Adapter.inl b/ACE/ace/Base_Thread_Adapter.inl deleted file mode 100644 index 7fa3959034b..00000000000 --- a/ACE/ace/Base_Thread_Adapter.inl +++ /dev/null @@ -1,48 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE long -ACE_OS_Thread_Descriptor::flags (void) const -{ - return flags_; -} - -ACE_INLINE -ACE_OS_Thread_Descriptor::ACE_OS_Thread_Descriptor (long flags) - : flags_ (flags) -{ -} - -ACE_INLINE void -ACE_Base_Thread_Adapter::set_log_msg_hooks ( - ACE_INIT_LOG_MSG_HOOK init_hook, - ACE_INHERIT_LOG_MSG_HOOK inherit_hook, - ACE_CLOSE_LOG_MSG_HOOK close_hook, - ACE_SYNC_LOG_MSG_HOOK sync_hook, - ACE_THR_DESC_LOG_MSG_HOOK thr_desc_hook) -{ - ACE_Base_Thread_Adapter::init_log_msg_hook_ = init_hook; - ACE_Base_Thread_Adapter::inherit_log_msg_hook_ = inherit_hook; - ACE_Base_Thread_Adapter::close_log_msg_hook_ = close_hook; - ACE_Base_Thread_Adapter::sync_log_msg_hook_ = sync_hook; - ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ = thr_desc_hook; -} - -ACE_INLINE ACE_THR_C_FUNC -ACE_Base_Thread_Adapter::entry_point (void) -{ - return this->entry_point_; -} - -#ifdef ACE_USES_GPROF -ACE_INLINE itimerval* -ACE_Base_Thread_Adapter::timerval (void) -{ - return &(this->itimer_); -} -#endif // ACE_USES_GPROF - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Based_Pointer_Repository.cpp b/ACE/ace/Based_Pointer_Repository.cpp deleted file mode 100644 index a76d3dbcbd3..00000000000 --- a/ACE/ace/Based_Pointer_Repository.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// $Id$ - -#include "ace/Map_Manager.h" -#include "ace/Based_Pointer_Repository.h" -#include "ace/Guard_T.h" -#include "ace/Null_Mutex.h" -#include "ace/Synch_Traits.h" -#include "ace/RW_Thread_Mutex.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Based_Pointer_Repository_Rep - * - * @brief Implementation for the ACE_Based_Pointer_Repository. - * - * Every memory pool in ACE binds it's mapping base address and - * the mapped size to this repository every time it maps/remaps a - * new chunk of memory successfully. - */ -class ACE_Based_Pointer_Repository_Rep -{ -public: - // Useful typedefs. - typedef ACE_Map_Manager MAP_MANAGER; - typedef ACE_Map_Iterator MAP_ITERATOR; - typedef ACE_Map_Entry MAP_ENTRY; - - /// Keeps track of the mapping between addresses and their associated - /// values. - MAP_MANAGER addr_map_; - - /// Synchronize concurrent access to the map. - ACE_SYNCH_MUTEX lock_; -}; - -ACE_Based_Pointer_Repository::ACE_Based_Pointer_Repository (void) -{ - ACE_TRACE ("ACE_Based_Pointer_Repository::ACE_Based_Pointer_Repository"); - ACE_NEW (this->rep_, - ACE_Based_Pointer_Repository_Rep); -} - -ACE_Based_Pointer_Repository::~ACE_Based_Pointer_Repository (void) -{ - ACE_TRACE ("ACE_Based_Pointer_Repository::~ACE_Based_Pointer_Repository"); - delete this->rep_; -} - -// Search for appropriate base address in repository - -int -ACE_Based_Pointer_Repository::find (void *addr, void *&base_addr) -{ - ACE_TRACE ("ACE_Based_Pointer_Repository::find"); - ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->rep_->lock_, -1); - ACE_Based_Pointer_Repository_Rep::MAP_ENTRY *ce = 0; - - for (ACE_Based_Pointer_Repository_Rep::MAP_ITERATOR iter (this->rep_->addr_map_); - iter.next (ce) != 0; - iter.advance ()) - // Check to see if is within any of the regions. - if (addr >= ce->ext_id_ - && addr < ((char *)ce->ext_id_ + ce->int_id_)) - { - // Assign the base address. - base_addr = ce->ext_id_; - return 1; - } - - // Assume base address 0 (e.g., if new'ed). - base_addr = 0; - return 0; -} - -// Bind a new entry to the repository or update the size of an -// existing entry. - -int -ACE_Based_Pointer_Repository::bind (void *addr, size_t size) -{ - ACE_TRACE ("ACE_Based_Pointer_Repository::bind"); - ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->rep_->lock_, -1); - - return this->rep_->addr_map_.rebind (addr, size); -} - -// Unbind a base from the repository. - -int -ACE_Based_Pointer_Repository::unbind (void *addr) -{ - ACE_TRACE ("ACE_Based_Pointer_Repository::unbind"); - ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->rep_->lock_, -1); - ACE_Based_Pointer_Repository_Rep::MAP_ENTRY *ce = 0; - - // Search for service handlers that requested notification. - - for (ACE_Based_Pointer_Repository_Rep::MAP_ITERATOR iter (this->rep_->addr_map_); - iter.next (ce) != 0; - iter.advance ()) - { - // Check to see if is within any of the regions and if - // so, unbind the key from the map. - if (addr >= ce->ext_id_ - && addr < ((char *)ce->ext_id_ + ce->int_id_)) - // Unbind base address. - return this->rep_->addr_map_.unbind (ce->ext_id_); - } - - return 0; -} - -#if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION) -template ACE_Singleton * - ACE_Singleton::singleton_; -#endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */ - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Based_Pointer_Repository.h b/ACE/ace/Based_Pointer_Repository.h deleted file mode 100644 index f7d7ac64125..00000000000 --- a/ACE/ace/Based_Pointer_Repository.h +++ /dev/null @@ -1,91 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Based_Pointer_Repository.h - * - * $Id$ - * - * @author Dietrich Quehl - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_BASED_POINTER_REPOSITORY_H -#define ACE_BASED_POINTER_REPOSITORY_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Singleton.h" -#include "ace/Synch_Traits.h" -#include "ace/os_include/os_stddef.h" - - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Forward decl., using the "Cheshire Cat" technique. -class ACE_Based_Pointer_Repository_Rep; - -/** - * @class ACE_Based_Pointer_Repository - * - * @brief Maps pointers to the base address of the region to which each - * pointer belongs. - */ -class ACE_Export ACE_Based_Pointer_Repository -{ -public: - // = Use ACE_Null_Mutex to allow locking while iterating. - - // = Initialization and termination methods. - ACE_Based_Pointer_Repository (void); - ~ACE_Based_Pointer_Repository (void); - - // = Search structure methods. - /** - * Return the appropriate @a base_addr region that contains @a addr. - * Returns 1 on success and 0 if the @a addr isn't contained in any - * @a base_addr region. - */ - int find (void *addr, - void *&base_addr); - - /// Bind a new entry to the repository or update the size of an - /// existing entry. Returns 0 on success and -1 on failure. - int bind (void *addr, - size_t size); - - /// Unbind from the repository the that @a addr is - /// contained within. - int unbind (void *addr); - -private: - - /// Use the "Cheshire-Cat" technique to hide the implementation in - /// order to avoid circular #include dependencies. - ACE_Based_Pointer_Repository_Rep *rep_; - -}; - -// ---------------------------------- - -/// Declare a process wide singleton -ACE_SINGLETON_DECLARE (ACE_Singleton, - ACE_Based_Pointer_Repository, - ACE_SYNCH_RW_MUTEX) - -/// Provide a Singleton access point to the based pointer repository. -typedef ACE_Singleton - ACE_BASED_POINTER_REPOSITORY; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#include /**/ "ace/post.h" - -#endif /* ACE_BASED_POINTER_REPOSITORY_H */ diff --git a/ACE/ace/Based_Pointer_T.cpp b/ACE/ace/Based_Pointer_T.cpp deleted file mode 100644 index 217e1634690..00000000000 --- a/ACE/ace/Based_Pointer_T.cpp +++ /dev/null @@ -1,121 +0,0 @@ -// $Id$ - -#ifndef ACE_BASED_POINTER_T_CPP -#define ACE_BASED_POINTER_T_CPP - -#include "ace/Based_Pointer_T.h" -#include "ace/Based_Pointer_Repository.h" -#include "ace/Log_Msg.h" - -# define ACE_TRACEX(X) ACE_Trace ____ (ACE_TEXT (X), __LINE__, ACE_TEXT (__FILE__)) - -#if !defined (__ACE_INLINE__) -#include "ace/Based_Pointer_T.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template -ACE_Based_Pointer::ACE_Based_Pointer (void) -{ - ACE_TRACE ("ACE_Based_Pointer::ACE_Based_Pointer"); -} - -template void -ACE_Based_Pointer_Basic::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Based_Pointer_Basic::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntarget_ = %d\n"), this->target_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("base_offset_ = %d\n"), this->base_offset_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("computed pointer = %x\n"), - (CONCRETE *)(ACE_COMPUTE_BASED_POINTER (this)))); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -template -ACE_Based_Pointer::ACE_Based_Pointer (CONCRETE *initial) - : ACE_Based_Pointer_Basic (initial) -{ - ACE_TRACE ("ACE_Based_Pointer_Basic::ACE_Based_Pointer_Basic"); -} - -template -ACE_Based_Pointer::ACE_Based_Pointer (const void* base_addr, int) - : ACE_Based_Pointer_Basic (base_addr, 0) -{ - ACE_TRACE ("ACE_Based_Pointer_Basic::ACE_Based_Pointer_Basic"); -} - -template -ACE_Based_Pointer_Basic::ACE_Based_Pointer_Basic (void) - : target_ (0), - base_offset_ (0) -{ - ACE_TRACE ("ACE_Based_Pointer_Basic::ACE_Based_Pointer_Basic"); - void *base_addr = 0; - - // Find the base address associated with our pointer. Note - // that it's ok for to return 0, which simply indicates that - // the address is not in memory-mapped virtual address space. - ACE_BASED_POINTER_REPOSITORY::instance ()->find (this, - base_addr); - this->base_offset_ = (char *) this - (char *) base_addr; -} - -template -ACE_Based_Pointer_Basic::ACE_Based_Pointer_Basic (const void *base_addr, int) - : target_ (0), - base_offset_ (0) -{ - ACE_TRACE ("ACE_Based_Pointer_Basic::ACE_Based_Pointer_Basic"); - this->base_offset_ = (char *) this - (char *) base_addr; -} - -template -ACE_Based_Pointer_Basic::ACE_Based_Pointer_Basic (CONCRETE *rhs) - : target_ (0), - base_offset_ (0) -{ - ACE_TRACE ("ACE_Based_Pointer_Basic::ACE_Based_Pointer_Basic"); - - if (rhs == 0) - // Store a value of that indicate "NULL" pointer. - this->target_ = -1; - else - { - void *base_addr = 0; - - // Find the base address associated with the pointer. - // Note that it's ok for to return 0, which simply - // indicates that the address is not in memory-mapped virtual - // address space. - ACE_BASED_POINTER_REPOSITORY::instance ()->find (this, - base_addr); - this->base_offset_ = (char *) this - (char *) base_addr; - this->target_ = ((char *) rhs - (char *) base_addr); - } -} - -template -ACE_Based_Pointer_Basic::ACE_Based_Pointer_Basic (const ACE_Based_Pointer_Basic &) -{ - ACE_TRACE ("ACE_Based_Pointer_Basic::ACE_Based_Pointer_Basic"); - - ACE_ASSERT (0); // not implemented. -} - -template -ACE_Based_Pointer::ACE_Based_Pointer (const ACE_Based_Pointer &rhs) - : ACE_Based_Pointer_Basic (rhs) -{ - ACE_TRACE ("ACE_Based_Pointer::ACE_Based_Pointer"); - ACE_ASSERT (0); // not implemented. -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_BASED_POINTER_T_CPP */ diff --git a/ACE/ace/Based_Pointer_T.h b/ACE/ace/Based_Pointer_T.h deleted file mode 100644 index bb5874f002f..00000000000 --- a/ACE/ace/Based_Pointer_T.h +++ /dev/null @@ -1,205 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Based_Pointer_T.h - * - * $Id$ - * - * @author Dietrich Quehl - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_BASED_POINTER_T_H -#define ACE_BASED_POINTER_T_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" -#include "ace/Basic_Types.h" - -#if defined (_MSC_VER) -// Suppress warning e.g. "return type for -// 'ACE_Based_Pointer::operator ->' is 'long *' (i.e., not a UDT -// or reference to a UDT. Will produce errors if applied using infix -// notation)" -#pragma warning(disable: 4284) -#endif /* _MSC_VER */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Based_Pointer_Basic - * - * @brief A proxy that keeps track of the relative offset of a "pointer" - * from its base address. - * This class makes it possible to transparently use "pointers" in - * shared memory as easily as programming with pointers to local - * memory. In particular, we don't need to ensure that the base - * addresses of all the pointers are mapped into separate - * processes at the same absolute memory base address. - */ -template -class ACE_Based_Pointer_Basic -{ -public: - /** - * This constructor initializes the by asking the - * Singleton for the base address of - * the memory region within which it is instantiated. Two results - * are possible: - * - * 1. An has stored a base address/size pair and the - * new based-pointer instance is located between the base address and - * the base address + size - 1. In this case, the repository - * returns the base address. - * - * 2. No suitable address/size pair was found. The repository - * assumes an address in the regular (not mapped) virtual address - * space of the process and returns 0. In this case, the - * based-pointer uses its address as an offset to it's base - * address 0. - */ - ACE_Based_Pointer_Basic (void); - - /** - * Initialize this object using the pointer. This - * constructor initializes the by asking the - * Singleton for the base address of - * the memory region within which it is instantiated. Three results - * are possible: - * - * 1. An has stored a base address/size pair and the - * new based-pointer instance is located between the base address and - * the base address + size - 1. In this case, the repository - * returns the base address. - * - * 2. No suitable address/size pair was found. The repository - * assumes an address in the regular (not mapped) virtual address - * space of the process and returns 0. In this case, the - * based-pointer uses its address as an offset to its base - * address 0. - * - * 3. If is 0 then set the value of to -1, which - * indicates a "NULL" pointer. - */ - ACE_Based_Pointer_Basic (CONCRETE *initial); - - /// Copy constructor. - ACE_Based_Pointer_Basic (const ACE_Based_Pointer_Basic &); - - /// Constructor for know base address. is only used to - /// resolve overload ambiguity. - ACE_Based_Pointer_Basic (const void *base_addr, int o); - - /// Pseudo-assignment operator. - void operator = (CONCRETE *from); - - /// Pseudo-assignment operator. - void operator = (const ACE_Based_Pointer_Basic &); - - /// Dereference operator. - CONCRETE& operator * (void) const; - - /// Less than operator. - bool operator < (const ACE_Based_Pointer_Basic &) const; - - /// Less than or equal operator. - bool operator <= (const ACE_Based_Pointer_Basic &) const; - - /// Greater than operator. - bool operator > (const ACE_Based_Pointer_Basic &) const; - - /// Greater than or equal operator. - bool operator >= (const ACE_Based_Pointer_Basic &) const; - - /// Equality operator. - bool operator == (const ACE_Based_Pointer_Basic &) const; - - /// Inequality operator. - bool operator != (const ACE_Based_Pointer_Basic &) const; - - /// Subscript operator. - CONCRETE& operator [](int index) const; - - /// Increment operator. - void operator+= (int index); - - /// Returns the underlying memory address of the smart pointer. - operator CONCRETE *() const; - - /// Returns the underlying memory address of the smart pointer. - CONCRETE *addr (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - - /// Dump the state of the object. - void dump (void) const; - -protected: - ptrdiff_t target_; - - /// Keep track of our offset from the base pointer. - ptrdiff_t base_offset_; -}; - -/** - * @class ACE_Based_Pointer - * - * @brief A smart proxy that keeps track of the relative offset of a - * "pointer" from its base address. - * - * This class makes it possible to transparently use "pointers" in - * shared memory as easily as programming with pointers to local - * memory by overloading the C++ delegation operator ->(). - */ -template -class ACE_Based_Pointer : public ACE_Based_Pointer_Basic -{ -public: - // = Initialization method. - /// Constructor. See constructor for ACE_Based_Pointer_Basic for - /// details. - ACE_Based_Pointer (void); - - /// Initialize this object using the pointer. See - /// constructor for ACE_Based_Pointer_Basic for details. - ACE_Based_Pointer (CONCRETE *initial); - - /// Initialize this object with known @a base_addr. @a dummy is - /// a dummy value used to resolve overload ambiguity and it - /// otherwise ignored. - ACE_Based_Pointer (const void *base_addr, int dummy); - - /// Copy constructor (not implemented yet). - ACE_Based_Pointer (const ACE_Based_Pointer &); - - /// Assignment operator. - void operator = (const ACE_Based_Pointer &); - - /// Pseudo-assignment operator. - void operator = (CONCRETE *from); - - /// The C++ "delegation operator". - CONCRETE *operator-> (void); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Based_Pointer_T.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Based_Pointer_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Based_Pointer_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" - -#endif /* ACE_BASED_POINTER_T_H */ diff --git a/ACE/ace/Based_Pointer_T.inl b/ACE/ace/Based_Pointer_T.inl deleted file mode 100644 index 5fb2c985f40..00000000000 --- a/ACE/ace/Based_Pointer_T.inl +++ /dev/null @@ -1,139 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#define ACE_COMPUTE_BASED_POINTER(P) (((char *) (P) - (P)->base_offset_) + (P)->target_) -#include "ace/Global_Macros.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template ACE_INLINE CONCRETE * -ACE_Based_Pointer::operator->(void) -{ - ACE_TRACE ("ACE_Based_Pointer::operator->"); - return reinterpret_cast (ACE_COMPUTE_BASED_POINTER (this)); -} - -template ACE_INLINE void -ACE_Based_Pointer_Basic::operator = (CONCRETE *rhs) -{ - ACE_TRACE ("ACE_Based_Pointer_Basic::operator ="); - if (rhs == 0) - // Store a value of that indicate "NULL" pointer. - this->target_ = -1; - else - this->target_ = ((char *) rhs - - ((char *) this - this->base_offset_)); -} - -template ACE_INLINE void -ACE_Based_Pointer::operator = (CONCRETE *rhs) -{ - ACE_TRACE ("ACE_Based_Pointer::operator ="); - if (rhs == 0) - // Store a value of that indicate "NULL" pointer. - this->target_ = -1; - else - this->target_ = ((char *) rhs - - ((char *) this - this->base_offset_)); -} - -template ACE_INLINE CONCRETE& -ACE_Based_Pointer_Basic::operator *(void) const -{ - ACE_TRACE ("ACE_Based_Pointer_Basic::operator *"); - return *reinterpret_cast (ACE_COMPUTE_BASED_POINTER (this)); -} - -template ACE_INLINE CONCRETE * -ACE_Based_Pointer_Basic::addr (void) const -{ - ACE_TRACE ("ACE_Based_Pointer_Basic::addr"); - - if (this->target_ == -1) - return 0; - else - return reinterpret_cast (ACE_COMPUTE_BASED_POINTER (this)); -} - -template ACE_INLINE -ACE_Based_Pointer_Basic::operator CONCRETE *() const -{ - ACE_TRACE ("ACE_Based_Pointer_Basic::operator CONCRETE *()"); - - return this->addr (); -} - -template ACE_INLINE CONCRETE& -ACE_Based_Pointer_Basic::operator [] (int index) const -{ - ACE_TRACE ("ACE_Based_Pointer_Basic::operator []"); - CONCRETE *c = - reinterpret_cast (ACE_COMPUTE_BASED_POINTER (this)); - return c[index]; -} - -template ACE_INLINE void -ACE_Based_Pointer_Basic::operator += (int index) -{ - ACE_TRACE ("ACE_Based_Pointer_Basic::operator +="); - this->base_offset_ += (index * sizeof (CONCRETE)); -} - -template ACE_INLINE bool -ACE_Based_Pointer_Basic::operator == (const ACE_Based_Pointer_Basic &rhs) const -{ - ACE_TRACE ("ACE_Based_Pointer_Basic::operator =="); - return ACE_COMPUTE_BASED_POINTER (this) == ACE_COMPUTE_BASED_POINTER (&rhs); -} - -template ACE_INLINE bool -ACE_Based_Pointer_Basic::operator != (const ACE_Based_Pointer_Basic &rhs) const -{ - ACE_TRACE ("ACE_Based_Pointer_Basic::operator !="); - return !(*this == rhs); -} - -template ACE_INLINE bool -ACE_Based_Pointer_Basic::operator < (const ACE_Based_Pointer_Basic &rhs) const -{ - ACE_TRACE ("ACE_Based_Pointer_Basic::operator <"); - return ACE_COMPUTE_BASED_POINTER (this) < ACE_COMPUTE_BASED_POINTER (&rhs); -} - -template ACE_INLINE bool -ACE_Based_Pointer_Basic::operator <= (const ACE_Based_Pointer_Basic &rhs) const -{ - ACE_TRACE ("ACE_Based_Pointer_Basic::operator <="); - return ACE_COMPUTE_BASED_POINTER (this) <= ACE_COMPUTE_BASED_POINTER (&rhs); -} - -template ACE_INLINE bool -ACE_Based_Pointer_Basic::operator > (const ACE_Based_Pointer_Basic &rhs) const -{ - ACE_TRACE ("ACE_Based_Pointer_Basic::operator >"); - return ACE_COMPUTE_BASED_POINTER (this) > ACE_COMPUTE_BASED_POINTER (&rhs); -} - -template ACE_INLINE bool -ACE_Based_Pointer_Basic::operator >= (const ACE_Based_Pointer_Basic &rhs) const -{ - ACE_TRACE ("ACE_Based_Pointer_Basic::operator >="); - return ACE_COMPUTE_BASED_POINTER (this) >= ACE_COMPUTE_BASED_POINTER (&rhs); -} - -template ACE_INLINE void -ACE_Based_Pointer_Basic::operator= (const ACE_Based_Pointer_Basic &rhs) -{ - ACE_TRACE ("ACE_Based_Pointer_Basic::operator="); - *this = rhs.addr (); -} - -template ACE_INLINE void -ACE_Based_Pointer::operator= (const ACE_Based_Pointer &rhs) -{ - ACE_TRACE ("ACE_Based_Pointer::operator="); - *this = rhs.addr (); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Basic_Stats.cpp b/ACE/ace/Basic_Stats.cpp deleted file mode 100644 index 9c0b2a7c2f5..00000000000 --- a/ACE/ace/Basic_Stats.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// $Id$ - -#include "ace/Basic_Stats.h" -#include "ace/Log_Msg.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Basic_Stats.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, - Basic_Stats, - "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -void -ACE_Basic_Stats::accumulate (const ACE_Basic_Stats &rhs) -{ - if (rhs.samples_count_ == 0) - return; - - if (this->samples_count_ == 0) - { - this->min_ = rhs.min_; - this->min_at_ = rhs.min_at_; - - this->max_ = rhs.max_; - this->max_at_ = rhs.max_at_; - } - else - { - if (this->min_ > rhs.min_) - { - this->min_ = rhs.min_; - this->min_at_ = rhs.min_at_; - } - if (this->max_ < rhs.max_) - { - this->max_ = rhs.max_; - this->max_at_ = rhs.max_at_; - } - } - - this->samples_count_ += rhs.samples_count_; - this->sum_ += rhs.sum_; -} - -void -ACE_Basic_Stats::dump_results (const ACE_TCHAR *msg, ACE_UINT32 sf) const -{ -#ifndef ACE_NLOGGING - if (this->samples_count () == 0u) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("%s : no data collected\n"), msg)); - return; - } - - ACE_UINT64 avg = this->sum_ / this->samples_count_; - - ACE_UINT64 l_min = this->min_ / sf; - ACE_UINT64 l_max = this->max_ / sf; - ACE_UINT64 l_avg = avg / sf; - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("%s latency : %Q[%d]/%Q/%Q[%d] (min/avg/max)\n"), - msg, - l_min, this->min_at_, - l_avg, - l_max, this->max_at_)); - -#else - ACE_UNUSED_ARG (msg); - ACE_UNUSED_ARG (sf); -#endif /* ACE_NLOGGING */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Basic_Stats.h b/ACE/ace/Basic_Stats.h deleted file mode 100644 index 11f24ca6bf8..00000000000 --- a/ACE/ace/Basic_Stats.h +++ /dev/null @@ -1,87 +0,0 @@ - -//============================================================================= -/** - * @file Basic_Stats.h - * - * $Id$ - * - * @author Carlos O'Ryan - */ -//============================================================================= - - -#ifndef ACE_BASIC_STATS_H -#define ACE_BASIC_STATS_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" -#include "ace/Basic_Types.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/// Collect basic stats about a series of samples -/** - * Compute the average and standard deviation (aka jitter) for an - * arbitrary number of samples, using constant space. - * Normally used for latency statistics. - */ -class ACE_Export ACE_Basic_Stats -{ -public: - /// Constructor - /** - * The number of samples is pre-allocated, and cannot changes once - * the class is initialized. - */ - ACE_Basic_Stats (void); - - /// The number of samples received so far - ACE_UINT32 samples_count (void) const; - - /// Record one sample. - void sample (ACE_UINT64 value); - - /// Update the values to reflect the stats in @a rhs. - void accumulate (const ACE_Basic_Stats &rhs); - - /// Dump all the samples - /** - * Prints out the results, using @a msg as a prefix for each message and - * scaling all the numbers by @a scale_factor. The latter is useful because - * high resolution timer samples are acquired in clock ticks, but often - * presented in microseconds. - */ - void dump_results (const ACE_TCHAR *msg, - ACE_UINT32 scale_factor) const; - - /// The number of samples - ACE_UINT32 samples_count_; - - /// The minimum value - ACE_UINT64 min_; - - /// The number of the sample that had the minimum value - ACE_UINT32 min_at_; - - /// The maximum value - ACE_UINT64 max_; - - /// The number of the sample that had the maximum value - ACE_UINT32 max_at_; - - /// The sum of all the values - ACE_UINT64 sum_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Basic_Stats.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_BASIC_STATS_H */ diff --git a/ACE/ace/Basic_Stats.inl b/ACE/ace/Basic_Stats.inl deleted file mode 100644 index bbdce099907..00000000000 --- a/ACE/ace/Basic_Stats.inl +++ /dev/null @@ -1,53 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_Basic_Stats::ACE_Basic_Stats (void) - : samples_count_ (0) - , min_ (0) - , min_at_ (0) - , max_ (0) - , max_at_ (0) - , sum_ (0) -{ -} - -ACE_INLINE ACE_UINT32 -ACE_Basic_Stats::samples_count (void) const -{ - return this->samples_count_; -} - -ACE_INLINE void -ACE_Basic_Stats::sample (ACE_UINT64 value) -{ - ++this->samples_count_; - - if (this->samples_count_ == 1u) - { - this->min_ = value; - this->min_at_ = this->samples_count_; - this->max_ = value; - this->max_at_ = this->samples_count_; - } - else - { - if (this->min_ > value) - { - this->min_ = value; - this->min_at_ = this->samples_count_; - } - if (this->max_ < value) - { - this->max_ = value; - this->max_at_ = this->samples_count_; - } - } - - this->sum_ += value; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Basic_Types.cpp b/ACE/ace/Basic_Types.cpp deleted file mode 100644 index f2e055b991e..00000000000 --- a/ACE/ace/Basic_Types.cpp +++ /dev/null @@ -1,139 +0,0 @@ -#include "ace/Basic_Types.h" - -#if !defined (__ACE_INLINE__) -# include "ace/Basic_Types.inl" -#endif /* ! __ACE_INLINE__ */ - - -ACE_RCSID (ace, - Basic_Types, - "$Id$") - - -#if defined (ACE_LACKS_LONGLONG_T) && !defined (ACE_LACKS_UNSIGNEDLONGLONG_T) -# include "ace/Log_Msg.h" -# include "ace/OS_NS_stdio.h" -# include "ace/OS_NS_string.h" -# if !defined (ACE_LACKS_IOSTREAM_TOTALLY) -// FUZZ: disable check_for_streams_include -# include "ace/streams.h" -# endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -void -ACE_U_LongLong::output (FILE *file) const -{ - if (h_ () > 0) - ACE_OS::fprintf (file, "0x%lx%0*lx", h_ (), 2 * sizeof l_ (), l_ ()); - else - ACE_OS::fprintf (file, "0x%lx", l_ ()); -} - - -ACE_TCHAR * -ACE_U_LongLong::as_string (ACE_TCHAR *output, - unsigned int base, - unsigned int uppercase) const -{ - if (*this == 0) - { - ACE_OS::strcpy(output, "0"); - } - else - { - switch(base) - { - case 8: - { - unsigned int index = 0; - int bshift = 31; - while(bshift >= 1) - { - unsigned int sval = (this->h_ () >> bshift) & 7; - if (sval > 0 || index != 0) - { - output[index] = sval + '0'; - ++index; - } - bshift -= 3; - } - bshift = 30; - while(bshift >= 0) - { - unsigned int sval = (this->l_ () >> bshift) & 7; - // Combine the last bit of hi with the first 3-bit digit - if (bshift == 30) - { - sval |= (this->h_ () & 1) << 2; - } - if (sval > 0 || index != 0) - { - output[index] = sval + '0'; - ++index; - } - bshift -= 3; - } - output[index] = '\0'; - break; - } - case 10: - { - ACE_OS::sprintf(output, "%.0f", *this / 1.0); - break; - } - case 16: - { - if (this->h_ () != 0) - { - ACE_OS::sprintf(output, - (uppercase ? "%lX%0*lX" : "%lx%0*lx"), - this->h_ (), 2 * sizeof this->l_ (), - this->l_ ()); - } - else - { - ACE_OS::sprintf(output, - (uppercase ? "%lX" : "%lx"), this->l_ ()); - - } - break; - } - default: - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Unsupported base = %u\n"), base)); - output[0] = '\0'; - } - } - } - - return output; -} - - -# if !defined (ACE_LACKS_IOSTREAM_TOTALLY) -ostream& -operator<< (ostream& os, const ACE_U_LongLong& ll) -{ -#ifdef __TANDEM && (__CPLUSPLUS_VERSION >= 3) - unsigned long flags = os.flags(); -#else - unsigned long flags = os.setf(0); -#endif - char buffer[32]; - - if ((flags & ios::oct) != 0) - os << ll.as_string (buffer, 8); - else if ((flags & ios::hex) != 0) - os << ll.as_string (buffer, 16, (flags & ios::uppercase)); - else - os << ll.as_string (buffer); - return os; -} -# endif - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_LACKS_LONGLONG_T */ - diff --git a/ACE/ace/Basic_Types.h b/ACE/ace/Basic_Types.h deleted file mode 100644 index 2d6942bb511..00000000000 --- a/ACE/ace/Basic_Types.h +++ /dev/null @@ -1,890 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Basic_Types.h - * - * $Id$ - * - * @author David L. Levine - * - * #defines the list of preprocessor macros below. The config.h file can - * pre-define any of these to short-cut the definitions. This is usually - * only necessary if the preprocessor does all of its math using integers. - * - * Sizes of built-in types: - * - ACE_SIZEOF_CHAR - * - ACE_SIZEOF_WCHAR - * - ACE_SIZEOF_SHORT - * - ACE_SIZEOF_INT - * - ACE_SIZEOF_LONG - * - ACE_SIZEOF_LONG_LONG - * - ACE_SIZEOF_VOID_P - * - ACE_SIZEOF_FLOAT - * - ACE_SIZEOF_DOUBLE - * - ACE_SIZEOF_LONG_DOUBLE - * - * Wrappers for built-in types of specific sizes: - * - ACE_USHORT16 (For backward compatibility. Use ACE_UINT16 instead.) - * - ACE_INT8 - * - ACE_UINT8 - * - ACE_INT16 - * - ACE_UINT16 - * - ACE_INT32 - * - ACE_UINT32 - * - ACE_UINT64 - * (@note ACE_INT64 is partly defined, there is no ACE_LongLong for - * platforms that don't have a native 8-byte integer type.) - * - * Byte-order (endian-ness) determination: - * ACE_BYTE_ORDER, to either ACE_BIG_ENDIAN or ACE_LITTLE_ENDIAN - * - * - */ -//============================================================================= - -#include "ace/config-lite.h" - -#ifndef ACE_BASIC_TYPES_H -# define ACE_BASIC_TYPES_H - -# include /**/ "ace/pre.h" - -# if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -# endif /* ACE_LACKS_PRAGMA_ONCE */ - -// Pull in definitions -# include "ace/os_include/os_limits.h" // Integer limits -# include "ace/os_include/os_float.h" // Floating point limits -# include "ace/os_include/os_stdlib.h" // Other types -# include "ace/os_include/os_stddef.h" // Get ptrdiff_t - see further comments below - -# if defined(ACE_LACKS_LONGLONG_T) -# include "ace/os_include/os_stdio.h" // For long long emulation -# endif /* ACE_LACKS_LONGLONG_T */ - -# include "ace/os_include/sys/os_types.h" - -# if !defined (ACE_LACKS_SYS_PARAM_H) -# include /**/ -# endif /* ACE_LACKS_SYS_PARAM_H */ - -# include "ace/ACE_export.h" - -# if !defined (ACE_LACKS_STDINT_H) -# include -# endif -# if !defined (ACE_LACKS_INTTYPES_H) -# include -# endif - -#ifdef ACE_LACKS_INTPTR_T -# include "ace/If_Then_Else.h" - -// This intptr_t typedef is here instead of -// since it depends on the template -// metaprogramming in . - -// We could compare ACE_SIZEOF_VOID_P against ACE_SIZEOF_LONG, etc. -// However, that depends on the ACE preprocessor symbol definitions in -// the platform-specific configuration header being correct. -// The template meta-programming approach we take below, -// i.e. determining the type at compile-time rather than at -// preprocessing-time, will work for all platforms, and does not -// depend on ACE developer-defined configuration parameters. - -typedef ACE::If_Then_Else< - (sizeof (void*) == sizeof (signed int)), - signed int, - ACE::If_Then_Else< - (sizeof (void*) == sizeof (signed long)), - signed long, -#ifdef ACE_LACKS_LONGLONG_T - void /* Unknown. Force an invalid type */ -#else - ACE::If_Then_Else< - (sizeof (void*) == sizeof (signed long long)), - signed long long, - void /* Unknown. Force an invalid type */ - >::result_type -#endif /* ACE_LACKS_LONGLONG_T */ - >::result_type - >::result_type intptr_t; - -typedef ACE::If_Then_Else< - (sizeof (void*) == sizeof (unsigned int)), - unsigned int, - ACE::If_Then_Else< - (sizeof (void*) == sizeof (unsigned long)), - unsigned long, -#ifdef ACE_LACKS_UNSIGNEDLONGLONG_T - void /* Unknown. Force an invalid type */ -#else - ACE::If_Then_Else< - (sizeof (void*) == sizeof (unsigned long long)), - unsigned long long, - void /* Unknown. Force an invalid type */ - >::result_type -#endif /* ACE_LACKS_UNSIGNEDLONGLONG_T */ - >::result_type - >::result_type uintptr_t; - -#endif /* ACE_LACKS_INTPTR_T */ - -// A char always has 1 byte, by definition. -# define ACE_SIZEOF_CHAR 1 - -// Unfortunately, there isn't a portable way to determine the size of a wchar. -// So we just define them on a platform basis. If the platform doesn't -// define it and it's an XPG4 system, assume wchar_t is 4 bytes. Some code -// uses ACE_SIZEOF_WCHAR in preprocessor statements, so sizeof() isn't valid. -// If the platform config doesn't set this, and this guess is wrong, -// Basic_Types_Test should catch the inconsistency. -# if defined (ACE_HAS_WCHAR) -# if !defined (ACE_SIZEOF_WCHAR) -# if defined (ACE_HAS_XPG4_MULTIBYTE_CHAR) -# define ACE_SIZEOF_WCHAR 4 -# else -// 0 so the Basic_Types test will catch this. -# define ACE_SIZEOF_WCHAR 0 -# endif /* ACE_HAS_XPG4_MULTIBYTE_CHAR */ -# endif /* !ACE_SIZEOF_WCHAR */ -# endif /* ACE_HAS_WCHAR */ - -// The number of bytes in a short. -# if !defined (ACE_SIZEOF_SHORT) -# if (USHRT_MAX) == 255U -# define ACE_SIZEOF_SHORT 1 -# elif (USHRT_MAX) == 65535U -# define ACE_SIZEOF_SHORT 2 -# elif (USHRT_MAX) == 4294967295U -# define ACE_SIZEOF_SHORT 4 -# elif (USHRT_MAX) == 18446744073709551615U -# define ACE_SIZEOF_SHORT 8 -# else -# error: unsupported short size, must be updated for this platform! -# endif /* USHRT_MAX */ -# endif /* !defined (ACE_SIZEOF_SHORT) */ - -// The number of bytes in an int. -# if !defined (ACE_SIZEOF_INT) -# if (UINT_MAX) == 65535U -# define ACE_SIZEOF_INT 2 -# elif (UINT_MAX) == 4294967295U -# define ACE_SIZEOF_INT 4 -# elif (UINT_MAX) == 18446744073709551615U -# define ACE_SIZEOF_INT 8 -# else -# error: unsupported int size, must be updated for this platform! -# endif /* UINT_MAX */ -# endif /* !defined (ACE_SIZEOF_INT) */ - -// The number of bytes in a long. -# if !defined (ACE_SIZEOF_LONG) -# if (ULONG_MAX) == 65535UL -# define ACE_SIZEOF_LONG 2 -# elif ((ULONG_MAX) == 4294967295UL) -# define ACE_SIZEOF_LONG 4 -# elif ((ULONG_MAX) == 18446744073709551615UL) -# define ACE_SIZEOF_LONG 8 -# else -# error: unsupported long size, must be updated for this platform! -# endif /* ULONG_MAX */ -# endif /* !defined (ACE_SIZEOF_LONG) */ - -// The number of bytes in a long long. -# if !defined (ACE_SIZEOF_LONG_LONG) -# if defined (ACE_LACKS_LONGLONG_T) -# define ACE_SIZEOF_LONG_LONG 8 -# elif defined (ULLONG_MAX) -# if ((ULLONG_MAX) == 4294967295ULL) -# define ACE_SIZEOF_LONG_LONG 4 -# elif ((ULLONG_MAX) == 18446744073709551615ULL) -# define ACE_SIZEOF_LONG_LONG 8 -# endif -# elif defined (ULONGLONG_MAX) -# if ((ULONGLONG_MAX) == 4294967295ULL) -# define ACE_SIZEOF_LONG_LONG 4 -# elif ((ULONGLONG_MAX) == 18446744073709551615ULL) -# define ACE_SIZEOF_LONG_LONG 8 -# endif -# endif -# // If we can't determine the size of long long, assume it is 8 -# // instead of erroring out. (Either ULLONG_MAX and ULONGLONG_MAX -# // may not be supported; or an extended C/C++ dialect may need to -# // be selected. If this assumption is wrong, it can be addressed -# // in the platform-specific config header. -# if !defined (ACE_SIZEOF_LONG_LONG) -# define ACE_SIZEOF_LONG_LONG 8 -# endif -# endif /* !defined (ACE_SIZEOF_LONG_LONG) */ - - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// The sizes of the commonly implemented types are now known. Set up -// typedefs for whatever we can. Some of these are needed for certain -// cases of ACE_UINT64, so do them before the 64-bit stuff. - -#if defined (ACE_INT8_TYPE) - typedef ACE_INT8_TYPE ACE_INT8; -#elif defined (ACE_HAS_INT8_T) - typedef int8_t ACE_INT8; -#elif !defined (ACE_LACKS_SIGNED_CHAR) - typedef signed char ACE_INT8; -#else - typedef char ACE_INT8; -#endif /* defined (ACE_INT8_TYPE) */ - -#if defined (ACE_UINT8_TYPE) - typedef ACE_UINT8_TYPE ACE_UINT8; -#elif defined (ACE_HAS_UINT8_T) - typedef uint8_t ACE_UINT8; -#else - typedef unsigned char ACE_UINT8; -#endif /* defined (ACE_UINT8_TYPE) */ - -#if defined (ACE_INT16_TYPE) - typedef ACE_INT16_TYPE ACE_INT16; -#elif defined (ACE_HAS_INT16_T) - typedef int16_t ACE_INT16; -#elif ACE_SIZEOF_SHORT == 2 - typedef short ACE_INT16; -#elif ACE_SIZEOF_INT == 2 - typedef int ACE_INT16; -#else -# error Have to add to the ACE_INT16 type setting -#endif /* defined (ACE_INT16_TYPE) */ - -#if defined (ACE_UINT16_TYPE) - typedef ACE_UINT16_TYPE ACE_UINT16; -#elif defined (ACE_HAS_UINT16_T) - typedef uint16_t ACE_UINT16; -#elif ACE_SIZEOF_SHORT == 2 - typedef unsigned short ACE_UINT16; -#elif ACE_SIZEOF_INT == 2 - typedef unsigned int ACE_UINT16; -#else -# error Have to add to the ACE_UINT16 type setting -#endif /* defined (ACE_UINT16_TYPE) */ - -#if defined (ACE_INT32_TYPE) - typedef ACE_INT32_TYPE ACE_INT32; -#elif defined (ACE_HAS_INT32_T) - typedef int32_t ACE_INT32; -#elif ACE_SIZEOF_INT == 4 - typedef int ACE_INT32; -#elif ACE_SIZEOF_LONG == 4 - typedef long ACE_INT32; -#else -# error Have to add to the ACE_INT32 type setting -#endif /* defined (ACE_INT32_TYPE) */ - -#if defined (ACE_UINT32_TYPE) - typedef ACE_UINT32_TYPE ACE_UINT32; -#elif defined (ACE_HAS_UINT32_T) - typedef uint32_t ACE_UINT32; -#elif ACE_SIZEOF_INT == 4 - typedef unsigned int ACE_UINT32; -#elif ACE_SIZEOF_LONG == 4 - typedef unsigned long ACE_UINT32; -#else -# error Have to add to the ACE_UINT32 type setting -#endif /* defined (ACE_UINT32_TYPE) */ - -#if defined (ACE_INT64_TYPE) - typedef ACE_INT64_TYPE ACE_INT64; -#elif defined (ACE_HAS_INT64_T) - typedef int64_t ACE_INT64; -#elif ACE_SIZEOF_LONG == 8 - typedef long ACE_INT64; -#elif !defined (ACE_LACKS_LONGLONG_T) && ACE_SIZEOF_LONG_LONG == 8 -# ifdef __GNUC__ - // Silence g++ "-pedantic" warnings regarding use of "long long" - // type. - __extension__ -# endif /* __GNUC__ */ - typedef long long ACE_INT64; -#endif /* defined (ACE_INT64_TYPE) */ - -#if !(defined (ACE_LACKS_LONGLONG_T) || defined (ACE_LACKS_UNSIGNEDLONGLONG_T)) -/* See matching #if around ACE_U_LongLong class declaration below */ - -# if defined (ACE_UINT64_TYPE) - typedef ACE_UINT64_TYPE ACE_UINT64; -# elif defined (ACE_HAS_UINT64_T) - typedef uint64_t ACE_UINT64; -# elif ACE_SIZEOF_LONG == 8 - typedef unsigned long ACE_UINT64; -# elif ACE_SIZEOF_LONG_LONG == 8 -# ifdef __GNUC__ - // Silence g++ "-pedantic" warnings regarding use of "long long" - // type. - __extension__ -# endif /* __GNUC__ */ - typedef unsigned long long ACE_UINT64; -# endif /* defined (ACE_UINT64_TYPE) */ -#endif /* !(ACE_LACKS_LONGLONG_T || ACE_LACKS_UNSIGNEDLONGLONG_T) */ - - -typedef ACE_UINT16 ACE_USHORT16; // @@ Backward compatibility. - -// Define a generic byte for use in codecs -typedef unsigned char ACE_Byte; - -// Define a pseudo wide character type when wchar is not supported so we -// can support basic wide character string operations. - -# if defined (ACE_HAS_WCHAR) || defined (ACE_HAS_XPG4_MULTIBYTE_CHAR) -# define ACE_WINT_T wint_t -# define ACE_WCHAR_T wchar_t -# else -# define ACE_WINT_T ACE_UINT16 -# define ACE_WCHAR_T ACE_UINT16 -# endif /* ACE_HAS_WCHAR */ - -// The number of bytes in a void *. -# ifndef ACE_SIZEOF_VOID_P -# define ACE_SIZEOF_VOID_P ACE_SIZEOF_LONG -# endif /* ACE_SIZEOF_VOID_P */ - -// Type for doing arithmetic on pointers ... as elsewhere, we assume -// that unsigned versions of a type are the same size as the signed -// version of the same type. -# if defined (ACE_HAS_WINCE) && (_WIN32_WCE < 400) -typedef unsigned long ptrdiff_t; // evc3, PocketPC don't defined ptrdiff_t -# endif - -ACE_END_VERSIONED_NAMESPACE_DECL - -// Byte-order (endian-ness) determination. -# if defined (BYTE_ORDER) -# if (BYTE_ORDER == LITTLE_ENDIAN) -# define ACE_LITTLE_ENDIAN 0x0123 -# define ACE_BYTE_ORDER ACE_LITTLE_ENDIAN -# elif (BYTE_ORDER == BIG_ENDIAN) -# define ACE_BIG_ENDIAN 0x3210 -# define ACE_BYTE_ORDER ACE_BIG_ENDIAN -# else -# error: unknown BYTE_ORDER! -# endif /* BYTE_ORDER */ -# elif defined (_BYTE_ORDER) -# if (_BYTE_ORDER == _LITTLE_ENDIAN) -# define ACE_LITTLE_ENDIAN 0x0123 -# define ACE_BYTE_ORDER ACE_LITTLE_ENDIAN -# elif (_BYTE_ORDER == _BIG_ENDIAN) -# define ACE_BIG_ENDIAN 0x3210 -# define ACE_BYTE_ORDER ACE_BIG_ENDIAN -# else -# error: unknown _BYTE_ORDER! -# endif /* _BYTE_ORDER */ -# elif defined (__BYTE_ORDER) -# if (__BYTE_ORDER == __LITTLE_ENDIAN) -# define ACE_LITTLE_ENDIAN 0x0123 -# define ACE_BYTE_ORDER ACE_LITTLE_ENDIAN -# elif (__BYTE_ORDER == __BIG_ENDIAN) -# define ACE_BIG_ENDIAN 0x3210 -# define ACE_BYTE_ORDER ACE_BIG_ENDIAN -# else -# error: unknown __BYTE_ORDER! -# endif /* __BYTE_ORDER */ -# else /* ! BYTE_ORDER && ! __BYTE_ORDER */ - // We weren't explicitly told, so we have to figure it out . . . -# if defined (i386) || defined (__i386__) || defined (_M_IX86) || \ - defined (vax) || defined (__alpha) || defined (__LITTLE_ENDIAN__) || \ - defined (ARM) || defined (_M_IA64) || defined (__ia64__) || \ - defined (_M_AMD64) || defined (__amd64) - // We know these are little endian. -# define ACE_LITTLE_ENDIAN 0x0123 -# define ACE_BYTE_ORDER ACE_LITTLE_ENDIAN -# else - // Otherwise, we assume big endian. -# define ACE_BIG_ENDIAN 0x3210 -# define ACE_BYTE_ORDER ACE_BIG_ENDIAN -# endif -# endif /* ! BYTE_ORDER && ! __BYTE_ORDER */ - -// Byte swapping macros to deal with differences between little endian -// and big endian machines. Note that "long" here refers to 32 bit -// quantities. -# define ACE_SWAP_LONG(L) ((ACE_SWAP_WORD ((L) & 0xFFFF) << 16) \ - | ACE_SWAP_WORD(((L) >> 16) & 0xFFFF)) -# define ACE_SWAP_WORD(L) ((((L) & 0x00FF) << 8) | (((L) & 0xFF00) >> 8)) - -# if defined (ACE_LITTLE_ENDIAN) -# define ACE_HTONL(X) ACE_SWAP_LONG (X) -# define ACE_NTOHL(X) ACE_SWAP_LONG (X) -# define ACE_IDL_NCTOHL(X) (X) -# define ACE_IDL_NSTOHL(X) (X) -# else -# define ACE_HTONL(X) X -# define ACE_NTOHL(X) X -# define ACE_IDL_NCTOHL(X) (X << 24) -# define ACE_IDL_NSTOHL(X) ((X) << 16) -# endif /* ACE_LITTLE_ENDIAN */ - -# if defined (ACE_LITTLE_ENDIAN) -# define ACE_HTONS(x) ACE_SWAP_WORD(x) -# define ACE_NTOHS(x) ACE_SWAP_WORD(x) -# else -# define ACE_HTONS(x) x -# define ACE_NTOHS(x) x -# endif /* ACE_LITTLE_ENDIAN */ - -#if defined (ACE_LACKS_LONGLONG_T) - // This throws away the high 32 bits. It's very unlikely that a - // pointer will be more than 32 bits wide if the platform does not - // support 64-bit integers. -# define ACE_LONGLONG_TO_PTR(PTR_TYPE, L) \ - reinterpret_cast (L.lo ()) -#elif defined (ACE_OPENVMS) && (!defined (__INITIAL_POINTER_SIZE) || (__INITIAL_POINTER_SIZE < 64)) -# define ACE_LONGLONG_TO_PTR(PTR_TYPE, L) \ - reinterpret_cast (static_cast (L)) -#else /* ! ACE_LACKS_LONGLONG_T */ -# define ACE_LONGLONG_TO_PTR(PTR_TYPE, L) \ - reinterpret_cast (static_cast (L)) -#endif /* ! ACE_LACKS_LONGLONG_T */ - -// If the platform lacks an unsigned long long, define one. -#if defined (ACE_LACKS_LONGLONG_T) || defined (ACE_LACKS_UNSIGNEDLONGLONG_T) -// Forward declaration for streams -# include "ace/iosfwd.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_U_LongLong - * - * @brief Unsigned long long for platforms that don't have one. - * - * Provide our own unsigned long long. This is intended to be - * use with ACE_High_Res_Timer, so the division operator assumes - * that the quotient fits into a u_long. - * Please note that the constructor takes (optionally) two values. - * The high one contributes 0x100000000 times its value. So, - * for example, (0, 2) is _not_ 20000000000, but instead - * 0x200000000. To emphasize this, the default values are expressed - * in hex, and output () dumps the value in hex. - */ - class ACE_Export ACE_U_LongLong - { - public: - // = Initialization and termination methods. -#if defined (ACE_LACKS_UNSIGNEDLONGLONG_T) - ACE_U_LongLong (const long long value = 0x0); -#else - ACE_U_LongLong (const ACE_UINT32 lo = 0x0, const ACE_UINT32 hi = 0x0); -#endif - ACE_U_LongLong (const ACE_U_LongLong &); - ACE_U_LongLong &operator= (const ACE_U_LongLong &); - ACE_U_LongLong &operator= (const ACE_INT32 &); - ACE_U_LongLong &operator= (const ACE_UINT32 &); - ~ACE_U_LongLong (void); - - // = Overloaded relation operators. - bool operator== (const ACE_U_LongLong &) const; - bool operator== (const ACE_UINT32) const; - bool operator!= (const ACE_U_LongLong &) const; - bool operator!= (const ACE_UINT32) const; - bool operator< (const ACE_U_LongLong &) const; - bool operator< (const ACE_UINT32) const; - bool operator<= (const ACE_U_LongLong &) const; - bool operator<= (const ACE_UINT32) const; - bool operator> (const ACE_U_LongLong &) const; - bool operator> (const ACE_UINT32) const; - bool operator>= (const ACE_U_LongLong &) const; - bool operator>= (const ACE_UINT32) const; - - ACE_U_LongLong operator+ (const ACE_U_LongLong &) const; - ACE_U_LongLong operator+ (const ACE_UINT32) const; - ACE_U_LongLong operator- (const ACE_U_LongLong &) const; - ACE_U_LongLong operator- (const ACE_UINT32) const; - ACE_U_LongLong operator* (const ACE_UINT32) const; - ACE_U_LongLong &operator*= (const ACE_UINT32); - - ACE_U_LongLong operator<< (const unsigned int) const; - ACE_U_LongLong &operator<<= (const unsigned int); - ACE_U_LongLong operator>> (const unsigned int) const; - ACE_U_LongLong &operator>>= (const unsigned int); - - double operator/ (const double) const; - - ACE_U_LongLong &operator+= (const ACE_U_LongLong &); - ACE_U_LongLong &operator+= (const ACE_UINT32); - ACE_U_LongLong &operator-= (const ACE_U_LongLong &); - ACE_U_LongLong &operator-= (const ACE_UINT32); - ACE_U_LongLong &operator++ (); - ACE_U_LongLong &operator-- (); - const ACE_U_LongLong operator++ (int); - const ACE_U_LongLong operator-- (int); - ACE_U_LongLong &operator|= (const ACE_U_LongLong); - ACE_U_LongLong &operator|= (const ACE_UINT32); - ACE_U_LongLong &operator&= (const ACE_U_LongLong); - ACE_U_LongLong &operator&= (const ACE_UINT32); - - // Note that the following take ACE_UINT32 arguments. These are - // typical use cases, and easy to implement. But, they limit the - // return values to 32 bits as well. There are no checks for - // overflow. - ACE_UINT32 operator/ (const ACE_UINT32) const; - ACE_UINT32 operator% (const ACE_UINT32) const; - - // The following only operate on the lower 32 bits (they take only - // 32 bit arguments). - ACE_UINT32 operator| (const ACE_INT32) const; - ACE_UINT32 operator& (const ACE_INT32) const; - - // The following operators convert their arguments to - // ACE_UINT32. So, there may be information loss if they are - // used. - ACE_U_LongLong operator* (const ACE_INT32) const; - ACE_U_LongLong &operator*= (const ACE_INT32); - ACE_UINT32 operator/ (const ACE_INT32) const; -# if ACE_SIZEOF_INT == 4 - ACE_UINT32 operator/ (const unsigned long) const; - ACE_UINT32 operator/ (const long) const; -# else /* ACE_SIZEOF_INT != 4 */ - ACE_UINT32 operator/ (const unsigned int) const; - ACE_UINT32 operator/ (const int) const; -# endif /* ACE_SIZEOF_INT != 4 */ - - // = Helper methods. - /// Outputs the value to the FILE, in hex. - void output (FILE * = stdout) const; - - ACE_TCHAR *as_string (ACE_TCHAR *string, - unsigned int base = 10, - unsigned int uppercase = 0) const; - - ACE_UINT32 hi (void) const; - ACE_UINT32 lo (void) const; - - void hi (const ACE_UINT32 hi); - void lo (const ACE_UINT32 lo); - -#if defined (ACE_LACKS_UNSIGNEDLONGLONG_T) - long long to_int64 (void) const; -# endif - - private: - -#if defined (ACE_LACKS_UNSIGNEDLONGLONG_T) - long long data_; -#else - public: - struct ace_hi_lo_correct_endian - { -# if defined (ACE_BIG_ENDIAN) - /// High 32 bits. - ACE_UINT32 hi_; - /// Low 32 bits. - ACE_UINT32 lo_; - -# else - - /// Low 32 bits. - ACE_UINT32 lo_; - /// High 32 bits. - ACE_UINT32 hi_; -# endif /* ! ACE_BIG_ENDIAN */ - }; - private: - union - { - struct ace_hi_lo_correct_endian data_; - - /// To ensure alignment on 8-byte boundary. - double for_alignment_; - }; - - // @note the following four accessors are inlined here in - // order to minimize the extent of the data_ struct. It's - // only used here; the .i and .cpp files use the accessors. - - /// Internal utility function to hide access through struct. - const ACE_UINT32 &h_ () const { return data_.hi_; } - - /// Internal utility function to hide access through struct. - ACE_UINT32 &h_ () { return data_.hi_; } - - /// Internal utility function to hide access through struct. - const ACE_UINT32 &l_ () const { return data_.lo_; } - - /// Internal utility function to hide access through struct. - ACE_UINT32 &l_ () { return data_.lo_; } - - // @note the above four accessors are inlined here in - // order to minimize the extent of the data_ struct. It's - // only used here; the .inl and .cpp files use the accessors. - - /// These functions are used to implement multiplication. - ACE_UINT32 ul_shift (ACE_UINT32 a, - ACE_UINT32 c_in, - ACE_UINT32 *c_out) const; - ACE_U_LongLong ull_shift (ACE_U_LongLong a, - ACE_UINT32 c_in, - ACE_UINT32 *c_out) const; - ACE_U_LongLong ull_add (ACE_U_LongLong a, - ACE_U_LongLong b, - ACE_UINT32 *carry) const; - ACE_U_LongLong ull_mult (ACE_U_LongLong a, - ACE_UINT32 b, - ACE_UINT32 *carry) const; -#endif // ACE_LACKS_UNSIGNEDLONGLONG_T - }; - - typedef ACE_U_LongLong ACE_UINT64; - -#if !defined (ACE_LACKS_IOSTREAM_TOTALLY) - ostream &operator<< (ostream &, const ACE_U_LongLong &); -#endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */ - -ACE_END_VERSIONED_NAMESPACE_DECL - -# endif /* ACE_LACKS_LONGLONG_T */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Conversions from ACE_UINT64 to ACE_UINT32. ACE_CU64_TO_CU32 should -// be used on const ACE_UINT64's. -# if defined (ACE_LACKS_LONGLONG_T) || defined (ACE_LACKS_UNSIGNEDLONGLONG_T) -inline ACE_UINT32 -ACE_U64_TO_U32 (ACE_U_LongLong const & n) -{ - /** - * @note We could add a cast operator to ACE_U_LongLong but that may - * cause more problems than it solves. Force users to perform - * an explicit cast via ACE_{C}U64_TO_{C}U32. - */ - return n.lo (); -} - -inline ACE_UINT32 -ACE_CU64_TO_CU32 (ACE_U_LongLong const & n) -{ - return ACE_U64_TO_U32 (n); -} -# else /* ! ACE_LACKS_LONGLONG_T */ -inline ACE_UINT32 -ACE_U64_TO_U32 (ACE_UINT64 n) -{ - return static_cast (n); -} - -inline ACE_UINT32 -ACE_CU64_TO_CU32 (ACE_UINT64 n) -{ - return static_cast (n); -} -# endif /* ! ACE_LACKS_LONGLONG_T */ - -ACE_END_VERSIONED_NAMESPACE_DECL - -// 64-bit literals require special marking on some platforms. -# if defined (ACE_LACKS_LONGLONG_T) - // Can only specify 32-bit arguments. -# define ACE_UINT64_LITERAL(n) n ## UL - // This one won't really work, but it'll keep - // some compilers happy until we have better support -# define ACE_INT64_LITERAL(n) n ## L -# elif defined (ACE_WIN32) -# if defined (__MINGW32__) -# define ACE_UINT64_LITERAL(n) n ## ull -# define ACE_INT64_LITERAL(n) n ## ll -# else -# define ACE_UINT64_LITERAL(n) n ## ui64 -# define ACE_INT64_LITERAL(n) n ## i64 -# endif /* defined (__MINGW32__) */ -# elif defined (__TANDEM) -# define ACE_UINT64_LITERAL(n) n ## LL -# define ACE_INT64_LITERAL(n) n ## LL -# else /* ! ACE_WIN32 && ! ACE_LACKS_LONGLONG_T */ -# define ACE_UINT64_LITERAL(n) n ## ull -# define ACE_INT64_LITERAL(n) n ## ll -# endif /* ! ACE_WIN32 && ! ACE_LACKS_LONGLONG_T */ - -#if !defined (ACE_INT8_FORMAT_SPECIFIER) -# if defined (PRId8) -# define ACE_INT8_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRId8) -# else -# define ACE_INT8_FORMAT_SPECIFIER ACE_TEXT ("%d") -# endif /* defined (PRId8) */ -#endif /* ACE_INT8_FORMAT_SPECIFIER */ - -#if !defined (ACE_UINT8_FORMAT_SPECIFIER) -# if defined (PRIu8) -# define ACE_UINT8_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRIu8) -# else -# define ACE_UINT8_FORMAT_SPECIFIER ACE_TEXT ("%u") -# endif /* defined (PRIu8) */ -#endif /* ACE_UINT8_FORMAT_SPECIFIER */ - -#if !defined (ACE_INT16_FORMAT_SPECIFIER) -# if defined (PRId16) -# define ACE_INT16_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRId16) -# else -# define ACE_INT16_FORMAT_SPECIFIER ACE_TEXT ("%d") -# endif /* defined (PRId16) */ -#endif /* ACE_INT16_FORMAT_SPECIFIER */ - -#if !defined (ACE_UINT16_FORMAT_SPECIFIER) -# if defined (PRIu16) -# define ACE_UINT16_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRIu16) -# else -# define ACE_UINT16_FORMAT_SPECIFIER ACE_TEXT ("%u") -# endif /* defined (PRIu16) */ -#endif /* ACE_UINT16_FORMAT_SPECIFIER */ - -#if !defined (ACE_INT32_FORMAT_SPECIFIER) -# if defined (PRId32) -# define ACE_INT32_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRId32) -# elif ACE_SIZEOF_INT == 4 -# define ACE_INT32_FORMAT_SPECIFIER ACE_TEXT ("%d") -# else -# define ACE_INT32_FORMAT_SPECIFIER ACE_TEXT ("%ld") -# endif /* defined (PRId32) */ -#endif /* ACE_INT32_FORMAT_SPECIFIER */ - -#if !defined (ACE_UINT32_FORMAT_SPECIFIER) -# if defined (PRIu32) -# define ACE_UINT32_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRIu32) -# elif ACE_SIZEOF_INT == 4 -# define ACE_UINT32_FORMAT_SPECIFIER ACE_TEXT ("%u") -# else -# define ACE_UINT32_FORMAT_SPECIFIER ACE_TEXT ("%lu") -# endif /* defined (PRIu32) */ -#endif /* ACE_UINT32_FORMAT_SPECIFIER */ - -#if !defined (ACE_INT64_FORMAT_SPECIFIER) -# if defined (PRId64) -# define ACE_INT64_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRId64) -# elif ACE_SIZEOF_LONG == 8 -# define ACE_INT64_FORMAT_SPECIFIER ACE_TEXT ("%ld") -# else -# define ACE_INT64_FORMAT_SPECIFIER ACE_TEXT ("%lld") -# endif /* defined (PRId64) */ -#endif /* ACE_INT64_FORMAT_SPECIFIER */ - -#if !defined (ACE_UINT64_FORMAT_SPECIFIER) -# if defined (PRIu64) -# define ACE_UINT64_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRIu64) -# elif ACE_SIZEOF_LONG == 8 -# define ACE_UINT64_FORMAT_SPECIFIER ACE_TEXT ("%lu") -# else -# define ACE_UINT64_FORMAT_SPECIFIER ACE_TEXT ("%llu") -# endif /* defined (PRIu64) */ -#endif /* ACE_UINT64_FORMAT_SPECIFIER */ - -#if !defined (ACE_SSIZE_T_FORMAT_SPECIFIER) -# if defined (ACE_WIN64) -# define ACE_SSIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%I64d") -# else -# define ACE_SSIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%d") -# endif /* ACE_WIN64 */ -#endif /* ACE_SSIZE_T_FORMAT_SPECIFIER */ - -#if !defined (ACE_SIZE_T_FORMAT_SPECIFIER) -# if defined (ACE_WIN64) -# define ACE_SIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%I64u") -# else -# define ACE_SIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%u") -# endif /* ACE_WIN64 */ -#endif /* ACE_SIZE_T_FORMAT_SPECIFIER */ - -// Cast from UINT64 to a double requires an intermediate cast to INT64 -// on some platforms. -# if defined (ACE_LACKS_LONGLONG_T) - // Only use the low 32 bits. -# define ACE_UINT64_DBLCAST_ADAPTER(n) ACE_U64_TO_U32 (n) -# elif defined (ACE_LACKS_UNSIGNEDLONGLONG_T) -# define ACE_UINT64_DBLCAST_ADAPTER(n) ((n).to_int64 ()) -# elif defined (ACE_WIN32) -# define ACE_UINT64_DBLCAST_ADAPTER(n) static_cast<__int64> (n) -# else /* ! ACE_WIN32 && ! ACE_LACKS_LONGLONG_T */ -# define ACE_UINT64_DBLCAST_ADAPTER(n) (n) -# endif /* ! ACE_WIN32 && ! ACE_LACKS_LONGLONG_T */ - - -// The number of bytes in a float. -# ifndef ACE_SIZEOF_FLOAT -# if FLT_MAX_EXP == 128 -# define ACE_SIZEOF_FLOAT 4 -# elif FLT_MAX_EXP == 1024 -# define ACE_SIZEOF_FLOAT 8 -# else -# error: unsupported float size, must be updated for this platform! -# endif /* FLT_MAX_EXP */ -# endif /* ACE_SIZEOF_FLOAT */ - -// The number of bytes in a double. -# ifndef ACE_SIZEOF_DOUBLE -# if DBL_MAX_EXP == 128 -# define ACE_SIZEOF_DOUBLE 4 -# elif DBL_MAX_EXP == 1024 -# define ACE_SIZEOF_DOUBLE 8 -# else -# error: unsupported double size, must be updated for this platform! -# endif /* DBL_MAX_EXP */ -# endif /* ACE_SIZEOF_DOUBLE */ - -// The number of bytes in a long double. -# ifndef ACE_SIZEOF_LONG_DOUBLE -# if LDBL_MAX_EXP == 128 -# define ACE_SIZEOF_LONG_DOUBLE 4 -# elif LDBL_MAX_EXP == 1024 -# define ACE_SIZEOF_LONG_DOUBLE 8 -# elif LDBL_MAX_EXP == 16384 -# if defined (LDBL_DIG) && LDBL_DIG == 18 -# if defined (__ia64) || defined (__x86_64) -# define ACE_SIZEOF_LONG_DOUBLE 16 -# else /* ! __ia64 */ -# define ACE_SIZEOF_LONG_DOUBLE 12 -# endif /* __ia64 */ -# else /* ! LDBL_DIG || LDBL_DIG != 18 */ -# define ACE_SIZEOF_LONG_DOUBLE 16 -# endif /* ! LDBL_DIG || LDBL_DIG != 18 */ -# else -# error: unsupported double size, must be updated for this platform! -# endif /* LDBL_MAX_EXP */ -# endif /* ACE_SIZEOF_LONG_DOUBLE */ - -// Max and min sizes for the ACE integer types. -#define ACE_CHAR_MAX 0x7F -#define ACE_CHAR_MIN -(ACE_CHAR_MAX)-1 -#define ACE_OCTET_MAX 0xFF -#define ACE_INT16_MAX 0x7FFF -#define ACE_INT16_MIN -(ACE_INT16_MAX)-1 -#define ACE_UINT16_MAX 0xFFFF -#define ACE_WCHAR_MAX ACE_UINT16_MAX -#define ACE_INT32_MAX 0x7FFFFFFF -#define ACE_INT32_MIN -(ACE_INT32_MAX)-1 -#define ACE_UINT32_MAX 0xFFFFFFFF -#define ACE_INT64_MAX ACE_INT64_LITERAL(0x7FFFFFFFFFFFFFFF) -#define ACE_INT64_MIN -(ACE_INT64_MAX)-1 - -#if defined (ACE_LACKS_UNSIGNEDLONGLONG_T) -// ACE_U_LongLong's constructor accepts a "long long" in this -// case. Set it to ACE_U_LongLong (-1) since the bit pattern for long -// long (-1) is the same as the maximum unsigned long long value. -# define ACE_UINT64_MAX ACE_U_LongLong (ACE_INT64_LITERAL (0xFFFFFFFFFFFFFFFF)) -#elif defined (ACE_LACKS_LONGLONG_T) -// ACE_U_LongLong's constructor accepts an ACE_UINT32 low and high -// pair of parameters. -# define ACE_UINT64_MAX ACE_U_LongLong (0xFFFFFFFFu, 0xFFFFFFFFu) -#else -# define ACE_UINT64_MAX ACE_UINT64_LITERAL (0xFFFFFFFFFFFFFFFF) -#endif /* ACE_LACKS_UNSIGNEDLONGLONG_T */ - -// These use ANSI/IEEE format. -#define ACE_FLT_MAX 3.402823466e+38F -#define ACE_FLT_MIN 1.175494351e-38F -#define ACE_DBL_MAX 1.7976931348623158e+308 -#define ACE_DBL_MIN 2.2250738585072014e-308 - -# if defined (__ACE_INLINE__) -# include "ace/Basic_Types.inl" -# endif /* __ACE_INLINE__ */ - -# include /**/ "ace/post.h" -#endif /* ACE_BASIC_TYPES_H */ diff --git a/ACE/ace/Basic_Types.inl b/ACE/ace/Basic_Types.inl deleted file mode 100644 index 15f9a9a1ab6..00000000000 --- a/ACE/ace/Basic_Types.inl +++ /dev/null @@ -1,954 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -# if !defined (ACE_LACKS_LONGLONG_T) && defined (ACE_LACKS_UNSIGNEDLONGLONG_T) - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Implementation for ACE_U_LongLong when we have signed long long -// but no unsigned long long. - -ACE_INLINE -ACE_U_LongLong::ACE_U_LongLong (const long long value) - : data_ (value) -{ -} - -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::hi (void) const -{ - return (data_ >> 32) & 0xFFFFFFFF; -} - -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::lo (void) const -{ - return data_ & 0xFFFFFFFF; -} - -ACE_INLINE void -ACE_U_LongLong::hi (const ACE_UINT32 hi) -{ - data_ = hi; - data_ <<= 32; -} - -ACE_INLINE void -ACE_U_LongLong::lo (const ACE_UINT32 lo) -{ - data_ = lo; -} - -ACE_INLINE long long -ACE_U_LongLong::to_int64 (void) const -{ - return data_; -} - -ACE_INLINE -ACE_U_LongLong::~ACE_U_LongLong (void) -{ -} - -ACE_INLINE bool -ACE_U_LongLong::operator== (const ACE_U_LongLong &n) const -{ - return data_ == n.data_; -} - -ACE_INLINE bool -ACE_U_LongLong::operator== (const ACE_UINT32 n) const -{ - return data_ == n; -} - -ACE_INLINE bool -ACE_U_LongLong::operator!= (const ACE_U_LongLong &n) const -{ - return ! (*this == n); -} - -ACE_INLINE bool -ACE_U_LongLong::operator!= (const ACE_UINT32 n) const -{ - return ! (*this == n); -} - -ACE_INLINE bool -ACE_U_LongLong::operator< (const ACE_U_LongLong &n) const -{ - if (data_ > 0) - if (n.data_ > 0) - return data_ < n.data_; - else - return true; - else - if (n.data_ > 0) - return false; - else - return data_ < n.data_; -} - -ACE_INLINE bool -ACE_U_LongLong::operator< (const ACE_UINT32 n) const -{ - return operator< (static_cast (n)); -} - -ACE_INLINE bool -ACE_U_LongLong::operator<= (const ACE_U_LongLong &n) const -{ - if (data_ == n.data_) return true; - - return data_ < n.data_; -} - -ACE_INLINE bool -ACE_U_LongLong::operator<= (const ACE_UINT32 n) const -{ - return operator<= (static_cast (n)); -} - -ACE_INLINE bool -ACE_U_LongLong::operator> (const ACE_U_LongLong &n) const -{ - if (data_ > 0) - if (n.data_ > 0) - return data_ > n.data_; - else - return false; - else - if (n.data_ > 0) - return true; - else - return data_ > n.data_; -} - -ACE_INLINE bool -ACE_U_LongLong::operator> (const ACE_UINT32 n) const -{ - return operator> (static_cast (n)); -} - -ACE_INLINE bool -ACE_U_LongLong::operator>= (const ACE_U_LongLong &n) const -{ - if (data_ == n.data_) return true; - - return data_ > n.data_; -} - -ACE_INLINE bool -ACE_U_LongLong::operator>= (const ACE_UINT32 n) const -{ - return operator>= (static_cast (n)); -} - -ACE_INLINE -ACE_U_LongLong::ACE_U_LongLong (const ACE_U_LongLong &n) - : data_ (n.data_) -{ -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator= (const ACE_U_LongLong &n) -{ - data_ = n.data_; - - return *this; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator= (const ACE_INT32 &rhs) -{ - if (rhs >= 0) - { - data_ = rhs; - data_ &= 0xFFFFFFFF; - } - else - { - // We do not handle the case where a negative 32 bit integer is - // assigned to this representation of a 64 bit unsigned integer. - // The "undefined behavior" behavior performed by this - // implementation is to simply set all bits to zero. - data_ = 0; - } - - return *this; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator= (const ACE_UINT32 &rhs) -{ - data_ = rhs; - - return *this; -} - - -ACE_INLINE ACE_U_LongLong -ACE_U_LongLong::operator+ (const ACE_U_LongLong &n) const -{ - return data_ + n.data_; -} - -ACE_INLINE ACE_U_LongLong -ACE_U_LongLong::operator+ (const ACE_UINT32 n) const -{ - return operator+ (static_cast (n)); -} - -ACE_INLINE ACE_U_LongLong -ACE_U_LongLong::operator- (const ACE_U_LongLong &n) const -{ - return data_ - n.data_; -} - -ACE_INLINE ACE_U_LongLong -ACE_U_LongLong::operator- (const ACE_UINT32 n) const -{ - return operator- (static_cast (n)); -} - -ACE_INLINE ACE_U_LongLong -ACE_U_LongLong::operator<< (const u_int n) const -{ - return data_ << n; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator<<= (const u_int n) -{ - data_ <<= n; - - return *this; -} - -ACE_INLINE ACE_U_LongLong -ACE_U_LongLong::operator>> (const u_int n) const -{ - return data_ >> n; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator>>= (const u_int n) -{ - data_ >>= n; - - return *this; -} - -ACE_INLINE double -ACE_U_LongLong::operator/ (const double n) const -{ - return data_ / n; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator+= (const ACE_U_LongLong &n) -{ - data_ += n.data_; - - return *this; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator+= (const ACE_UINT32 n) -{ - return operator+= (static_cast (n)); -} - -ACE_INLINE ACE_U_LongLong -ACE_U_LongLong::operator* (const ACE_UINT32 n) const -{ - return data_ * n; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator*= (const ACE_UINT32 n) -{ - data_ *= n; - - return *this; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator-= (const ACE_U_LongLong &n) -{ - data_ -= n.data_; - - return *this; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator-= (const ACE_UINT32 n) -{ - return operator-= (static_cast (n)); -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator++ () -{ - ++data_; - - return *this; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator-- () -{ - --data_; - - return *this; -} - -ACE_INLINE const ACE_U_LongLong -ACE_U_LongLong::operator++ (int) -{ - // Post-increment operator should always be implemented in terms of - // the pre-increment operator to enforce consistent semantics. - ACE_U_LongLong temp (*this); - ++*this; - return temp; -} - -ACE_INLINE const ACE_U_LongLong -ACE_U_LongLong::operator-- (int) -{ - // Post-decrement operator should always be implemented in terms of - // the pre-decrement operator to enforce consistent semantics. - ACE_U_LongLong temp (*this); - --*this; - return temp; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator|= (const ACE_U_LongLong n) -{ - data_ |= n.data_; - - return *this; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator|= (const ACE_UINT32 n) -{ - return operator|= (static_cast (n)); -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator&= (const ACE_U_LongLong n) -{ - data_ &= n.data_; - - return *this; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator&= (const ACE_UINT32 n) -{ - return operator&= (static_cast (n)); -} - -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::operator/ (const ACE_UINT32 n) const -{ - return data_ / n; -} - -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::operator% (const ACE_UINT32 n) const -{ - return data_ % n; -} - -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::operator| (const ACE_INT32 n) const -{ - return data_ | n; -} - -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::operator& (const ACE_INT32 n) const -{ - return data_ & n; -} - -ACE_INLINE ACE_U_LongLong -ACE_U_LongLong::operator* (const ACE_INT32 n) const -{ - return operator* ((ACE_UINT32) n); -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator*= (const ACE_INT32 n) -{ - return operator*= ((ACE_UINT32) n); -} - -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::operator/ (const ACE_INT32 n) const -{ - return operator/ ((ACE_UINT32) n); -} - -#if ACE_SIZEOF_INT == 4 -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::operator/ (const u_long n) const -{ - return operator/ ((ACE_UINT32) n); -} - -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::operator/ (const long n) const -{ - return operator/ ((ACE_UINT32) n); -} - -#else /* ACE_SIZEOF_INT != 4 */ -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::operator/ (const u_int n) const -{ - return operator/ ((ACE_UINT32) n); -} - -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::operator/ (const int n) const -{ - return operator/ ((ACE_UINT32) n); -} -#endif - -ACE_END_VERSIONED_NAMESPACE_DECL - -#elif defined (ACE_LACKS_LONGLONG_T) - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_U_LongLong::ACE_U_LongLong (const ACE_UINT32 lo, const ACE_UINT32 hi) -{ - h_ () = hi; - l_ () = lo; -} - -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::hi (void) const -{ - return h_ (); -} - -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::lo (void) const -{ - return l_ (); -} - -ACE_INLINE void -ACE_U_LongLong::hi (const ACE_UINT32 hi) -{ - h_ () = hi; -} - -ACE_INLINE void -ACE_U_LongLong::lo (const ACE_UINT32 lo) -{ - l_ () = lo; -} - -ACE_INLINE -ACE_U_LongLong::~ACE_U_LongLong (void) -{ -} - -ACE_INLINE bool -ACE_U_LongLong::operator== (const ACE_U_LongLong &n) const -{ - return h_ () == n.h_ () && l_ () == n.l_ (); -} - -ACE_INLINE bool -ACE_U_LongLong::operator== (const ACE_UINT32 n) const -{ - return h_ () == 0 && l_ () == n; -} - -ACE_INLINE bool -ACE_U_LongLong::operator!= (const ACE_U_LongLong &n) const -{ - return ! (*this == n); -} - -ACE_INLINE bool -ACE_U_LongLong::operator!= (const ACE_UINT32 n) const -{ - return ! (*this == n); -} - -ACE_INLINE bool -ACE_U_LongLong::operator< (const ACE_U_LongLong &n) const -{ - return h_ () < n.h_ () ? 1 - : h_ () > n.h_ () ? 0 - : l_ () < n.l_ (); -} - -ACE_INLINE bool -ACE_U_LongLong::operator< (const ACE_UINT32 n) const -{ - return operator< (static_cast (n)); -} - -ACE_INLINE bool -ACE_U_LongLong::operator<= (const ACE_U_LongLong &n) const -{ - return h_ () < n.h_ () ? 1 - : h_ () > n.h_ () ? 0 - : l_ () <= n.l_ (); -} - -ACE_INLINE bool -ACE_U_LongLong::operator<= (const ACE_UINT32 n) const -{ - return operator<= (static_cast (n)); -} - -ACE_INLINE bool -ACE_U_LongLong::operator> (const ACE_U_LongLong &n) const -{ - return h_ () > n.h_ () ? 1 - : h_ () < n.h_ () ? 0 - : l_ () > n.l_ (); -} - -ACE_INLINE bool -ACE_U_LongLong::operator> (const ACE_UINT32 n) const -{ - return operator> (static_cast (n)); -} - -ACE_INLINE bool -ACE_U_LongLong::operator>= (const ACE_U_LongLong &n) const -{ - return h_ () > n.h_ () ? 1 - : h_ () < n.h_ () ? 0 - : l_ () >= n.l_ (); -} - -ACE_INLINE bool -ACE_U_LongLong::operator>= (const ACE_UINT32 n) const -{ - return operator>= (static_cast (n)); -} - -ACE_INLINE -ACE_U_LongLong::ACE_U_LongLong (const ACE_U_LongLong &n) -{ - h_ () = n.h_ (); - l_ () = n.l_ (); -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator= (const ACE_U_LongLong &n) -{ - h_ () = n.h_ (); - l_ () = n.l_ (); - - return *this; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator= (const ACE_INT32 &rhs) -{ - if (rhs >= 0) - { - l_ () = static_cast (rhs); - h_ () = 0; - } - else - { - // We do not handle the case where a negative 32 bit integer is - // assigned to this representation of a 64 bit unsigned integer. - // The "undefined behavior" behavior performed by this - // implementation is to simply set all bits to zero. - l_ () = 0; - h_ () = 0; - } - - return *this; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator= (const ACE_UINT32 &rhs) -{ - l_ () = rhs; - h_ () = 0; - - return *this; -} - - -ACE_INLINE ACE_U_LongLong -ACE_U_LongLong::operator+ (const ACE_U_LongLong &n) const -{ - ACE_U_LongLong ret (l_ () + n.l_ (), h_ () + n.h_ ()); - if (ret.l_ () < n.l_ ()) /* carry */ ++ret.h_ (); - - return ret; -} - -ACE_INLINE ACE_U_LongLong -ACE_U_LongLong::operator+ (const ACE_UINT32 n) const -{ - return operator+ (static_cast (n)); -} - -ACE_INLINE ACE_U_LongLong -ACE_U_LongLong::operator- (const ACE_U_LongLong &n) const -{ - ACE_U_LongLong ret (l_ () - n.l_ (), h_ () - n.h_ ()); - if (l_ () < n.l_ ()) /* borrow */ --ret.h_ (); - - return ret; -} - -ACE_INLINE ACE_U_LongLong -ACE_U_LongLong::operator- (const ACE_UINT32 n) const -{ - return operator- (static_cast (n)); -} - -ACE_INLINE ACE_U_LongLong -ACE_U_LongLong::operator<< (const u_int n) const -{ - const ACE_UINT32 carry_mask = l_ () >> (32 - n); - ACE_U_LongLong ret (n < 32 ? l_ () << n : 0, - n < 32 ? (h_ () << n) | carry_mask : carry_mask); - - return ret; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator<<= (const u_int n) -{ - const ACE_UINT32 carry_mask = l_ () >> (32 - n); - h_ () = n < 32 ? (h_ () << n) | carry_mask : carry_mask; - - // g++ 2.7.2.3/Solaris 2.5.1 doesn't modify l_ () if shifted by 32. - l_ () = n < 32 ? l_ () << n : 0; - - return *this; -} - -ACE_INLINE ACE_U_LongLong -ACE_U_LongLong::operator>> (const u_int n) const -{ - const ACE_UINT32 carry_mask = h_ () << (32 - n); - ACE_U_LongLong ret (n < 32 ? (l_ () >> n) | carry_mask : 0, - n < 32 ? h_ () >> n : 0); - - return ret; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator>>= (const u_int n) -{ - const ACE_UINT32 carry_mask = h_ () << (32 - n); - l_ () = n < 32 ? (l_ () >> n) | carry_mask : carry_mask; - h_ () = n < 32 ? h_ () >> n : 0; - - return *this; -} - -ACE_INLINE double -ACE_U_LongLong::operator/ (const double n) const -{ - // See the derivation above in operator/ (const ACE_UINT32). - - return ((double) 0xffffffffu - n + 1.0) / n * h_ () + - (double) h_ () + (double) l_ () / n; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator+= (const ACE_U_LongLong &n) -{ - h_ () += n.h_ (); - l_ () += n.l_ (); - if (l_ () < n.l_ ()) /* carry */ ++h_ (); - - return *this; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator+= (const ACE_UINT32 n) -{ - return operator+= (static_cast (n)); -} - -#define ACE_HIGHBIT (~(~0UL >> 1)) - -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::ul_shift (ACE_UINT32 a, ACE_UINT32 c_in, ACE_UINT32 *c_out) const -{ - const ACE_UINT32 b = (a << 1) | c_in; - *c_out = (*c_out << 1) + ((a & ACE_HIGHBIT) > 0); - - return b; -} - -ACE_INLINE ACE_U_LongLong -ACE_U_LongLong::ull_shift (ACE_U_LongLong a, - ACE_UINT32 c_in, - ACE_UINT32 *c_out) const -{ - ACE_U_LongLong b; - - b.l_ () = (a.l_ () << 1) | c_in; - c_in = ((a.l_ () & ACE_HIGHBIT) > 0); - b.h_ () = (a.h_ () << 1) | c_in; - *c_out = (*c_out << 1) + ((a.h_ () & ACE_HIGHBIT) > 0); - - return b; -} - -ACE_INLINE ACE_U_LongLong -ACE_U_LongLong::ull_add (ACE_U_LongLong a, ACE_U_LongLong b, ACE_UINT32 *carry) const -{ - ACE_U_LongLong r (0, 0); - ACE_UINT32 c1, c2, c3, c4; - - c1 = a.l_ () % 2; - c2 = b.l_ () % 2; - c3 = 0; - - r.l_ () = a.l_ ()/2 + b.l_ ()/2 + (c1+c2)/2; - r.l_ () = ul_shift (r.l_ (), (c1+c2)%2, &c3); - - c1 = a.h_ () % 2; - c2 = b.h_ () % 2; - c4 = 0; - - r.h_ () = a.h_ ()/2 + b.h_ ()/2 + (c1+c2+c3)/2; - r.h_ () = ul_shift (r.h_ (), (c1+c2+c3)%2, &c4); - - *carry = c4; - - return r; -} - -ACE_INLINE ACE_U_LongLong -ACE_U_LongLong::ull_mult (ACE_U_LongLong a, ACE_UINT32 b, ACE_UINT32 *carry) const -{ - register ACE_UINT32 mask = ACE_HIGHBIT; - const ACE_U_LongLong zero (0, 0); - ACE_U_LongLong accum (0, 0); - ACE_UINT32 c; - - *carry = 0; - if (b > 0) - do - { - accum = ull_shift (accum, 0U, carry); - if (b & mask) - accum = ull_add (accum, a, &c); - else - accum = ull_add (accum, zero, &c); - *carry += c; - mask >>= 1; - } - while (mask > 0); - - return accum; -} - -ACE_INLINE ACE_U_LongLong -ACE_U_LongLong::operator* (const ACE_UINT32 n) const -{ - ACE_UINT32 carry; // will throw the carry away - - return ull_mult (*this, n, &carry); -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator*= (const ACE_UINT32 n) -{ - ACE_UINT32 carry; // will throw the carry away - - return *this = ull_mult (*this, n, &carry); -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator-= (const ACE_U_LongLong &n) -{ - h_ () -= n.h_ (); - if (l_ () < n.l_ ()) /* borrow */ --h_ (); - l_ () -= n.l_ (); - - return *this; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator-= (const ACE_UINT32 n) -{ - return operator-= (static_cast (n)); -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator++ () -{ - ++l_ (); - if (l_ () == 0) /* carry */ ++h_ (); - - return *this; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator-- () -{ - if (l_ () == 0) /* borrow */ --h_ (); - --l_ (); - - return *this; -} - -ACE_INLINE const ACE_U_LongLong -ACE_U_LongLong::operator++ (int) -{ - // Post-increment operator should always be implemented in terms of - // the pre-increment operator to enforce consistent semantics. - ACE_U_LongLong temp (*this); - ++*this; - return temp; -} - -ACE_INLINE const ACE_U_LongLong -ACE_U_LongLong::operator-- (int) -{ - // Post-decrement operator should always be implemented in terms of - // the pre-decrement operator to enforce consistent semantics. - ACE_U_LongLong temp (*this); - --*this; - return temp; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator|= (const ACE_U_LongLong n) -{ - l_ () |= n.l_ (); - h_ () |= n.h_ (); - - return *this; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator|= (const ACE_UINT32 n) -{ - return operator|= (static_cast (n)); -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator&= (const ACE_U_LongLong n) -{ - l_ () &= n.l_ (); - h_ () &= n.h_ (); - - return *this; -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator&= (const ACE_UINT32 n) -{ - return operator&= (static_cast (n)); -} - -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::operator/ (const ACE_UINT32 n) const -{ - // This takes advantage of the fact that the return type has only 32 - // bits. Replace 0x100000000 with 0xffffffff + 1 because the former - // has 33 bits. - // Quotient = (0x100000000u * hi_ + lo_) / n - // = ((0x100000000u - n + n) * hi_ + lo_) / n - // = ((0x100000000u - n) / n * hi_ + hi_ * n / n + lo_ / n - // = (0x100000000u - n) / n * hi_ + hi_ + lo_ / n - // = (0xffffffffu - n + 1) / n * hi_ + hi_ + lo_ / n - - return (0xffffffffu - n + 1) / n * h_ () + h_ () + l_ () / n; -} - -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::operator% (const ACE_UINT32 n) const -{ - // Because the argument is an ACE_UINT32, the result can never be - // bigger than 32 bits. Replace 0x100000000 with 0xffffffff + 1 - // because the former has 33 bits. - // Mod = (0x100000000u * hi_ + lo_) % n - // = (0x100000000u % n * hi_ + lo_ % n) % n - // = ((0x100000000u - n) % n * hi_ + lo_ % n) % n - // = ((0xffffffffu - n + 1) % n * hi_ + lo_ % n) % n - - return ((0xffffffff - n + 1) % n * h_ () + l_ () % n) % n; -} - -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::operator| (const ACE_INT32 n) const -{ - return l_ () | n; -} - -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::operator& (const ACE_INT32 n) const -{ - return l_ () & n; -} - -ACE_INLINE ACE_U_LongLong -ACE_U_LongLong::operator* (const ACE_INT32 n) const -{ - return operator* ((ACE_UINT32) n); -} - -ACE_INLINE ACE_U_LongLong & -ACE_U_LongLong::operator*= (const ACE_INT32 n) -{ - return operator*= ((ACE_UINT32) n); -} - -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::operator/ (const ACE_INT32 n) const -{ - return operator/ ((ACE_UINT32) n); -} - -#if ACE_SIZEOF_INT == 4 -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::operator/ (const u_long n) const -{ - return operator/ ((ACE_UINT32) n); -} - -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::operator/ (const long n) const -{ - return operator/ ((ACE_UINT32) n); -} - -#else /* ACE_SIZEOF_INT != 4 */ -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::operator/ (const u_int n) const -{ - return operator/ ((ACE_UINT32) n); -} - -ACE_INLINE ACE_UINT32 -ACE_U_LongLong::operator/ (const int n) const -{ - return operator/ ((ACE_UINT32) n); -} -#endif /* ACE_SIZEOF_INT != 4 */ - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_LACKS_LONGLONG_T || ACE_LACKS_UNSIGNEDLONGLONG_T */ diff --git a/ACE/ace/Bound_Ptr.h b/ACE/ace/Bound_Ptr.h deleted file mode 100644 index a310e3b8a56..00000000000 --- a/ACE/ace/Bound_Ptr.h +++ /dev/null @@ -1,388 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Bound_Ptr.h - * - * $Id$ - * - * @author Christopher Kohlhoff - * @author Boris Kolpackov - */ -//============================================================================= - -#ifndef ACE_BOUND_PTR_H -#define ACE_BOUND_PTR_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Auto_Ptr.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Bound_Ptr_Counter - * - * @brief An ACE_Bound_Ptr_Counter object encapsulates an - * object reference count. - * - * Do not use this class directly, use ACE_Strong_Bound_Ptr or - * ACE_Weak_Bound_Ptr instead. - */ -template -class ACE_Bound_Ptr_Counter -{ -public: - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - - ACE_Bound_Ptr_Counter (long init_obj_ref_count = 0); - ~ACE_Bound_Ptr_Counter (void); - - /// Create a ACE_Bound_Ptr_Counter and initialize the - /// reference count to indicate ownership by a strong pointer. - static ACE_Bound_Ptr_Counter *create_strong (void); - - /// Increase both the object and counter reference counts and return - /// the new object reference count. A return value of -1 indicates - /// that the object has already been destroyed. - static long attach_strong (ACE_Bound_Ptr_Counter *counter); - - /// Decreases both the object and counter reference counts and - /// deletes whichever has no more references. Returns the new object - /// reference count. - static long detach_strong (ACE_Bound_Ptr_Counter *counter); - - /// Create a ACE_Bound_Ptr_Counter and initialize the - /// reference count to indicate no ownership. - static ACE_Bound_Ptr_Counter *create_weak (void); - - /// Increase the counter reference count and return argument. - static void attach_weak (ACE_Bound_Ptr_Counter *counter); - - /// Decreases the counter reference count and deletes the counter if - /// it has no more references. - static void detach_weak (ACE_Bound_Ptr_Counter *counter); - - /// Determine whether the object has been deleted. - static bool object_was_deleted (ACE_Bound_Ptr_Counter *counter); - -private: - - /// Allocate a new ACE_Bound_Ptr_Counter instance, - /// returning NULL if it cannot be created. - static ACE_Bound_Ptr_Counter *internal_create (long init_obj_ref_count); - -private: - - /// Reference count of underlying object. Is set to -1 once the - /// object has been destroyed to indicate to all weak pointers that - /// it is no longer valid. - long obj_ref_count_; - - /// Reference count of this counter. - long self_ref_count_; - - /// Mutex variable to synchronize access to the reference counts. - ACE_LOCK lock_; -}; - -// Forward decl. -template class ACE_Weak_Bound_Ptr; - -/** - * @class ACE_Strong_Bound_Ptr - * - * @brief This class implements support for a reference counted - * pointer. - * - * Assigning or copying instances of an ACE_Strong_Bound_Ptr will - * automatically increment the reference count of the underlying object. - * When the last instance of an ACE_Strong_Bound_Ptr that references a - * particular object is destroyed or overwritten, it will invoke delete - * on its underlying pointer. - */ -template -class ACE_Strong_Bound_Ptr -{ -public: - /// Constructor that initializes an ACE_Strong_Bound_Ptr to point to the - /// object \ immediately. - explicit ACE_Strong_Bound_Ptr (X *p = 0); - - /// Constructor that initializes an ACE_Strong_Bound_Ptr by stealing - /// ownership of an object from an auto_ptr. - explicit ACE_Strong_Bound_Ptr (auto_ptr p); - - /// Copy constructor binds @c this and @a r to the same object. - ACE_Strong_Bound_Ptr (const ACE_Strong_Bound_Ptr &r); - - /// Constructor binds @c this and @a r to the same object. - ACE_Strong_Bound_Ptr (const ACE_Weak_Bound_Ptr &r); - - /// Copy constructor binds @c this and @a r to the same object if - /// Y* can be implicitly converted to X*. - template - ACE_Strong_Bound_Ptr (const ACE_Strong_Bound_Ptr &r) - : counter_ (r.counter_), - ptr_ (dynamic_cast(r.ptr_)) - { - // This ctor is temporarily defined here to increase our chances - // of being accepted by broken compilers. - // - COUNTER::attach_strong (this->counter_); - } - - /// Destructor. - ~ACE_Strong_Bound_Ptr (void); - - /// Assignment operator that binds @c this and @a r to the same object. - void operator = (const ACE_Strong_Bound_Ptr &r); - - /// Assignment operator that binds @c this and @a r to the same object. - void operator = (const ACE_Weak_Bound_Ptr &r); - - /// Assignment operator that binds @c this and @a r to the same object - /// if Y* can be implicitly converted to X*. - template - ACE_Weak_Bound_Ptr& - operator= (const ACE_Strong_Bound_Ptr &r) - { - // This operator is temporarily defined here to increase our chances - // of being accepted by broken compilers. - // - - // This will work if &r == this, by first increasing the ref count - - COUNTER *new_counter = r.counter_; - X* new_ptr = dynamic_cast (r.ptr_); - COUNTER::attach_strong (new_counter); - if (COUNTER::detach_strong (this->counter_) == 0) - delete this->ptr_; - this->counter_ = new_counter; - this->ptr_ = new_ptr; - - return *this; - } - - /// Equality operator that returns @c true if both - /// ACE_Strong_Bound_Ptr instances point to the same underlying - /// object. - /** - * @note It also returns @c true if both objects have just been - * instantiated and not used yet. - */ - bool operator == (const ACE_Strong_Bound_Ptr &r) const; - - /// Equality operator that returns true if the ACE_Strong_Bound_Ptr - /// and ACE_Weak_Bound_Ptr objects point to the same underlying - /// object. - /** - * @note It also returns @c true if both objects have just been - * instantiated and not used yet. - */ - bool operator == (const ACE_Weak_Bound_Ptr &r) const; - - /// Equality operator that returns @c true if the - /// ACE_Strong_Bound_Ptr and the raw pointer point to the same - /// underlying object. - bool operator == (X *p) const; - - /// Inequality operator, which is the opposite of equality. - bool operator != (const ACE_Strong_Bound_Ptr &r) const; - - /// Inequality operator, which is the opposite of equality. - bool operator != (const ACE_Weak_Bound_Ptr &r) const; - - /// Inequality operator, which is the opposite of equality. - bool operator != (X *p) const; - - /// Redirection operator - X *operator-> (void) const; - - /// Dereference operator - X &operator * (void) const; - - /// Get the pointer value. - X *get (void) const; - - /// Resets the ACE_Strong_Bound_Ptr to refer to a different - /// underlying object. - void reset (X *p = 0); - - /// Resets the ACE_Strong_Bound_Ptr to refer to a different - /// underlying object, ownership of which is stolen from the - /// auto_ptr. - void reset (auto_ptr p); - - /// Allows us to check for NULL on all ACE_Strong_Bound_Ptr - /// objects. - int null (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - typedef X X_t; // This indirection is for Borland C++. - - friend class ACE_Weak_Bound_Ptr; - - template - friend class ACE_Strong_Bound_Ptr; - - /// The ACE_Bound_Ptr_Counter type. - typedef ACE_Bound_Ptr_Counter COUNTER; - - /// The reference counter. - COUNTER *counter_; - - /// The underlying object. - X *ptr_; -}; - -/** - * @class ACE_Weak_Bound_Ptr - * - * @brief This class implements support for a weak pointer that complements - * ACE_Strong_Bound_Ptr. - * - * Unlike ACE_Strong_Bound_Ptr, assigning or copying instances of an - * ACE_Weak_Bound_Ptr will not automatically increment the reference - * count of the underlying object. What ACE_Weak_Bound_Ptr does is - * preserve the knowledge that the object is in fact reference - * counted, and thus provides an alternative to raw pointers where - * non-ownership associations must be maintained. When the last - * instance of an ACE_Strong_Bound_Ptr that references a particular - * object is destroyed or overwritten, the corresponding - * ACE_Weak_Bound_Ptr instances are set to NULL. - */ -template -class ACE_Weak_Bound_Ptr -{ -public: - /// Constructor that initializes an ACE_Weak_Bound_Ptr to point to - /// the object \ immediately. - explicit ACE_Weak_Bound_Ptr (X *p = 0); - - /// Copy constructor binds @c this and @a r to the same object. - ACE_Weak_Bound_Ptr (const ACE_Weak_Bound_Ptr &r); - - /// Constructor binds @c this and @a r to the same object. - ACE_Weak_Bound_Ptr (const ACE_Strong_Bound_Ptr &r); - - /// Destructor. - ~ACE_Weak_Bound_Ptr (void); - - /// Assignment operator that binds @c this and @a r to the same object. - void operator = (const ACE_Weak_Bound_Ptr &r); - - /// Assignment operator that binds @c this and @a r to the same object. - void operator = (const ACE_Strong_Bound_Ptr &r); - - /// Equality operator that returns @c true if both - /// ACE_Weak_Bound_Ptr objects point to the same underlying object. - /** - * @note It also returns @c true if both objects have just been - * instantiated and not used yet. - */ - bool operator == (const ACE_Weak_Bound_Ptr &r) const; - - /// Equality operator that returns @c true if the ACE_Weak_Bound_Ptr - /// and ACE_Strong_Bound_Ptr objects point to the same underlying - /// object. - /** - * @note It also returns @c true if both objects have just been - * instantiated and not used yet. - */ - bool operator == (const ACE_Strong_Bound_Ptr &r) const; - - /// Equality operator that returns @c true if the ACE_Weak_Bound_Ptr - /// and the raw pointer point to the same underlying object. - bool operator == (X *p) const; - - /// Inequality operator, which is the opposite of equality. - bool operator != (const ACE_Weak_Bound_Ptr &r) const; - - /// Inequality operator, which is the opposite of equality. - bool operator != (const ACE_Strong_Bound_Ptr &r) const; - - /// Inequality operator, which is the opposite of equality. - bool operator != (X *p) const; - - /// Redirection operator. - /** - * It returns a temporary strong pointer and makes use of the - * chaining properties of operator-> to ensure that the underlying - * object does not disappear while you are using it. If you are - * certain of the lifetimes of the object, and do not want to incur - * the locking overhead, then use the unsafe_get method instead. - */ - ACE_Strong_Bound_Ptr operator-> (void) const; - - /// Obtain a strong pointer corresponding to this weak pointer. This - /// function is useful to create a temporary strong pointer for - /// conversion to a reference. - ACE_Strong_Bound_Ptr strong (void) const; - - /// Get the pointer value. Warning: this does not affect the - /// reference count of the underlying object, so it may disappear on - /// you while you are using it if you are not careful. - X *unsafe_get (void) const; - - /// Resets the ACE_Weak_Bound_Ptr to refer to a different underlying - /// object. - void reset (X *p = 0); - - /// Increment the reference count on the underlying object. - /** - * Returns the new reference count on the object. This function may - * be used to integrate the bound pointers into an external - * reference counting mechanism such as those used by COM or CORBA - * servants. - */ - long add_ref (void); - - /// Decrement the reference count on the underlying object, which is deleted - /// if the count has reached zero. - /** - * Returns the new reference count on the object. This function may - * be used to integrate the bound pointers into an external - * reference counting mechanism such as those used by COM or CORBA - * servants. - */ - long remove_ref (void); - - /// Allows us to check for NULL on all ACE_Weak_Bound_Ptr objects. - int null (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - typedef X X_t; // This indirection is for Borland C++. - - friend class ACE_Strong_Bound_Ptr; - - /// The ACE_Bound_Ptr_Counter type. - typedef ACE_Bound_Ptr_Counter COUNTER; - - /// The reference counter. - COUNTER *counter_; - - /// The underlying object. - X *ptr_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#include "ace/Bound_Ptr.inl" - -#include /**/ "ace/post.h" - -#endif /* ACE_BOUND_PTR_H */ diff --git a/ACE/ace/Bound_Ptr.inl b/ACE/ace/Bound_Ptr.inl deleted file mode 100644 index 52c100e16b0..00000000000 --- a/ACE/ace/Bound_Ptr.inl +++ /dev/null @@ -1,494 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// Bound_Ptr.i - -#include "ace/Guard_T.h" -#if !defined (ACE_NEW_THROWS_EXCEPTIONS) -# include "ace/Log_Msg.h" -#endif /* ACE_NEW_THROWS_EXCEPTIONS */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template inline ACE_Bound_Ptr_Counter * -ACE_Bound_Ptr_Counter::internal_create (long init_obj_ref_count) -{ - ACE_Bound_Ptr_Counter *temp = 0; - ACE_NEW_RETURN (temp, - ACE_Bound_Ptr_Counter (init_obj_ref_count), - 0); - return temp; -} - -template inline ACE_Bound_Ptr_Counter * -ACE_Bound_Ptr_Counter::create_strong (void) -{ - // Set initial object reference count to 1. - ACE_Bound_Ptr_Counter *temp = internal_create (1); -#if defined (ACE_NEW_THROWS_EXCEPTIONS) - if (temp == 0) - ACE_throw_bad_alloc; -#else - ACE_ASSERT (temp != 0); -#endif /* ACE_NEW_THROWS_EXCEPTIONS */ - return temp; -} - - - -template inline long -ACE_Bound_Ptr_Counter::attach_strong (ACE_Bound_Ptr_Counter* counter) -{ - ACE_GUARD_RETURN (ACE_LOCK, guard, counter->lock_, -1); - - // Can't attach a strong pointer to an object that has already been deleted. - if (counter->obj_ref_count_ == -1) - return -1; - - long new_obj_ref_count = ++counter->obj_ref_count_; - ++counter->self_ref_count_; - - return new_obj_ref_count; -} - -template inline long -ACE_Bound_Ptr_Counter::detach_strong (ACE_Bound_Ptr_Counter* counter) -{ - ACE_Bound_Ptr_Counter *counter_del = 0; - long new_obj_ref_count; - - { - ACE_GUARD_RETURN (ACE_LOCK, guard, counter->lock_, -1); - - if ((new_obj_ref_count = --counter->obj_ref_count_) == 0) - // Change the object reference count to -1 to indicate that the - // object has been deleted, as opposed to a weak pointer that - // simply hasn't had any strong pointers created from it yet. - counter->obj_ref_count_ = -1; - - if (--counter->self_ref_count_ == 0) - // Since counter contains the lock held by the ACE_Guard, the - // guard needs to be released before freeing the memory holding - // the lock. So save the pointer to free, then release, then - // free. - counter_del = counter; - - } // Release the lock - - delete counter_del; - - return new_obj_ref_count; -} - -template inline ACE_Bound_Ptr_Counter * -ACE_Bound_Ptr_Counter::create_weak (void) -{ - // Set initial object reference count to 0. - - ACE_Bound_Ptr_Counter *temp = internal_create (0); -#if defined (ACE_NEW_THROWS_EXCEPTIONS) - if (temp == 0) - ACE_throw_bad_alloc; -#else - ACE_ASSERT (temp != 0); -#endif /* ACE_NEW_THROWS_EXCEPTIONS */ - return temp; -} - -template inline void -ACE_Bound_Ptr_Counter::attach_weak (ACE_Bound_Ptr_Counter* counter) -{ - ACE_GUARD (ACE_LOCK, guard, counter->lock_); - - ++counter->self_ref_count_; -} - -template inline void -ACE_Bound_Ptr_Counter::detach_weak (ACE_Bound_Ptr_Counter* counter) -{ - ACE_Bound_Ptr_Counter *counter_del = 0; - - { - ACE_GUARD (ACE_LOCK, guard, counter->lock_); - - if (--counter->self_ref_count_ == 0) - // Since counter contains the lock held by the ACE_Guard, the - // guard needs to be released before freeing the memory holding - // the lock. So save the pointer to free, then release, then - // free. - counter_del = counter; - - } // Release the lock - - delete counter_del; -} - -template inline bool -ACE_Bound_Ptr_Counter::object_was_deleted (ACE_Bound_Ptr_Counter *counter) -{ - ACE_GUARD_RETURN (ACE_LOCK, guard, counter->lock_, 0); - - return counter->obj_ref_count_ == -1; -} - -template inline -ACE_Bound_Ptr_Counter::ACE_Bound_Ptr_Counter (long init_obj_ref_count) - : obj_ref_count_ (init_obj_ref_count), - self_ref_count_ (1) -{ -} - -template inline -ACE_Bound_Ptr_Counter::~ACE_Bound_Ptr_Counter (void) -{ -} - -template inline -ACE_Strong_Bound_Ptr::ACE_Strong_Bound_Ptr (X *p) - : counter_ (COUNTER::create_strong ()), - ptr_ (p) -{ -} - -template inline -ACE_Strong_Bound_Ptr::ACE_Strong_Bound_Ptr (auto_ptr p) - : counter_ (COUNTER::create_strong ()), - ptr_ (p.release()) -{ -} - -template inline -ACE_Strong_Bound_Ptr::ACE_Strong_Bound_Ptr (const ACE_Strong_Bound_Ptr &r) - : counter_ (r.counter_), - ptr_ (r.ptr_) -{ - COUNTER::attach_strong (this->counter_); -} - -template inline -ACE_Strong_Bound_Ptr::ACE_Strong_Bound_Ptr (const ACE_Weak_Bound_Ptr &r) - : counter_ (r.counter_), - ptr_ (r.ptr_) -{ - // When creating a strong pointer from a weak one we can't assume that the - // underlying object still exists. Therefore we must check for a return value - // of -1, which indicates that the object has been destroyed. - if (COUNTER::attach_strong (this->counter_) == -1) - { - // Underlying object has already been deleted, so set this pointer to null. - this->counter_ = COUNTER::create_strong (); - this->ptr_ = 0; - } -} - -template inline -ACE_Strong_Bound_Ptr::~ACE_Strong_Bound_Ptr (void) -{ - if (COUNTER::detach_strong (this->counter_) == 0) - delete this->ptr_; -} - -template inline void -ACE_Strong_Bound_Ptr::operator = (const ACE_Strong_Bound_Ptr &rhs) -{ - // This will work if &r == this, by first increasing the ref count, but - // why go through all that? - if (&rhs == this) - return; - - COUNTER *new_counter = rhs.counter_; - X_t *new_ptr = rhs.ptr_; - COUNTER::attach_strong (new_counter); - if (COUNTER::detach_strong (this->counter_) == 0) - delete this->ptr_; - this->counter_ = new_counter; - this->ptr_ = new_ptr; -} - -template inline void -ACE_Strong_Bound_Ptr::operator = (const ACE_Weak_Bound_Ptr &rhs) -{ - // This will work if &r == this, by first increasing the ref count, but - // why go through all that? - if (&rhs == this) - return; - - COUNTER *new_counter = rhs.counter_; - X_t *new_ptr = rhs.ptr_; - - // When creating a strong pointer from a weak one we can't assume that the - // underlying object still exists. Therefore we must check for a return value - // of -1, which indicates that the object has been destroyed. - if (COUNTER::attach_strong (new_counter) == -1) - { - // Underlying object has already been deleted, so set this pointer to null. - new_counter = COUNTER::create_strong (); - new_ptr = 0; - } - - if (COUNTER::detach_strong (this->counter_) == 0) - delete this->ptr_; - this->counter_ = new_counter; - this->ptr_ = new_ptr; -} - -template inline bool -ACE_Strong_Bound_Ptr::operator== (const ACE_Strong_Bound_Ptr &r) const -{ - return this->ptr_ == r.ptr_; -} - -template inline bool -ACE_Strong_Bound_Ptr::operator== (const ACE_Weak_Bound_Ptr &r) const -{ - // Use the weak pointer's operator== since it will check for null. - return r == *this; -} - -template inline bool -ACE_Strong_Bound_Ptr::operator== (X *p) const -{ - return this->ptr_ == p; -} - -template inline bool -ACE_Strong_Bound_Ptr::operator!= (const ACE_Strong_Bound_Ptr &r) const -{ - return this->ptr_ != r.ptr_; -} - -template inline bool -ACE_Strong_Bound_Ptr::operator!= (const ACE_Weak_Bound_Ptr &r) const -{ - // Use the weak pointer's operator!= since it will check for null. - return r != *this; -} - -template inline bool -ACE_Strong_Bound_Ptr::operator!= (X *p) const -{ - return this->ptr_ != p; -} - -template inline X * -ACE_Strong_Bound_Ptr::operator-> (void) const -{ - return this->ptr_; -} - -template inline X & -ACE_Strong_Bound_Ptr::operator *() const -{ - return *this->ptr_; -} - -template inline X* -ACE_Strong_Bound_Ptr::get (void) const -{ - return this->ptr_; -} - -template inline int -ACE_Strong_Bound_Ptr::null (void) const -{ - return this->ptr_ == 0; -} - -template inline void -ACE_Strong_Bound_Ptr::reset (X *p) -{ - COUNTER *old_counter = this->counter_; - X_t *old_ptr = this->ptr_; - this->counter_ = COUNTER::create_strong (); - this->ptr_ = p; - if (COUNTER::detach_strong (old_counter) == 0) - delete old_ptr; -} - -template inline void -ACE_Strong_Bound_Ptr::reset (auto_ptr p) -{ - COUNTER *old_counter = this->counter_; - X_t *old_ptr = this->ptr_; - this->counter_ = COUNTER::create_strong (); - this->ptr_ = p.release (); - if (COUNTER::detach_strong (old_counter) == 0) - delete old_ptr; -} - -template inline -ACE_Weak_Bound_Ptr::ACE_Weak_Bound_Ptr (X *p) - : counter_ (COUNTER::create_weak ()), - ptr_ (p) -{ -} - -template inline -ACE_Weak_Bound_Ptr::ACE_Weak_Bound_Ptr (const ACE_Weak_Bound_Ptr &r) - : counter_ (r.counter_), - ptr_ (r.ptr_) -{ - COUNTER::attach_weak (this->counter_); -} - -template inline -ACE_Weak_Bound_Ptr::ACE_Weak_Bound_Ptr (const ACE_Strong_Bound_Ptr &r) - : counter_ (r.counter_), - ptr_ (r.ptr_) -{ - COUNTER::attach_weak (this->counter_); -} - -template inline -ACE_Weak_Bound_Ptr::~ACE_Weak_Bound_Ptr (void) -{ - COUNTER::detach_weak (this->counter_); -} - -template inline void -ACE_Weak_Bound_Ptr::operator = (const ACE_Weak_Bound_Ptr &rhs) -{ - // This will work if &rhs == this, by first increasing the ref count - COUNTER *new_counter = rhs.counter_; - COUNTER::attach_weak (new_counter); - COUNTER::detach_weak (this->counter_); - this->counter_ = new_counter; - this->ptr_ = rhs.ptr_; -} - -template inline void -ACE_Weak_Bound_Ptr::operator = (const ACE_Strong_Bound_Ptr &rhs) -{ - // This will work if &rhs == this, by first increasing the ref count - COUNTER *new_counter = rhs.counter_; - COUNTER::attach_weak (new_counter); - COUNTER::detach_weak (this->counter_); - this->counter_ = new_counter; - this->ptr_ = rhs.ptr_; -} - -template inline bool -ACE_Weak_Bound_Ptr::operator== (const ACE_Weak_Bound_Ptr &r) const -{ - // A weak pointer must behave as though it is automatically set to null - // if the underlying object has been deleted. - if (COUNTER::object_was_deleted (this->counter_)) - return r.ptr_ == 0; - - return this->ptr_ == r.ptr_; -} - -template inline bool -ACE_Weak_Bound_Ptr::operator== (const ACE_Strong_Bound_Ptr &r) const -{ - // A weak pointer must behave as though it is automatically set to null - // if the underlying object has been deleted. - if (COUNTER::object_was_deleted (this->counter_)) - return r.ptr_ == 0; - - return this->ptr_ == r.ptr_; -} - -template inline bool -ACE_Weak_Bound_Ptr::operator== (X *p) const -{ - // A weak pointer must behave as though it is automatically set to null - // if the underlying object has been deleted. - if (COUNTER::object_was_deleted (this->counter_)) - return p == 0; - - return this->ptr_ == p; -} - -template inline bool -ACE_Weak_Bound_Ptr::operator!= (const ACE_Weak_Bound_Ptr &r) const -{ - // A weak pointer must behave as though it is automatically set to null - // if the underlying object has been deleted. - if (COUNTER::object_was_deleted (this->counter_)) - return r.ptr_ != 0; - - return this->ptr_ != r.ptr_; -} - -template inline bool -ACE_Weak_Bound_Ptr::operator!= (const ACE_Strong_Bound_Ptr &r) const -{ - // A weak pointer must behave as though it is automatically set to null - // if the underlying object has been deleted. - if (COUNTER::object_was_deleted (this->counter_)) - return r.ptr_ != 0; - - return this->ptr_ != r.ptr_; -} - -template inline bool -ACE_Weak_Bound_Ptr::operator!= (X *p) const -{ - // A weak pointer must behave as though it is automatically set to null - // if the underlying object has been deleted. - if (COUNTER::object_was_deleted (this->counter_)) - return p != 0; - - return this->ptr_ != p; -} - -template inline ACE_Strong_Bound_Ptr -ACE_Weak_Bound_Ptr::operator-> (void) const -{ - return ACE_Strong_Bound_Ptr (*this); -} - -template inline ACE_Strong_Bound_Ptr -ACE_Weak_Bound_Ptr::strong (void) const -{ - return ACE_Strong_Bound_Ptr (*this); -} - -template inline X* -ACE_Weak_Bound_Ptr::unsafe_get (void) const -{ - // We do not check if the object has been deleted, since this operation - // is defined to be unsafe! - return this->ptr_; -} - -template inline int -ACE_Weak_Bound_Ptr::null (void) const -{ - // A weak pointer must behave as though it is automatically set to null - // if the underlying object has been deleted. - if (COUNTER::object_was_deleted (this->counter_)) - return 1; - - return this->ptr_ == 0; -} - -template inline void -ACE_Weak_Bound_Ptr::reset (X *p) -{ - COUNTER *old_counter = this->counter_; - this->counter_ = COUNTER::create_weak (); - this->ptr_ = p; - COUNTER::detach_weak (old_counter); -} - -template inline long -ACE_Weak_Bound_Ptr::add_ref () -{ - return COUNTER::attach_strong (counter_); -} - -template inline long -ACE_Weak_Bound_Ptr::remove_ref () -{ - long new_obj_ref_count = COUNTER::detach_strong (counter_); - if (new_obj_ref_count == 0) - { - delete this->ptr_; - this->ptr_ = 0; - } - return new_obj_ref_count; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/CDR_Base.cpp b/ACE/ace/CDR_Base.cpp deleted file mode 100644 index eb6f0bb0514..00000000000 --- a/ACE/ace/CDR_Base.cpp +++ /dev/null @@ -1,799 +0,0 @@ -#include "ace/CDR_Base.h" - -#if !defined (__ACE_INLINE__) -# include "ace/CDR_Base.inl" -#endif /* ! __ACE_INLINE__ */ - -#include "ace/Message_Block.h" -#include "ace/OS_Memory.h" -#include "ace/OS_NS_string.h" - -ACE_RCSID (ace, - CDR_Base, - "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -#if defined (NONNATIVE_LONGDOUBLE) -static const ACE_INT16 max_eleven_bit = 0x3ff; -static const ACE_INT16 max_fifteen_bit = 0x3fff; -#endif /* NONNATIVE_LONGDOUBLE */ - -// -// See comments in CDR_Base.inl about optimization cases for swap_XX_array. -// - -void -ACE_CDR::swap_2_array (char const * orig, char* target, size_t n) -{ - // ACE_ASSERT(n > 0); The caller checks that n > 0 - - // We pretend that AMD64/GNU G++ systems have a Pentium CPU to - // take advantage of the inline assembly implementation. - - // Later, we try to read in 32 or 64 bit chunks, - // so make sure we don't do that for unaligned addresses. -#if ACE_SIZEOF_LONG == 8 && \ - !((defined(__amd64__) || defined (__x86_64__)) && defined(__GNUG__)) - char const * const o8 = ACE_ptr_align_binary (orig, 8); - while (orig < o8 && n > 0) - { - ACE_CDR::swap_2 (orig, target); - orig += 2; - target += 2; - --n; - } -#else - char const * const o4 = ACE_ptr_align_binary (orig, 4); - // this is an _if_, not a _while_. The mistmatch can only be by 2. - if (orig != o4) - { - ACE_CDR::swap_2 (orig, target); - orig += 2; - target += 2; - --n; - } -#endif - if (n == 0) - return; - - // - // Loop unrolling. Here be dragons. - // - - // (n & (~3)) is the greatest multiple of 4 not bigger than n. - // In the while loop ahead, orig will move over the array by 8 byte - // increments (4 elements of 2 bytes). - // end marks our barrier for not falling outside. - char const * const end = orig + 2 * (n & (~3)); - - // See if we're aligned for writting in 64 or 32 bit chunks... -#if ACE_SIZEOF_LONG == 8 && \ - !((defined(__amd64__) || defined (__x86_64__)) && defined(__GNUG__)) - if (target == ACE_ptr_align_binary (target, 8)) -#else - if (target == ACE_ptr_align_binary (target, 4)) -#endif - { - while (orig < end) - { -#if defined (ACE_HAS_INTEL_ASSEMBLY) - unsigned int a = - * reinterpret_cast (orig); - unsigned int b = - * reinterpret_cast (orig + 4); - asm ( "bswap %1" : "=r" (a) : "0" (a) ); - asm ( "bswap %1" : "=r" (b) : "0" (b) ); - asm ( "rol $16, %1" : "=r" (a) : "0" (a) ); - asm ( "rol $16, %1" : "=r" (b) : "0" (b) ); - * reinterpret_cast (target) = a; - * reinterpret_cast (target + 4) = b; -#elif defined(ACE_HAS_PENTIUM) \ - && (defined(_MSC_VER) || defined(__BORLANDC__)) \ - && !defined(ACE_LACKS_INLINE_ASSEMBLY) - __asm mov ecx, orig; - __asm mov edx, target; - __asm mov eax, [ecx]; - __asm mov ebx, 4[ecx]; - __asm bswap eax; - __asm bswap ebx; - __asm rol eax, 16; - __asm rol ebx, 16; - __asm mov [edx], eax; - __asm mov 4[edx], ebx; -#elif ACE_SIZEOF_LONG == 8 - // 64 bit architecture. - register unsigned long a = - * reinterpret_cast (orig); - - register unsigned long a1 = (a & 0x00ff00ff00ff00ffUL) << 8; - register unsigned long a2 = (a & 0xff00ff00ff00ff00UL) >> 8; - - a = (a1 | a2); - - * reinterpret_cast (target) = a; -#else - register ACE_UINT32 a = - * reinterpret_cast (orig); - register ACE_UINT32 b = - * reinterpret_cast (orig + 4); - - register ACE_UINT32 a1 = (a & 0x00ff00ffU) << 8; - register ACE_UINT32 b1 = (b & 0x00ff00ffU) << 8; - register ACE_UINT32 a2 = (a & 0xff00ff00U) >> 8; - register ACE_UINT32 b2 = (b & 0xff00ff00U) >> 8; - - a = (a1 | a2); - b = (b1 | b2); - - * reinterpret_cast (target) = a; - * reinterpret_cast (target + 4) = b; -#endif - orig += 8; - target += 8; - } - } - else - { - // We're out of luck. We have to write in 2 byte chunks. - while (orig < end) - { -#if defined (ACE_HAS_INTEL_ASSEMBLY) - unsigned int a = - * reinterpret_cast (orig); - unsigned int b = - * reinterpret_cast (orig + 4); - asm ( "bswap %1" : "=r" (a) : "0" (a) ); - asm ( "bswap %1" : "=r" (b) : "0" (b) ); - // We're little endian. - * reinterpret_cast (target + 2) - = (unsigned short) (a & 0xffff); - * reinterpret_cast (target + 6) - = (unsigned short) (b & 0xffff); - asm ( "shrl $16, %1" : "=r" (a) : "0" (a) ); - asm ( "shrl $16, %1" : "=r" (b) : "0" (b) ); - * reinterpret_cast (target + 0) - = (unsigned short) (a & 0xffff); - * reinterpret_cast (target + 4) - = (unsigned short) (b & 0xffff); -#elif defined (ACE_HAS_PENTIUM) \ - && (defined (_MSC_VER) || defined (__BORLANDC__)) \ - && !defined (ACE_LACKS_INLINE_ASSEMBLY) - __asm mov ecx, orig; - __asm mov edx, target; - __asm mov eax, [ecx]; - __asm mov ebx, 4[ecx]; - __asm bswap eax; - __asm bswap ebx; - // We're little endian. - __asm mov 2[edx], ax; - __asm mov 6[edx], bx; - __asm shr eax, 16; - __asm shr ebx, 16; - __asm mov 0[edx], ax; - __asm mov 4[edx], bx; -#elif ACE_SIZEOF_LONG == 8 - // 64 bit architecture. - register unsigned long a = - * reinterpret_cast (orig); - - register unsigned long a1 = (a & 0x00ff00ff00ff00ffUL) << 8; - register unsigned long a2 = (a & 0xff00ff00ff00ff00UL) >> 8; - - a = (a1 | a2); - - ACE_UINT16 b1 = static_cast (a >> 48); - ACE_UINT16 b2 = static_cast ((a >> 32) & 0xffff); - ACE_UINT16 b3 = static_cast ((a >> 16) & 0xffff); - ACE_UINT16 b4 = static_cast (a & 0xffff); - -#if defined(ACE_LITTLE_ENDIAN) - * reinterpret_cast (target) = b4; - * reinterpret_cast (target + 2) = b3; - * reinterpret_cast (target + 4) = b2; - * reinterpret_cast (target + 6) = b1; -#else - * reinterpret_cast (target) = b1; - * reinterpret_cast (target + 2) = b2; - * reinterpret_cast (target + 4) = b3; - * reinterpret_cast (target + 6) = b4; -#endif -#else - register ACE_UINT32 a = - * reinterpret_cast (orig); - register ACE_UINT32 b = - * reinterpret_cast (orig + 4); - - register ACE_UINT32 a1 = (a & 0x00ff00ff) << 8; - register ACE_UINT32 b1 = (b & 0x00ff00ff) << 8; - register ACE_UINT32 a2 = (a & 0xff00ff00) >> 8; - register ACE_UINT32 b2 = (b & 0xff00ff00) >> 8; - - a = (a1 | a2); - b = (b1 | b2); - - ACE_UINT32 c1 = static_cast (a >> 16); - ACE_UINT32 c2 = static_cast (a & 0xffff); - ACE_UINT32 c3 = static_cast (b >> 16); - ACE_UINT32 c4 = static_cast (b & 0xffff); - -#if defined(ACE_LITTLE_ENDIAN) - * reinterpret_cast (target) = c2; - * reinterpret_cast (target + 2) = c1; - * reinterpret_cast (target + 4) = c4; - * reinterpret_cast (target + 6) = c3; -#else - * reinterpret_cast (target) = c1; - * reinterpret_cast (target + 2) = c2; - * reinterpret_cast (target + 4) = c3; - * reinterpret_cast (target + 6) = c4; -#endif -#endif - - orig += 8; - target += 8; - } - } - - // (n & 3) == (n % 4). - switch (n&3) { - case 3: - ACE_CDR::swap_2 (orig, target); - orig += 2; - target += 2; - case 2: - ACE_CDR::swap_2 (orig, target); - orig += 2; - target += 2; - case 1: - ACE_CDR::swap_2 (orig, target); - } -} - -void -ACE_CDR::swap_4_array (char const * orig, char* target, size_t n) -{ - // ACE_ASSERT (n > 0); The caller checks that n > 0 - -#if ACE_SIZEOF_LONG == 8 - // Later, we read from *orig in 64 bit chunks, - // so make sure we don't generate unaligned readings. - char const * const o8 = ACE_ptr_align_binary (orig, 8); - // The mismatch can only be by 4. - if (orig != o8) - { - ACE_CDR::swap_4 (orig, target); - orig += 4; - target += 4; - --n; - } -#endif /* ACE_SIZEOF_LONG == 8 */ - - if (n == 0) - return; - - // - // Loop unrolling. Here be dragons. - // - - // (n & (~3)) is the greatest multiple of 4 not bigger than n. - // In the while loop, orig will move over the array by 16 byte - // increments (4 elements of 4 bytes). - // ends marks our barrier for not falling outside. - char const * const end = orig + 4 * (n & (~3)); - -#if ACE_SIZEOF_LONG == 8 - // 64 bits architecture. - // See if we can write in 8 byte chunks. - if (target == ACE_ptr_align_binary (target, 8)) - { - while (orig < end) - { - register unsigned long a = - * reinterpret_cast (orig); - register unsigned long b = - * reinterpret_cast (orig + 8); - -#if defined(ACE_HAS_INTEL_ASSEMBLY) - asm ("bswapq %1" : "=r" (a) : "0" (a)); - asm ("bswapq %1" : "=r" (b) : "0" (b)); - asm ("rol $32, %1" : "=r" (a) : "0" (a)); - asm ("rol $32, %1" : "=r" (b) : "0" (b)); -#else - register unsigned long a84 = (a & 0x000000ff000000ffL) << 24; - register unsigned long b84 = (b & 0x000000ff000000ffL) << 24; - register unsigned long a73 = (a & 0x0000ff000000ff00L) << 8; - register unsigned long b73 = (b & 0x0000ff000000ff00L) << 8; - register unsigned long a62 = (a & 0x00ff000000ff0000L) >> 8; - register unsigned long b62 = (b & 0x00ff000000ff0000L) >> 8; - register unsigned long a51 = (a & 0xff000000ff000000L) >> 24; - register unsigned long b51 = (b & 0xff000000ff000000L) >> 24; - - a = (a84 | a73 | a62 | a51); - b = (b84 | b73 | b62 | b51); -#endif - - * reinterpret_cast (target) = a; - * reinterpret_cast (target + 8) = b; - - orig += 16; - target += 16; - } - } - else - { - // We are out of luck, we have to write in 4 byte chunks. - while (orig < end) - { - register unsigned long a = - * reinterpret_cast (orig); - register unsigned long b = - * reinterpret_cast (orig + 8); - -#if defined(ACE_HAS_INTEL_ASSEMBLY) - asm ("bswapq %1" : "=r" (a) : "0" (a)); - asm ("bswapq %1" : "=r" (b) : "0" (b)); - asm ("rol $32, %1" : "=r" (a) : "0" (a)); - asm ("rol $32, %1" : "=r" (b) : "0" (b)); -#else - register unsigned long a84 = (a & 0x000000ff000000ffL) << 24; - register unsigned long b84 = (b & 0x000000ff000000ffL) << 24; - register unsigned long a73 = (a & 0x0000ff000000ff00L) << 8; - register unsigned long b73 = (b & 0x0000ff000000ff00L) << 8; - register unsigned long a62 = (a & 0x00ff000000ff0000L) >> 8; - register unsigned long b62 = (b & 0x00ff000000ff0000L) >> 8; - register unsigned long a51 = (a & 0xff000000ff000000L) >> 24; - register unsigned long b51 = (b & 0xff000000ff000000L) >> 24; - - a = (a84 | a73 | a62 | a51); - b = (b84 | b73 | b62 | b51); -#endif - - ACE_UINT32 c1 = static_cast (a >> 32); - ACE_UINT32 c2 = static_cast (a & 0xffffffff); - ACE_UINT32 c3 = static_cast (b >> 32); - ACE_UINT32 c4 = static_cast (b & 0xffffffff); - -#if defined (ACE_LITTLE_ENDIAN) - * reinterpret_cast (target + 0) = c2; - * reinterpret_cast (target + 4) = c1; - * reinterpret_cast (target + 8) = c4; - * reinterpret_cast (target + 12) = c3; -#else - * reinterpret_cast (target + 0) = c1; - * reinterpret_cast (target + 4) = c2; - * reinterpret_cast (target + 8) = c3; - * reinterpret_cast (target + 12) = c4; -#endif - orig += 16; - target += 16; - } - } - -#else /* ACE_SIZEOF_LONG != 8 */ - - while (orig < end) - { -#if defined (ACE_HAS_PENTIUM) && defined (__GNUG__) - register unsigned int a = - *reinterpret_cast (orig); - register unsigned int b = - *reinterpret_cast (orig + 4); - register unsigned int c = - *reinterpret_cast (orig + 8); - register unsigned int d = - *reinterpret_cast (orig + 12); - - asm ("bswap %1" : "=r" (a) : "0" (a)); - asm ("bswap %1" : "=r" (b) : "0" (b)); - asm ("bswap %1" : "=r" (c) : "0" (c)); - asm ("bswap %1" : "=r" (d) : "0" (d)); - - *reinterpret_cast (target) = a; - *reinterpret_cast (target + 4) = b; - *reinterpret_cast (target + 8) = c; - *reinterpret_cast (target + 12) = d; -#elif defined (ACE_HAS_PENTIUM) \ - && (defined (_MSC_VER) || defined (__BORLANDC__)) \ - && !defined (ACE_LACKS_INLINE_ASSEMBLY) - __asm mov eax, orig - __asm mov esi, target - __asm mov edx, [eax] - __asm mov ecx, 4[eax] - __asm mov ebx, 8[eax] - __asm mov eax, 12[eax] - __asm bswap edx - __asm bswap ecx - __asm bswap ebx - __asm bswap eax - __asm mov [esi], edx - __asm mov 4[esi], ecx - __asm mov 8[esi], ebx - __asm mov 12[esi], eax -#else - register ACE_UINT32 a = - * reinterpret_cast (orig); - register ACE_UINT32 b = - * reinterpret_cast (orig + 4); - register ACE_UINT32 c = - * reinterpret_cast (orig + 8); - register ACE_UINT32 d = - * reinterpret_cast (orig + 12); - - // Expect the optimizer reordering this A LOT. - // We leave it this way for clarity. - a = (a << 24) | ((a & 0xff00) << 8) | ((a & 0xff0000) >> 8) | (a >> 24); - b = (b << 24) | ((b & 0xff00) << 8) | ((b & 0xff0000) >> 8) | (b >> 24); - c = (c << 24) | ((c & 0xff00) << 8) | ((c & 0xff0000) >> 8) | (c >> 24); - d = (d << 24) | ((d & 0xff00) << 8) | ((d & 0xff0000) >> 8) | (d >> 24); - - * reinterpret_cast (target) = a; - * reinterpret_cast (target + 4) = b; - * reinterpret_cast (target + 8) = c; - * reinterpret_cast (target + 12) = d; -#endif - - orig += 16; - target += 16; - } - -#endif /* ACE_SIZEOF_LONG == 8 */ - - // (n & 3) == (n % 4). - switch (n & 3) { - case 3: - ACE_CDR::swap_4 (orig, target); - orig += 4; - target += 4; - case 2: - ACE_CDR::swap_4 (orig, target); - orig += 4; - target += 4; - case 1: - ACE_CDR::swap_4 (orig, target); - } -} - -// -// We don't benefit from unrolling in swap_8_array and swap_16_array -// (swap_8 and swap_16 are big enough). -// -void -ACE_CDR::swap_8_array (char const * orig, char* target, size_t n) -{ - // ACE_ASSERT(n > 0); The caller checks that n > 0 - - char const * const end = orig + 8*n; - while (orig < end) - { - swap_8 (orig, target); - orig += 8; - target += 8; - } -} - -void -ACE_CDR::swap_16_array (char const * orig, char* target, size_t n) -{ - // ACE_ASSERT(n > 0); The caller checks that n > 0 - - char const * const end = orig + 16*n; - while (orig < end) - { - swap_16 (orig, target); - orig += 16; - target += 16; - } -} - -void -ACE_CDR::mb_align (ACE_Message_Block *mb) -{ -#if !defined (ACE_CDR_IGNORE_ALIGNMENT) - char * const start = ACE_ptr_align_binary (mb->base (), - ACE_CDR::MAX_ALIGNMENT); -#else - char * const start = mb->base (); -#endif /* ACE_CDR_IGNORE_ALIGNMENT */ - mb->rd_ptr (start); - mb->wr_ptr (start); -} - -int -ACE_CDR::grow (ACE_Message_Block *mb, size_t minsize) -{ - size_t newsize = - ACE_CDR::first_size (minsize + ACE_CDR::MAX_ALIGNMENT); - - if (newsize <= mb->size ()) - return 0; - - ACE_Data_Block *db = - mb->data_block ()->clone_nocopy (0, newsize); - - if (db == 0) - return -1; - - // Do the equivalent of ACE_CDR::mb_align() here to avoid having - // to allocate an ACE_Message_Block on the stack thereby avoiding - // the manipulation of the data blocks reference count - size_t mb_len = mb->length (); - char *start = ACE_ptr_align_binary (db->base (), - ACE_CDR::MAX_ALIGNMENT); - - ACE_OS::memcpy (start, mb->rd_ptr (), mb_len); - mb->data_block (db); - - // Setting the data block on the mb resets the read and write - // pointers back to the beginning. We must set the rd_ptr to the - // aligned start and adjust the write pointer to the end - mb->rd_ptr (start); - mb->wr_ptr (start + mb_len); - - // Remove the DONT_DELETE flags from mb - mb->clr_self_flags (ACE_Message_Block::DONT_DELETE); - - return 0; -} - -size_t -ACE_CDR::total_length (const ACE_Message_Block* begin, - const ACE_Message_Block* end) -{ - size_t l = 0; - // Compute the total size. - for (const ACE_Message_Block *i = begin; - i != end; - i = i->cont ()) - l += i->length (); - return l; -} - -void -ACE_CDR::consolidate (ACE_Message_Block *dst, - const ACE_Message_Block *src) -{ - if (src == 0) - return; - - size_t newsize = - ACE_CDR::first_size (ACE_CDR::total_length (src, 0) - + ACE_CDR::MAX_ALIGNMENT); - dst->size (newsize); - -#if !defined (ACE_CDR_IGNORE_ALIGNMENT) - // We must copy the contents of into the new buffer, but - // respecting the alignment. - ptrdiff_t srcalign = - ptrdiff_t(src->rd_ptr ()) % ACE_CDR::MAX_ALIGNMENT; - ptrdiff_t dstalign = - ptrdiff_t(dst->rd_ptr ()) % ACE_CDR::MAX_ALIGNMENT; - ptrdiff_t offset = srcalign - dstalign; - if (offset < 0) - offset += ACE_CDR::MAX_ALIGNMENT; - dst->rd_ptr (static_cast (offset)); - dst->wr_ptr (dst->rd_ptr ()); -#endif /* ACE_CDR_IGNORE_ALIGNMENT */ - - for (const ACE_Message_Block* i = src; - i != 0; - i = i->cont ()) - { - // If the destination and source are the same, do not - // attempt to copy the data. Just update the write pointer. - if (dst->wr_ptr () != i->rd_ptr ()) - dst->copy (i->rd_ptr (), i->length ()); - else - dst->wr_ptr (i->length ()); - } -} - -#if defined (NONNATIVE_LONGLONG) -bool -ACE_CDR::LongLong::operator== (const ACE_CDR::LongLong &rhs) const -{ - return this->h == rhs.h && this->l == rhs.l; -} - -bool -ACE_CDR::LongLong::operator!= (const ACE_CDR::LongLong &rhs) const -{ - return this->l != rhs.l || this->h != rhs.h; -} - -#endif /* NONNATIVE_LONGLONG */ - -#if defined (NONNATIVE_LONGDOUBLE) -ACE_CDR::LongDouble& -ACE_CDR::LongDouble::assign (const ACE_CDR::LongDouble::NativeImpl& rhs) -{ - ACE_OS::memset (this->ld, 0, sizeof (this->ld)); - - if (sizeof (rhs) == 8) - { -#if defined (ACE_LITTLE_ENDIAN) - static const size_t byte_zero = 1; - static const size_t byte_one = 0; - char rhs_ptr[16]; - ACE_CDR::swap_8 (reinterpret_cast (&rhs), rhs_ptr); -#else - static const size_t byte_zero = 0; - static const size_t byte_one = 1; - const char* rhs_ptr = reinterpret_cast (&rhs); -#endif - ACE_INT16 sign = static_cast ( - static_cast (rhs_ptr[0])) & 0x8000; - ACE_INT16 exponent = ((rhs_ptr[0] & 0x7f) << 4) | - ((rhs_ptr[1] >> 4) & 0xf); - const char* exp_ptr = reinterpret_cast (&exponent); - - // Infinity and NaN have an exponent of 0x7ff in 64-bit IEEE - if (exponent == 0x7ff) - { - exponent = 0x7fff; - } - else - { - exponent = (exponent - max_eleven_bit) + max_fifteen_bit; - } - exponent |= sign; - - // Store the sign bit and exponent - this->ld[0] = exp_ptr[byte_zero]; - this->ld[1] = exp_ptr[byte_one]; - - // Store the mantissa. In an 8 byte double, it is split by - // 4 bits (because of the 12 bits for sign and exponent), so - // we have to shift and or the rhs to get the right bytes. - size_t li = 2; - bool direction = true; - for (size_t ri = 1; ri < sizeof (rhs);) - { - if (direction) - { - this->ld[li] |= ((rhs_ptr[ri] << 4) & 0xf0); - direction = false; - ++ri; - } - else - { - this->ld[li] |= ((rhs_ptr[ri] >> 4) & 0xf); - direction = true; - ++li; - } - } -#if defined (ACE_LITTLE_ENDIAN) - ACE_OS::memcpy (rhs_ptr, this->ld, sizeof (this->ld)); - ACE_CDR::swap_16 (rhs_ptr, this->ld); -#endif - } - else - { - ACE_OS::memcpy(this->ld, - reinterpret_cast (&rhs), sizeof (rhs)); - } - return *this; -} - -ACE_CDR::LongDouble& -ACE_CDR::LongDouble::assign (const ACE_CDR::LongDouble& rhs) -{ - if (this != &rhs) - *this = rhs; - return *this; -} - -bool -ACE_CDR::LongDouble::operator== (const ACE_CDR::LongDouble &rhs) const -{ - return ACE_OS::memcmp (this->ld, rhs.ld, 16) == 0; -} - -bool -ACE_CDR::LongDouble::operator!= (const ACE_CDR::LongDouble &rhs) const -{ - return ACE_OS::memcmp (this->ld, rhs.ld, 16) != 0; -} - -ACE_CDR::LongDouble::operator ACE_CDR::LongDouble::NativeImpl () const -{ - ACE_CDR::LongDouble::NativeImpl ret = 0.0; - char* lhs_ptr = reinterpret_cast (&ret); - - if (sizeof (ret) == 8) - { -#if defined (ACE_LITTLE_ENDIAN) - static const size_t byte_zero = 1; - static const size_t byte_one = 0; - char copy[16]; - ACE_CDR::swap_16 (this->ld, copy); -#else - static const size_t byte_zero = 0; - static const size_t byte_one = 1; - const char* copy = this->ld; -#endif - ACE_INT16 exponent = 0; - char* exp_ptr = reinterpret_cast (&exponent); - exp_ptr[byte_zero] = copy[0]; - exp_ptr[byte_one] = copy[1]; - - ACE_INT16 sign = (exponent & 0x8000); - exponent &= 0x7fff; - - // Infinity and NaN have an exponent of 0x7fff in 128-bit IEEE - if (exponent == 0x7fff) - { - exponent = 0x7ff; - } - else - { - exponent = (exponent - max_fifteen_bit) + max_eleven_bit; - } - exponent = (exponent << 4) | sign; - - // Store the sign and exponent - lhs_ptr[0] = exp_ptr[byte_zero]; - lhs_ptr[1] = exp_ptr[byte_one]; - - // Store the mantissa. In an 8 byte double, it is split by - // 4 bits (because of the 12 bits for sign and exponent), so - // we have to shift and or the rhs to get the right bytes. - size_t li = 1; - bool direction = true; - for (size_t ri = 2; li < sizeof (ret);) { - if (direction) - { - lhs_ptr[li] |= ((copy[ri] >> 4) & 0xf); - direction = false; - ++li; - } - else - { - lhs_ptr[li] |= ((copy[ri] & 0xf) << 4); - direction = true; - ++ri; - } - } - -#if defined (ACE_LITTLE_ENDIAN) - ACE_CDR::swap_8 (lhs_ptr, lhs_ptr); -#endif - } - else - { - ACE_OS::memcpy(lhs_ptr, this->ld, sizeof (ret)); - } - - // This bit of code is unnecessary. However, this code is - // necessary to work around a bug in the gcc 4.1.1 optimizer. - ACE_CDR::LongDouble tmp; - tmp.assign (ret); - - return ret; -} -#endif /* NONNATIVE_LONGDOUBLE */ - -#if defined(_UNICOS) && !defined(_CRAYMPP) -// placeholders to get things compiling -ACE_CDR::Float::Float (void) -{ -} - -ACE_CDR::Float::Float (const float & /* init */) -{ -} - -ACE_CDR::Float & -ACE_CDR::Float::operator= (const float & /* rhs */) -{ - return *this; -} - -bool -ACE_CDR::Float::operator!= (const ACE_CDR::Float & /* rhs */) const -{ - return false; -} -#endif /* _UNICOS */ - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/CDR_Base.h b/ACE/ace/CDR_Base.h deleted file mode 100644 index afd278a5e59..00000000000 --- a/ACE/ace/CDR_Base.h +++ /dev/null @@ -1,353 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file CDR_Base.h - * - * $Id$ - * - * ACE Common Data Representation (CDR) basic types. - * - * The current implementation assumes that the host has 1-byte, - * 2-byte and 4-byte integral types, and that it has single - * precision and double precision IEEE floats. - * Those assumptions are pretty good these days, with Crays being - * the only known exception. - * - * - * @author TAO version by - * @author Aniruddha Gokhale - * @author Carlos O'Ryan - * @author ACE version by - * @author Jeff Parsons - * @author Istvan Buki - */ -//============================================================================= - - -#ifndef ACE_CDR_BASE_H -#define ACE_CDR_BASE_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Basic_Types.h" -#include "ace/Default_Constants.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -class ACE_Message_Block; - -/** - * @class ACE_CDR - * - * @brief Keep constants and some routines common to both Output and - * Input CDR streams. - */ -class ACE_Export ACE_CDR -{ -public: - // = Constants defined by the CDR protocol. - // By defining as many of these constants as possible as enums we - // ensure they get inlined and avoid pointless static memory - // allocations. - - enum - { - // Note that some of these get reused as part of the standard - // binary format: unsigned is the same size as its signed cousin, - // float is LONG_SIZE, and double is LONGLONG_SIZE. - - OCTET_SIZE = 1, - SHORT_SIZE = 2, - LONG_SIZE = 4, - LONGLONG_SIZE = 8, - LONGDOUBLE_SIZE = 16, - - OCTET_ALIGN = 1, - SHORT_ALIGN = 2, - LONG_ALIGN = 4, - LONGLONG_ALIGN = 8, - /// @note the CORBA LongDouble alignment requirements do not - /// match its size... - LONGDOUBLE_ALIGN = 8, - - /// Maximal CDR 1.1 alignment: "quad precision" FP (i.e. "CDR::Long - /// double", size as above). - MAX_ALIGNMENT = 8, - - /// The default buffer size. - /** - * @todo We want to add options to control this - * default value, so this constant should be read as the default - * default value ;-) - */ - DEFAULT_BUFSIZE = ACE_DEFAULT_CDR_BUFSIZE, - - /// The buffer size grows exponentially until it reaches this size; - /// afterwards it grows linearly using the next constant - EXP_GROWTH_MAX = ACE_DEFAULT_CDR_EXP_GROWTH_MAX, - - /// Once exponential growth is ruled out the buffer size increases - /// in chunks of this size, note that this constants have the same - /// value right now, but it does not need to be so. - LINEAR_GROWTH_CHUNK = ACE_DEFAULT_CDR_LINEAR_GROWTH_CHUNK - }; - - /** - * Do byte swapping for each basic IDL type size. There exist only - * routines to put byte, halfword (2 bytes), word (4 bytes), - * doubleword (8 bytes) and quadword (16 byte); because those are - * the IDL basic type sizes. - */ - static void swap_2 (char const *orig, char *target); - static void swap_4 (char const *orig, char *target); - static void swap_8 (char const *orig, char *target); - static void swap_16 (char const *orig, char *target); - static void swap_2_array (char const *orig, - char *target, - size_t length); - static void swap_4_array (char const *orig, - char *target, - size_t length); - static void swap_8_array (char const *orig, - char *target, - size_t length); - static void swap_16_array (char const *orig, - char *target, - size_t length); - - /// Align the message block to ACE_CDR::MAX_ALIGNMENT, - /// set by the CORBA spec at 8 bytes. - static void mb_align (ACE_Message_Block *mb); - - /** - * Compute the size of the smallest buffer that can contain at least - * @a minsize bytes. - * To understand how a "best fit" is computed look at the - * algorithm in the code. - * Basically the buffers grow exponentially, up to a certain point, - * then the buffer size grows linearly. - * The advantage of this algorithm is that is rapidly grows to a - * large value, but does not explode at the end. - */ - static size_t first_size (size_t minsize); - - /// Compute not the smallest, but the second smallest buffer that - /// will fir @a minsize bytes. - static size_t next_size (size_t minsize); - - /** - * Increase the capacity of mb to contain at least @a minsize bytes. - * If @a minsize is zero the size is increased by an amount at least - * large enough to contain any of the basic IDL types. - * @retval -1 Failure - * @retval 0 Success. - */ - static int grow (ACE_Message_Block *mb, size_t minsize); - - /// Copy a message block chain into a single message block, - /// preserving the alignment of the first message block of the - /// original stream, not the following message blocks. - static void consolidate (ACE_Message_Block *dst, - const ACE_Message_Block *src); - - static size_t total_length (const ACE_Message_Block *begin, - const ACE_Message_Block *end); - - /** - * @name Basic OMG IDL Types - * - * These types are for use in the CDR classes. The cleanest way to - * avoid complaints from all compilers is to define them all. - */ - //@{ - typedef bool Boolean; - typedef unsigned char Octet; - typedef char Char; - typedef ACE_WCHAR_T WChar; - typedef ACE_INT16 Short; - typedef ACE_UINT16 UShort; - typedef ACE_INT32 Long; - typedef ACE_UINT32 ULong; - typedef ACE_UINT64 ULongLong; - -# if (defined (_MSC_VER)) || (defined (__BORLANDC__)) - typedef __int64 LongLong; -# elif ACE_SIZEOF_LONG == 8 && !defined(_CRAYMPP) - typedef long LongLong; -# elif defined(__TANDEM) - typedef long long LongLong; -# elif ACE_SIZEOF_LONG_LONG == 8 && !defined (ACE_LACKS_LONGLONG_T) -# if defined (sun) && !defined (ACE_LACKS_U_LONGLONG_T) - // sun #defines u_longlong_t, maybe other platforms do also. - // Use it, at least with g++, so that its -pedantic doesn't - // complain about no ANSI C++ long long. - typedef longlong_t LongLong; -# else - // LynxOS 2.5.0 and Linux don't have u_longlong_t. - typedef long long LongLong; -# endif /* sun */ -# else /* no native 64 bit integer type */ -# define NONNATIVE_LONGLONG - struct ACE_Export LongLong - { -# if defined (ACE_BIG_ENDIAN) - ACE_CDR::Long h; - ACE_CDR::Long l; -# else - ACE_CDR::Long l; - ACE_CDR::Long h; -# endif /* ! ACE_BIG_ENDIAN */ - - /** - * @name Overloaded Relation Operators. - * - * The canonical comparison operators. - */ - //@{ - bool operator== (const LongLong &rhs) const; - bool operator!= (const LongLong &rhs) const; - //@} - }; -# endif /* no native 64 bit integer type */ - -# if defined (NONNATIVE_LONGLONG) -# define ACE_CDR_LONGLONG_INITIALIZER {0,0} -# else -# define ACE_CDR_LONGLONG_INITIALIZER 0 -# endif /* NONNATIVE_LONGLONG */ - -# if ACE_SIZEOF_FLOAT == 4 - typedef float Float; -# else /* ACE_SIZEOF_FLOAT != 4 */ - struct Float - { -# if ACE_SIZEOF_INT == 4 - // Use unsigned int to get word alignment. - unsigned int f; -# else /* ACE_SIZEOF_INT != 4 */ - // Applications will probably have trouble with this. - char f[4]; -# if defined(_UNICOS) && !defined(_CRAYMPP) - Float (void); - Float (const float &init); - Float & operator= (const float &rhs); - bool operator!= (const Float &rhs) const; -# endif /* _UNICOS */ -# endif /* ACE_SIZEOF_INT != 4 */ - }; -# endif /* ACE_SIZEOF_FLOAT != 4 */ - -# if ACE_SIZEOF_DOUBLE == 8 - typedef double Double; -# else /* ACE_SIZEOF_DOUBLE != 8 */ - struct Double - { -# if ACE_SIZEOF_LONG == 8 - // Use u long to get word alignment. - unsigned long f; -# else /* ACE_SIZEOF_INT != 8 */ - // Applications will probably have trouble with this. - char f[8]; -# endif /* ACE_SIZEOF_INT != 8 */ - }; -# endif /* ACE_SIZEOF_DOUBLE != 8 */ - - // 94-9-32 Appendix A defines a 128 bit floating point "long - // double" data type, with greatly extended precision and four - // more bits of exponent (compared to "double"). This is an IDL - // extension, not yet standard. - -# if ACE_SIZEOF_LONG_DOUBLE == 16 - typedef long double LongDouble; -# define ACE_CDR_LONG_DOUBLE_INITIALIZER 0 -# define ACE_CDR_LONG_DOUBLE_ASSIGNMENT(LHS, RHS) LHS = RHS -# else -# define NONNATIVE_LONGDOUBLE -# define ACE_CDR_LONG_DOUBLE_INITIALIZER {{0}} -# define ACE_CDR_LONG_DOUBLE_ASSIGNMENT(LHS, RHS) LHS.assign (RHS) - struct ACE_Export LongDouble - { - // VxWorks' compiler (gcc 2.96) gets confused by the operator long - // double, so we avoid using long double as the NativeImpl. - // Linux's x86 long double format (12 or 16 bytes) is incompatible - // with Windows, Solaris, AIX, MacOS X and HP-UX (and probably others) - // long double format (8 or 16 bytes). If you need 32-bit Linux to - // inter-operate with 64-bit Linux you will want to define this - // macro to 0 so that "long double" is used. Otherwise, do not define - // this macro. -# if defined (ACE_CDR_IMPLEMENT_WITH_NATIVE_DOUBLE) && \ - (ACE_CDR_IMPLEMENT_WITH_NATIVE_DOUBLE == 1) - typedef double NativeImpl; -# else - typedef long double NativeImpl; -# endif /* ACE_CDR_IMPLEMENT_WITH_NATIVE_DOUBLE==1 */ - - char ld[16]; - - LongDouble& assign (const NativeImpl& rhs); - LongDouble& assign (const LongDouble& rhs); - - bool operator== (const LongDouble &rhs) const; - bool operator!= (const LongDouble &rhs) const; - - LongDouble& operator*= (const NativeImpl rhs) { - return this->assign (static_cast (*this) * rhs); - } - LongDouble& operator/= (const NativeImpl rhs) { - return this->assign (static_cast (*this) / rhs); - } - LongDouble& operator+= (const NativeImpl rhs) { - return this->assign (static_cast (*this) + rhs); - } - LongDouble& operator-= (const NativeImpl rhs) { - return this->assign (static_cast (*this) - rhs); - } - LongDouble& operator++ () { - return this->assign (static_cast (*this) + 1); - } - LongDouble& operator-- () { - return this->assign (static_cast (*this) - 1); - } - LongDouble operator++ (int) { - LongDouble ldv = *this; - this->assign (static_cast (*this) + 1); - return ldv; - } - LongDouble operator-- (int) { - LongDouble ldv = *this; - this->assign (static_cast (*this) - 1); - return ldv; - } - - operator NativeImpl () const; - }; -# endif /* ACE_SIZEOF_LONG_DOUBLE != 16 */ - - //@} - -#if !defined (ACE_CDR_GIOP_MAJOR_VERSION) -# define ACE_CDR_GIOP_MAJOR_VERSION 1 -#endif /*ACE_CDR_GIOP_MAJOR_VERSION */ - -#if !defined (ACE_CDR_GIOP_MINOR_VERSION) -# define ACE_CDR_GIOP_MINOR_VERSION 2 -#endif /* ACE_CDR_GIOP_MINOR_VERSION */ -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -# include "ace/CDR_Base.inl" -#endif /* __ACE_INLINE__ */ - - -#include /**/ "ace/post.h" - -#endif /* ACE_CDR_BASE_H */ diff --git a/ACE/ace/CDR_Base.inl b/ACE/ace/CDR_Base.inl deleted file mode 100644 index b84470af87f..00000000000 --- a/ACE/ace/CDR_Base.inl +++ /dev/null @@ -1,255 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#if defined (ACE_HAS_INTRINSIC_BYTESWAP) -// Take advantage of MSVC++ byte swapping compiler intrinsics (found -// in ). -# pragma intrinsic (_byteswap_ushort, _byteswap_ulong, _byteswap_uint64) -#endif /* ACE_HAS_INTRINSIC_BYTESWAP */ - -#if defined (ACE_HAS_BSWAP_16) || defined (ACE_HAS_BSWAP_32) || defined (ACE_HAS_BSWAP_64) -# include "ace/os_include/os_byteswap.h" -#endif - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// -// The ACE_CDR::swap_X and ACE_CDR::swap_X_array routines are broken -// in 5 cases for optimization: -// -// * MSVC++ 7.1 or better -// => Compiler intrinsics -// -// * AMD64 CPU + gnu g++ -// => gcc amd64 inline assembly. -// -// * x86 Pentium CPU + gnu g++ -// (ACE_HAS_PENTIUM && __GNUG__) -// => gcc x86 inline assembly. -// -// * x86 Pentium CPU and (_MSC_VER) or BORLAND C++) -// (ACE_HAS_PENTIUM && ( _MSC_VER || __BORLANDC__ ) -// => MSC x86 inline assembly. -// -// * 64 bit architecture -// (ACE_SIZEOF_LONG == 8) -// => shift/masks using 64bit words. -// -// * default -// (none of the above) -// => shift/masks using 32bit words. -// -// -// Some things you could find useful to know if you intend to mess -// with this optimizations for swaps: -// -// * MSVC++ don't assume register values are conserved between -// statements. So you can clobber any register you want, -// whenever you want (well not *anyone* really, see manual). -// The MSVC++ optimizer will try to pick different registers -// for the C++ statements sorrounding your asm block, and if -// it's not possible will use the stack. -// -// * If you clobber registers with asm statements in gcc, you -// better do it in an asm-only function, or save/restore them -// before/after in the stack. If not, sorrounding C statements -// could end using the same registers and big-badda-bum (been -// there, done that...). The big-badda-bum could happen *even -// if you specify the clobbered register in your asm's*. -// Even better, use gcc asm syntax for detecting the register -// asigned to a certain variable so you don't have to clobber any -// register directly. -// - -ACE_INLINE void -ACE_CDR::swap_2 (const char *orig, char* target) -{ -#if defined (ACE_HAS_INTRINSIC_BYTESWAP) - // Take advantage of MSVC++ compiler intrinsic byte swapping - // function. - *reinterpret_cast (target) = - _byteswap_ushort (*reinterpret_cast (orig)); -#elif defined (ACE_HAS_BSWAP16) - *reinterpret_cast (target) = - bswap16 (*reinterpret_cast (orig)); -#elif defined (ACE_HAS_BSWAP_16) - *reinterpret_cast (target) = - bswap_16 (*reinterpret_cast (orig)); -#elif defined(ACE_HAS_INTEL_ASSEMBLY) - unsigned short a = - *reinterpret_cast (orig); - asm( "rolw $8, %0" : "=r" (a) : "0" (a) ); - *reinterpret_cast (target) = a; -#elif defined (ACE_HAS_PENTIUM) \ - && (defined(_MSC_VER) || defined(__BORLANDC__)) \ - && !defined(ACE_LACKS_INLINE_ASSEMBLY) - __asm mov ebx, orig; - __asm mov ecx, target; - __asm mov ax, [ebx]; - __asm rol ax, 8; - __asm mov [ecx], ax; -#else - register ACE_UINT16 usrc = * reinterpret_cast (orig); - register ACE_UINT16* udst = reinterpret_cast (target); - *udst = (usrc << 8) | (usrc >> 8); -#endif /* ACE_HAS_PENTIUM */ -} - -ACE_INLINE void -ACE_CDR::swap_4 (const char* orig, char* target) -{ -#if defined (ACE_HAS_INTRINSIC_BYTESWAP) - // Take advantage of MSVC++ compiler intrinsic byte swapping - // function. - *reinterpret_cast (target) = - _byteswap_ulong (*reinterpret_cast (orig)); -#elif defined (ACE_HAS_BSWAP32) - *reinterpret_cast (target) = - bswap32 (*reinterpret_cast (orig)); -#elif defined (ACE_HAS_BSWAP_32) - *reinterpret_cast (target) = - bswap_32 (*reinterpret_cast (orig)); -#elif defined(ACE_HAS_INTEL_ASSEMBLY) - // We have ACE_HAS_PENTIUM, so we know the sizeof's. - register unsigned int j = - *reinterpret_cast (orig); - asm ("bswap %1" : "=r" (j) : "0" (j)); - *reinterpret_cast (target) = j; -#elif defined(ACE_HAS_PENTIUM) \ - && (defined(_MSC_VER) || defined(__BORLANDC__)) \ - && !defined(ACE_LACKS_INLINE_ASSEMBLY) - __asm mov ebx, orig; - __asm mov ecx, target; - __asm mov eax, [ebx]; - __asm bswap eax; - __asm mov [ecx], eax; -#else - register ACE_UINT32 x = * reinterpret_cast (orig); - x = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24); - * reinterpret_cast (target) = x; -#endif /* ACE_HAS_INTRINSIC_BYTESWAP */ -} - -ACE_INLINE void -ACE_CDR::swap_8 (const char* orig, char* target) -{ -#if defined (ACE_HAS_INTRINSIC_BYTESWAP) - // Take advantage of MSVC++ compiler intrinsic byte swapping - // function. - *reinterpret_cast (target) = - _byteswap_uint64 (*reinterpret_cast (orig)); -#elif defined (ACE_HAS_BSWAP64) - *reinterpret_cast (target) = - bswap64 (*reinterpret_cast (orig)); -#elif defined (ACE_HAS_BSWAP_64) - *reinterpret_cast (target) = - bswap_64 (*reinterpret_cast (orig)); -#elif (defined (__amd64__) || defined (__x86_64__)) && defined(__GNUG__) - register unsigned long x = - * reinterpret_cast (orig); - asm ("bswapq %1" : "=r" (x) : "0" (x)); - *reinterpret_cast (target) = x; -#elif defined(ACE_HAS_PENTIUM) && defined(__GNUG__) - register unsigned int i = - *reinterpret_cast (orig); - register unsigned int j = - *reinterpret_cast (orig + 4); - asm ("bswap %1" : "=r" (i) : "0" (i)); - asm ("bswap %1" : "=r" (j) : "0" (j)); - *reinterpret_cast (target + 4) = i; - *reinterpret_cast (target) = j; -#elif defined(ACE_HAS_PENTIUM) \ - && (defined(_MSC_VER) || defined(__BORLANDC__)) \ - && !defined(ACE_LACKS_INLINE_ASSEMBLY) - __asm mov ecx, orig; - __asm mov edx, target; - __asm mov eax, [ecx]; - __asm mov ebx, 4[ecx]; - __asm bswap eax; - __asm bswap ebx; - __asm mov 4[edx], eax; - __asm mov [edx], ebx; -#elif ACE_SIZEOF_LONG == 8 - // 64 bit architecture. - register unsigned long x = - * reinterpret_cast (orig); - register unsigned long x84 = (x & 0x000000ff000000ffUL) << 24; - register unsigned long x73 = (x & 0x0000ff000000ff00UL) << 8; - register unsigned long x62 = (x & 0x00ff000000ff0000UL) >> 8; - register unsigned long x51 = (x & 0xff000000ff000000UL) >> 24; - x = (x84 | x73 | x62 | x51); - x = (x << 32) | (x >> 32); - *reinterpret_cast (target) = x; -#else - register ACE_UINT32 x = - * reinterpret_cast (orig); - register ACE_UINT32 y = - * reinterpret_cast (orig + 4); - x = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24); - y = (y << 24) | ((y & 0xff00) << 8) | ((y & 0xff0000) >> 8) | (y >> 24); - * reinterpret_cast (target) = y; - * reinterpret_cast (target + 4) = x; -#endif /* ACE_HAS_INTRINSIC_BYTESWAP */ -} - -ACE_INLINE void -ACE_CDR::swap_16 (const char* orig, char* target) -{ - swap_8 (orig + 8, target); - swap_8 (orig, target + 8); -} - -ACE_INLINE size_t -ACE_CDR::first_size (size_t minsize) -{ - if (minsize == 0) - return ACE_CDR::DEFAULT_BUFSIZE; - - size_t newsize = ACE_CDR::DEFAULT_BUFSIZE; - while (newsize < minsize) - { - if (newsize < ACE_CDR::EXP_GROWTH_MAX) - { - // We grow exponentially at the beginning, this is fast and - // reduces the number of allocations. - - // Quickly multiply by two using a bit shift. This is - // guaranteed to work since the variable is an unsigned - // integer. - newsize <<= 1; - } - else - { - // but continuing with exponential growth can result in over - // allocations and easily yield an allocation failure. - // So we grow linearly when the buffer is too big. - newsize += ACE_CDR::LINEAR_GROWTH_CHUNK; - } - } - return newsize; -} - -ACE_INLINE size_t -ACE_CDR::next_size (size_t minsize) -{ - size_t newsize = ACE_CDR::first_size (minsize); - - if (newsize == minsize) - { - // If necessary increment the size - if (newsize < ACE_CDR::EXP_GROWTH_MAX) - // Quickly multiply by two using a bit shift. This is - // guaranteed to work since the variable is an unsigned - // integer. - newsize <<= 1; - else - newsize += ACE_CDR::LINEAR_GROWTH_CHUNK; - } - - return newsize; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -// **************************************************************** diff --git a/ACE/ace/CDR_Size.cpp b/ACE/ace/CDR_Size.cpp deleted file mode 100644 index c737db786d9..00000000000 --- a/ACE/ace/CDR_Size.cpp +++ /dev/null @@ -1,244 +0,0 @@ -#include "ace/CDR_Size.h" -#include "ace/SString.h" -#include "ace/OS_Memory.h" - -#if !defined (__ACE_INLINE__) -# include "ace/CDR_Size.inl" -#endif /* ! __ACE_INLINE__ */ - -ACE_RCSID (ace, - CDR_Size, - "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_CDR::Boolean -ACE_SizeCDR::write_wchar (ACE_CDR::WChar x) -{ - // Note: translator framework is not supported. - // - if (ACE_OutputCDR::wchar_maxbytes () == 0) - { - errno = EACCES; - return (this->good_bit_ = false); - } - if (static_cast (major_version_) == 1 - && static_cast (minor_version_) == 2) - { - ACE_CDR::Octet len = - static_cast (ACE_OutputCDR::wchar_maxbytes ()); - if (this->write_1 (&len)) - { - if (ACE_OutputCDR::wchar_maxbytes () == sizeof(ACE_CDR::WChar)) - return - this->write_octet_array ( - reinterpret_cast (&x), - static_cast (len)); - else - if (ACE_OutputCDR::wchar_maxbytes () == 2) - { - ACE_CDR::Short sx = static_cast (x); - return - this->write_octet_array ( - reinterpret_cast (&sx), - static_cast (len)); - } - else - { - ACE_CDR::Octet ox = static_cast (x); - return - this->write_octet_array ( - reinterpret_cast (&ox), - static_cast (len)); - } - } - } - else if (static_cast (minor_version_) == 0) - { // wchar is not allowed with GIOP 1.0. - errno = EINVAL; - return (this->good_bit_ = false); - } - if (ACE_OutputCDR::wchar_maxbytes () == sizeof (ACE_CDR::WChar)) - { - const void *temp = &x; - return this->write_4 (reinterpret_cast (temp)); - } - else if (ACE_OutputCDR::wchar_maxbytes () == 2) - { - ACE_CDR::Short sx = static_cast (x); - return this->write_2 (reinterpret_cast (&sx)); - } - ACE_CDR::Octet ox = static_cast (x); - return this->write_1 (reinterpret_cast (&ox)); -} - -ACE_CDR::Boolean -ACE_SizeCDR::write_string (ACE_CDR::ULong len, - const ACE_CDR::Char *x) -{ - // Note: translator framework is not supported. - // - if (len != 0) - { - if (this->write_ulong (len + 1)) - return this->write_char_array (x, len + 1); - } - else - { - // Be nice to programmers: treat nulls as empty strings not - // errors. (OMG-IDL supports languages that don't use the C/C++ - // notion of null v. empty strings; nulls aren't part of the OMG-IDL - // string model.) - if (this->write_ulong (1)) - return this->write_char (0); - } - - return (this->good_bit_ = false); -} - -ACE_CDR::Boolean -ACE_SizeCDR::write_string (const ACE_CString &x) -{ - // @@ Leave this method in here, not the `.i' file so that we don't - // have to unnecessarily pull in the `ace/SString.h' header. - return this->write_string (static_cast (x.length ()), - x.c_str()); -} - -ACE_CDR::Boolean -ACE_SizeCDR::write_wstring (ACE_CDR::ULong len, - const ACE_CDR::WChar *x) -{ - // Note: translator framework is not supported. - // - if (ACE_OutputCDR::wchar_maxbytes () == 0) - { - errno = EACCES; - return (this->good_bit_ = false); - } - - if (static_cast (this->major_version_) == 1 - && static_cast (this->minor_version_) == 2) - { - if (x != 0) - { - //In GIOP 1.2 the length field contains the number of bytes - //the wstring occupies rather than number of wchars - //Taking sizeof might not be a good way! This is a temporary fix. - if (this->write_ulong (ACE_OutputCDR::wchar_maxbytes () * len)) - return this->write_wchar_array (x, len); - } - else - //In GIOP 1.2 zero length wstrings are legal - return this->write_ulong (0); - } - - else - if (x != 0) - { - if (this->write_ulong (len + 1)) - return this->write_wchar_array (x, len + 1); - } - else if (this->write_ulong (1)) - return this->write_wchar (0); - return (this->good_bit_ = false); -} - -ACE_CDR::Boolean -ACE_SizeCDR::write_1 (const ACE_CDR::Octet *) -{ - this->adjust (1); - return true; -} - -ACE_CDR::Boolean -ACE_SizeCDR::write_2 (const ACE_CDR::UShort *) -{ - this->adjust (ACE_CDR::SHORT_SIZE); - return true; -} - -ACE_CDR::Boolean -ACE_SizeCDR::write_4 (const ACE_CDR::ULong *) -{ - this->adjust (ACE_CDR::LONG_SIZE); - return true; -} - -ACE_CDR::Boolean -ACE_SizeCDR::write_8 (const ACE_CDR::ULongLong *) -{ - this->adjust (ACE_CDR::LONGLONG_SIZE); - return true; -} - -ACE_CDR::Boolean -ACE_SizeCDR::write_16 (const ACE_CDR::LongDouble *) -{ - this->adjust (ACE_CDR::LONGDOUBLE_SIZE, - ACE_CDR::LONGDOUBLE_ALIGN); - return true; -} - -ACE_CDR::Boolean -ACE_SizeCDR::write_wchar_array_i (const ACE_CDR::WChar *, - ACE_CDR::ULong length) -{ - if (length == 0) - return true; - - size_t const align = (ACE_OutputCDR::wchar_maxbytes () == 2) ? - ACE_CDR::SHORT_ALIGN : - ACE_CDR::OCTET_ALIGN; - - this->adjust (ACE_OutputCDR::wchar_maxbytes () * length, align); - return true; -} - - -ACE_CDR::Boolean -ACE_SizeCDR::write_array (const void *, - size_t size, - size_t align, - ACE_CDR::ULong length) -{ - if (length == 0) - return true; - - this->adjust (size * length, align); - return true; -} - -ACE_CDR::Boolean -ACE_SizeCDR::write_boolean_array (const ACE_CDR::Boolean*, - ACE_CDR::ULong length) -{ - this->adjust (length, 1); - return true; -} - -void -ACE_SizeCDR::adjust (size_t size) -{ - adjust (size, size); -} - -void -ACE_SizeCDR::adjust (size_t size, - size_t align) -{ -#if !defined (ACE_LACKS_CDR_ALIGNMENT) - const size_t offset = ACE_align_binary (size_, align) - size_; - size_ += offset; -#endif /* ACE_LACKS_CDR_ALIGNMENT */ - size_ += size; -} - -ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, const ACE_CString &x) -{ - ss.write_string (x); - return ss.good_bit (); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/CDR_Size.h b/ACE/ace/CDR_Size.h deleted file mode 100644 index a7ff689479b..00000000000 --- a/ACE/ace/CDR_Size.h +++ /dev/null @@ -1,241 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file CDR_Size.h - * - * $Id$ - * - * - * ACE Common Data Representation (CDR) size-calculating stream. - * - * - * The current implementation assumes that the host has 1-byte, - * 2-byte and 4-byte integral types, and that it has single - * precision and double precision IEEE floats. - * Those assumptions are pretty good these days, with Crays beign - * the only known exception. - * - * - * @author Boris Kolpackov - * - */ -//============================================================================= - -#ifndef ACE_CDR_SIZE_H -#define ACE_CDR_SIZE_H - -#include /**/ "ace/pre.h" - -#include "ace/CDR_Base.h" -#include "ace/CDR_Stream.h" // for ACE_OutputCDR::from_* - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/SStringfwd.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_SizeCDR - * - * @brief A CDR stream for calculating size of the representation. - * - */ -class ACE_Export ACE_SizeCDR -{ -public: - /// Default constructor. - ACE_SizeCDR (ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION, - ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION); - - /// Returns @c false if an error has ocurred. - bool good_bit (void) const; - - - /// Reset current size. - void reset (void); - - - /// Return current size. - size_t total_length (void) const; - - - // Return 0 on failure and 1 on success. - //@{ @name Size-calculating pseudo-write operations - ACE_CDR::Boolean write_boolean (ACE_CDR::Boolean x); - ACE_CDR::Boolean write_char (ACE_CDR::Char x); - ACE_CDR::Boolean write_wchar (ACE_CDR::WChar x); - ACE_CDR::Boolean write_octet (ACE_CDR::Octet x); - ACE_CDR::Boolean write_short (ACE_CDR::Short x); - ACE_CDR::Boolean write_ushort (ACE_CDR::UShort x); - ACE_CDR::Boolean write_long (ACE_CDR::Long x); - ACE_CDR::Boolean write_ulong (ACE_CDR::ULong x); - ACE_CDR::Boolean write_longlong (const ACE_CDR::LongLong &x); - ACE_CDR::Boolean write_ulonglong (const ACE_CDR::ULongLong &x); - ACE_CDR::Boolean write_float (ACE_CDR::Float x); - ACE_CDR::Boolean write_double (const ACE_CDR::Double &x); - ACE_CDR::Boolean write_longdouble (const ACE_CDR::LongDouble &x); - - /// For string we offer methods that accept a precomputed length. - ACE_CDR::Boolean write_string (const ACE_CDR::Char *x); - ACE_CDR::Boolean write_string (ACE_CDR::ULong len, - const ACE_CDR::Char *x); - ACE_CDR::Boolean write_string (const ACE_CString &x); - ACE_CDR::Boolean write_wstring (const ACE_CDR::WChar *x); - ACE_CDR::Boolean write_wstring (ACE_CDR::ULong length, - const ACE_CDR::WChar *x); - //@} - - /// @note the portion written starts at and ends - /// at . - /// The length is *NOT* stored into the CDR stream. - //@{ @name Array write operations - ACE_CDR::Boolean write_boolean_array (const ACE_CDR::Boolean *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_char_array (const ACE_CDR::Char *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_wchar_array (const ACE_CDR::WChar* x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_octet_array (const ACE_CDR::Octet* x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_short_array (const ACE_CDR::Short *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_ushort_array (const ACE_CDR::UShort *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_long_array (const ACE_CDR::Long *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_ulong_array (const ACE_CDR::ULong *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_longlong_array (const ACE_CDR::LongLong* x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_ulonglong_array (const ACE_CDR::ULongLong *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_float_array (const ACE_CDR::Float *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_double_array (const ACE_CDR::Double *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_longdouble_array (const ACE_CDR::LongDouble* x, - ACE_CDR::ULong length); - - /// - /// Adjust to @a size and count octets. - void adjust (size_t size); - - /// As above, but now the size and alignment requirements may be - /// different. - void adjust (size_t size, - size_t align); - -private: - /// disallow copying... - ACE_SizeCDR (const ACE_SizeCDR& rhs); - ACE_SizeCDR& operator= (const ACE_SizeCDR& rhs); - - ACE_CDR::Boolean write_1 (const ACE_CDR::Octet *x); - ACE_CDR::Boolean write_2 (const ACE_CDR::UShort *x); - ACE_CDR::Boolean write_4 (const ACE_CDR::ULong *x); - ACE_CDR::Boolean write_8 (const ACE_CDR::ULongLong *x); - ACE_CDR::Boolean write_16 (const ACE_CDR::LongDouble *x); - - /** - * write an array of @a length elements, each of @a size bytes and the - * start aligned at a multiple of . The elements are assumed - * to be packed with the right alignment restrictions. It is mostly - * designed for buffers of the basic types. - * - * This operation uses ; as explained above it is expected - * that using assignment is faster that for one element, - * but for several elements should be more efficient, it - * could be interesting to find the break even point and optimize - * for that case, but that would be too platform dependent. - */ - ACE_CDR::Boolean write_array (const void *x, - size_t size, - size_t align, - ACE_CDR::ULong length); - - - ACE_CDR::Boolean write_wchar_array_i (const ACE_CDR::WChar* x, - ACE_CDR::ULong length); - -private: - /// Set to false when an error ocurrs. - bool good_bit_; - - /// Current size. - size_t size_; - -protected: - /// GIOP version information - ACE_CDR::Octet major_version_; - ACE_CDR::Octet minor_version_; -}; - -// @@ This operator should not be inlined since they force SString.h -// to be included in this header. -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - const ACE_CString &x); - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -# include "ace/CDR_Size.inl" -#else /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Not used by CORBA or TAO -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - ACE_CDR::Char x); - -// CDR size-calculating output operators for primitive types - -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - ACE_CDR::Short x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - ACE_CDR::UShort x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - ACE_CDR::Long x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - ACE_CDR::ULong x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - ACE_CDR::LongLong x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - ACE_CDR::ULongLong x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR& ss, - ACE_CDR::LongDouble x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - ACE_CDR::Float x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - ACE_CDR::Double x); - -// CDR size-calculating output operator from helper classes - -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - ACE_OutputCDR::from_boolean x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - ACE_OutputCDR::from_char x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - ACE_OutputCDR::from_wchar x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - ACE_OutputCDR::from_octet x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - ACE_OutputCDR::from_string x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - ACE_OutputCDR::from_wstring x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - const ACE_CDR::Char* x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - const ACE_CDR::WChar* x); - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* __ACE_INLINE__ */ - - -#include /**/ "ace/post.h" - -#endif /* ACE_CDR_SIZE_H */ diff --git a/ACE/ace/CDR_Size.inl b/ACE/ace/CDR_Size.inl deleted file mode 100644 index 2527af22989..00000000000 --- a/ACE/ace/CDR_Size.inl +++ /dev/null @@ -1,424 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/OS_NS_string.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_SizeCDR::ACE_SizeCDR (ACE_CDR::Octet major_version, - ACE_CDR::Octet minor_version) - : good_bit_ (true), - size_ (0), - major_version_ (major_version), - minor_version_ (minor_version) -{ -} - -ACE_INLINE bool -ACE_SizeCDR::good_bit (void) const -{ - return this->good_bit_; -} - -ACE_INLINE void -ACE_SizeCDR::reset (void) -{ - this->size_ = 0; -} - -ACE_INLINE size_t -ACE_SizeCDR::total_length (void) const -{ - return this->size_; -} - - -// Encode the CDR stream. - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_octet (ACE_CDR::Octet x) -{ - return this->write_1 (reinterpret_cast (&x)); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_boolean (ACE_CDR::Boolean x) -{ - return (ACE_CDR::Boolean) this->write_octet (x ? (ACE_CDR::Octet) 1 : (ACE_CDR::Octet) 0); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_char (ACE_CDR::Char x) -{ - // Note: translator framework is not supported. - // - return this->write_1 (reinterpret_cast (&x)); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_short (ACE_CDR::Short x) -{ - return this->write_2 (reinterpret_cast (&x)); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_ushort (ACE_CDR::UShort x) -{ - return this->write_2 (reinterpret_cast (&x)); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_long (ACE_CDR::Long x) -{ - return this->write_4 (reinterpret_cast (&x)); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_ulong (ACE_CDR::ULong x) -{ - return this->write_4 (reinterpret_cast (&x)); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_longlong (const ACE_CDR::LongLong &x) -{ - return this->write_8 (reinterpret_cast (&x)); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_ulonglong (const ACE_CDR::ULongLong &x) -{ - const void *temp = &x; - return this->write_8 (reinterpret_cast (temp)); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_float (ACE_CDR::Float x) -{ - const void *temp = &x; - return this->write_4 (reinterpret_cast (temp)); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_double (const ACE_CDR::Double &x) -{ - const void *temp = &x; - return this->write_8 (reinterpret_cast (temp)); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_longdouble (const ACE_CDR::LongDouble &x) -{ - const void *temp = &x; - return this->write_16 (reinterpret_cast (temp)); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_string (const ACE_CDR::Char *x) -{ - if (x != 0) - { - const ACE_CDR::ULong len = - static_cast (ACE_OS::strlen (x)); - return this->write_string (len, x); - } - return this->write_string (0, 0); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_wstring (const ACE_CDR::WChar *x) -{ - if (x != 0) - { - ACE_CDR::ULong len = - static_cast (ACE_OS::strlen (x)); - return this->write_wstring (len, x); - } - return this->write_wstring (0, 0); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_char_array (const ACE_CDR::Char *x, - ACE_CDR::ULong length) -{ - // Note: translator framework is not supported. - // - return this->write_array (x, - ACE_CDR::OCTET_SIZE, - ACE_CDR::OCTET_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_wchar_array (const ACE_CDR::WChar* x, - ACE_CDR::ULong length) -{ - // Note: translator framework is not supported. - // - if (ACE_OutputCDR::wchar_maxbytes () == 0) - { - errno = EACCES; - return (ACE_CDR::Boolean) (this->good_bit_ = false); - } - if (ACE_OutputCDR::wchar_maxbytes () == sizeof (ACE_CDR::WChar)) - return this->write_array (x, - sizeof (ACE_CDR::WChar), - sizeof (ACE_CDR::WChar) == 2 - ? ACE_CDR::SHORT_ALIGN - : ACE_CDR::LONG_ALIGN, - length); - return this->write_wchar_array_i (x,length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_octet_array (const ACE_CDR::Octet* x, - ACE_CDR::ULong length) -{ - return this->write_array (x, - ACE_CDR::OCTET_SIZE, - ACE_CDR::OCTET_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_short_array (const ACE_CDR::Short *x, - ACE_CDR::ULong length) -{ - return this->write_array (x, - ACE_CDR::SHORT_SIZE, - ACE_CDR::SHORT_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_ushort_array (const ACE_CDR::UShort *x, - ACE_CDR::ULong length) -{ - return this->write_array (x, - ACE_CDR::SHORT_SIZE, - ACE_CDR::SHORT_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_long_array (const ACE_CDR::Long *x, - ACE_CDR::ULong length) -{ - return this->write_array (x, - ACE_CDR::LONG_SIZE, - ACE_CDR::LONG_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_ulong_array (const ACE_CDR::ULong *x, - ACE_CDR::ULong length) -{ - return this->write_array (x, - ACE_CDR::LONG_SIZE, - ACE_CDR::LONG_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_longlong_array (const ACE_CDR::LongLong *x, - ACE_CDR::ULong length) -{ - return this->write_array (x, - ACE_CDR::LONGLONG_SIZE, - ACE_CDR::LONGLONG_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_ulonglong_array (const ACE_CDR::ULongLong *x, - ACE_CDR::ULong length) -{ - return this->write_array (x, - ACE_CDR::LONGLONG_SIZE, - ACE_CDR::LONGLONG_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_float_array (const ACE_CDR::Float *x, - ACE_CDR::ULong length) -{ - return this->write_array (x, - ACE_CDR::LONG_SIZE, - ACE_CDR::LONG_ALIGN, - length); -} - - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_double_array (const ACE_CDR::Double *x, - ACE_CDR::ULong length) -{ - return this->write_array (x, - ACE_CDR::LONGLONG_SIZE, - ACE_CDR::LONGLONG_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_longdouble_array (const ACE_CDR::LongDouble* x, - ACE_CDR::ULong length) -{ - return this->write_array (x, - ACE_CDR::LONGDOUBLE_SIZE, - ACE_CDR::LONGDOUBLE_ALIGN, - length); -} - - -// **************************************************************** - - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, ACE_CDR::Char x) -{ - ss.write_char (x); - return (ACE_CDR::Boolean) ss.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, ACE_CDR::Short x) -{ - ss.write_short (x); - return (ACE_CDR::Boolean) ss.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, ACE_CDR::UShort x) -{ - ss.write_ushort (x); - return (ACE_CDR::Boolean) ss.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, ACE_CDR::Long x) -{ - ss.write_long (x); - return (ACE_CDR::Boolean) ss.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, ACE_CDR::ULong x) -{ - ss.write_ulong (x); - return (ACE_CDR::Boolean) ss.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, ACE_CDR::LongLong x) -{ - ss.write_longlong (x); - return (ACE_CDR::Boolean) ss.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, ACE_CDR::ULongLong x) -{ - ss.write_ulonglong (x); - return (ACE_CDR::Boolean) ss.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, ACE_CDR::LongDouble x) -{ - ss.write_longdouble (x); - return (ACE_CDR::Boolean) ss.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, ACE_CDR::Float x) -{ - ss.write_float (x); - return (ACE_CDR::Boolean) ss.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, ACE_CDR::Double x) -{ - ss.write_double (x); - return (ACE_CDR::Boolean) ss.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, const ACE_CDR::Char *x) -{ - ss.write_string (x); - return (ACE_CDR::Boolean) ss.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, const ACE_CDR::WChar *x) -{ - ss.write_wstring (x); - return (ACE_CDR::Boolean) ss.good_bit (); -} - -// The following use the helper classes -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_boolean x) -{ - ss.write_boolean (x.val_); - return (ACE_CDR::Boolean) ss.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_char x) -{ - ss.write_char (x.val_); - return (ACE_CDR::Boolean) ss.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_wchar x) -{ - ss.write_wchar (x.val_); - return (ACE_CDR::Boolean) ss.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_octet x) -{ - ss.write_octet (x.val_); - return (ACE_CDR::Boolean) ss.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_string x) -{ - ACE_CDR::ULong len = 0; - - if (x.val_ != 0) - { - len = static_cast (ACE_OS::strlen (x.val_)); - } - - ss.write_string (len, x.val_); - return - (ACE_CDR::Boolean) (ss.good_bit () && (!x.bound_ || len <= x.bound_)); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_wstring x) -{ - ACE_CDR::ULong len = 0; - - if (x.val_ != 0) - { - len = static_cast (ACE_OS::strlen (x.val_)); - } - - ss.write_wstring (len, x.val_); - return - (ACE_CDR::Boolean) (ss.good_bit () && (!x.bound_ || len <= x.bound_)); -} - - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/CDR_Stream.cpp b/ACE/ace/CDR_Stream.cpp deleted file mode 100644 index 00af2b70940..00000000000 --- a/ACE/ace/CDR_Stream.cpp +++ /dev/null @@ -1,1892 +0,0 @@ -#include "ace/CDR_Stream.h" -#include "ace/SString.h" -#include "ace/Auto_Ptr.h" - -#if !defined (__ACE_INLINE__) -# include "ace/CDR_Stream.inl" -#endif /* ! __ACE_INLINE__ */ - -ACE_RCSID (ace, - CDR_Stream, - "$Id$") - -// **************************************************************** - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -size_t ACE_OutputCDR::wchar_maxbytes_ = sizeof (ACE_CDR::WChar); - -ACE_OutputCDR::ACE_OutputCDR (size_t size, - int byte_order, - ACE_Allocator *buffer_allocator, - ACE_Allocator *data_block_allocator, - ACE_Allocator *message_block_allocator, - size_t memcpy_tradeoff, - ACE_CDR::Octet major_version, - ACE_CDR::Octet minor_version) - : start_ ((size ? size : (size_t) ACE_CDR::DEFAULT_BUFSIZE) + ACE_CDR::MAX_ALIGNMENT, - ACE_Message_Block::MB_DATA, - 0, - 0, - buffer_allocator, - 0, - 0, - ACE_Time_Value::zero, - ACE_Time_Value::max_time, - data_block_allocator, - message_block_allocator), -#if !defined (ACE_LACKS_CDR_ALIGNMENT) - current_alignment_ (0), -#endif /* ACE_LACKS_CDR_ALIGNMENT */ - current_is_writable_ (true), - do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), - good_bit_ (true), - memcpy_tradeoff_ (memcpy_tradeoff), - major_version_ (major_version), - minor_version_ (minor_version), - char_translator_ (0), - wchar_translator_ (0) - -{ - ACE_CDR::mb_align (&this->start_); - this->current_ = &this->start_; -} - -ACE_OutputCDR::ACE_OutputCDR (char *data, - size_t size, - int byte_order, - ACE_Allocator *buffer_allocator, - ACE_Allocator *data_block_allocator, - ACE_Allocator *message_block_allocator, - size_t memcpy_tradeoff, - ACE_CDR::Octet major_version, - ACE_CDR::Octet minor_version) - : start_ (size, - ACE_Message_Block::MB_DATA, - 0, - data, - buffer_allocator, - 0, - 0, - ACE_Time_Value::zero, - ACE_Time_Value::max_time, - data_block_allocator, - message_block_allocator), -#if !defined (ACE_LACKS_CDR_ALIGNMENT) - current_alignment_ (0), -#endif /* ACE_LACKS_CDR_ALIGNMENT */ - current_is_writable_ (true), - do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), - good_bit_ (true), - memcpy_tradeoff_ (memcpy_tradeoff), - major_version_ (major_version), - minor_version_ (minor_version), - char_translator_ (0), - wchar_translator_ (0) -{ - // We cannot trust the buffer to be properly aligned - ACE_CDR::mb_align (&this->start_); - this->current_ = &this->start_; -} - -ACE_OutputCDR::ACE_OutputCDR (ACE_Data_Block *data_block, - int byte_order, - ACE_Allocator *message_block_allocator, - size_t memcpy_tradeoff, - ACE_CDR::Octet major_version, - ACE_CDR::Octet minor_version) - : start_ (data_block, - ACE_Message_Block::DONT_DELETE, - message_block_allocator), -#if !defined (ACE_LACKS_CDR_ALIGNMENT) - current_alignment_ (0), -#endif /* ACE_LACKS_CDR_ALIGNMENT */ - current_is_writable_ (true), - do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), - good_bit_ (true), - memcpy_tradeoff_ (memcpy_tradeoff), - major_version_ (major_version), - minor_version_ (minor_version), - char_translator_ (0), - wchar_translator_ (0) -{ - // We cannot trust the buffer to be properly aligned - ACE_CDR::mb_align (&this->start_); - this->current_ = &this->start_; -} - -ACE_OutputCDR::ACE_OutputCDR (ACE_Message_Block *data, - int byte_order, - size_t memcpy_tradeoff, - ACE_CDR::Octet major_version, - ACE_CDR::Octet minor_version) - : start_ (data->data_block ()->duplicate ()), -#if !defined (ACE_LACKS_CDR_ALIGNMENT) - current_alignment_ (0), -#endif /* ACE_LACKS_CDR_ALIGNMENT */ - current_is_writable_ (true), - do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), - good_bit_ (true), - memcpy_tradeoff_ (memcpy_tradeoff), - major_version_ (major_version), - minor_version_ (minor_version), - char_translator_ (0), - wchar_translator_ (0) -{ - // We cannot trust the buffer to be properly aligned - ACE_CDR::mb_align (&this->start_); - this->current_ = &this->start_; -} - -/*static*/ void -ACE_OutputCDR::wchar_maxbytes (size_t maxbytes) -{ - ACE_OutputCDR::wchar_maxbytes_ = maxbytes; -} - -/*static*/ size_t -ACE_OutputCDR::wchar_maxbytes () -{ - return ACE_OutputCDR::wchar_maxbytes_; -} - -int -ACE_OutputCDR::grow_and_adjust (size_t size, - size_t align, - char*& buf) -{ - if (!this->current_is_writable_ - || this->current_->cont () == 0 - || this->current_->cont ()->size () < size + ACE_CDR::MAX_ALIGNMENT) - { - // Calculate the new buffer's length; if growing for encode, we - // don't grow in "small" chunks because of the cost. - size_t cursize = this->current_->size (); - if (this->current_->cont () != 0) - cursize = this->current_->cont ()->size (); - size_t minsize = size; - -#if !defined (ACE_LACKS_CDR_ALIGNMENT) - minsize += ACE_CDR::MAX_ALIGNMENT; -#endif /* ACE_LACKS_CDR_ALIGNMENT */ - - // Make sure that there is enough room for bytes, but - // also make it bigger than whatever our current size is. - if (minsize < cursize) - minsize = cursize; - - size_t const newsize = ACE_CDR::next_size (minsize); - - this->good_bit_ = false; - ACE_Message_Block* tmp = 0; - ACE_NEW_RETURN (tmp, - ACE_Message_Block (newsize, - ACE_Message_Block::MB_DATA, - 0, - 0, - this->current_->data_block ()->allocator_strategy (), - 0, - 0, - ACE_Time_Value::zero, - ACE_Time_Value::max_time, - this->current_->data_block ()->data_block_allocator ()), - -1); - - // Message block initialization may fail while the construction - // succeds. Since as a matter of policy, ACE may throw no - // exceptions, we have to do a separate check like this. - if (tmp != 0 && tmp->size () < newsize) - { - delete tmp; - errno = ENOMEM; - return -1; - } - - this->good_bit_ = true; - -#if !defined (ACE_LACKS_CDR_ALIGNMENT) - // The new block must start with the same alignment as the - // previous block finished. - ptrdiff_t const tmpalign = - reinterpret_cast (tmp->rd_ptr ()) % ACE_CDR::MAX_ALIGNMENT; - ptrdiff_t const curalign = - static_cast (this->current_alignment_) % ACE_CDR::MAX_ALIGNMENT; - ptrdiff_t offset = curalign - tmpalign; - if (offset < 0) - offset += ACE_CDR::MAX_ALIGNMENT; - tmp->rd_ptr (static_cast (offset)); - tmp->wr_ptr (tmp->rd_ptr ()); -#endif /* ACE_LACKS_CDR_ALIGNMENT */ - - // grow the chain and set the current block. - tmp->cont (this->current_->cont ()); - this->current_->cont (tmp); - } - this->current_ = this->current_->cont (); - this->current_is_writable_ = true; - - return this->adjust (size, align, buf); -} - -ACE_CDR::Boolean -ACE_OutputCDR::write_wchar (ACE_CDR::WChar x) -{ - if (this->wchar_translator_ != 0) - return (this->good_bit_ = this->wchar_translator_->write_wchar (*this, x)); - if (ACE_OutputCDR::wchar_maxbytes_ == 0) - { - errno = EACCES; - return (this->good_bit_ = false); - } - if (static_cast (major_version_) == 1 - && static_cast (minor_version_) == 2) - { - ACE_CDR::Octet len = - static_cast (ACE_OutputCDR::wchar_maxbytes_); - if (this->write_1 (&len)) - { - if (ACE_OutputCDR::wchar_maxbytes_ == sizeof(ACE_CDR::WChar)) - return - this->write_octet_array ( - reinterpret_cast (&x), - static_cast (len)); - else - if (ACE_OutputCDR::wchar_maxbytes_ == 2) - { - ACE_CDR::Short sx = static_cast (x); - return - this->write_octet_array ( - reinterpret_cast (&sx), - static_cast (len)); - } - else - { - ACE_CDR::Octet ox = static_cast (x); - return - this->write_octet_array ( - reinterpret_cast (&ox), - static_cast (len)); - } - } - } - else if (static_cast (minor_version_) == 0) - { // wchar is not allowed with GIOP 1.0. - errno = EINVAL; - return (this->good_bit_ = false); - } - if (ACE_OutputCDR::wchar_maxbytes_ == sizeof (ACE_CDR::WChar)) - { - void const * const temp = &x; - return - this->write_4 (reinterpret_cast (temp)); - } - else if (ACE_OutputCDR::wchar_maxbytes_ == 2) - { - ACE_CDR::Short sx = static_cast (x); - return this->write_2 (reinterpret_cast (&sx)); - } - ACE_CDR::Octet ox = static_cast (x); - return this->write_1 (reinterpret_cast (&ox)); -} - -ACE_CDR::Boolean -ACE_OutputCDR::write_string (ACE_CDR::ULong len, - const ACE_CDR::Char *x) -{ - // @@ This is a slight violation of "Optimize for the common case", - // i.e. normally the translator will be 0, but OTOH the code is - // smaller and should be better for the cache ;-) ;-) - if (this->char_translator_ != 0) - return this->char_translator_->write_string (*this, len, x); - - if (len != 0) - { - if (this->write_ulong (len + 1)) - return this->write_char_array (x, len + 1); - } - else - { - // Be nice to programmers: treat nulls as empty strings not - // errors. (OMG-IDL supports languages that don't use the C/C++ - // notion of null v. empty strings; nulls aren't part of the OMG-IDL - // string model.) - if (this->write_ulong (1)) - return this->write_char (0); - } - - return (this->good_bit_ = false); -} - -ACE_CDR::Boolean -ACE_OutputCDR::write_string (const ACE_CString &x) -{ - // @@ Leave this method in here, not the `.i' file so that we don't - // have to unnecessarily pull in the `ace/SString.h' header. - return this->write_string (static_cast (x.length ()), - x.c_str()); -} - -ACE_CDR::Boolean -ACE_OutputCDR::write_wstring (ACE_CDR::ULong len, - const ACE_CDR::WChar *x) -{ - // @@ This is a slight violation of "Optimize for the common case", - // i.e. normally the translator will be 0, but OTOH the code is - // smaller and should be better for the cache ;-) ;-) - // What do we do for GIOP 1.2??? - if (this->wchar_translator_ != 0) - return this->wchar_translator_->write_wstring (*this, len, x); - if (ACE_OutputCDR::wchar_maxbytes_ == 0) - { - errno = EACCES; - return (this->good_bit_ = false); - } - - if (static_cast (this->major_version_) == 1 - && static_cast (this->minor_version_) == 2) - { - if (x != 0) - { - //In GIOP 1.2 the length field contains the number of bytes - //the wstring occupies rather than number of wchars - //Taking sizeof might not be a good way! This is a temporary fix. - if (this->write_ulong (ACE_OutputCDR::wchar_maxbytes_ * len)) - return this->write_wchar_array (x, len); - } - else - //In GIOP 1.2 zero length wstrings are legal - return this->write_ulong (0); - } - - else - if (x != 0) - { - if (this->write_ulong (len + 1)) - return this->write_wchar_array (x, len + 1); - } - else if (this->write_ulong (1)) - return this->write_wchar (0); - return (this->good_bit_ = false); -} - -ACE_CDR::Boolean -ACE_OutputCDR::write_octet_array_mb (const ACE_Message_Block* mb) -{ - // If the buffer is small and it fits in the current message - // block it is be cheaper just to copy the buffer. - for (const ACE_Message_Block* i = mb; - i != 0; - i = i->cont ()) - { - size_t const length = i->length (); - - // If the mb does not own its data we are forced to make a copy. - if (ACE_BIT_ENABLED (i->flags (), - ACE_Message_Block::DONT_DELETE)) - { - if (! this->write_array (i->rd_ptr (), - ACE_CDR::OCTET_SIZE, - ACE_CDR::OCTET_ALIGN, - static_cast (length))) - return (this->good_bit_ = false); - continue; - } - - if (length < this->memcpy_tradeoff_ - && this->current_->wr_ptr () + length < this->current_->end ()) - { - if (! this->write_array (i->rd_ptr (), - ACE_CDR::OCTET_SIZE, - ACE_CDR::OCTET_ALIGN, - static_cast (length))) - return (this->good_bit_ = false); - continue; - } - - ACE_Message_Block* cont = 0; - this->good_bit_ = false; - ACE_NEW_RETURN (cont, - ACE_Message_Block (i->data_block ()->duplicate ()), - false); - this->good_bit_ = true; - - if (this->current_->cont () != 0) - ACE_Message_Block::release (this->current_->cont ()); - cont->rd_ptr (i->rd_ptr ()); - cont->wr_ptr (i->wr_ptr ()); - - this->current_->cont (cont); - this->current_ = cont; - this->current_is_writable_ = false; -#if !defined (ACE_LACKS_CDR_ALIGNMENT) - this->current_alignment_ = - (this->current_alignment_ + cont->length ()) % ACE_CDR::MAX_ALIGNMENT; -#endif /* ACE_LACKS_CDR_ALIGNMENT */ - } - - return true; -} - -ACE_CDR::Boolean -ACE_OutputCDR::write_1 (const ACE_CDR::Octet *x) -{ - char *buf = 0; - if (this->adjust (1, buf) == 0) - { - *reinterpret_cast (buf) = *x; - return true; - } - - return false; -} - -ACE_CDR::Boolean -ACE_OutputCDR::write_2 (const ACE_CDR::UShort *x) -{ - char *buf = 0; - if (this->adjust (ACE_CDR::SHORT_SIZE, buf) == 0) - { -#if !defined (ACE_ENABLE_SWAP_ON_WRITE) - *reinterpret_cast (buf) = *x; - return true; -#else - if (!this->do_byte_swap_) - { - *reinterpret_cast (buf) = *x; - return true; - } - else - { - ACE_CDR::swap_2 (reinterpret_cast (x), buf); - return true; - } -#endif /* ACE_ENABLE_SWAP_ON_WRITE */ - } - - return false; -} - -ACE_CDR::Boolean -ACE_OutputCDR::write_4 (const ACE_CDR::ULong *x) -{ - char *buf = 0; - if (this->adjust (ACE_CDR::LONG_SIZE, buf) == 0) - { -#if !defined (ACE_ENABLE_SWAP_ON_WRITE) - *reinterpret_cast (buf) = *x; - return true; -#else - if (!this->do_byte_swap_) - { - *reinterpret_cast (buf) = *x; - return true; - } - else - { - ACE_CDR::swap_4 (reinterpret_cast (x), buf); - return true; - } -#endif /* ACE_ENABLE_SWAP_ON_WRITE */ - } - - return false; -} - -ACE_CDR::Boolean -ACE_OutputCDR::write_8 (const ACE_CDR::ULongLong *x) -{ - char *buf = 0; - - if (this->adjust (ACE_CDR::LONGLONG_SIZE, buf) == 0) - { -#if defined (__arm__) - // Convert to Intel format (12345678 => 56781234) - const char *orig = reinterpret_cast (x); - char *target = buf; - register ACE_UINT32 x = - *reinterpret_cast (orig); - register ACE_UINT32 y = - *reinterpret_cast (orig + 4); - *reinterpret_cast (target) = y; - *reinterpret_cast (target + 4) = x; - return true; -#else -# if !defined (ACE_ENABLE_SWAP_ON_WRITE) - *reinterpret_cast (buf) = *x; - return true; -# else - if (!this->do_byte_swap_) - { - *reinterpret_cast (buf) = *x; - return true; - } - else - { - ACE_CDR::swap_8 (reinterpret_cast (x), buf); - return true; - } -# endif /* ACE_ENABLE_SWAP_ON_WRITE */ -#endif /* !__arm__ */ - } - - return false; -} - -ACE_CDR::Boolean -ACE_OutputCDR::write_16 (const ACE_CDR::LongDouble *x) -{ - char* buf = 0; - if (this->adjust (ACE_CDR::LONGDOUBLE_SIZE, - ACE_CDR::LONGDOUBLE_ALIGN, - buf) == 0) - { -#if !defined (ACE_ENABLE_SWAP_ON_WRITE) - *reinterpret_cast (buf) = *x; - return 1; -#else - if (!this->do_byte_swap_) - { - *reinterpret_cast (buf) = *x; - return true; - } - else - { - ACE_CDR::swap_16 (reinterpret_cast (x), buf); - return true; - } -#endif /* ACE_ENABLE_SWAP_ON_WRITE */ - } - - return false; -} - -ACE_CDR::Boolean -ACE_OutputCDR::write_wchar_array_i (const ACE_CDR::WChar *x, - ACE_CDR::ULong length) -{ - if (length == 0) - return true; - char* buf = 0; - size_t const align = (ACE_OutputCDR::wchar_maxbytes_ == 2) ? - ACE_CDR::SHORT_ALIGN : - ACE_CDR::OCTET_ALIGN; - - if (this->adjust (ACE_OutputCDR::wchar_maxbytes_ * length, align, buf) == 0) - { - if (ACE_OutputCDR::wchar_maxbytes_ == 2) - { - ACE_CDR::UShort *sb = reinterpret_cast (buf); - for (size_t i = 0; i < length; ++i) -#if !defined (ACE_ENABLE_SWAP_ON_WRITE) - sb[i] = static_cast (x[i]); -#else - if (!this->do_byte_swap_) - sb[i] = static_cast (x[i]); - else - { - ACE_CDR::UShort sx = static_cast (x[i]); - ACE_CDR::swap_2 (reinterpret_cast (&sx), &buf[i * 2]); - } -#endif /* ACE_ENABLE_SWAP_ON_WRITE */ - } - else - { - for (size_t i = 0; i < length; ++i) - buf[i] = static_cast (x[i]); - } - return this->good_bit_; - } - return false; -} - - -ACE_CDR::Boolean -ACE_OutputCDR::write_array (const void *x, - size_t size, - size_t align, - ACE_CDR::ULong length) -{ - if (length == 0) - return true; - char *buf = 0; - if (this->adjust (size * length, align, buf) == 0) - { -#if !defined (ACE_ENABLE_SWAP_ON_WRITE) - ACE_OS::memcpy (buf, x, size*length); - return true; -#else - if (!this->do_byte_swap_ || size == 1) - { - ACE_OS::memcpy (buf, x, size*length); - return true; - } - else - { - const char *source = reinterpret_cast (x); - switch (size) - { - case 2: - ACE_CDR::swap_2_array (source, buf, length); - return true; - case 4: - ACE_CDR::swap_4_array (source, buf, length); - return true; - case 8: - ACE_CDR::swap_8_array (source, buf, length); - return true; - case 16: - ACE_CDR::swap_16_array (source, buf, length); - return true; - default: - // TODO: print something? - this->good_bit_ = false; - return false; - } - } -#endif /* ACE_ENABLE_SWAP_ON_WRITE */ - } - this->good_bit_ = false; - return false; -} - - -ACE_CDR::Boolean -ACE_OutputCDR::write_boolean_array (const ACE_CDR::Boolean* x, - ACE_CDR::ULong length) -{ - // It is hard to optimize this, the spec requires that on the wire - // booleans be represented as a byte with value 0 or 1, but in - // memory it is possible (though very unlikely) that a boolean has - // a non-zero value (different from 1). - // We resort to a simple loop. - ACE_CDR::Boolean const * const end = x + length; - - for (ACE_CDR::Boolean const * i = x; - i != end && this->good_bit (); - ++i) - (void) this->write_boolean (*i); - - return this->good_bit (); -} - - -char * -ACE_OutputCDR::write_long_placeholder (void) -{ - this->align_write_ptr (ACE_CDR::LONG_SIZE); - char *pos = this->current_->wr_ptr (); - this->write_long (0); - return pos; -} - - -char * -ACE_OutputCDR::write_short_placeholder (void) -{ - this->align_write_ptr (ACE_CDR::SHORT_SIZE); - char *pos = this->current_->wr_ptr(); - this->write_short (0); - return pos; -} - - -ACE_CDR::Boolean -ACE_OutputCDR::replace (ACE_CDR::Long x, char* loc) -{ - if (this->find (loc) == 0) - return false; - -#if !defined (ACE_ENABLE_SWAP_ON_WRITE) - *reinterpret_cast (loc) = x; -#else - if (!this->do_byte_swap_) - { - *reinterpret_cast (loc) = x; - } - else - { - ACE_CDR::swap_4 (reinterpret_cast (&x), loc); - } -#endif /* ACE_ENABLE_SWAP_ON_WRITE */ - - return true; -} - - -ACE_CDR::Boolean -ACE_OutputCDR::replace (ACE_CDR::Short x, char* loc) -{ - if (this->find (loc) == 0) - return false; - -#if !defined (ACE_ENABLE_SWAP_ON_WRITE) - *reinterpret_cast (loc) = x; -#else - if (!this->do_byte_swap_) - { - *reinterpret_cast (loc) = x; - } - else - { - ACE_CDR::swap_2 (reinterpret_cast (&x), loc); - } -#endif /* ACE_ENABLE_SWAP_ON_WRITE */ - - return true; -} - - -int -ACE_OutputCDR::consolidate (void) -{ - // Optimize by only doing something if we need to - if (this->current_ != &this->start_) - { - // Set the number of bytes in the top-level block, reallocating - // if necessary. The rd_ptr and wr_ptr remain at the original offsets - // into the buffer, even if it is reallocated. - // Return an error if the allocation failed. - size_t const newsize = - ACE_CDR::first_size (this->total_length () - + ACE_CDR::MAX_ALIGNMENT); - if (this->start_.size (newsize) < 0) - { - return -1; - } - - // Consolidate the chain into the first block. NOTE that - // ACE_CDR::consolidate can not be used since we don't want to - // overwrite what is already in the first block. We just append it since - // the read and write pointers weren't affected by the resizing above. - // We also don't have to worry about alignment since the start block is - // already aligned. - // NOTE also we know there is a continuation since we checked for it - // above. There is therefore no reason to check for a 0 continuation - // field here. - ACE_Message_Block *cont = this->start_.cont (); - for (const ACE_Message_Block* i = cont; i != 0; i = i->cont ()) - { - this->start_.copy (i->rd_ptr (), i->length ()); - } - - // Release the old blocks that were consolidated and reset the - // current_ and current_is_writable_ to reflect the single used block. - ACE_Message_Block::release (cont); - this->start_.cont (0); - this->current_ = &this->start_; - this->current_is_writable_ = true; - } - - return 0; -} - - -ACE_Message_Block* -ACE_OutputCDR::find (char* loc) -{ - ACE_Message_Block* mb = 0; - for (mb = &this->start_; mb != 0; mb = mb->cont ()) - { - if (loc <= mb->wr_ptr () && loc >= mb->rd_ptr ()) - { - break; - } - } - - return mb; -} - - -// **************************************************************** - -ACE_InputCDR::ACE_InputCDR (const char *buf, - size_t bufsiz, - int byte_order, - ACE_CDR::Octet major_version, - ACE_CDR::Octet minor_version) - : start_ (buf, bufsiz), - do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), - good_bit_ (true), - major_version_ (major_version), - minor_version_ (minor_version), - char_translator_ (0), - wchar_translator_ (0) -{ - this->start_.wr_ptr (bufsiz); -} - -ACE_InputCDR::ACE_InputCDR (size_t bufsiz, - int byte_order, - ACE_CDR::Octet major_version, - ACE_CDR::Octet minor_version) - : start_ (bufsiz), - do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), - good_bit_ (true), - major_version_ (major_version), - minor_version_ (minor_version), - char_translator_ (0), - wchar_translator_ (0) -{ -} - -ACE_InputCDR::ACE_InputCDR (const ACE_Message_Block *data, - int byte_order, - ACE_CDR::Octet major_version, - ACE_CDR::Octet minor_version, - ACE_Lock* lock) -: start_ (0, ACE_Message_Block::MB_DATA, 0, 0, 0, lock), - good_bit_ (true), - major_version_ (major_version), - minor_version_ (minor_version), - char_translator_ (0), - wchar_translator_ (0) - -{ - this->reset (data, byte_order); -} - -ACE_InputCDR::ACE_InputCDR (ACE_Data_Block *data, - ACE_Message_Block::Message_Flags flag, - int byte_order, - ACE_CDR::Octet major_version, - ACE_CDR::Octet minor_version) - : start_ (data, flag), - do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), - good_bit_ (true), - major_version_ (major_version), - minor_version_ (minor_version), - char_translator_ (0), - wchar_translator_ (0) - -{ -} - -ACE_InputCDR::ACE_InputCDR (ACE_Data_Block *data, - ACE_Message_Block::Message_Flags flag, - size_t rd_pos, - size_t wr_pos, - int byte_order, - ACE_CDR::Octet major_version, - ACE_CDR::Octet minor_version) - : start_ (data, flag), - do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), - good_bit_ (true), - major_version_ (major_version), - minor_version_ (minor_version), - char_translator_ (0), - wchar_translator_ (0) - -{ - // Set the read pointer - this->start_.rd_ptr (rd_pos); - - // Set the write pointer after doing a sanity check. - char* wrpos = this->start_.base () + wr_pos; - - if (this->start_.end () >= wrpos) - { - this->start_.wr_ptr (wr_pos); - } -} - - -ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs, - size_t size, - ACE_CDR::Long offset) - : start_ (rhs.start_, - ACE_CDR::MAX_ALIGNMENT), - do_byte_swap_ (rhs.do_byte_swap_), - good_bit_ (true), - major_version_ (rhs.major_version_), - minor_version_ (rhs.minor_version_), - char_translator_ (rhs.char_translator_), - wchar_translator_ (rhs.wchar_translator_) - -{ -#if !defined (ACE_LACKS_CDR_ALIGNMENT) - // Align the base pointer assuming that the incoming stream is also - // aligned the way we are aligned - char *incoming_start = ACE_ptr_align_binary (rhs.start_.base (), - ACE_CDR::MAX_ALIGNMENT); -#else - char *incoming_start = rhs.start_.base (); -#endif /* ACE_LACKS_CDR_ALIGNMENT */ - - const size_t newpos = - (rhs.start_.rd_ptr() - incoming_start) + offset; - - if (newpos <= this->start_.space () - && newpos + size <= this->start_.space ()) - { - this->start_.rd_ptr (newpos); - this->start_.wr_ptr (newpos + size); - } - else - this->good_bit_ = false; -} - -ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs, - size_t size) - : start_ (rhs.start_, - ACE_CDR::MAX_ALIGNMENT), - do_byte_swap_ (rhs.do_byte_swap_), - good_bit_ (true), - major_version_ (rhs.major_version_), - minor_version_ (rhs.minor_version_), - char_translator_ (rhs.char_translator_), - wchar_translator_ (rhs.wchar_translator_) - -{ -#if !defined (ACE_LACKS_CDR_ALIGNMENT) - // Align the base pointer assuming that the incoming stream is also - // aligned the way we are aligned - char *incoming_start = ACE_ptr_align_binary (rhs.start_.base (), - ACE_CDR::MAX_ALIGNMENT); -#else - char *incoming_start = rhs.start_.base (); -#endif /* ACE_LACKS_CDR_ALIGNMENT */ - - const size_t newpos = - rhs.start_.rd_ptr() - incoming_start; - - if (newpos <= this->start_.space () - && newpos + size <= this->start_.space ()) - { - // Notice that ACE_Message_Block::duplicate may leave the - // wr_ptr() with a higher value than what we actually want. - this->start_.rd_ptr (newpos); - this->start_.wr_ptr (newpos + size); - - ACE_CDR::Octet byte_order = 0; - (void) this->read_octet (byte_order); - this->do_byte_swap_ = (byte_order != ACE_CDR_BYTE_ORDER); - } - else - this->good_bit_ = false; -} - -ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs) - : start_ (rhs.start_, - ACE_CDR::MAX_ALIGNMENT), - do_byte_swap_ (rhs.do_byte_swap_), - good_bit_ (true), - major_version_ (rhs.major_version_), - minor_version_ (rhs.minor_version_), - char_translator_ (rhs.char_translator_), - wchar_translator_ (rhs.wchar_translator_) -{ -#if !defined (ACE_LACKS_CDR_ALIGNMENT) - char *buf = ACE_ptr_align_binary (rhs.start_.base (), - ACE_CDR::MAX_ALIGNMENT); -#else - char *buf = rhs.start_.base (); -#endif /* ACE_LACKS_CDR_ALIGNMENT */ - - size_t rd_offset = rhs.start_.rd_ptr () - buf; - size_t wr_offset = rhs.start_.wr_ptr () - buf; - this->start_.rd_ptr (rd_offset); - this->start_.wr_ptr (wr_offset); -} - -ACE_InputCDR::ACE_InputCDR (ACE_InputCDR::Transfer_Contents x) - : start_ (x.rhs_.start_.data_block ()), - do_byte_swap_ (x.rhs_.do_byte_swap_), - good_bit_ (true), - major_version_ (x.rhs_.major_version_), - minor_version_ (x.rhs_.minor_version_), - char_translator_ (x.rhs_.char_translator_), - wchar_translator_ (x.rhs_.wchar_translator_) -{ - - this->start_.rd_ptr (x.rhs_.start_.rd_ptr ()); - this->start_.wr_ptr (x.rhs_.start_.wr_ptr ()); - - ACE_Data_Block* db = this->start_.data_block ()->clone_nocopy (); - (void) x.rhs_.start_.replace_data_block (db); -} - -ACE_InputCDR& -ACE_InputCDR::operator= (const ACE_InputCDR& rhs) -{ - if (this != &rhs) - { - this->start_.data_block (rhs.start_.data_block ()->duplicate ()); - this->start_.rd_ptr (rhs.start_.rd_ptr ()); - this->start_.wr_ptr (rhs.start_.wr_ptr ()); - this->do_byte_swap_ = rhs.do_byte_swap_; - this->good_bit_ = true; - this->char_translator_ = rhs.char_translator_; - this->major_version_ = rhs.major_version_; - this->minor_version_ = rhs.minor_version_; - } - return *this; -} - -ACE_InputCDR::ACE_InputCDR (const ACE_OutputCDR& rhs, - ACE_Allocator* buffer_allocator, - ACE_Allocator* data_block_allocator, - ACE_Allocator* message_block_allocator) - : start_ (rhs.total_length () + ACE_CDR::MAX_ALIGNMENT, - ACE_Message_Block::MB_DATA, - 0, - 0, - buffer_allocator, - 0, - 0, - ACE_Time_Value::zero, - ACE_Time_Value::max_time, - data_block_allocator, - message_block_allocator), - do_byte_swap_ (rhs.do_byte_swap_), - good_bit_ (true), - major_version_ (rhs.major_version_), - minor_version_ (rhs.minor_version_), - char_translator_ (rhs.char_translator_), - wchar_translator_ (rhs.wchar_translator_) -{ - ACE_CDR::mb_align (&this->start_); - for (const ACE_Message_Block *i = rhs.begin (); - i != rhs.end (); - i = i->cont ()) - this->start_.copy (i->rd_ptr (), i->length ()); -} - -ACE_CDR::Boolean -ACE_InputCDR::skip_wchar (void) -{ - if (static_cast (major_version_) == 1 - && static_cast (minor_version_) == 2) - { - ACE_CDR::Octet len; - if (this->read_1 (&len)) - return this->skip_bytes (static_cast (len)); - } - else - { - ACE_CDR::WChar x; - void * const temp = &x; - if (ACE_OutputCDR::wchar_maxbytes_ == 2) - return this->read_2 (reinterpret_cast (temp)); - else - return this->read_4 (reinterpret_cast (temp)); - } - - return (this->good_bit_ = false); -} - -ACE_CDR::Boolean -ACE_InputCDR::read_wchar (ACE_CDR::WChar& x) -{ - if (this->wchar_translator_ != 0) - { - this->good_bit_ = this->wchar_translator_->read_wchar (*this,x); - return this->good_bit_; - } - if (ACE_OutputCDR::wchar_maxbytes_ == 0) - { - errno = EACCES; - return (this->good_bit_ = false); - } - - if (ACE_OutputCDR::wchar_maxbytes_ == sizeof (ACE_CDR::WChar)) - { - if (static_cast (major_version_) == 1 - && static_cast (minor_version_) == 2) - { - ACE_CDR::Octet len; - - if (this->read_1 (&len)) - return this->read_array - (reinterpret_cast (&x), - static_cast (len), - ACE_CDR::OCTET_ALIGN, - 1); - - else - return (this->good_bit_ = false); - } - - void * const temp = &x; - if (sizeof (ACE_CDR::WChar) == 2) - return this->read_2 (reinterpret_cast (temp)); - else - return this->read_4 (reinterpret_cast (temp)); - } - - if (static_cast (major_version_) == 1 - && static_cast (minor_version_) == 2) - { - ACE_CDR::Octet len; - - if (this->read_1 (&len)) - { - if (len == 2) - { - ACE_CDR::Short sx; - if (this->read_array - (reinterpret_cast (&sx), - static_cast (len), - ACE_CDR::OCTET_ALIGN, - 1)) - { - x = static_cast (sx); - return true; - } - } - else - { - ACE_CDR::Octet ox; - if (this->read_array - (reinterpret_cast (&ox), - static_cast (len), - ACE_CDR::OCTET_ALIGN, - 1)) - { - x = static_cast (ox); - return true; - } - } - } - } - else - { - if (ACE_OutputCDR::wchar_maxbytes_ == 2) - { - ACE_CDR::UShort sx; - if (this->read_2 (reinterpret_cast (&sx))) - { - x = static_cast (sx); - return true; - } - } - else - { - ACE_CDR::Octet ox; - if (this->read_1 (&ox)) - { - x = static_cast (ox); - return true; - } - - } - } - return (this->good_bit_ = false); -} - -ACE_CDR::Boolean -ACE_InputCDR::read_string (ACE_CDR::Char *&x) -{ - // @@ This is a slight violation of "Optimize for the common case", - // i.e. normally the translator will be 0, but OTOH the code is - // smaller and should be better for the cache ;-) ;-) - if (this->char_translator_ != 0) - { - this->good_bit_ = this->char_translator_->read_string (*this, x); - return this->good_bit_; - } - - ACE_CDR::ULong len = 0; - - if (!this->read_ulong (len)) - return false; - - // A check for the length being too great is done later in the - // call to read_char_array but we want to have it done before - // the memory is allocated. - if (len > 0 && len <= this->length()) - { - ACE_NEW_RETURN (x, - ACE_CDR::Char[len], - 0); - - ACE_Auto_Basic_Array_Ptr safe_data (x); - - if (this->read_char_array (x, len)) - { - (void) safe_data.release (); - return true; - } - } - else if (len == 0) - { - // Convert any null strings to empty strings since empty - // strings can cause crashes. (See bug 58.) - ACE_NEW_RETURN (x, - ACE_CDR::Char[1], - 0); - ACE_OS::strcpy (const_cast (x), ""); - return true; - } - - x = 0; - return (this->good_bit_ = false); -} - -ACE_CDR::Boolean -ACE_InputCDR::read_string (ACE_CString &x) -{ - ACE_CDR::Char * data = 0; - if (this->read_string (data)) - { - ACE_Auto_Basic_Array_Ptr safe_data (data); - x = data; - return true; - } - - x = ""; - return (this->good_bit_ = false); -} - -ACE_CDR::Boolean -ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x) -{ - // @@ This is a slight violation of "Optimize for the common case", - // i.e. normally the translator will be 0, but OTOH the code is - // smaller and should be better for the cache ;-) ;-) - if (this->wchar_translator_ != 0) - { - this->good_bit_ = this->wchar_translator_->read_wstring (*this, x); - return this->good_bit_; - } - if (ACE_OutputCDR::wchar_maxbytes_ == 0) - { - errno = EACCES; - return (this->good_bit_ = false); - } - - ACE_CDR::ULong len = 0; - if (!this->read_ulong (len)) - return false; - - // A check for the length being too great is done later in the - // call to read_char_array but we want to have it done before - // the memory is allocated. - if (len > 0 && len <= this->length ()) - { - ACE_Auto_Basic_Array_Ptr safe_data; - - if (static_cast (this->major_version_) == 1 - && static_cast (this->minor_version_) == 2) - { - len /= ACE_OutputCDR::wchar_maxbytes_; - - //allocating one extra for the null character needed by applications - ACE_NEW_RETURN (x, - ACE_CDR::WChar [len + 1], - false); - - ACE_auto_ptr_reset (safe_data, x); - - if (this->read_wchar_array (x, len)) - { - - //Null character used by applications to find the end of - //the wstring - //Is this okay with the GIOP 1.2 spec?? - x[len] = '\x00'; - - (void) safe_data.release (); - - return true; - } - } - else - { - ACE_NEW_RETURN (x, - ACE_CDR::WChar [len], - false); - - ACE_auto_ptr_reset (safe_data, x); - - if (this->read_wchar_array (x, len)) - { - (void) safe_data.release (); - - return true; - } - } - } - else if (len == 0) - { - // Convert any null strings to empty strings since empty - // strings can cause crashes. (See bug 58.) - ACE_NEW_RETURN (x, - ACE_CDR::WChar[1], - false); - x[0] = '\x00'; - return true; - } - - this->good_bit_ = false; - x = 0; - return false; -} - -ACE_CDR::Boolean -ACE_InputCDR::read_array (void* x, - size_t size, - size_t align, - ACE_CDR::ULong length) -{ - if (length == 0) - return true; - char* buf = 0; - - if (this->adjust (size * length, align, buf) == 0) - { -#if defined (ACE_DISABLE_SWAP_ON_READ) - ACE_OS::memcpy (x, buf, size*length); -#else - if (!this->do_byte_swap_ || size == 1) - ACE_OS::memcpy (x, buf, size*length); - else - { - char *target = reinterpret_cast (x); - switch (size) - { - case 2: - ACE_CDR::swap_2_array (buf, target, length); - break; - case 4: - ACE_CDR::swap_4_array (buf, target, length); - break; - case 8: - ACE_CDR::swap_8_array (buf, target, length); - break; - case 16: - ACE_CDR::swap_16_array (buf, target, length); - break; - default: - // TODO: print something? - this->good_bit_ = false; - return false; - } - } -#endif /* ACE_DISABLE_SWAP_ON_READ */ - return this->good_bit_; - } - return false; -} - -ACE_CDR::Boolean -ACE_InputCDR::read_wchar_array_i (ACE_CDR::WChar* x, - ACE_CDR::ULong length) -{ - if (length == 0) - return true; - char* buf = 0; - size_t const align = (ACE_OutputCDR::wchar_maxbytes_ == 2) ? - ACE_CDR::SHORT_ALIGN : - ACE_CDR::OCTET_ALIGN; - - if (this->adjust (ACE_OutputCDR::wchar_maxbytes_ * length, align, buf) == 0) - { - if (ACE_OutputCDR::wchar_maxbytes_ == 2) - { - ACE_CDR::UShort *sb = reinterpret_cast (buf); - for (size_t i = 0; i < length; ++i) -#if defined (ACE_DISABLE_SWAP_ON_READ) - x[i] = static_cast (sb[i]); -#else - if (!this->do_byte_swap_) - x[i] = static_cast (sb[i]); - else - { - ACE_CDR::UShort sx; - ACE_CDR::swap_2 (&buf[i * 2], reinterpret_cast (&sx)); - x[i] = static_cast (sx); - } -#endif /* ACE_DISABLE_SWAP_ON_READ */ - } - else - { - for (size_t i = 0; i < length; ++i) - x[i] = static_cast (buf[i]); - } - return this->good_bit_; - } - return false; -} - - -ACE_CDR::Boolean -ACE_InputCDR::read_boolean_array (ACE_CDR::Boolean *x, - ACE_CDR::ULong length) -{ - // Make sure the length of the array isn't greater than the length of - // the stream. - if (length > this->length ()) - { - this->good_bit_ = false; - return false; - } - - // It is hard to optimize this, the spec requires that on the wire - // booleans be represented as a byte with value 0 or 1, but in - // memory it is possible (though very unlikely) that a boolean has - // a non-zero value (different from 1). - // We resort to a simple loop. - for (ACE_CDR::ULong i = 0; i != length && this->good_bit_; ++i) - (void) this->read_boolean (x[i]); - - return this->good_bit_; -} - -ACE_CDR::Boolean -ACE_InputCDR::read_1 (ACE_CDR::Octet *x) -{ - if (this->rd_ptr () < this->wr_ptr ()) - { - *x = *reinterpret_cast (this->rd_ptr ()); - this->start_.rd_ptr (1); - return true; - } - - this->good_bit_ = false; - return false; -} - -ACE_CDR::Boolean -ACE_InputCDR::read_2 (ACE_CDR::UShort *x) -{ - char *buf = 0; - if (this->adjust (ACE_CDR::SHORT_SIZE, buf) == 0) - { -#if !defined (ACE_DISABLE_SWAP_ON_READ) - if (!this->do_byte_swap_) - *x = *reinterpret_cast (buf); - else - ACE_CDR::swap_2 (buf, reinterpret_cast (x)); -#else - *x = *reinterpret_cast (buf); -#endif /* ACE_DISABLE_SWAP_ON_READ */ - return true; - } - this->good_bit_ = false; - return false; -} - -ACE_CDR::Boolean -ACE_InputCDR::read_4 (ACE_CDR::ULong *x) -{ - char *buf = 0; - if (this->adjust (ACE_CDR::LONG_SIZE, buf) == 0) - { -#if !defined (ACE_DISABLE_SWAP_ON_READ) - if (!this->do_byte_swap_) - *x = *reinterpret_cast (buf); - else - ACE_CDR::swap_4 (buf, reinterpret_cast (x)); -#else - *x = *reinterpret_cast (buf); -#endif /* ACE_DISABLE_SWAP_ON_READ */ - return true; - } - this->good_bit_ = false; - return false; -} - -ACE_CDR::Boolean -ACE_InputCDR::read_8 (ACE_CDR::ULongLong *x) -{ - char *buf = 0; - - if (this->adjust (ACE_CDR::LONGLONG_SIZE, buf) == 0) - { -#if !defined (ACE_DISABLE_SWAP_ON_READ) -# if defined (__arm__) - if (!this->do_byte_swap_) - { - // Convert from Intel format (12345678 => 56781234) - const char *orig = buf; - char *target = reinterpret_cast (x); - register ACE_UINT32 x = - *reinterpret_cast (orig); - register ACE_UINT32 y = - *reinterpret_cast (orig + 4); - *reinterpret_cast (target) = y; - *reinterpret_cast (target + 4) = x; - } - else - { - // Convert from Sparc format (12345678 => 43218765) - const char *orig = buf; - char *target = reinterpret_cast (x); - register ACE_UINT32 x = - *reinterpret_cast (orig); - register ACE_UINT32 y = - *reinterpret_cast (orig + 4); - x = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24); - y = (y << 24) | ((y & 0xff00) << 8) | ((y & 0xff0000) >> 8) | (y >> 24); - *reinterpret_cast (target) = x; - *reinterpret_cast (target + 4) = y; - } -# else - if (!this->do_byte_swap_) - *x = *reinterpret_cast (buf); - else - ACE_CDR::swap_8 (buf, reinterpret_cast (x)); -# endif /* !__arm__ */ -#else - *x = *reinterpret_cast (buf); -#endif /* ACE_DISABLE_SWAP_ON_READ */ - return true; - } - - this->good_bit_ = false; - return false; -} - -ACE_CDR::Boolean -ACE_InputCDR::read_16 (ACE_CDR::LongDouble *x) -{ - char *buf = 0; - if (this->adjust (ACE_CDR::LONGDOUBLE_SIZE, - ACE_CDR::LONGDOUBLE_ALIGN, - buf) == 0) - { -#if !defined (ACE_DISABLE_SWAP_ON_READ) - if (!this->do_byte_swap_) - *x = *reinterpret_cast (buf); - else - ACE_CDR::swap_16 (buf, reinterpret_cast (x)); -#else - *x = *reinterpret_cast (buf); -#endif /* ACE_DISABLE_SWAP_ON_READ */ - return true; - } - - this->good_bit_ = false; - return false; -} - -ACE_CDR::Boolean -ACE_InputCDR::skip_string (void) -{ - ACE_CDR::ULong len = 0; - if (this->read_ulong (len)) - { - if (this->rd_ptr () + len <= this->wr_ptr ()) - { - this->rd_ptr (len); - return true; - } - this->good_bit_ = false; - } - return false; -} - -ACE_CDR::Boolean -ACE_InputCDR::skip_wstring (void) -{ - ACE_CDR::Boolean continue_skipping = true; - ACE_CDR::ULong len = 0; - - continue_skipping = read_ulong (len); - - if (continue_skipping && len != 0) - { - if (static_cast (this->major_version_) == 1 - && static_cast (this->minor_version_) == 2) - continue_skipping = this->skip_bytes ((size_t)len); - else - while (continue_skipping && len--) - continue_skipping = this->skip_wchar (); - } - return continue_skipping; -} - -ACE_CDR::Boolean -ACE_InputCDR::skip_bytes (size_t len) -{ - if (this->rd_ptr () + len <= this->wr_ptr ()) - { - this->rd_ptr (len); - return true; - } - this->good_bit_ = false; - return false; -} - -int -ACE_InputCDR::grow (size_t newsize) -{ - if (ACE_CDR::grow (&this->start_, newsize) == -1) - return -1; - - ACE_CDR::mb_align (&this->start_); - this->start_.wr_ptr (newsize); - return 0; -} - -void -ACE_InputCDR::reset (const ACE_Message_Block* data, - int byte_order) -{ - this->reset_byte_order (byte_order); - ACE_CDR::consolidate (&this->start_, data); -} - -void -ACE_InputCDR::steal_from (ACE_InputCDR &cdr) -{ - this->do_byte_swap_ = cdr.do_byte_swap_; - this->start_.data_block (cdr.start_.data_block ()->duplicate ()); - - // If the message block had a DONT_DELETE flags, just clear it off.. - this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE); - this->start_.rd_ptr (cdr.start_.rd_ptr ()); - - this->start_.wr_ptr (cdr.start_.wr_ptr ()); - this->major_version_ = cdr.major_version_; - this->minor_version_ = cdr.minor_version_; - cdr.reset_contents (); -} - -void -ACE_InputCDR::exchange_data_blocks (ACE_InputCDR &cdr) -{ - // Exchange byte orders - int const byte_order = cdr.do_byte_swap_; - cdr.do_byte_swap_ = this->do_byte_swap_; - this->do_byte_swap_ = byte_order; - - // Get the destination read and write pointers - size_t const drd_pos = - cdr.start_.rd_ptr () - cdr.start_.base (); - size_t const dwr_pos = - cdr.start_.wr_ptr () - cdr.start_.base (); - - // Get the source read & write pointers - size_t const srd_pos = - this->start_.rd_ptr () - this->start_.base (); - size_t const swr_pos = - this->start_.wr_ptr () - this->start_.base (); - - // Exchange data_blocks. Dont release any of the data blocks. - ACE_Data_Block *dnb = - this->start_.replace_data_block (cdr.start_.data_block ()); - cdr.start_.replace_data_block (dnb); - - // Exchange the flags information.. - ACE_Message_Block::Message_Flags df = cdr.start_.self_flags (); - ACE_Message_Block::Message_Flags sf = this->start_.self_flags (); - - cdr.start_.clr_self_flags (df); - this->start_.clr_self_flags (sf); - - cdr.start_.set_self_flags (sf); - this->start_.set_self_flags (df); - - // Reset the pointers to zero before it is set again. - cdr.start_.reset (); - this->start_.reset (); - - // Set the read and write pointers. - if (cdr.start_.size () >= srd_pos) - cdr.start_.rd_ptr (srd_pos); - - if (cdr.start_.size () >= swr_pos) - cdr.start_.wr_ptr (swr_pos); - - if (this->start_.size () >= drd_pos) - this->start_.rd_ptr (drd_pos); - - if (this->start_.size () >= dwr_pos) - this->start_.wr_ptr (dwr_pos); - - ACE_CDR::Octet const dmajor = cdr.major_version_; - ACE_CDR::Octet const dminor = cdr.minor_version_; - - // Exchange the GIOP version info - cdr.major_version_ = this->major_version_; - cdr.minor_version_ = this->minor_version_; - - this->major_version_ = dmajor; - this->minor_version_ = dminor; -} - -ACE_Data_Block * -ACE_InputCDR::clone_from (ACE_InputCDR &cdr) -{ - this->do_byte_swap_ = cdr.do_byte_swap_; - - // Get the read & write pointer positions in the incoming CDR - // streams - char *rd_ptr = cdr.start_.rd_ptr (); - char *wr_ptr = cdr.start_.wr_ptr (); - - // Now reset the incoming CDR stream - cdr.start_.reset (); - - // As we have reset the stream, try to align the underlying message - // block in the incoming stream - ACE_CDR::mb_align (&cdr.start_); - - // Get the read & write pointer positions again - char *nrd_ptr = cdr.start_.rd_ptr (); - char *nwr_ptr = cdr.start_.wr_ptr (); - - // Actual length of the stream is.. - // @todo: This will look idiotic, but we dont seem to have much of a - // choice. How do we calculate the length of the incoming stream? - // Calling the method before calling reset () would give us the - // wrong length of the stream that needs copying. So we do the - // calulation like this - // (1) We get the and positions of the incoming - // stream. - // (2) Then we reset the stream and then align it. - // (3) We get the and positions again. (Points #1 - // thru #3 has been done already) - // (4) The difference in the and positions gives - // us the following, the actual bytes traversed by the and - // . - // (5) The bytes traversed by the is the actual length of - // the stream. - - // Actual bytes traversed - size_t rd_bytes = rd_ptr - nrd_ptr; - size_t wr_bytes = wr_ptr - nwr_ptr; - - ACE_CDR::mb_align (&this->start_); - - ACE_Data_Block *db = - this->start_.data_block (); - - // If the size of the data that needs to be copied are higher than - // what is available, then do a reallocation. - if (wr_bytes > (this->start_.size () - ACE_CDR::MAX_ALIGNMENT)) - { - // @@NOTE: We need to probably add another method to the message - // block interface to simplify this - db = - cdr.start_.data_block ()->clone_nocopy (); - - if (db == 0 || db->size ((wr_bytes) + - ACE_CDR::MAX_ALIGNMENT) == -1) - return 0; - - // Replace our data block by using the incoming CDR stream. - db = this->start_.replace_data_block (db); - - // Align the start_ message block. - ACE_CDR::mb_align (&this->start_); - - // Clear the DONT_DELETE flag if it has been set - this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE); - } - - // Now do the copy - (void) ACE_OS::memcpy (this->start_.wr_ptr (), - cdr.start_.rd_ptr (), - wr_bytes); - - // Set the read pointer position to the same point as that was in - // cdr. - this->start_.rd_ptr (rd_bytes); - this->start_.wr_ptr (wr_bytes); - - // We have changed the read & write pointers for the incoming - // stream. Set them back to the positions that they were before.. - cdr.start_.rd_ptr (rd_bytes); - cdr.start_.wr_ptr (wr_bytes); - - this->major_version_ = cdr.major_version_; - this->minor_version_ = cdr.minor_version_; - - // Copy the char/wchar translators - this->char_translator_ = cdr.char_translator_; - this->wchar_translator_ = cdr.wchar_translator_; - - return db; -} - -ACE_Message_Block* -ACE_InputCDR::steal_contents (void) -{ - ACE_Message_Block* block = this->start_.clone (); - this->start_.data_block (block->data_block ()->clone ()); - - // If at all our message had a DONT_DELETE flag set, just clear it - // off. - this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE); - - ACE_CDR::mb_align (&this->start_); - - return block; -} - -void -ACE_InputCDR::reset_contents (void) -{ - this->start_.data_block (this->start_.data_block ()->clone_nocopy ()); - - // Reset the flags... - this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE); -} - -// -------------------------------------------------------------- - -ACE_Char_Codeset_Translator::~ACE_Char_Codeset_Translator (void) -{ -} - -// -------------------------------------------------------------- - -ACE_WChar_Codeset_Translator::~ACE_WChar_Codeset_Translator (void) -{ -} - -// -------------------------------------------------------------- - -ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, const ACE_CString &x) -{ - os.write_string (x); - return os.good_bit (); -} - -ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, ACE_CString &x) -{ - is.read_string (x); - return is.good_bit (); -} - -#if defined (GEN_OSTREAM_OPS) - -std::ostream& -operator<< (std::ostream &os, ACE_OutputCDR::from_boolean x) -{ - return (x.val_ ? os << "true" : os << "false"); -} - -std::ostream& -operator<< (std::ostream &os, ACE_OutputCDR::from_char x) -{ - return os << '\'' << x.val_ << '\''; -} - -std::ostream& -operator<< (std::ostream &os, ACE_OutputCDR::from_wchar x) -{ - os.setf (ios_base::showbase); - os.setf (ios_base::hex, ios_base::basefield); - os << x.val_; - os.unsetf (ios_base::showbase); - os.setf (ios_base::dec, ios_base::basefield); - return os; -} - -std::ostream& -operator<< (std::ostream &os, ACE_OutputCDR::from_octet x) -{ - // Same format (hex) and no risk of overflow. - ACE_CDR::WChar w = static_cast (x.val_); - ACE_OutputCDR::from_wchar tmp (w); - return os << tmp; -} - -#endif /* GEN_OSTREAM_OPS */ - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/CDR_Stream.h b/ACE/ace/CDR_Stream.h deleted file mode 100644 index 58ddea442ed..00000000000 --- a/ACE/ace/CDR_Stream.h +++ /dev/null @@ -1,1364 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file CDR_Stream.h - * - * $Id$ - * - * ACE Common Data Representation (CDR) marshaling and demarshaling - * classes. - * - * This implementation was inspired in the CDR class in SunSoft's - * IIOP engine, but has a completely different implementation and a - * different interface too. - * - * The current implementation assumes that the host has 1-byte, - * 2-byte and 4-byte integral types, and that it has single - * precision and double precision IEEE floats. - * Those assumptions are pretty good these days, with Crays beign - * the only known exception. - * - * Optimizations - * ------------- - * ACE_LACKS_CDR_ALIGNMENT - * @author Arvind S. Krishna - * - * CDR stream ignores alignment when marshaling data. Use this option - * only when ACE_DISABLE_SWAP_ON_READ can be enabled. This option requires - * ACE CDR engine to do both marshaling and demarshaling. - * - * - * @author TAO version by Aniruddha Gokhale - * @author Carlos O'Ryan - * @author ACE version by Jeff Parsons - * @author Istvan Buki - * @author Codeset translation by Jim Rogers - */ -//============================================================================= - -#ifndef ACE_CDR_STREAM_H -#define ACE_CDR_STREAM_H - -#include /**/ "ace/pre.h" - -#include "ace/CDR_Base.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/SStringfwd.h" -#include "ace/Message_Block.h" - -#if defined (GEN_OSTREAM_OPS) -#include "ace/streams.h" -#endif /* GEN_OSTREAM_OPS */ - -// Stuff used by the ACE CDR classes. -#if defined ACE_LITTLE_ENDIAN -# define ACE_CDR_BYTE_ORDER 1 -// little endian encapsulation byte order has value = 1 -#else /* ! ACE_LITTLE_ENDIAN */ -# define ACE_CDR_BYTE_ORDER 0 -// big endian encapsulation byte order has value = 0 -#endif /* ! ACE_LITTLE_ENDIAN */ - - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -class ACE_Char_Codeset_Translator; -class ACE_WChar_Codeset_Translator; - -class ACE_InputCDR; - -/** - * @class ACE_OutputCDR - * - * @brief A CDR stream for writing, i.e. for marshalling. - * - * This class is based on the the CORBA spec for Java (98-02-29), - * java class omg.org.CORBA.portable.OutputStream. It diverts in - * a few ways: - * + Operations taking arrays don't have offsets, because in C++ - * it is easier to describe an array starting from x+offset. - * + Operations return an error status, because exceptions are - * not widely available in C++ (yet). - */ -class ACE_Export ACE_OutputCDR -{ -public: - /** - * The Codeset translators need access to some private members to - * efficiently marshal arrays - * For reading from an output CDR stream. - */ - friend class ACE_Char_Codeset_Translator; - friend class ACE_WChar_Codeset_Translator; - friend class ACE_InputCDR; - - /// Default constructor, allocates @a size bytes in the internal - /// buffer, if @a size == 0 it allocates the default size. - ACE_OutputCDR (size_t size = 0, - int byte_order = ACE_CDR_BYTE_ORDER, - ACE_Allocator* buffer_allocator = 0, - ACE_Allocator* data_block_allocator = 0, - ACE_Allocator* message_block_allocator = 0, - size_t memcpy_tradeoff = ACE_DEFAULT_CDR_MEMCPY_TRADEOFF, - ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION, - ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION); - - /// Build a CDR stream with an initial buffer, it will *not* remove - /// , since it did not allocated it. It's important to be careful - /// with the alignment of . - /** - * Create an output stream from an arbitrary buffer, care must be - * exercised with alignment, because this contructor will align if - * needed. In this case @a data will not point to the start of the - * output stream. @c begin()->rd_ptr() points to the start of the - * output stream. See @c ACE_ptr_align_binary() to properly align a - * pointer and use ACE_CDR::MAX_ALIGNMENT for the correct alignment. - */ - ACE_OutputCDR (char *data, - size_t size, - int byte_order = ACE_CDR_BYTE_ORDER, - ACE_Allocator* buffer_allocator = 0, - ACE_Allocator* data_block_allocator = 0, - ACE_Allocator* message_block_allocator = 0, - size_t memcpy_tradeoff = ACE_DEFAULT_CDR_MEMCPY_TRADEOFF, - ACE_CDR::Octet giop_major_version = ACE_CDR_GIOP_MAJOR_VERSION, - ACE_CDR::Octet giop_minor_version = ACE_CDR_GIOP_MINOR_VERSION); - - /// Build a CDR stream with an initial data block, it will *not* remove - /// , since it did not allocated it. It's important to be - // careful with the alignment of . - /** - * Create an output stream from an arbitrary data block, care must be - * exercised with alignment, because this contructor will align if - * needed. In this case @a data_block will not point to the - * start of the output stream. begin()->rd_ptr() points to the start - * off the output stream. See ACE_ptr_align_binary() to properly align a - * pointer and use ACE_CDR::MAX_ALIGNMENT for the correct alignment. - */ - ACE_OutputCDR (ACE_Data_Block *data_block, - int byte_order = ACE_CDR_BYTE_ORDER, - ACE_Allocator* message_block_allocator = 0, - size_t memcpy_tradeoff = ACE_DEFAULT_CDR_MEMCPY_TRADEOFF, - ACE_CDR::Octet giop_major_version = ACE_CDR_GIOP_MAJOR_VERSION, - ACE_CDR::Octet giop_minor_version = ACE_CDR_GIOP_MINOR_VERSION); - - /// Build a CDR stream with an initial Message_Block chain, it will - /// *not* remove @a data, since it did not allocate it. - ACE_OutputCDR (ACE_Message_Block *data, - int byte_order = ACE_CDR_BYTE_ORDER, - size_t memcpy_tradeoff = ACE_DEFAULT_CDR_MEMCPY_TRADEOFF, - ACE_CDR::Octet giop_major_version = ACE_CDR_GIOP_MAJOR_VERSION, - ACE_CDR::Octet giop_minor_version = ACE_CDR_GIOP_MINOR_VERSION); - - /// destructor - ~ACE_OutputCDR (void); - - /** - * Disambiguate overload when inserting booleans, octets, chars, and - * bounded strings. - */ - //@{ @name Helper classes - - struct ACE_Export from_boolean - { - explicit from_boolean (ACE_CDR::Boolean b); - ACE_CDR::Boolean val_; - }; - - struct ACE_Export from_octet - { - explicit from_octet (ACE_CDR::Octet o); - ACE_CDR::Octet val_; - }; - - struct ACE_Export from_char - { - explicit from_char (ACE_CDR::Char c); - ACE_CDR::Char val_; - }; - - struct ACE_Export from_wchar - { - explicit from_wchar (ACE_CDR::WChar wc); - ACE_CDR::WChar val_; - }; - - struct ACE_Export from_string - { - from_string (ACE_CDR::Char* s, - ACE_CDR::ULong b, - ACE_CDR::Boolean nocopy = 0); - from_string (const ACE_CDR::Char* s, - ACE_CDR::ULong b, - ACE_CDR::Boolean nocopy = 0); - ACE_CDR::Char *val_; - ACE_CDR::ULong bound_; - ACE_CDR::Boolean nocopy_; - }; - - struct ACE_Export from_wstring - { - from_wstring (ACE_CDR::WChar* ws, - ACE_CDR::ULong b, - ACE_CDR::Boolean nocopy = 0); - from_wstring (const ACE_CDR::WChar* ws, - ACE_CDR::ULong b, - ACE_CDR::Boolean nocopy = 0); - ACE_CDR::WChar *val_; - ACE_CDR::ULong bound_; - ACE_CDR::Boolean nocopy_; - }; - //@} - - /** - * @{ @name Write operations - * Return 0 on failure and 1 on success. - */ - ACE_CDR::Boolean write_boolean (ACE_CDR::Boolean x); - ACE_CDR::Boolean write_char (ACE_CDR::Char x); - ACE_CDR::Boolean write_wchar (ACE_CDR::WChar x); - ACE_CDR::Boolean write_octet (ACE_CDR::Octet x); - ACE_CDR::Boolean write_short (ACE_CDR::Short x); - ACE_CDR::Boolean write_ushort (ACE_CDR::UShort x); - ACE_CDR::Boolean write_long (ACE_CDR::Long x); - ACE_CDR::Boolean write_ulong (ACE_CDR::ULong x); - ACE_CDR::Boolean write_longlong (const ACE_CDR::LongLong &x); - ACE_CDR::Boolean write_ulonglong (const ACE_CDR::ULongLong &x); - ACE_CDR::Boolean write_float (ACE_CDR::Float x); - ACE_CDR::Boolean write_double (const ACE_CDR::Double &x); - ACE_CDR::Boolean write_longdouble (const ACE_CDR::LongDouble &x); - - /// For string we offer methods that accept a precomputed length. - ACE_CDR::Boolean write_string (const ACE_CDR::Char *x); - ACE_CDR::Boolean write_string (ACE_CDR::ULong len, - const ACE_CDR::Char *x); - ACE_CDR::Boolean write_string (const ACE_CString &x); - ACE_CDR::Boolean write_wstring (const ACE_CDR::WChar *x); - ACE_CDR::Boolean write_wstring (ACE_CDR::ULong length, - const ACE_CDR::WChar *x); - //@} - - /// @note the portion written starts at and ends - /// at . - /// The length is *NOT* stored into the CDR stream. - //@{ @name Array write operations - ACE_CDR::Boolean write_boolean_array (const ACE_CDR::Boolean *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_char_array (const ACE_CDR::Char *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_wchar_array (const ACE_CDR::WChar* x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_octet_array (const ACE_CDR::Octet* x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_short_array (const ACE_CDR::Short *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_ushort_array (const ACE_CDR::UShort *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_long_array (const ACE_CDR::Long *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_ulong_array (const ACE_CDR::ULong *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_longlong_array (const ACE_CDR::LongLong* x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_ulonglong_array (const ACE_CDR::ULongLong *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_float_array (const ACE_CDR::Float *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_double_array (const ACE_CDR::Double *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean write_longdouble_array (const ACE_CDR::LongDouble* x, - ACE_CDR::ULong length); - - /// Write an octet array contained inside a MB, this can be optimized - /// to minimize copies. - ACE_CDR::Boolean write_octet_array_mb (const ACE_Message_Block* mb); - //@} - - /** - * @{ @name Placeholder/replace operations - * Facilitates writing a placeholder into a CDR stream to be replaced - * later with a different value. - * - * @note An example use for this facility is: - * @code - ACE_OutputCDR strm; - ... // insert values... - char *pos = strm.write_long_placeholder (); - ... // insert more values - ACE_CDR::Long real_val; // Somehow assign the "correct" value - strm.replace (real_val, pos); // Replace earlier placeholder - @endcode - */ - - /** - * Write a placeholder into the stream. The placeholder's pointer - * is returned so it may later be passed as the @a loc argument to - * replace (). - * These methods align the stream's write pointer properly prior to - * writing the placeholder. - */ - char* write_long_placeholder (void); - char* write_short_placeholder (void); - - /** - * Writes a new value into a specific location. This is commonly - * used to update a prior "placeholder" location in the stream. - * The specified location is assumed to have proper CDR alignment for the - * type to insert. This requirement is satisfied by using one of the - * placeholder-writing methods to align the stream for the anticipated - * value and obtain the correct location. - * Treatment of @a x with repect to byte swapping is the same as for when - * any value is inserted. - * - * @param x The value to insert into the specified location. - * @param loc The location at which to insert @a x. @a loc must be a valid - * position within the stream's current set of message blocks. - * - * @sa write_long_placeholder(), write_short_placeholder () - */ - ACE_CDR::Boolean replace (ACE_CDR::Long x, char* loc); - ACE_CDR::Boolean replace (ACE_CDR::Short x, char* loc); - //@} - - /** - * Return 0 on failure and 1 on success. - */ - //@{ @name Append contents of own CDR stream to another - ACE_CDR::Boolean append_boolean (ACE_InputCDR &); - ACE_CDR::Boolean append_char (ACE_InputCDR &); - ACE_CDR::Boolean append_wchar (ACE_InputCDR &); - ACE_CDR::Boolean append_octet (ACE_InputCDR &); - ACE_CDR::Boolean append_short (ACE_InputCDR &); - ACE_CDR::Boolean append_ushort (ACE_InputCDR &); - ACE_CDR::Boolean append_long (ACE_InputCDR &); - ACE_CDR::Boolean append_ulong (ACE_InputCDR &); - ACE_CDR::Boolean append_longlong (ACE_InputCDR &); - ACE_CDR::Boolean append_ulonglong (ACE_InputCDR &); - ACE_CDR::Boolean append_float (ACE_InputCDR &); - ACE_CDR::Boolean append_double (ACE_InputCDR &); - ACE_CDR::Boolean append_longdouble (ACE_InputCDR &); - - ACE_CDR::Boolean append_wstring (ACE_InputCDR &); - ACE_CDR::Boolean append_string (ACE_InputCDR &); - //@} - - /// Returns @c false if an error has ocurred. - /** - * @note The only expected error is to run out of memory. - */ - bool good_bit (void) const; - - /// Reuse the CDR stream to write on the old buffer. - void reset (void); - - /// Add the length of each message block in the chain. - size_t total_length (void) const; - - /** - * Return the start of the message block chain for this CDR stream. - * @note The complete CDR stream is represented by a chain of - * message blocks. - */ - const ACE_Message_Block *begin (void) const; - - /// Return the last message in the chain that is is use. - const ACE_Message_Block *end (void) const; - - /// Return the message block in chain. - const ACE_Message_Block *current (void) const; - - /// Replace the message block chain with a single message block. - /** - * Upon successful completion, there will be a single message block - * containing the data from the complete message block chain. - * - * @note The only expected error is to run out of memory. - */ - int consolidate (void); - - /** - * Access the underlying buffer (read only). @note This - * method only returns a pointer to the first block in the - * chain. - */ - const char *buffer (void) const; - - /** - * Return the size of first message block in the block chain. @note This - * method only returns information about the first block in the - * chain. - */ - size_t length (void) const; - - /** - * Utility function to allow the user more flexibility. - * Pads the stream up to the nearest -byte boundary. - * Argument MUST be a power of 2. - * Returns 0 on success and -1 on failure. - */ - int align_write_ptr (size_t alignment); - - /// Access the codeset translators. They can be null! - ACE_Char_Codeset_Translator *char_translator (void) const; - ACE_WChar_Codeset_Translator *wchar_translator (void) const; - - /// Set the char codeset translator. - void char_translator (ACE_Char_Codeset_Translator *); - /// Set the wchar codeset translator. - void wchar_translator (ACE_WChar_Codeset_Translator *); - - /// set the global size of serialized wchars. This may be different - /// than the size of a wchar_t. - static void wchar_maxbytes (size_t max_bytes); - - /// access the serialized size of wchars. - static size_t wchar_maxbytes (void); - - /** - * Return alignment of the wr_ptr(), with respect to the start of - * the CDR stream. This is not the same as the alignment of - * current->wr_ptr()! - */ - size_t current_alignment (void) const; - - /** - * Returns (in @a buf) the next position in the buffer aligned to - * @a size, it advances the Message_Block wr_ptr past the data - * (i.e., @a buf + @a size). If necessary it grows the Message_Block - * buffer. Sets the good_bit to false and returns a -1 on failure. - */ - int adjust (size_t size, - char *&buf); - - /// As above, but now the size and alignment requirements may be - /// different. - int adjust (size_t size, - size_t align, - char *&buf); - - /// If non-zero then this stream is writing in non-native byte order, - /// this is only meaningful if ACE_ENABLE_SWAP_ON_WRITE is defined. - bool do_byte_swap (void) const; - - /// If returns 0, this returns ACE_CDR_BYTE_ORDER else - /// it returns !ACE_CDR_BYTE_ORDER. - int byte_order (void) const; - - /// For use by a gateway, which creates the output stream for the - /// reply to the client in its native byte order, but which must - /// send the reply in the byte order of the target's reply to the - /// gateway. - void reset_byte_order (int byte_order); - - /// set GIOP version info - void set_version (ACE_CDR::Octet major, ACE_CDR::Octet minor); - - /// Set the underlying GIOP version.. - void get_version (ACE_CDR::Octet &major, ACE_CDR::Octet &minor); - -private: - - // Find the message block in the chain of message blocks - // that the provide location locates. - ACE_Message_Block* find (char* loc); - - /// disallow copying... - ACE_OutputCDR (const ACE_OutputCDR& rhs); - ACE_OutputCDR& operator= (const ACE_OutputCDR& rhs); - - ACE_CDR::Boolean write_1 (const ACE_CDR::Octet *x); - ACE_CDR::Boolean write_2 (const ACE_CDR::UShort *x); - ACE_CDR::Boolean write_4 (const ACE_CDR::ULong *x); - ACE_CDR::Boolean write_8 (const ACE_CDR::ULongLong *x); - ACE_CDR::Boolean write_16 (const ACE_CDR::LongDouble *x); - - /** - * write an array of @a length elements, each of @a size bytes and the - * start aligned at a multiple of . The elements are assumed - * to be packed with the right alignment restrictions. It is mostly - * designed for buffers of the basic types. - * - * This operation uses ; as explained above it is expected - * that using assignment is faster that for one element, - * but for several elements should be more efficient, it - * could be interesting to find the break even point and optimize - * for that case, but that would be too platform dependent. - */ - ACE_CDR::Boolean write_array (const void *x, - size_t size, - size_t align, - ACE_CDR::ULong length); - - - ACE_CDR::Boolean write_wchar_array_i (const ACE_CDR::WChar* x, - ACE_CDR::ULong length); - - - /** - * Grow the CDR stream. When it returns @a buf contains a pointer to - * memory in the CDR stream, with at least @a size bytes ahead of it - * and aligned to an boundary. It moved the to . - */ - int grow_and_adjust (size_t size, - size_t align, - char *&buf); - -private: - /// The start of the chain of message blocks. - ACE_Message_Block start_; - - /// The current block in the chain where we are writing. - ACE_Message_Block *current_; - -#if !defined (ACE_LACKS_CDR_ALIGNMENT) - /** - * The current alignment as measured from the start of the buffer. - * Usually this coincides with the alignment of the buffer in - * memory, but, when we chain another buffer this "quasi invariant" - * is broken. - * The current_alignment is used to readjust the buffer following - * the stolen message block. - */ - size_t current_alignment_; -#endif /* ACE_LACKS_CDR_ALIGNMENT */ - - /** - * Is the current block writable. When we steal a buffer from the - * user and just chain it into the message block we are not supposed - * to write on it, even if it is past the start and end of the - * buffer. - */ - bool current_is_writable_; - - /** - * If not zero swap bytes at writing so the created CDR stream byte - * order does *not* match the machine byte order. The motivation - * for such a beast is that in some setting a few (fast) machines - * can be serving hundreds of slow machines with the opposite byte - * order, so it makes sense (as a load balancing device) to put the - * responsibility in the writers. THIS IS NOT A STANDARD IN CORBA, - * USE AT YOUR OWN RISK - */ - bool do_byte_swap_; - - /// Set to false when an error ocurrs. - bool good_bit_; - - /// Break-even point for copying. - size_t const memcpy_tradeoff_; - -protected: - /// GIOP version information - ACE_CDR::Octet major_version_; - ACE_CDR::Octet minor_version_; - - /// If not nil, invoke for translation of character and string data. - ACE_Char_Codeset_Translator *char_translator_; - ACE_WChar_Codeset_Translator *wchar_translator_; - - /** - * Some wide char codesets may be defined with a maximum number - * of bytes that is smaller than the size of a wchar_t. This means - * that the CDR cannot simply memcpy a block of wchars to and from - * the stream, but must instead realign the bytes appropriately. - * In cases when wchar i/o is not allowed, such as with GIOP 1.0, - * or not having a native wchar codeset defined, the maxbytes is - * set to zero, indicating no wchar data is allowed. - */ - static size_t wchar_maxbytes_; -}; - - -// **************************************************************** - -/** - * @class ACE_InputCDR - * - * @brief A CDR stream for reading, i.e. for demarshalling. - * - * This class is based on the the CORBA spec for Java (98-02-29), - * java class omg.org.CORBA.portable.InputStream. It diverts in a - * few ways: - * + Operations to retrieve basic types take parameters by - * reference. - * + Operations taking arrays don't have offsets, because in C++ - * it is easier to describe an array starting from x+offset. - * + Operations return an error status, because exceptions are - * not widely available in C++ (yet). - */ -class ACE_Export ACE_InputCDR -{ -public: - /// The translator need privileged access to efficiently demarshal - /// arrays and the such - friend class ACE_Char_Codeset_Translator; - friend class ACE_WChar_Codeset_Translator; - - /** - * Create an input stream from an arbitrary buffer. The buffer must - * be properly aligned because this contructor will *not* work if - * the buffer is aligned unproperly.See ACE_ptr_align_binary() for - * instructions on how to align a pointer properly and use - * ACE_CDR::MAX_ALIGNMENT for the correct alignment. - */ - ACE_InputCDR (const char *buf, - size_t bufsiz, - int byte_order = ACE_CDR_BYTE_ORDER, - ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION, - ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION); - - /// Create an empty input stream. The caller is responsible for - /// putting the right data and providing the right alignment. - ACE_InputCDR (size_t bufsiz, - int byte_order = ACE_CDR_BYTE_ORDER, - ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION, - ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION); - - /// Create an input stream from an ACE_Message_Block - /** - * The alignment of the @arg data block is carried into the new - * ACE_InputCDR object. This constructor either increments the - * @arg data reference count, or copies the data (if it's a compound - * message block) so the caller can release the block immediately - * upon return. - */ - ACE_InputCDR (const ACE_Message_Block *data, - int byte_order = ACE_CDR_BYTE_ORDER, - ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION, - ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION, - ACE_Lock* lock = 0); - - /// Create an input stream from an ACE_Data_Block. The - /// indicates whether the can be deleted by the CDR stream - /// or not - ACE_InputCDR (ACE_Data_Block *data, - ACE_Message_Block::Message_Flags flag = 0, - int byte_order = ACE_CDR_BYTE_ORDER, - ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION, - ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION); - - /// Create an input stream from an ACE_Data_Block. It also sets the - /// read and write pointers at the desired positions. This would be - /// helpful if the applications desires to create a new CDR stream - /// from a semi-processed datablock. - ACE_InputCDR (ACE_Data_Block *data, - ACE_Message_Block::Message_Flags flag, - size_t read_pointer_position, - size_t write_pointer_position, - int byte_order = ACE_CDR_BYTE_ORDER, - ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION, - ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION); - - /** - * These make a copy of the current stream state, but do not copy - * the internal buffer, so the same stream can be read multiple - * times efficiently. - */ - ACE_InputCDR (const ACE_InputCDR& rhs); - - ACE_InputCDR& operator= (const ACE_InputCDR& rhs); - - /// When interpreting indirected TypeCodes it is useful to make a - /// "copy" of the stream starting in the new position. - ACE_InputCDR (const ACE_InputCDR& rhs, - size_t size, - ACE_CDR::Long offset); - - /// This creates an encapsulated stream, the first byte must be (per - /// the spec) the byte order of the encapsulation. - ACE_InputCDR (const ACE_InputCDR& rhs, - size_t size); - - /// Create an input CDR from an output CDR. - ACE_InputCDR (const ACE_OutputCDR& rhs, - ACE_Allocator* buffer_allocator = 0, - ACE_Allocator* data_block_allocator = 0, - ACE_Allocator* message_block_allocator = 0); - - /// Helper class to transfer the contents from one input CDR to - /// another without requiring any extra memory allocations, data - /// copies or too many temporaries. - struct ACE_Export Transfer_Contents - { - Transfer_Contents (ACE_InputCDR &rhs); - - ACE_InputCDR &rhs_; - }; - /// Transfer the contents from to a new CDR - ACE_InputCDR (Transfer_Contents rhs); - - /// Destructor - ~ACE_InputCDR (void); - - /// Disambiguate overloading when extracting octets, chars, - /// booleans, and bounded strings - //@{ @name Helper classes - - struct ACE_Export to_boolean - { - explicit to_boolean (ACE_CDR::Boolean &b); - ACE_CDR::Boolean &ref_; - }; - - struct ACE_Export to_char - { - explicit to_char (ACE_CDR::Char &c); - ACE_CDR::Char &ref_; - }; - - struct ACE_Export to_wchar - { - explicit to_wchar (ACE_CDR::WChar &wc); - ACE_CDR::WChar &ref_; - }; - - struct ACE_Export to_octet - { - explicit to_octet (ACE_CDR::Octet &o); - ACE_CDR::Octet &ref_; - }; - - struct ACE_Export to_string - { - /** - * @deprecated The constructor taking a non-const string is now - * deprecated (C++ mapping 00-01-02), but we keep it - * around for backward compatibility. - */ - to_string (ACE_CDR::Char *&s, - ACE_CDR::ULong b); - to_string (const ACE_CDR::Char *&s, - ACE_CDR::ULong b); - const ACE_CDR::Char *&val_; - ACE_CDR::ULong bound_; - }; - - struct ACE_Export to_wstring - { - /// The constructor taking a non-const wstring is - /// now deprecated (C++ mapping 00-01-02), but we - /// keep it around for backward compatibility. - to_wstring (ACE_CDR::WChar *&ws, - ACE_CDR::ULong b); - to_wstring (const ACE_CDR::WChar *&ws, - ACE_CDR::ULong b); - const ACE_CDR::WChar *&val_; - ACE_CDR::ULong bound_; - }; - //@} - - /** - * Return @c false on failure and @c true on success. - */ - //@{ @name Read basic IDL types - ACE_CDR::Boolean read_boolean (ACE_CDR::Boolean& x); - ACE_CDR::Boolean read_char (ACE_CDR::Char &x); - ACE_CDR::Boolean read_wchar (ACE_CDR::WChar& x); - ACE_CDR::Boolean read_octet (ACE_CDR::Octet& x); - ACE_CDR::Boolean read_short (ACE_CDR::Short &x); - ACE_CDR::Boolean read_ushort (ACE_CDR::UShort &x); - ACE_CDR::Boolean read_long (ACE_CDR::Long &x); - ACE_CDR::Boolean read_ulong (ACE_CDR::ULong &x); - ACE_CDR::Boolean read_longlong (ACE_CDR::LongLong& x); - ACE_CDR::Boolean read_ulonglong (ACE_CDR::ULongLong& x); - ACE_CDR::Boolean read_float (ACE_CDR::Float &x); - ACE_CDR::Boolean read_double (ACE_CDR::Double &x); - ACE_CDR::Boolean read_longdouble (ACE_CDR::LongDouble &x); - - ACE_CDR::Boolean read_string (ACE_CDR::Char *&x); - ACE_CDR::Boolean read_string (ACE_CString &x); - ACE_CDR::Boolean read_wstring (ACE_CDR::WChar*& x); - //@} - - /** - * The buffer @a x must be large enough to contain @a length - * elements. - * Return @c false on failure and @c true on success. - */ - //@{ @name Read basic IDL types arrays - ACE_CDR::Boolean read_boolean_array (ACE_CDR::Boolean* x, - ACE_CDR::ULong length); - ACE_CDR::Boolean read_char_array (ACE_CDR::Char *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean read_wchar_array (ACE_CDR::WChar* x, - ACE_CDR::ULong length); - ACE_CDR::Boolean read_octet_array (ACE_CDR::Octet* x, - ACE_CDR::ULong length); - ACE_CDR::Boolean read_short_array (ACE_CDR::Short *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean read_ushort_array (ACE_CDR::UShort *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean read_long_array (ACE_CDR::Long *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean read_ulong_array (ACE_CDR::ULong *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean read_longlong_array (ACE_CDR::LongLong* x, - ACE_CDR::ULong length); - ACE_CDR::Boolean read_ulonglong_array (ACE_CDR::ULongLong* x, - ACE_CDR::ULong length); - ACE_CDR::Boolean read_float_array (ACE_CDR::Float *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean read_double_array (ACE_CDR::Double *x, - ACE_CDR::ULong length); - ACE_CDR::Boolean read_longdouble_array (ACE_CDR::LongDouble* x, - ACE_CDR::ULong length); - //@} - - /** - * Return @c false on failure and @c true on success. - */ - //@{ @name Skip elements - ACE_CDR::Boolean skip_boolean (void); - ACE_CDR::Boolean skip_char (void); - ACE_CDR::Boolean skip_wchar (void); - ACE_CDR::Boolean skip_octet (void); - ACE_CDR::Boolean skip_short (void); - ACE_CDR::Boolean skip_ushort (void); - ACE_CDR::Boolean skip_long (void); - ACE_CDR::Boolean skip_ulong (void); - ACE_CDR::Boolean skip_longlong (void); - ACE_CDR::Boolean skip_ulonglong (void); - ACE_CDR::Boolean skip_float (void); - ACE_CDR::Boolean skip_double (void); - ACE_CDR::Boolean skip_longdouble (void); - //@} - - /** - * The next field must be a string, this method skips it. It is - * useful in parsing a TypeCode. - * @return @c false on failure and @c true on success. - */ - ACE_CDR::Boolean skip_wstring (void); - ACE_CDR::Boolean skip_string (void); - - /// Skip @a n bytes in the CDR stream. - /** - * @return @c false on failure and @c true on success. - */ - ACE_CDR::Boolean skip_bytes (size_t n); - - /// returns @c false if a problem has been detected. - bool good_bit (void) const; - - /** - * @return The start of the message block chain for this CDR - * stream. - * - * @note In the current implementation the chain has length 1, but - * we are planning to change that. - */ - const ACE_Message_Block* start (void) const; - - // = The following functions are useful to read the contents of the - // CDR stream from a socket or file. - - /** - * Grow the internal buffer, reset @c rd_ptr to the first byte in - * the new buffer that is properly aligned, and set @c wr_ptr to @c - * rd_ptr @c + @c newsize - */ - int grow (size_t newsize); - - /** - * After reading and partially parsing the contents the user can - * detect a change in the byte order, this method will let him/her - * change it. - */ - void reset_byte_order (int byte_order); - - /// Re-initialize the CDR stream, copying the contents of the chain - /// of message_blocks starting from @a data. - void reset (const ACE_Message_Block *data, - int byte_order); - - /// Steal the contents from the current CDR. - ACE_Message_Block *steal_contents (void); - - /// Steal the contents of @a cdr and make a shallow copy into this - /// stream. - void steal_from (ACE_InputCDR &cdr); - - /// Exchange data blocks with the caller of this method. The read - /// and write pointers are also exchanged. - /** - * @note We now do only with the start_ message block. - */ - void exchange_data_blocks (ACE_InputCDR &cdr); - - /// Copy the data portion from the @c cdr to this cdr and return the - /// data content (ie. the ACE_Data_Block) from this CDR to the - /// caller. - /** - * @note The caller is responsible for managing the memory of the - * returned ACE_Data_Block. - */ - ACE_Data_Block* clone_from (ACE_InputCDR &cdr); - - /// Re-initialize the CDR stream, forgetting about the old contents - /// of the stream and allocating a new buffer (from the allocators). - void reset_contents (void); - - /// Returns the current position for the @c rd_ptr. - char* rd_ptr (void); - - /// Returns the current position for the @c wr_ptr. - char* wr_ptr (void); - - /// Return how many bytes are left in the stream. - size_t length (void) const; - - /** - * Utility function to allow the user more flexibility. - * Skips up to the nearest @a alignment-byte boundary. - * Argument MUST be a power of 2. - * - * @return 0 on success and -1 on failure. - */ - int align_read_ptr (size_t alignment); - - /// If @c true then this stream is writing in non-native byte order. - /// This is only meaningful if ACE_ENABLE_SWAP_ON_WRITE is defined. - bool do_byte_swap (void) const; - - /// If @c do_byte_swap() returns @c false, this returns - /// ACE_CDR_BYTE_ORDER else it returns !ACE_CDR_BYTE_ORDER. - int byte_order (void) const; - - /// Access the codeset translators. They can be nil! - ACE_Char_Codeset_Translator *char_translator (void) const; - ACE_WChar_Codeset_Translator *wchar_translator (void) const; - - /// Set the codeset translators. - void char_translator (ACE_Char_Codeset_Translator *); - void wchar_translator (ACE_WChar_Codeset_Translator *); - - /** - * Returns (in @a buf) the next position in the buffer aligned to - * @a size. It advances the Message_Block @c rd_ptr past the data - * (i.e., @c buf @c + @c size). Sets the good_bit to @c false and - * returns a -1 on failure. - */ - int adjust (size_t size, - char *&buf); - - /// As above, but now the size and alignment requirements may be - /// different. - int adjust (size_t size, - size_t align, - char *&buf); - - /// Set the underlying GIOP version.. - void set_version (ACE_CDR::Octet major, ACE_CDR::Octet minor); - - /// Set the underlying GIOP version.. - void get_version (ACE_CDR::Octet &major, ACE_CDR::Octet &minor); - -protected: - - /// The start of the chain of message blocks, even though in the - /// current version the chain always has length 1. - ACE_Message_Block start_; - - /// The CDR stream byte order does not match the one on the machine, - /// swapping is needed while reading. - bool do_byte_swap_; - - /// set to @c false when an error occurs. - bool good_bit_; - - /// The GIOP versions for this stream - ACE_CDR::Octet major_version_; - ACE_CDR::Octet minor_version_; - - /// If not nil, invoke for translation of character and string data. - ACE_Char_Codeset_Translator *char_translator_; - ACE_WChar_Codeset_Translator *wchar_translator_; - -private: - - ACE_CDR::Boolean read_1 (ACE_CDR::Octet *x); - ACE_CDR::Boolean read_2 (ACE_CDR::UShort *x); - ACE_CDR::Boolean read_4 (ACE_CDR::ULong *x); - ACE_CDR::Boolean read_8 (ACE_CDR::ULongLong *x); - ACE_CDR::Boolean read_16 (ACE_CDR::LongDouble *x); - - // Several types can be read using the same routines, since TAO - // tries to use native types with known size for each CORBA type. - // We could use void* or char* to make the interface more - // consistent, but using native types let us exploit the strict - // alignment requirements of CDR streams and implement the - // operations using asignment. - - /** - * Read an array of @a length elements, each of @a size bytes and the - * start aligned at a multiple of . The elements are assumed - * to be packed with the right alignment restrictions. It is mostly - * designed for buffers of the basic types. - * - * This operation uses ; as explained above it is expected - * that using assignment is faster that for one element, - * but for several elements should be more efficient, it - * could be interesting to find the break even point and optimize - * for that case, but that would be too platform dependent. - */ - ACE_CDR::Boolean read_array (void* x, - size_t size, - size_t align, - ACE_CDR::ULong length); - - /** - * On those occasions when the native codeset for wchar is smaller than - * the size of a wchar_t, such as using UTF-16 with a 4-byte wchar_t, a - * special form of reading the array is needed. Actually, this should be - * a default translator. - */ - ACE_CDR::Boolean read_wchar_array_i (ACE_CDR::WChar * x, - ACE_CDR::ULong length); - - /// Move the rd_ptr ahead by @a offset bytes. - void rd_ptr (size_t offset); - - /// Points to the continuation field of the current message block. - char* end (void); -}; - -// **************************************************************** - -/** - * @class ACE_Char_Codeset_Translator - * - * @brief Codeset translation routines common to both Output and Input - * CDR streams. - * - * This class is a base class for defining codeset translation - * routines to handle the character set translations required by - * both CDR Input streams and CDR Output streams. - * - * Translators are reference counted. This allows for stateful as well - * as stateless translators. Stateless translators will be allocated - * once whereas CDR Streams own their own copy of a stateful translator. - */ -class ACE_Export ACE_Char_Codeset_Translator -{ -public: - virtual ~ACE_Char_Codeset_Translator (); - - /// Read a single character from the stream, converting from the - /// stream codeset to the native codeset - virtual ACE_CDR::Boolean read_char (ACE_InputCDR&, - ACE_CDR::Char&) = 0; - - /// Read a string from the stream, including the length, converting - /// the characters from the stream codeset to the native codeset - virtual ACE_CDR::Boolean read_string (ACE_InputCDR&, - ACE_CDR::Char *&) = 0; - - /// Read an array of characters from the stream, converting the - /// characters from the stream codeset to the native codeset. - virtual ACE_CDR::Boolean read_char_array (ACE_InputCDR&, - ACE_CDR::Char*, - ACE_CDR::ULong) = 0; - - /// Write a single character to the stream, converting from the - /// native codeset to the stream codeset - virtual ACE_CDR::Boolean write_char (ACE_OutputCDR&, - ACE_CDR::Char) = 0; - - /// Write a string to the stream, including the length, converting - /// from the native codeset to the stream codeset - virtual ACE_CDR::Boolean write_string (ACE_OutputCDR&, - ACE_CDR::ULong, - const ACE_CDR::Char*) = 0; - - /// Write an array of characters to the stream, converting from the - /// native codeset to the stream codeset - virtual ACE_CDR::Boolean write_char_array (ACE_OutputCDR&, - const ACE_CDR::Char*, - ACE_CDR::ULong) = 0; - - virtual ACE_CDR::ULong ncs () = 0; - virtual ACE_CDR::ULong tcs () = 0; -protected: - /// Children have access to low-level routines because they cannot - /// use read_char or something similar (it would recurse). - ACE_CDR::Boolean read_1 (ACE_InputCDR& input, - ACE_CDR::Octet *x); - ACE_CDR::Boolean write_1 (ACE_OutputCDR& output, - const ACE_CDR::Octet *x); - - /// Efficiently read @a length elements of size @a size each from - /// into ; the data must be aligned to . - ACE_CDR::Boolean read_array (ACE_InputCDR& input, - void* x, - size_t size, - size_t align, - ACE_CDR::ULong length); - - /** - * Efficiently write @a length elements of size @a size from into - * . Before inserting the elements enough padding is added - * to ensure that the elements will be aligned to in the - * stream. - */ - ACE_CDR::Boolean write_array (ACE_OutputCDR& output, - const void *x, - size_t size, - size_t align, - ACE_CDR::ULong length); - - /** - * Exposes the stream implementation of , this is useful in - * many cases to minimize memory allocations during marshaling. - * On success @a buf will contain a contiguous area in the CDR stream - * that can hold @a size bytes aligned to . - * Results - */ - int adjust (ACE_OutputCDR& out, - size_t size, - size_t align, - char *&buf); - - /// Used by derived classes to set errors in the CDR stream. - void good_bit (ACE_OutputCDR& out, bool bit); - - /// Obtain the CDR Stream's major & minor version values. - ACE_CDR::Octet major_version (ACE_InputCDR& input); - ACE_CDR::Octet minor_version (ACE_InputCDR& input); - ACE_CDR::Octet major_version (ACE_OutputCDR& output); - ACE_CDR::Octet minor_version (ACE_OutputCDR& output); -}; - -// **************************************************************** - -/** - * @class ACE_WChar_Codeset_Translator - * - * @brief Codeset translation routines common to both Output and Input - * CDR streams. - * - * This class is a base class for defining codeset translation - * routines to handle the character set translations required by - * both CDR Input streams and CDR Output streams. - */ -class ACE_Export ACE_WChar_Codeset_Translator -{ -public: - virtual ~ACE_WChar_Codeset_Translator (); - - virtual ACE_CDR::Boolean read_wchar (ACE_InputCDR&, - ACE_CDR::WChar&) = 0; - virtual ACE_CDR::Boolean read_wstring (ACE_InputCDR&, - ACE_CDR::WChar *&) = 0; - virtual ACE_CDR::Boolean read_wchar_array (ACE_InputCDR&, - ACE_CDR::WChar*, - ACE_CDR::ULong) = 0; - virtual ACE_CDR::Boolean write_wchar (ACE_OutputCDR&, - ACE_CDR::WChar) = 0; - virtual ACE_CDR::Boolean write_wstring (ACE_OutputCDR&, - ACE_CDR::ULong, - const ACE_CDR::WChar*) = 0; - virtual ACE_CDR::Boolean write_wchar_array (ACE_OutputCDR&, - const ACE_CDR::WChar*, - ACE_CDR::ULong) = 0; - - virtual ACE_CDR::ULong ncs () = 0; - virtual ACE_CDR::ULong tcs () = 0; -protected: - /// Children have access to low-level routines because they cannot - /// use read_char or something similar (it would recurse). - ACE_CDR::Boolean read_1 (ACE_InputCDR& input, - ACE_CDR::Octet *x); - ACE_CDR::Boolean read_2 (ACE_InputCDR& input, - ACE_CDR::UShort *x); - ACE_CDR::Boolean read_4 (ACE_InputCDR& input, - ACE_CDR::ULong *x); - ACE_CDR::Boolean write_1 (ACE_OutputCDR& output, - const ACE_CDR::Octet *x); - ACE_CDR::Boolean write_2 (ACE_OutputCDR& output, - const ACE_CDR::UShort *x); - ACE_CDR::Boolean write_4 (ACE_OutputCDR& output, - const ACE_CDR::ULong *x); - - /// Efficiently read @a length elements of size @a size each from - /// into ; the data must be aligned to . - ACE_CDR::Boolean read_array (ACE_InputCDR& input, - void* x, - size_t size, - size_t align, - ACE_CDR::ULong length); - - /** - * Efficiently write @a length elements of size @a size from into - * . Before inserting the elements enough padding is added - * to ensure that the elements will be aligned to in the - * stream. - */ - ACE_CDR::Boolean write_array (ACE_OutputCDR& output, - const void *x, - size_t size, - size_t align, - ACE_CDR::ULong length); - - /** - * Exposes the stream implementation of , this is useful in - * many cases to minimize memory allocations during marshaling. - * On success @a buf will contain a contiguous area in the CDR stream - * that can hold @a size bytes aligned to . - * Results - */ - int adjust (ACE_OutputCDR& out, - size_t size, - size_t align, - char *&buf); - - /// Used by derived classes to set errors in the CDR stream. - void good_bit (ACE_OutputCDR& out, bool bit); - - /// Obtain the CDR Stream's major & minor version values. - ACE_CDR::Octet major_version (ACE_InputCDR& input); - ACE_CDR::Octet minor_version (ACE_InputCDR& input); - ACE_CDR::Octet major_version (ACE_OutputCDR& output); - ACE_CDR::Octet minor_version (ACE_OutputCDR& output); - -}; - -// @@ These operators should not be inlined since they force SString.h -// to be included in this header. -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - const ACE_CString &x); - -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - ACE_CString &x); - - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -# include "ace/CDR_Stream.inl" -#else /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Not used by CORBA or TAO -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - ACE_CDR::Char x); -// CDR output operators for primitive types - -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - ACE_CDR::Short x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - ACE_CDR::UShort x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - ACE_CDR::Long x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - ACE_CDR::ULong x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - ACE_CDR::LongLong x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - ACE_CDR::ULongLong x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR& os, - ACE_CDR::LongDouble x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - ACE_CDR::Float x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - ACE_CDR::Double x); - -// CDR output operator from helper classes - -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - ACE_OutputCDR::from_boolean x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - ACE_OutputCDR::from_char x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - ACE_OutputCDR::from_wchar x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - ACE_OutputCDR::from_octet x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - ACE_OutputCDR::from_string x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - ACE_OutputCDR::from_wstring x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - const ACE_CDR::Char* x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - const ACE_CDR::WChar* x); - -// Not used by CORBA or TAO -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - ACE_CDR::Char &x); -// CDR input operators for primitive types - -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - ACE_CDR::Short &x); -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - ACE_CDR::UShort &x); -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - ACE_CDR::Long &x); -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - ACE_CDR::ULong &x); -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - ACE_CDR::LongLong &x); -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - ACE_CDR::ULongLong &x); -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - ACE_CDR::LongDouble &x); -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - ACE_CDR::Float &x); -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - ACE_CDR::Double &x); - -// CDR input operator from helper classes - -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - ACE_InputCDR::to_boolean x); -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - ACE_InputCDR::to_char x); -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - ACE_InputCDR::to_wchar x); -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - ACE_InputCDR::to_octet x); -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - ACE_InputCDR::to_string x); -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - ACE_InputCDR::to_wstring x); -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - ACE_CDR::Char*& x); -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - ACE_CDR::WChar*& x); - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* __ACE_INLINE__ */ - -#if defined (GEN_OSTREAM_OPS) - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// ostream insertion operators for debugging code generated from IDL. All -// but these below are either in generated code itself or are unambiguous -// primitive types. - -ACE_Export std::ostream& operator<< (std::ostream &os, - ACE_OutputCDR::from_boolean x); - -ACE_Export std::ostream& operator<< (std::ostream &os, - ACE_OutputCDR::from_char x); - -ACE_Export std::ostream& operator<< (std::ostream &os, - ACE_OutputCDR::from_wchar x); - -ACE_Export std::ostream& operator<< (std::ostream &os, - ACE_OutputCDR::from_octet x); - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* GEN_OSTREAM_OPS */ - -#include /**/ "ace/post.h" - -#endif /* ACE_CDR_STREAM_H */ diff --git a/ACE/ace/CDR_Stream.inl b/ACE/ace/CDR_Stream.inl deleted file mode 100644 index 9f13889237f..00000000000 --- a/ACE/ace/CDR_Stream.inl +++ /dev/null @@ -1,1700 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/OS_NS_string.h" -#include "ace/OS_Memory.h" - -// **************************************************************** - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// implementing the special types -ACE_INLINE -ACE_OutputCDR::from_boolean::from_boolean (ACE_CDR::Boolean b) - : val_ (b) -{ -} - -ACE_INLINE -ACE_InputCDR::to_boolean::to_boolean (ACE_CDR::Boolean &b) - : ref_ (b) -{ -} - -ACE_INLINE -ACE_OutputCDR::from_octet::from_octet (ACE_CDR::Octet o) - : val_ (o) -{ -} - -ACE_INLINE -ACE_InputCDR::to_octet::to_octet (ACE_CDR::Octet &o) - : ref_ (o) -{ -} - -ACE_INLINE -ACE_OutputCDR::from_char::from_char (ACE_CDR::Char c) - : val_ (c) -{ -} - -ACE_INLINE -ACE_InputCDR::to_char::to_char (ACE_CDR::Char &c) - : ref_ (c) -{ -} - -ACE_INLINE -ACE_OutputCDR::from_wchar::from_wchar (ACE_CDR::WChar wc) - : val_ (wc) -{ -} - -ACE_INLINE -ACE_InputCDR::to_wchar::to_wchar (ACE_CDR::WChar &wc) - : ref_ (wc) -{ -} - -ACE_INLINE -ACE_OutputCDR::from_string::from_string (ACE_CDR::Char *s, - ACE_CDR::ULong b, - ACE_CDR::Boolean nocopy) - : val_ (s), - bound_ (b), - nocopy_ (nocopy) -{ -} - -ACE_INLINE -ACE_OutputCDR::from_string::from_string (const ACE_CDR::Char *s, - ACE_CDR::ULong b, - ACE_CDR::Boolean nocopy) - : val_ (const_cast (s)), - bound_ (b), - nocopy_ (nocopy) -{ -} - -ACE_INLINE -ACE_InputCDR::to_string::to_string (ACE_CDR::Char *&s, - ACE_CDR::ULong b) - : val_ (const_cast (s)), - bound_ (b) -{ -} - -ACE_INLINE -ACE_InputCDR::to_string::to_string (const ACE_CDR::Char *&s, - ACE_CDR::ULong b) - : val_ (s), - bound_ (b) -{ -} - -ACE_INLINE -ACE_OutputCDR::from_wstring::from_wstring (ACE_CDR::WChar *ws, - ACE_CDR::ULong b, - ACE_CDR::Boolean nocopy) - : val_ (ws), - bound_ (b), - nocopy_ (nocopy) -{ -} - -ACE_INLINE -ACE_OutputCDR::from_wstring::from_wstring (const ACE_CDR::WChar *ws, - ACE_CDR::ULong b, - ACE_CDR::Boolean nocopy) - : val_ (const_cast (ws)), - bound_ (b), - nocopy_ (nocopy) -{ -} - -ACE_INLINE -ACE_InputCDR::to_wstring::to_wstring (ACE_CDR::WChar *&ws, - ACE_CDR::ULong b) - : val_ (const_cast (ws)), - bound_ (b) -{ -} - -ACE_INLINE -ACE_InputCDR::to_wstring::to_wstring (const ACE_CDR::WChar *&ws, - ACE_CDR::ULong b) - : val_ (ws), - bound_ (b) -{ -} - -ACE_INLINE -ACE_InputCDR::Transfer_Contents::Transfer_Contents (ACE_InputCDR &rhs) - : rhs_ (rhs) -{ -} - -// **************************************************************** - -ACE_INLINE -ACE_OutputCDR::~ACE_OutputCDR (void) -{ - if (this->start_.cont () != 0) - { - ACE_Message_Block::release (this->start_.cont ()); - this->start_.cont (0); - } - this->current_ = 0; -} - -ACE_INLINE void -ACE_OutputCDR::reset (void) -{ - this->current_ = &this->start_; - this->current_is_writable_ = true; - ACE_CDR::mb_align (&this->start_); - -#if !defined (ACE_LACKS_CDR_ALIGNMENT) - this->current_alignment_ = 0; -#endif /* ACE_LACKS_CDR_ALIGNMENT */ - - // It is tempting not to remove the memory, but we need to do so to - // release any potential user buffers chained in the continuation - // field. - - ACE_Message_Block * const cont = this->start_.cont (); - if (cont) - { - ACE_Message_Block::release (cont); - this->start_.cont (0); - } -} - -// Encode the CDR stream. - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_octet (ACE_CDR::Octet x) -{ - return this->write_1 (&x); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_boolean (ACE_CDR::Boolean x) -{ - return - static_cast ( - this->write_octet ( - x - ? static_cast (1) - : static_cast (0))); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_char (ACE_CDR::Char x) -{ - if (this->char_translator_ == 0) - { - ACE_CDR::Octet temp = static_cast (x); - return this->write_1 (&temp); - } - return this->char_translator_->write_char (*this, x); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_short (ACE_CDR::Short x) -{ - ACE_CDR::UShort temp = static_cast (x); - return this->write_2 (&temp); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_ushort (ACE_CDR::UShort x) -{ - return this->write_2 (&x); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_long (ACE_CDR::Long x) -{ - ACE_CDR::ULong temp = static_cast (x); - return this->write_4 (&temp); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_ulong (ACE_CDR::ULong x) -{ - return this->write_4 (&x); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_longlong (const ACE_CDR::LongLong &x) -{ - void const * const temp = &x; - return this->write_8 (reinterpret_cast (temp)); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_ulonglong (const ACE_CDR::ULongLong &x) -{ - return this->write_8 (&x); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_float (ACE_CDR::Float x) -{ - void const * const temp = &x; - return this->write_4 (reinterpret_cast (temp)); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_double (const ACE_CDR::Double &x) -{ - void const * const temp = &x; - return this->write_8 (reinterpret_cast (temp)); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_longdouble (const ACE_CDR::LongDouble &x) -{ - return this->write_16 (&x); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_string (const ACE_CDR::Char *x) -{ - if (x) - { - ACE_CDR::ULong const len = - static_cast (ACE_OS::strlen (x)); - return this->write_string (len, x); - } - - return this->write_string (0, 0); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_wstring (const ACE_CDR::WChar *x) -{ - if (x) - { - ACE_CDR::ULong const len = - static_cast (ACE_OS::strlen (x)); - return this->write_wstring (len, x); - } - - return this->write_wstring (0, 0); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_char_array (const ACE_CDR::Char *x, - ACE_CDR::ULong length) -{ - if (this->char_translator_ == 0) - return this->write_array (x, - ACE_CDR::OCTET_SIZE, - ACE_CDR::OCTET_ALIGN, - length); - return this->char_translator_->write_char_array (*this, x, length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_wchar_array (const ACE_CDR::WChar* x, - ACE_CDR::ULong length) -{ - if (this->wchar_translator_) - return this->wchar_translator_->write_wchar_array (*this, x, length); - - if (ACE_OutputCDR::wchar_maxbytes_ == 0) - { - errno = EACCES; - return (ACE_CDR::Boolean) (this->good_bit_ = false); - } - - if (ACE_OutputCDR::wchar_maxbytes_ == sizeof (ACE_CDR::WChar)) - return this->write_array (x, - sizeof (ACE_CDR::WChar), - sizeof (ACE_CDR::WChar) == 2 - ? ACE_CDR::SHORT_ALIGN - : ACE_CDR::LONG_ALIGN, - length); - return this->write_wchar_array_i (x,length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_octet_array (const ACE_CDR::Octet* x, - ACE_CDR::ULong length) -{ - return this->write_array (x, - ACE_CDR::OCTET_SIZE, - ACE_CDR::OCTET_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_short_array (const ACE_CDR::Short *x, - ACE_CDR::ULong length) -{ - return this->write_array (x, - ACE_CDR::SHORT_SIZE, - ACE_CDR::SHORT_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_ushort_array (const ACE_CDR::UShort *x, - ACE_CDR::ULong length) -{ - return this->write_array (x, - ACE_CDR::SHORT_SIZE, - ACE_CDR::SHORT_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_long_array (const ACE_CDR::Long *x, - ACE_CDR::ULong length) -{ - return this->write_array (x, - ACE_CDR::LONG_SIZE, - ACE_CDR::LONG_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_ulong_array (const ACE_CDR::ULong *x, - ACE_CDR::ULong length) -{ - return this->write_array (x, - ACE_CDR::LONG_SIZE, - ACE_CDR::LONG_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_longlong_array (const ACE_CDR::LongLong *x, - ACE_CDR::ULong length) -{ - return this->write_array (x, - ACE_CDR::LONGLONG_SIZE, - ACE_CDR::LONGLONG_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_ulonglong_array (const ACE_CDR::ULongLong *x, - ACE_CDR::ULong length) -{ - return this->write_array (x, - ACE_CDR::LONGLONG_SIZE, - ACE_CDR::LONGLONG_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_float_array (const ACE_CDR::Float *x, - ACE_CDR::ULong length) -{ - return this->write_array (x, - ACE_CDR::LONG_SIZE, - ACE_CDR::LONG_ALIGN, - length); -} - - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_double_array (const ACE_CDR::Double *x, - ACE_CDR::ULong length) -{ - return this->write_array (x, - ACE_CDR::LONGLONG_SIZE, - ACE_CDR::LONGLONG_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_longdouble_array (const ACE_CDR::LongDouble* x, - ACE_CDR::ULong length) -{ - return this->write_array (x, - ACE_CDR::LONGDOUBLE_SIZE, - ACE_CDR::LONGDOUBLE_ALIGN, - length); -} - -ACE_INLINE bool -ACE_OutputCDR::good_bit (void) const -{ - return this->good_bit_; -} - -ACE_INLINE int -ACE_OutputCDR::adjust (size_t size, - size_t align, - char*& buf) -{ - if (!this->current_is_writable_) - return this->grow_and_adjust (size, align, buf); - -#if !defined (ACE_LACKS_CDR_ALIGNMENT) - size_t const offset = - ACE_align_binary (this->current_alignment_, align) - - this->current_alignment_; - - buf = this->current_->wr_ptr () + offset; -#else - buf = this->current_->wr_ptr (); -#endif /* ACE_LACKS_CDR_ALIGNMENT */ - - char * const end = buf + size; - - if (end <= this->current_->end () && - end >= buf) - { -#if !defined (ACE_LACKS_CDR_ALIGNMENT) - this->current_alignment_ += offset + size; -#endif /* ACE_LACKS_CDR_ALIGNMENT */ - this->current_->wr_ptr (end); - return 0; - } - - return this->grow_and_adjust (size, align, buf); -} - -ACE_INLINE int -ACE_OutputCDR::adjust (size_t size, char*& buf) -{ - return this->adjust (size, size, buf); -} - -ACE_INLINE void -ACE_OutputCDR::set_version (ACE_CDR::Octet major, ACE_CDR::Octet minor) -{ - this->major_version_ = major; - this->minor_version_ = minor; -} - -ACE_INLINE void -ACE_OutputCDR::get_version (ACE_CDR::Octet &major, ACE_CDR::Octet &minor) -{ - major = this->major_version_; - minor = this->minor_version_; -} - - -ACE_INLINE const ACE_Message_Block* -ACE_OutputCDR::begin (void) const -{ - return &this->start_; -} - -ACE_INLINE const ACE_Message_Block* -ACE_OutputCDR::end (void) const -{ - return this->current_->cont (); -} - -ACE_INLINE const ACE_Message_Block* -ACE_OutputCDR::current (void) const -{ - return this->current_; -} - -ACE_INLINE size_t -ACE_OutputCDR::total_length (void) const -{ - return ACE_CDR::total_length (this->begin (), this->end ()); -} - -ACE_INLINE const char* -ACE_OutputCDR::buffer (void) const -{ - return this->start_.rd_ptr (); -} - -ACE_INLINE size_t -ACE_OutputCDR::length (void) const -{ - return this->start_.length (); -} - -ACE_INLINE bool -ACE_OutputCDR::do_byte_swap (void) const -{ - return this->do_byte_swap_; -} - -ACE_INLINE int -ACE_OutputCDR::byte_order (void) const -{ - if (this->do_byte_swap ()) - return !ACE_CDR_BYTE_ORDER; - else - return ACE_CDR_BYTE_ORDER; -} - -ACE_INLINE void -ACE_OutputCDR::reset_byte_order (int byte_order) -{ - this->do_byte_swap_ = (byte_order != ACE_CDR_BYTE_ORDER); -} - -ACE_INLINE size_t -ACE_OutputCDR::current_alignment (void) const -{ -#if !defined (ACE_LACKS_CDR_ALIGNMENT) - return this->current_alignment_; -#else - // Default value set to 0 - return 0; -#endif /* ACE_LACKS_CDR_ALIGNMENT */ -} - -ACE_INLINE int -ACE_OutputCDR::align_write_ptr (size_t alignment) -{ -#if !defined (ACE_LACKS_CDR_ALIGNMENT) - char *dummy; - return this->adjust (0, alignment, dummy); -#else - ACE_UNUSED_ARG (alignment); - // A return value of -1 from this function is used - // to indicate failure, returning 0 - return 0; -#endif /* ACE_LACKS_CDR_ALIGNMENT */ -} - -ACE_INLINE ACE_Char_Codeset_Translator * -ACE_OutputCDR::char_translator (void) const -{ - return this->char_translator_; -} - -ACE_INLINE ACE_WChar_Codeset_Translator * -ACE_OutputCDR::wchar_translator (void) const -{ - return this->wchar_translator_; -} - -ACE_INLINE void -ACE_OutputCDR::char_translator (ACE_Char_Codeset_Translator * ctran) -{ - this->char_translator_ = ctran; -} - -ACE_INLINE void -ACE_OutputCDR::wchar_translator (ACE_WChar_Codeset_Translator * wctran) -{ - this->wchar_translator_ = wctran; -} - -// **************************************************************** - -ACE_INLINE -ACE_InputCDR::~ACE_InputCDR (void) -{ -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_octet (ACE_CDR::Octet& x) -{ - return this->read_1 (&x); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_boolean (ACE_CDR::Boolean& x) -{ - ACE_CDR::Octet tmp = 0; - (void) this->read_octet (tmp); - x = tmp ? true : false; - return (ACE_CDR::Boolean) this->good_bit_; -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_char (ACE_CDR::Char &x) -{ - if (this->char_translator_ == 0) - { - void *temp = &x; - return this->read_1 (reinterpret_cast (temp)); - } - return this->char_translator_->read_char (*this, x); -} - - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_short (ACE_CDR::Short &x) -{ - void *temp = &x; - return this->read_2 (reinterpret_cast (temp)); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_ushort (ACE_CDR::UShort &x) -{ - return this->read_2 (&x); -} - - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_long (ACE_CDR::Long &x) -{ - void *temp = &x; - return this->read_4 (reinterpret_cast (temp)); -} - - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_ulong (ACE_CDR::ULong &x) -{ - return this->read_4 (&x); -} - - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_longlong (ACE_CDR::LongLong &x) -{ - void *temp = &x; - return this->read_8 (reinterpret_cast (temp)); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_ulonglong (ACE_CDR::ULongLong &x) -{ - return this->read_8 (&x); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_float (ACE_CDR::Float &x) -{ - void *temp = &x; - return this->read_4 (reinterpret_cast (temp)); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_double (ACE_CDR::Double &x) -{ - void *temp = &x; - return this->read_8 (reinterpret_cast (temp)); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_longdouble (ACE_CDR::LongDouble &x) -{ - return this->read_16 (&x); -} - -ACE_INLINE size_t -ACE_InputCDR::length (void) const -{ - return this->start_.length (); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_char_array (ACE_CDR::Char* x, - ACE_CDR::ULong length) -{ - // Make sure the length of the array isn't greater than the length of - // the stream. - if (length > this->length ()) - { - this->good_bit_ = false; - return false; - } - - if (this->char_translator_ == 0) - return this->read_array (x, - ACE_CDR::OCTET_SIZE, - ACE_CDR::OCTET_ALIGN, - length); - return this->char_translator_->read_char_array (*this, x, length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_wchar_array (ACE_CDR::WChar* x, - ACE_CDR::ULong length) -{ - // Make sure the length of the array isn't greater than the length of - // the stream. - if (length * ACE_OutputCDR::wchar_maxbytes_ > this->length ()) - { - this->good_bit_ = false; - return false; - } - - if (this->wchar_translator_ != 0) - return this->wchar_translator_->read_wchar_array (*this, x, length); - if (ACE_OutputCDR::wchar_maxbytes_ != sizeof (ACE_CDR::WChar)) - return this->read_wchar_array_i (x, length); - return this->read_array (x, - sizeof (ACE_CDR::WChar), - sizeof (ACE_CDR::WChar) == 2 - ? ACE_CDR::SHORT_ALIGN - : ACE_CDR::LONG_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_octet_array (ACE_CDR::Octet* x, - ACE_CDR::ULong length) -{ - // Make sure the length of the array isn't greater than the length of - // the stream. - if (length * ACE_CDR::OCTET_SIZE > this->length ()) - { - this->good_bit_ = false; - return false; - } - - return this->read_array (x, - ACE_CDR::OCTET_SIZE, - ACE_CDR::OCTET_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_short_array (ACE_CDR::Short *x, - ACE_CDR::ULong length) -{ - // Make sure the length of the array isn't greater than the length of - // the stream. - if (length * ACE_CDR::SHORT_SIZE > this->length ()) - { - this->good_bit_ = false; - return false; - } - - return this->read_array (x, - ACE_CDR::SHORT_SIZE, - ACE_CDR::SHORT_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_ushort_array (ACE_CDR::UShort *x, - ACE_CDR::ULong length) -{ - // Make sure the length of the array isn't greater than the length of - // the stream. - if (length * ACE_CDR::SHORT_SIZE > this->length ()) - { - this->good_bit_ = false; - return false; - } - - return this->read_array (x, - ACE_CDR::SHORT_SIZE, - ACE_CDR::SHORT_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_long_array (ACE_CDR::Long *x, - ACE_CDR::ULong length) -{ - // Make sure the length of the array isn't greater than the length of - // the stream. - if (length * ACE_CDR::LONG_SIZE > this->length ()) - { - this->good_bit_ = false; - return false; - } - - return this->read_array (x, - ACE_CDR::LONG_SIZE, - ACE_CDR::LONG_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_ulong_array (ACE_CDR::ULong *x, - ACE_CDR::ULong length) -{ - // Make sure the length of the array isn't greater than the length of - // the stream. - if (length * ACE_CDR::LONG_SIZE > this->length ()) - { - this->good_bit_ = false; - return false; - } - - return this->read_array (x, - ACE_CDR::LONG_SIZE, - ACE_CDR::LONG_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_longlong_array (ACE_CDR::LongLong *x, - ACE_CDR::ULong length) -{ - // Make sure the length of the array isn't greater than the length of - // the stream. - if (length * ACE_CDR::LONGLONG_SIZE > this->length ()) - { - this->good_bit_ = false; - return false; - } - - return this->read_array (x, - ACE_CDR::LONGLONG_SIZE, - ACE_CDR::LONGLONG_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_ulonglong_array (ACE_CDR::ULongLong *x, - ACE_CDR::ULong length) -{ - // Make sure the length of the array isn't greater than the length of - // the stream. - if (length * ACE_CDR::LONGLONG_SIZE > this->length ()) - { - this->good_bit_ = false; - return false; - } - - return this->read_array (x, - ACE_CDR::LONGLONG_SIZE, - ACE_CDR::LONGLONG_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_float_array (ACE_CDR::Float *x, - ACE_CDR::ULong length) -{ - // Make sure the length of the array isn't greater than the length of - // the stream. - if (length * ACE_CDR::LONG_SIZE > this->length ()) - { - this->good_bit_ = false; - return false; - } - - return this->read_array (x, - ACE_CDR::LONG_SIZE, - ACE_CDR::LONG_ALIGN, - length); -} - - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_double_array (ACE_CDR::Double *x, - ACE_CDR::ULong length) -{ - // Make sure the length of the array isn't greater than the length of - // the stream. - if (length * ACE_CDR::LONGLONG_SIZE > this->length ()) - { - this->good_bit_ = false; - return false; - } - - return this->read_array (x, - ACE_CDR::LONGLONG_SIZE, - ACE_CDR::LONGLONG_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_longdouble_array (ACE_CDR::LongDouble* x, - ACE_CDR::ULong length) -{ - // Make sure the length of the array isn't greater than the length of - // the stream. - if (length * ACE_CDR::LONGDOUBLE_SIZE > this->length ()) - { - this->good_bit_ = false; - return false; - } - return this->read_array (x, - ACE_CDR::LONGDOUBLE_SIZE, - ACE_CDR::LONGDOUBLE_ALIGN, - length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::skip_octet (void) -{ - ACE_CDR::Octet x; - return this->read_1 (&x); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::skip_char (void) -{ - return this->skip_octet (); // sizeof (Char) == sizeof (Octet) -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::skip_boolean (void) -{ - return this->skip_octet () && this->good_bit_; -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::skip_ushort (void) -{ - ACE_CDR::UShort x; - return this->read_2 (&x); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::skip_short (void) -{ - return this->skip_ushort (); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::skip_ulong (void) -{ - ACE_CDR::ULong x; - return this->read_4 (&x); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::skip_long (void) -{ - return this->skip_ulong (); // sizeof (Long) == sizeof (ULong) -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::skip_ulonglong (void) -{ - ACE_CDR::ULongLong x; - return this->read_8 (&x); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::skip_longlong (void) -{ - return this->skip_ulonglong (); // sizeof (LongLong) == sizeof (ULongLong) -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::skip_float (void) -{ - return this->skip_ulong (); // sizeof(Float) == sizeof (ULong) -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::skip_double (void) -{ - return this->skip_ulonglong (); // sizeof(Double) == sizeof (ULongLong) -} - -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::skip_longdouble (void) -{ - ACE_CDR::LongDouble x; - return this->read_16 (&x); -} - -ACE_INLINE char* -ACE_InputCDR::end (void) -{ - return this->start_.end (); -} - -ACE_INLINE void -ACE_InputCDR::rd_ptr (size_t offset) -{ - this->start_.rd_ptr (offset); -} - -ACE_INLINE char* -ACE_InputCDR::rd_ptr (void) -{ - return this->start_.rd_ptr (); -} - -ACE_INLINE char* -ACE_InputCDR::wr_ptr (void) -{ - return this->start_.wr_ptr (); -} - -ACE_INLINE int -ACE_InputCDR::adjust (size_t size, - size_t align, - char*& buf) -{ -#if !defined (ACE_LACKS_CDR_ALIGNMENT) - buf = ACE_ptr_align_binary (this->rd_ptr (), align); -#else - buf = this->rd_ptr (); -#endif /* ACE_LACKS_CDR_ALIGNMENT */ - - char * const end = buf + size; - if (end <= this->wr_ptr ()) - { - this->start_.rd_ptr (end); - return 0; - } - - this->good_bit_ = false; - return -1; -#if defined (ACE_LACKS_CDR_ALIGNMENT) - ACE_UNUSED_ARG (align); -#endif /* ACE_LACKS_CDR_ALIGNMENT */ -} - -ACE_INLINE int -ACE_InputCDR::adjust (size_t size, - char*& buf) -{ - return this->adjust (size, size, buf); -} - -ACE_INLINE const ACE_Message_Block* -ACE_InputCDR::start (void) const -{ - return &this->start_; -} - -ACE_INLINE bool -ACE_InputCDR::good_bit (void) const -{ - return this->good_bit_; -} - -// **************************************************************** - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, ACE_CDR::Char x) -{ - os.write_char (x); - return (ACE_CDR::Boolean) os.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, ACE_CDR::Short x) -{ - os.write_short (x); - return (ACE_CDR::Boolean) os.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, ACE_CDR::UShort x) -{ - os.write_ushort (x); - return (ACE_CDR::Boolean) os.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, ACE_CDR::Long x) -{ - os.write_long (x); - return (ACE_CDR::Boolean) os.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, ACE_CDR::ULong x) -{ - os.write_ulong (x); - return (ACE_CDR::Boolean) os.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, ACE_CDR::LongLong x) -{ - os.write_longlong (x); - return (ACE_CDR::Boolean) os.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, ACE_CDR::ULongLong x) -{ - os.write_ulonglong (x); - return (ACE_CDR::Boolean) os.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, ACE_CDR::LongDouble x) -{ - os.write_longdouble (x); - return (ACE_CDR::Boolean) os.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, ACE_CDR::Float x) -{ - os.write_float (x); - return (ACE_CDR::Boolean) os.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, ACE_CDR::Double x) -{ - os.write_double (x); - return (ACE_CDR::Boolean) os.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, const ACE_CDR::Char *x) -{ - os.write_string (x); - return (ACE_CDR::Boolean) os.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, const ACE_CDR::WChar *x) -{ - os.write_wstring (x); - return (ACE_CDR::Boolean) os.good_bit (); -} - -// The following use the helper classes -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_boolean x) -{ - (void) os.write_boolean (x.val_); - return (ACE_CDR::Boolean) os.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_char x) -{ - os.write_char (x.val_); - return (ACE_CDR::Boolean) os.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_wchar x) -{ - os.write_wchar (x.val_); - return (ACE_CDR::Boolean) os.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_octet x) -{ - os.write_octet (x.val_); - return (ACE_CDR::Boolean) os.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_string x) -{ - ACE_CDR::ULong len = 0; - - if (x.val_ != 0) - { - len = static_cast (ACE_OS::strlen (x.val_)); - } - - os.write_string (len, x.val_); - return - (ACE_CDR::Boolean) (os.good_bit () && (!x.bound_ || len <= x.bound_)); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_wstring x) -{ - ACE_CDR::ULong len = 0; - - if (x.val_ != 0) - { - len = static_cast (ACE_OS::strlen (x.val_)); - } - - os.write_wstring (len, x.val_); - return - (ACE_CDR::Boolean) (os.good_bit () && (!x.bound_ || len <= x.bound_)); -} - -// **************************************************************** - -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, ACE_CDR::Char &x) -{ - return is.read_char (x) && is.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, ACE_CDR::Short &x) -{ - return is.read_short (x) && is.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, ACE_CDR::UShort &x) -{ - return is.read_ushort (x) && is.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator>>(ACE_InputCDR &is, ACE_CDR::Long &x) -{ - return is.read_long (x) && is.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, ACE_CDR::ULong &x) -{ - return is.read_ulong (x) && is.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR& is, ACE_CDR::LongLong &x) -{ - return is.read_longlong (x) && is.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR& is, ACE_CDR::ULongLong &x) -{ - return is.read_ulonglong (x) && is.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR& is, ACE_CDR::LongDouble &x) -{ - return is.read_longdouble (x) && is.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, ACE_CDR::Float &x) -{ - return is.read_float (x) && is.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, ACE_CDR::Double &x) -{ - return is.read_double (x) && is.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, ACE_CDR::Char *&x) -{ - return is.read_string (x) && is.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, ACE_CDR::WChar *&x) -{ - return is.read_wstring (x) && is.good_bit (); -} - -// The following use the helper classes -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, ACE_InputCDR::to_boolean x) -{ - return is.read_boolean (x.ref_); -} - -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, ACE_InputCDR::to_char x) -{ - return is.read_char (x.ref_) && is.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, ACE_InputCDR::to_wchar x) -{ - return is.read_wchar (x.ref_) && is.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, ACE_InputCDR::to_octet x) -{ - return is.read_octet (x.ref_) && is.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, ACE_InputCDR::to_string x) -{ - // check if the bounds are satisfied - return - (is.read_string (const_cast (x.val_)) - && is.good_bit () - && (!x.bound_ - || ACE_OS::strlen (x.val_) <= x.bound_)); -} - -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, ACE_InputCDR::to_wstring x) -{ - // check if the bounds are satisfied - return - (is.read_wstring (const_cast (x.val_)) - && is.good_bit () - && (!x.bound_ - || ACE_OS::strlen (x.val_) <= x.bound_)); -} - -// *************************************************************************** -// We must define these methods here because they use the "read_*" inlined -// methods of the ACE_InputCDR class -// *************************************************************************** - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::append_boolean (ACE_InputCDR &stream) -{ - ACE_CDR::Boolean x; - return stream.read_boolean (x) ? this->write_boolean (x) : false; -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::append_char (ACE_InputCDR &stream) -{ - ACE_CDR::Char x; - return stream.read_char (x) ? this->write_char (x) : false; -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::append_wchar (ACE_InputCDR &stream) -{ - ACE_CDR::WChar x; - return stream.read_wchar (x) ? this->write_wchar (x) : false; -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::append_octet (ACE_InputCDR &stream) -{ - ACE_CDR::Octet x; - return stream.read_octet (x) ? this->write_octet (x) : false; -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::append_short (ACE_InputCDR &stream) -{ - ACE_CDR::Short x; - return stream.read_short (x) ? this->write_short (x) : false; -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::append_ushort (ACE_InputCDR &stream) -{ - ACE_CDR::UShort x; - return stream.read_ushort (x) ? this->write_ushort (x) : false; -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::append_long (ACE_InputCDR &stream) -{ - ACE_CDR::Long x; - return stream.read_long (x) ? this->write_long (x) : false; -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::append_ulong (ACE_InputCDR &stream) -{ - ACE_CDR::ULong x; - return stream.read_ulong (x) ? this->write_ulong (x) : false; -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::append_longlong (ACE_InputCDR &stream) -{ - ACE_CDR::LongLong x; - return stream.read_longlong (x) ? this->write_longlong (x) : false; -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::append_ulonglong (ACE_InputCDR &stream) -{ - ACE_CDR::ULongLong x; - return stream.read_ulonglong (x) ? this->write_ulonglong (x) : false; -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::append_float (ACE_InputCDR &stream) -{ - ACE_CDR::Float x; - return stream.read_float (x) ? this->write_float (x) : false; -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::append_double (ACE_InputCDR &stream) -{ - ACE_CDR::Double x; - return stream.read_double (x) ? this->write_double (x) : false; -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::append_longdouble (ACE_InputCDR &stream) -{ - ACE_CDR::LongDouble x; - return stream.read_longdouble (x) ? this->write_longdouble (x) : false; -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::append_string (ACE_InputCDR &stream) -{ - ACE_CDR::Char *x; - const ACE_CDR::Boolean flag = - (stream.read_string (x) ? this->write_string (x) : false); - delete [] x; - return flag; -} - -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::append_wstring (ACE_InputCDR &stream) -{ - ACE_CDR::WChar *x; - const ACE_CDR::Boolean flag = - (stream.read_wstring (x) ? this->write_wstring (x) : false); - delete [] x; - return flag; -} - -ACE_INLINE void -ACE_InputCDR::reset_byte_order (int byte_order) -{ - this->do_byte_swap_ = (byte_order != ACE_CDR_BYTE_ORDER); -} - -ACE_INLINE bool -ACE_InputCDR::do_byte_swap (void) const -{ - return this->do_byte_swap_; -} - -ACE_INLINE int -ACE_InputCDR::byte_order (void) const -{ - return this->do_byte_swap () ? !ACE_CDR_BYTE_ORDER : ACE_CDR_BYTE_ORDER; -} - -ACE_INLINE int -ACE_InputCDR::align_read_ptr (size_t alignment) -{ -#if !defined (ACE_LACKS_CDR_ALIGNMENT) - char *buf = ACE_ptr_align_binary (this->rd_ptr (), - alignment); -#else - char *buf = this->rd_ptr (); -#endif /* ACE_LACKS_CDR_ALIGNMENT */ - - if (buf <= this->wr_ptr ()) - { - this->start_.rd_ptr (buf); - return 0; - } - - this->good_bit_ = false; - return -1; -} - -ACE_INLINE void -ACE_InputCDR::set_version (ACE_CDR::Octet major, ACE_CDR::Octet minor) -{ - this->major_version_ = major; - this->minor_version_ = minor; -} - -ACE_INLINE void -ACE_InputCDR::get_version (ACE_CDR::Octet &major, ACE_CDR::Octet &minor) -{ - major = this->major_version_; - minor = this->minor_version_; -} - -ACE_INLINE ACE_Char_Codeset_Translator * -ACE_InputCDR::char_translator (void) const -{ - return this->char_translator_; -} - -ACE_INLINE ACE_WChar_Codeset_Translator * -ACE_InputCDR::wchar_translator (void) const -{ - return this->wchar_translator_; -} - - -ACE_INLINE void -ACE_InputCDR::char_translator (ACE_Char_Codeset_Translator * ctran) -{ - this->char_translator_ = ctran; -} - -ACE_INLINE void -ACE_InputCDR::wchar_translator (ACE_WChar_Codeset_Translator * wctran) -{ - this->wchar_translator_ = wctran; -} - -// **************************************************************** - -ACE_INLINE ACE_CDR::Boolean -ACE_Char_Codeset_Translator::read_1 (ACE_InputCDR& input, - ACE_CDR::Octet *x) -{ - return input.read_1 (x); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_Char_Codeset_Translator::write_1 (ACE_OutputCDR& output, - const ACE_CDR::Octet *x) -{ - return output.write_1 (x); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_Char_Codeset_Translator::read_array (ACE_InputCDR& in, - void* x, - size_t size, - size_t align, - ACE_CDR::ULong length) -{ - return in.read_array (x, size, align, length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_Char_Codeset_Translator::write_array (ACE_OutputCDR& out, - const void *x, - size_t size, - size_t align, - ACE_CDR::ULong length) -{ - return out.write_array(x, size, align, length); -} - -ACE_INLINE int -ACE_Char_Codeset_Translator::adjust (ACE_OutputCDR& out, - size_t size, - size_t align, - char *&buf) -{ - return out.adjust(size, align, buf); -} - -ACE_INLINE void -ACE_Char_Codeset_Translator::good_bit (ACE_OutputCDR& out, bool bit) -{ - out.good_bit_ = bit; -} - -ACE_INLINE ACE_CDR::Octet -ACE_Char_Codeset_Translator::major_version (ACE_InputCDR& input) -{ - return input.major_version_; -} - -ACE_INLINE ACE_CDR::Octet -ACE_Char_Codeset_Translator::minor_version (ACE_InputCDR& input) -{ - return input.minor_version_; -} - -ACE_INLINE ACE_CDR::Octet -ACE_Char_Codeset_Translator::major_version (ACE_OutputCDR& output) -{ - return output.major_version_; -} - -ACE_INLINE ACE_CDR::Octet -ACE_Char_Codeset_Translator::minor_version (ACE_OutputCDR& output) -{ - return output.minor_version_; -} - -// **************************************************************** - -ACE_INLINE ACE_CDR::Boolean -ACE_WChar_Codeset_Translator::read_1 (ACE_InputCDR& input, - ACE_CDR::Octet *x) -{ - return input.read_1 (x); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_WChar_Codeset_Translator::read_2 (ACE_InputCDR& input, - ACE_CDR::UShort *x) -{ - return input.read_2 (x); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_WChar_Codeset_Translator::read_4 (ACE_InputCDR& input, - ACE_CDR::ULong *x) -{ - return input.read_4 (x); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_WChar_Codeset_Translator::write_1 (ACE_OutputCDR& output, - const ACE_CDR::Octet *x) -{ - return output.write_1 (x); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_WChar_Codeset_Translator::write_2 (ACE_OutputCDR& output, - const ACE_CDR::UShort *x) -{ - return output.write_2 (x); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_WChar_Codeset_Translator::write_4 (ACE_OutputCDR& output, - const ACE_CDR::ULong *x) -{ - return output.write_4 (x); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_WChar_Codeset_Translator::read_array (ACE_InputCDR& in, - void* x, - size_t size, - size_t align, - ACE_CDR::ULong length) -{ - return in.read_array (x, size, align, length); -} - -ACE_INLINE ACE_CDR::Boolean -ACE_WChar_Codeset_Translator::write_array (ACE_OutputCDR& out, - const void *x, - size_t size, - size_t align, - ACE_CDR::ULong length) -{ - return out.write_array(x, size, align, length); -} - -ACE_INLINE int -ACE_WChar_Codeset_Translator::adjust (ACE_OutputCDR& out, - size_t size, - size_t align, - char *&buf) -{ - return out.adjust(size, align, buf); -} - -ACE_INLINE void -ACE_WChar_Codeset_Translator::good_bit (ACE_OutputCDR& out, bool bit) -{ - out.good_bit_ = bit; -} - -ACE_INLINE ACE_CDR::Octet -ACE_WChar_Codeset_Translator::major_version (ACE_InputCDR& input) -{ - return input.major_version_; -} - -ACE_INLINE ACE_CDR::Octet -ACE_WChar_Codeset_Translator::minor_version (ACE_InputCDR& input) -{ - return input.minor_version_; -} - -ACE_INLINE ACE_CDR::Octet -ACE_WChar_Codeset_Translator::major_version (ACE_OutputCDR& output) -{ - return output.major_version_; -} - -ACE_INLINE ACE_CDR::Octet -ACE_WChar_Codeset_Translator::minor_version (ACE_OutputCDR& output) -{ - return output.minor_version_; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/CE_Screen_Output.cpp b/ACE/ace/CE_Screen_Output.cpp deleted file mode 100644 index 800cc1c0926..00000000000 --- a/ACE/ace/CE_Screen_Output.cpp +++ /dev/null @@ -1,158 +0,0 @@ -// $Id$ - -#include "ace/CE_Screen_Output.h" -#if defined (ACE_HAS_WINCE) - -#include "ace/Log_Msg.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_CE_Screen_Output::ACE_CE_Screen_Output(HWND hEdit) -: handler_(hEdit) -, pFile_(0) -{ -} - -ACE_CE_Screen_Output::ACE_CE_Screen_Output() -: handler_(0) -, pFile_(0) -{ -} - -ACE_CE_Screen_Output::~ACE_CE_Screen_Output() -{ - if (pFile_ != 0) { - fclose(pFile_); - } -} - -void ACE_CE_Screen_Output::log(ACE_Log_Record &log_record) -{ - ACE_TCHAR verbose_msg[ACE_Log_Record::MAXVERBOSELOGMSGLEN]; - int result = log_record.format_msg (ACE_TEXT("WindozeCE"), // host name - 0, // verbose flag - verbose_msg); - - if (result == 0) - { - verbose_msg[ ACE_OS::strlen(verbose_msg) - 1 ] = 0; // CE does not like '\n' by itself. - *this << verbose_msg << endl; - } -} - -void ACE_CE_Screen_Output::SetOutputWindow(HWND hEdit) -{ - handler_ = hEdit; -} - -void ACE_CE_Screen_Output::clear() -{ - SetWindowText(handler_, 0); -} - -ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (ACE_TCHAR* output) -{ - int length = GetWindowTextLength(handler_); - SendMessage(handler_, EM_SETSEL, length, length); - SendMessage(handler_, EM_REPLACESEL, 0, (LPARAM)output); - - if (pFile_ != 0) - { - fwprintf(pFile_, L"%s", output); - } - - return *this; -} - -ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (const ACE_TCHAR* output) -{ - ACE_TCHAR* buffer = ACE_OS::strdup(output); - if (buffer != 0) - { - *this << buffer; - delete buffer; - } - return *this; -} - -ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (ACE_ANTI_TCHAR* output) -{ - *this << ACE_TEXT_CHAR_TO_TCHAR(output); - return *this; -} - -ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (const ACE_ANTI_TCHAR* output) -{ - *this << ACE_TEXT_CHAR_TO_TCHAR(output); - return *this; -} - -ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (char output) -{ - *this << (int)output; - return *this; -} - -ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (unsigned char output) -{ - *this << (int)output; - return *this; -} - -ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (unsigned short output) -{ - ACE_TCHAR buffer[20]; - wsprintf(buffer, ACE_TEXT("%u"), output); - *this << buffer; - return *this; -} - -ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (int output) -{ - ACE_TCHAR buffer[20]; - wsprintf(buffer, ACE_TEXT("%d"), output); - *this << buffer; - return *this; -} - -ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (unsigned int output) -{ - ACE_TCHAR buffer[20]; - wsprintf(buffer, ACE_TEXT("%du"), output); - *this << buffer; - return *this; -} - -ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (float output) -{ - ACE_TCHAR buffer[20]; - swprintf(buffer, ACE_TEXT("%f"), output); - *this << buffer; - return *this; -} - -ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (long output) -{ - ACE_TCHAR buffer[20]; - wsprintf(buffer, ACE_TEXT("%l"), output); - *this << buffer; - return *this; -} - -ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (unsigned long output) -{ - ACE_TCHAR buffer[20]; - wsprintf(buffer, ACE_TEXT("%lu"), output); - *this << buffer; - return *this; -} - -ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (FILE* pFile) -{ - pFile_ = pFile; - return *this; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif // ACE_HAS_WINCE diff --git a/ACE/ace/CE_Screen_Output.h b/ACE/ace/CE_Screen_Output.h deleted file mode 100644 index e3ca13de295..00000000000 --- a/ACE/ace/CE_Screen_Output.h +++ /dev/null @@ -1,109 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file CE_Screen_Output.h - * - * $Id$ - * - * @author Si Mong Park - */ -//============================================================================= - -#ifndef ACE_CE_SCREEN_OUTPUT_H -#define ACE_CE_SCREEN_OUTPUT_H - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_WINCE) - -#include "ace/Log_Msg_Callback.h" -#include "ace/Log_Record.h" - -namespace -{ - const ACE_TCHAR endl[] = ACE_TEXT("\r\n"); - const ACE_TCHAR tab[] = ACE_TEXT("\t"); -} - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_CE_Screen_Output - * - * @brief Replacement of text output for Windows CE. - * - * This class allows standard text output to be displayed on - * text window for Windows CE. Generally, all ACE output will - * go through under CE if and only if user uses WindozeCE - * implementation by using main_ce instead of main. - * Also, for the easier debugging purpose, object pointer of - * this class can be gotten from ACE_Log_Msg::msg_callback() - * and then can be used directly by user just like cout stream. - */ -class ACE_Export ACE_CE_Screen_Output : public ACE_Log_Msg_Callback -{ -public: - - ACE_CE_Screen_Output (HWND hEdit); - - ACE_CE_Screen_Output (void); - - virtual ~ACE_CE_Screen_Output(); - - /// Implementation of pure virtual function from ACE_Log_Msg_Callback. - virtual void log (ACE_Log_Record &log_record); - - /// Interface to specify active window handle. - void SetOutputWindow (HWND hWnd); - - void clear (void); - - /// Stream insertion operator that performs actual print out. - /** - * @note This is the only one operator that performs output. All - * other perators convert the type and use this operator - * underneath. - */ - ACE_CE_Screen_Output& operator << (ACE_TCHAR*); - ACE_CE_Screen_Output& operator << (const ACE_TCHAR*); - - ACE_CE_Screen_Output& operator << (ACE_ANTI_TCHAR* output); - ACE_CE_Screen_Output& operator << (const ACE_ANTI_TCHAR* output); - - ACE_CE_Screen_Output& operator << (char output); - ACE_CE_Screen_Output& operator << (unsigned char output); - - ACE_CE_Screen_Output& operator << (unsigned short output); - - ACE_CE_Screen_Output& operator << (int output); - ACE_CE_Screen_Output& operator << (unsigned int output); - - ACE_CE_Screen_Output& operator << (float output); - - ACE_CE_Screen_Output& operator << (long output); - ACE_CE_Screen_Output& operator << (unsigned long output); - - ACE_CE_Screen_Output& operator << (FILE* pFile); - -private: - - ACE_CE_Screen_Output (ACE_CE_Screen_Output&); - -private: - - HWND handler_; - - /// FILE pointer that used to save output to file. This class does - /// not own the file handler pointer. - FILE* pFile_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif // ACE_HAS_WINCE -#endif // ACE_CE_SCREEN_OUTPUT_H diff --git a/ACE/ace/CORBA_macros.h b/ACE/ace/CORBA_macros.h deleted file mode 100644 index 22ded9a54b3..00000000000 --- a/ACE/ace/CORBA_macros.h +++ /dev/null @@ -1,575 +0,0 @@ -// -*- C++ -*- - -// ============================================================================ -/** - * @file CORBA_macros.h - * - * $Id$ - * - * Writing code that is portable between platforms with or without - * native C++ exceptions is hard. The following macros offer some - * help on this task, mostly oriented to making the ORB code and the - * IDL generated code portable. - * - * @author Nanbor Wang - * @author Aniruddha Gokhale - * @author Carlos O'Ryan , et al. - */ -// ============================================================================ - -// Macros for handling CORBA exceptions. - -#ifndef ACE_CORBA_MACROS_H -#define ACE_CORBA_MACROS_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -# if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -# endif /* ACE_LACKS_PRAGMA_ONCE */ - -#define ACE_ENV_POLLUTE_NAMES - -#include "ace/Exception_Macros.h" - -// The Windows MFC exception mechanism requires that a caught CException -// (including the CMemoryException in use here) be freed using its Delete() -// method. Thus, when MFC is in use and we're catching exceptions as a result -// of new(), the exception's Delete() method has to be called. No other -// platform imposes this sort of restriction/requirement. The Windows -// config stuff (at least for MSVC/MFC) defines a ACE_del_bad_alloc macro -// that works with its ACE_bad_alloc macro to implement this cleanup -// requirement. Since no other platform requires this, define it as -// empty here. -#if !defined (ACE_del_bad_alloc) -# define ACE_del_bad_alloc -#endif - -#if !defined (ACE_LACKS_DEPRECATED_MACROS) - -// If you wish to you use these macros for emulating exceptions on -// platforms which lack native exception support, you need to do the -// following: -// 1. Define a class Exception. You can name it as you please. This class -// should be at the root of the inheritance hierarchy of all the -// exceptions used in your application. It should define at a minimum -// the following pure virtual methods: -// a) _downcast () - Which allows narrowing of the base exception type to a -// derived type. -// b) _raise() - Which throws an exception of type Exception. -// -// Classes which derive from these should implement these operations. -// -// 2. Define a class Environment. You can name it as you please. This class -// is an exception holder. This class is always on the stack. It should -// support at a minimum the following methods: -// a) exception() - Which returns the Exception held in the current -// Environment. -// b) exception (Exception* foo) - Which replaces/sets the Exception -// held in the current Environment with foo. -// b) clear() - Which resets a particular instance of Environment. -// c) A copy constructor and an assignment operator. -// -// Note that the above description assumes that you use the following -// macros only within a particular domain. For example, if your -// application has to interoperate across domains, then you need to define -// an exception adapter to translate exceptions from one domain to -// exceptions in the other. Please refer to Stroustrup's book on how to do -// this. If your use case is this complex, you would be better off with -// going with native exceptions rather than emulated exceptions, though -// the macros should still work if you defined your adapter class as -// ACE_EXCEPTION_TYPE. - - -// The following macros assume that an environment variable is passed -// in/out of each function that can throw an exception. The type of the -// environment variable is defined by ACE_ENV_TYPE. - -#if !defined (ACE_ENV_TYPE) -# define ACE_ENV_TYPE CORBA::Environment -#endif /* ACE_ENV_TYPE */ - -// The name of the variable is defined by ACE_TRY_ENV. Below is the name -// that we use by default. If you wish to change it you can redefine -// ACE_TRY_ENV to change the default name. Also ACE_ADOPT_ENV allows the -// use of non-standard name within a scope. - -#if !defined (ACE_TRY_ENV) -# define ACE_TRY_ENV _ACE_CORBA_Environment_variable -#endif /* ACE_TRY_ENV */ - -// The base type of Exception from which all the other exception types are -// derived. You can set this to any type as you please. By default, it is -// set to CORBA::Exception. - -#if !defined (ACE_EXCEPTION_TYPE) -# define ACE_EXCEPTION_TYPE CORBA::Exception -#endif /* ACE_EXCEPTION_TYPE */ - -// This method is used to get the default value of the Environment -// variable. In the case of TAO, this variable is part of the TSS ORB -// resources and the method TAO_default_environment() returns the -// Environment variable. - -#if !defined (ACE_DEFAULT_GET_ENV_METHOD) -# define ACE_DEFAULT_GET_ENV_METHOD TAO_default_environment -#endif /* ACE_DEFAULT_GET_ENV_METHOD */ - -// This is the exception caught by ACE_CATCHANY. -#if !defined (ACE_ANY_EXCEPTION) -# define ACE_ANY_EXCEPTION ex -#endif /* ACE_ANY_EXCEPTION */ - -// Declare a new environment variable on the stack. The type of the -// environment variable is determined by ACE_ENV_TYPE. -#if defined (ACE_USES_NATIVE_EXCEPTIONS) -// Don't instantiate an emulated exception environment at all when -// using native C++ exception support. It won't be used. -# define ACE_DECLARE_NEW_ENV -#else -# define ACE_DECLARE_NEW_ENV \ - ACE_ENV_TYPE ACE_TRY_ENV -#endif /* ACE_USES_NATIVE_EXCEPTIONS */ - -// Provided for backward compatibility purposes. Don't use it in new code. -// Use the definition above along with defining ACE_ENV_TYPE. - -#if defined (ACE_ENV_POLLUTE_NAMES) -# define ACE_DECLARE_NEW_CORBA_ENV ACE_DECLARE_NEW_ENV -#endif /* ACE_ENV_POLLUTE_NAMES */ - -#if defined (ACE_USES_NATIVE_EXCEPTIONS) -// ----------------------------------------------------------------- - -// Provided for backward compatibility purposes. Don't use it in new code. -#if defined (ACE_ENV_POLLUTE_NAMES) -# define ACE_ADOPT_CORBA_ENV(ENV) -#endif /* ACE_ENV_POLLUTE_NAMES */ - -#define ACE_ADOPT_ENV (ENV) - -// No need to check. Native exceptions handle the control flow -// automatically when an exception occurs. -# define ACE_CHECK - -// Used when the function requires a return value. -# define ACE_CHECK_RETURN(RETV) - -// ACE_THROW_INT should not be used by the user. -# define ACE_THROW_INT(EXCEPTION) \ - throw EXCEPTION - -// Throwing an exception is easy. These two macros should _NOT_ be -// used within try blocks. -# define ACE_THROW(EXCEPTION) \ - throw EXCEPTION - -// Throwing an exception when the function requires a return value. -# define ACE_THROW_RETURN(EXCEPTION,RETV) \ - throw EXCEPTION - -// For compilers with native exceptions, we can simply use try to try. ;-) -// do {} while (0) is required to avoid compilation warnings. -# define ACE_TRY \ - do \ - { \ - try \ - { -# define ACE_TRY_NEW_ENV \ - do \ - { \ - try \ - { -# define ACE_TRY_EX(LABEL) \ - do \ - { \ - try \ - { - -// No need to check for exceptions within try block for compilers with -// native exceptions. -# define ACE_TRY_CHECK -# define ACE_TRY_CHECK_EX(LABEL) - -// Likewise, throwing exceptions within try blocks is easy. -# define ACE_TRY_THROW(EXCEPTION) throw EXCEPTION -# define ACE_TRY_THROW_EX(EXCEPTION,LABEL) throw EXCEPTION - -// Same thing for catch. -# define ACE_CATCH(EXCEPTION,VAR) \ - } \ - catch (EXCEPTION & VAR) \ - { \ - ACE_UNUSED_ARG (VAR); - -# define ACE_CATCHANY \ - ACE_CATCH(ACE_EXCEPTION_TYPE, ACE_ANY_EXCEPTION) - -# define ACE_CATCHALL \ - } \ - catch (...) \ - { - -# if defined (ACE_HAS_DEPRECATED_ACE_RETHROW) -# define ACE_RETHROW throw -# endif /* ACE_HAS_DEPRECATED_ACE_RETHROW */ - -// Rethrowing the exception from catch blocks. -# define ACE_RE_THROW throw -# define ACE_RE_THROW_EX(LABEL) throw - -// Close the catch block. -# define ACE_ENDTRY \ - } \ - } while (0) - -#else /* ! ACE_USES_NATIVE_EXCEPTIONS */ -// ----------------------------------------------------------------- - -// When handling compilers without native exceptions, things get a bit -// hairy. Exceptions are simulated using ACE_ENV_TYPE. The trick here is to -// make sure the flow-of-control can simulate the case when native -// exceptions occur... - -#if defined (ACE_ENV_POLLUTE_NAMES) -# define ACE_ADOPT_CORBA_ENV(ENV) ACE_ENV_TYPE &ACE_TRY_ENV = ENV -#endif /* ACE_ENV_POLLUTE_NAMES */ - -# define ACE_ADOPT_ENV(ENV) ACE_ENV_TYPE &ACE_TRY_ENV = ENV - -// Follow every statement that could throw exceptions with ACE_CHECK or -// ACE_CHECK_RETURN. These two macros should _NOT_ be used within try -// blocks. Use ACE_TRY_CHECK or ACE_TRY_CHECK_EX instead. -# define ACE_CHECK \ - if (ACE_TRY_ENV . exception () != 0) \ - return -// When function requires a return value -# define ACE_CHECK_RETURN(RETV) \ - if (ACE_TRY_ENV . exception () != 0) \ - return RETV - -// ACE_THROW_INT should not be used by the user. -# define ACE_THROW_INT(EXCEPTION) ACE_TRY_ENV.exception (new EXCEPTION) - -// Throwing exceptions will inevitably cause a return from the current -// function. These two macros should _NOT_ be used within try blocks. Use -// ACE_TRY_THROW or ACE_TRY_THROW_EX instead. -# define ACE_THROW(EXCEPTION) \ - do \ - { \ - ACE_TRY_ENV.exception (new EXCEPTION); \ - return; \ - } while (0) - -# define ACE_THROW_RETURN(EXCEPTION,RETV) \ - do \ - { \ - ACE_TRY_ENV.exception (new EXCEPTION); \ - return RETV; \ - } while (0) - -// ACE_TRY sets up flags to control program flow. ACE_TRY_FLAG acts like a -// one-shot flip-flop. When an exception occurs (detected using -// ACE_TRY_CHECK,) ACE_TRY_FLAG will be reset and the control goes back -// into ACE_TRY_LABEL. Since ACE_TRY_FLAG is reset, the try block won't get -// executed again and the control proceeds to the following catch blocks. -// ACE_EXCEPTION_NOT_CAUGHT flag is used to prevent catching an exception -// twice. This macro assumes there's already an ACE_ENV_TYPE variable -// ACE_TRY_ENV defined (which should be the case normally) -# define ACE_TRY \ - do { \ - int ACE_TRY_FLAG = 1; \ - int ACE_EXCEPTION_NOT_CAUGHT = 1; \ - ACE_TRY_LABEL: \ - if (ACE_TRY_FLAG) \ - do { - -// ACE_TRY_NEW_ENV functions like the macro ACE_TRY but defines a new -// ACE_ENV_TYPE variable ACE_TRY_ENV. It is most often used in the outer -// most function where no ACE_TRY_ENV is available. -# define ACE_TRY_NEW_ENV \ - do { \ - ACE_DECLARE_NEW_ENV;\ - int ACE_TRY_FLAG = 1; \ - int ACE_EXCEPTION_NOT_CAUGHT = 1; \ - ACE_TRY_LABEL: \ - if (ACE_TRY_FLAG) \ - do { - -// ACE_TRY_EX works exactly like ACE_TRY macro except the label used in the -// try block is customizable to avoid name clashing. It should be used when -// nested try blocks or multiple try blocks are required, in the same -// function. -# define ACE_TRY_EX(LABEL) \ - do { \ - int ACE_TRY_FLAG = 1; \ - int ACE_EXCEPTION_NOT_CAUGHT = 1; \ - ACE_TRY_LABEL ## LABEL: \ - if (ACE_TRY_FLAG) \ - do { - -// Check for exceptions within try blocks. -# define ACE_TRY_CHECK \ - { \ - if (ACE_TRY_ENV.exception () != 0) \ - { \ - ACE_TRY_FLAG = 0; \ - goto ACE_TRY_LABEL; \ - } \ - } - -// Checking exception within EX try blocks. -# define ACE_TRY_CHECK_EX(LABEL) \ - { \ - if (ACE_TRY_ENV.exception () != 0) \ - { \ - ACE_TRY_FLAG = 0; \ - goto ACE_TRY_LABEL ## LABEL; \ - } \ - } - -// Throwing exception within TRY blocks. -# define ACE_TRY_THROW(EXCEPTION) \ - { \ - ACE_TRY_ENV.exception (new EXCEPTION); \ - ACE_TRY_FLAG = 0; \ - goto ACE_TRY_LABEL; \ - } - -# define ACE_TRY_THROW_EX(EXCEPTION,LABEL) \ - { \ - ACE_TRY_ENV.exception (new EXCEPTION); \ - ACE_TRY_FLAG = 0; \ - goto ACE_TRY_LABEL ## LABEL; \ - } - -// When exceptions occur or try block finishes execution without exception, -// control will continue in the catch block. This macro first checks if -// there's any uncaught exception left. If all the conditions are met, we -// have caught an exception. It then resets ACE_EXCEPTION_NOT_CAUGHT to -// prevent subsequent catch blocks from catching the same exception again, -// and extracts out the underlying exception in ACE_TRY_ENV. We also make a -// copy of ACE_TRY_ENV in ACE_CAUGHT_ENV, in case we want to rethrow the -// exception. ACE_TRY_ENV is cleared out after the exception is caught so -// you should not use ACE_TRY_ENV within the catch block(You should use the -// exception directly). -# define ACE_CATCH(TYPE,VAR) \ - } while (0); \ - do \ - if (ACE_TRY_ENV.exception () != 0 && ACE_EXCEPTION_NOT_CAUGHT && \ - TYPE::_downcast(ACE_TRY_ENV.exception ()) != 0) \ - { \ - ACE_ENV_TYPE ACE_CAUGHT_ENV = ACE_TRY_ENV;\ - ACE_EXCEPTION_NOT_CAUGHT = 0; \ - TYPE &VAR = *TYPE::_downcast (ACE_CAUGHT_ENV.exception ()); \ - ACE_UNUSED_ARG (VAR); \ - ACE_TRY_ENV.clear (); - -// ACE_CATCHANY uses ACE_CATCH to catch all exceptions derived from -// ACE_EXCEPTION_TYPE -# define ACE_CATCHANY ACE_CATCH (ACE_EXCEPTION_TYPE, ACE_ANY_EXCEPTION) - -// Since there's no other exception for compilers without exception -// support, we simply catch all ACE_EXCEPTION_TYPE exceptions for -// ACE_CATCHALL. -# define ACE_CATCHALL ACE_CATCHANY - -# if defined (ACE_HAS_DEPRECATED_ACE_RETHROW) -# define ACE_RETHROW \ - do \ - ACE_TRY_ENV = ACE_CAUGHT_ENV; \ - while (0) -# endif /* ACE_HAS_DEPRECATED_ACE_RETHROW */ - -// Rethrowing exception within catch blocks. Notice that we depend on the -// ACE_CHECK/ACE_CHECK_RETURN following the ACE_ENDTRY, or ACE_TRY_CHECK/ -// ACE_TRY_CHECK_EX following the ACE_ENDTRY when the catch block is within -// another try block, to do the "Right Thing[TM]." -# define ACE_RE_THROW \ - do {\ - ACE_TRY_ENV = ACE_CAUGHT_ENV; \ - goto ACE_TRY_LABEL; \ - } while (0) -# define ACE_RE_THROW_EX(LABEL) \ - do {\ - ACE_TRY_ENV = ACE_CAUGHT_ENV; \ - goto ACE_TRY_LABEL ## LABEL; \ - } while (0) - -// Close the try block. Since exceptions may not get caught, and exceptions -// can also be rethrown from the catch block, it's always a good idea to -// follow ACE_ENDTRY with ACE_CHECK or ACE_TRY_CHECK (depending on the -// context.) -# define ACE_ENDTRY \ - } while (0); \ - } while (0) - -#endif /* ! ACE_USES_NATIVE_EXCEPTIONS */ - -#endif /* !ACE_LACKS_DEPRECATED_MACROS */ - -// ACE_HAS_EXCEPTIONS is not the same as ACE_NEW_THROWS_EXCEPTIONS. -#if defined(ACE_NEW_THROWS_EXCEPTIONS) - -# if defined (ACE_HAS_NEW_NOTHROW) - -# define ACE_NEW_THROW_EX(POINTER,CONSTRUCTOR,EXCEPTION) \ - do { POINTER = new (ACE_nothrow) CONSTRUCTOR; \ - if (POINTER == 0) { throw EXCEPTION; } \ - } while (0) - -# else - -# define ACE_NEW_THROW_EX(POINTER,CONSTRUCTOR,EXCEPTION) \ - do { try { POINTER = new CONSTRUCTOR; } \ - catch (ACE_bad_alloc) { ACE_del_bad_alloc throw EXCEPTION; } \ - } while (0) - -# endif /* ACE_HAS_NEW_NOTHROW */ - -#else /* ! ACE_NEW_THROWS_EXCEPTIONS */ - -# define ACE_NEW_THROW_EX(POINTER,CONSTRUCTOR,EXCEPTION) \ - do { POINTER = new CONSTRUCTOR; \ - if (POINTER == 0) { throw EXCEPTION; } \ - } while (0) - -#endif /* ACE_NEW_THROWS_EXCEPTIONS */ - -# define ACE_GUARD_THROW_EX(MUTEX,OBJ,LOCK,EXCEPTION) \ - ACE_Guard< MUTEX > OBJ (LOCK); \ - if (OBJ.locked () == 0) throw EXCEPTION; - -# define ACE_READ_GUARD_THROW_EX(MUTEX,OBJ,LOCK,EXCEPTION) \ - ACE_Read_Guard< MUTEX > OBJ (LOCK); \ - if (OBJ.locked () == 0) throw EXCEPTION; - -# define ACE_WRITE_GUARD_THROW_EX(MUTEX,OBJ,LOCK,EXCEPTION) \ - ACE_Write_Guard< MUTEX > OBJ (LOCK); \ - if (OBJ.locked () == 0) throw EXCEPTION; - -#if !defined (ACE_LACKS_DEPRECATED_MACROS) - -//@{ -/** - * @name Native C++ exceptions portability macros. - * - * The following macros are used to write code portable between platforms - * with and without native C++ exception support. Their main goal is to - * hide the presence of the ACE_ENV_TYPE argument, but they collaborate - * with the ACE_TRY_* macros to emulate the try/catch blocks. - */ - -/// Define a macro to emit code only when ACE_ENV_TYPE is used -#if !defined (ACE_USES_NATIVE_EXCEPTIONS) || defined (ACE_ENV_BKWD_COMPAT) -# define ACE_ENV_EMIT_CODE(X) X -#else -# define ACE_ENV_EMIT_CODE(X) -#endif /* ACE_USES_NATIVE_EXCEPTIONS && ! ACE_ENV_BKWD_COMPAT */ - -/// Another macro to emit code only when ACE_ENV_TYPE is used -#if !defined (ACE_USES_NATIVE_EXCEPTIONS) || defined (ACE_ENV_BKWD_COMPAT) -# define ACE_ENV_EMIT_CODE2(X,Y) X,Y -#else -# define ACE_ENV_EMIT_CODE2(X,Y) -#endif /* ACE_USES_NATIVE_EXCEPTIONS && ! ACE_ENV_BKWD_COMPAT */ - -/// Helper macro -#define ACE_ENV_EMIT_DUMMY - -/// Declare a ACE_ENV_TYPE argument as the last argument of a -/// function -/** - * Normally this macro is used as follows: - * - * void my_funct (int x, int y ACE_ENV_ARG_DECL); - * - * Its purpose is to provide developers (and users) with a mechanism to - * write code that is portable to platforms with and without native C++ - * exceptions. - */ -#define ACE_ENV_ARG_DECL \ - ACE_ENV_EMIT_CODE2(ACE_ENV_EMIT_DUMMY, \ - ACE_ENV_TYPE &ACE_TRY_ENV) - -/// Declare a ACE_ENV_TYPE argument with the default value obtained from -/// the ORB/application. -/** - * It is similar to ACE_ENV_ARG_DECL. The name of the default environment - * getter method needs to be changed when switching ORBs or when used with - * another application. - */ -#define ACE_ENV_ARG_DECL_WITH_DEFAULTS \ - ACE_ENV_EMIT_CODE2(ACE_ENV_EMIT_DUMMY, \ - ACE_ENV_TYPE &ACE_TRY_ENV = \ - ACE_DEFAULT_GET_ENV_METHOD ()) - -/// Declare a ACE_ENV_TYPE argument that is not used by the -/// function definition. -/** - * Similar to ACE_ENV_ARG_DECL, but the formal parameter name is dropped to - * avoid warnings about unused parameters - */ -#define ACE_ENV_ARG_DECL_NOT_USED \ - ACE_ENV_EMIT_CODE2(ACE_ENV_EMIT_DUMMY, \ - ACE_ENV_TYPE &) - -/// Declare a ACE_ENV_TYPE argument for methods that do not take any other -/// parameters -#define ACE_ENV_SINGLE_ARG_DECL \ - ACE_ENV_EMIT_CODE(ACE_ENV_TYPE &ACE_TRY_ENV) - -/// Declare a ACE_ENV_TYPE argument with a default value for methods that -/// do not take any other parameters. The name of the default environment -/// getter method needs to be changed when switching ORBs or when used in -/// another application. -#define ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS \ - ACE_ENV_EMIT_CODE(ACE_ENV_TYPE &ACE_TRY_ENV = \ - ACE_DEFAULT_GET_ENV_METHOD ()) - -/// Declare a ACE_ENV_TYPE argument for methods which don't use it. -#define ACE_ENV_SINGLE_ARG_DECL_NOT_USED \ - ACE_ENV_EMIT_CODE(ACE_ENV_TYPE &) - -/// Use the ACE_ENV_TYPE argument in a nested call -#define ACE_ENV_ARG_PARAMETER \ - ACE_ENV_EMIT_CODE2(ACE_ENV_EMIT_DUMMY, \ - ACE_TRY_ENV) - -/// Use the ACE_ENV_TYPE argument in a nested call, assuming that the -/// called function takes only the ACE_TRY_ENV argument. -#define ACE_ENV_SINGLE_ARG_PARAMETER \ - ACE_ENV_EMIT_CODE(ACE_TRY_ENV) - -/// Eliminate unused argument warnings about ACE_TRY_ENV -#define ACE_ENV_ARG_NOT_USED \ - ACE_ENV_EMIT_CODE(ACE_UNUSED_ARG(ACE_TRY_ENV)) -//@} - -#if !defined (ACE_USES_NATIVE_EXCEPTIONS) -// This thing can be moved above when we drop ACE_ENV_BKWD_COMPAT. -# define ACE_ENV_RAISE(ex) ACE_TRY_ENV.exception (ex) -#else -# define ACE_ENV_RAISE(ex) (ex)->_raise () -#endif /* ACE_USES_NATIVE_EXCEPTIONS */ - -// ============================================================ - -// Print out a TAO exception. This is not CORBA compliant. -# define ACE_PRINT_TAO_EXCEPTION(EX,INFO) \ - EX._tao_print_exception (INFO) - -// Print out a CORBA exception. There is not portable way to -// dump a CORBA exception. If you are using other ORB implementation, -// redefine the macro to get what you want. -# if !defined ACE_PRINT_EXCEPTION -# define ACE_PRINT_EXCEPTION(EX,INFO) ACE_PRINT_TAO_EXCEPTION(EX,INFO) -# endif /* ACE_PRINT_EXCEPTION */ - -#endif /* !ACE_LACKS_DEPRECATED_MACROS */ - -#include /**/ "ace/post.h" - -#endif /* ACE_CORBA_MACROS_H */ diff --git a/ACE/ace/Cache_Map_Manager_T.cpp b/ACE/ace/Cache_Map_Manager_T.cpp deleted file mode 100644 index b2526fcfa99..00000000000 --- a/ACE/ace/Cache_Map_Manager_T.cpp +++ /dev/null @@ -1,420 +0,0 @@ -// $Id$ - -#ifndef ACE_CACHE_MAP_MANAGER_T_CPP -#define ACE_CACHE_MAP_MANAGER_T_CPP - -#include "ace/Cache_Map_Manager_T.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Log_Msg.h" -#include "ace/Malloc_Base.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Cache_Map_Manager_T.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_Cache_Map_Manager) - -ACE_ALLOC_HOOK_DEFINE(ACE_Cache_Map_Iterator) - -ACE_ALLOC_HOOK_DEFINE(ACE_Cache_Map_Reverse_Iterator) - -#define ACE_T1 class KEY, class VALUE, class CMAP_TYPE, class ITERATOR_IMPL, class REVERSE_ITERATOR_IMPL, class CACHING_STRATEGY, class ATTRIBUTES -#define ACE_T2 KEY, VALUE, CMAP_TYPE, ITERATOR_IMPL, REVERSE_ITERATOR_IMPL, CACHING_STRATEGY, ATTRIBUTES - -template -ACE_Cache_Map_Manager::ACE_Cache_Map_Manager (CACHING_STRATEGY &caching_s, - size_t size, - ACE_Allocator *alloc) - : caching_strategy_ (caching_s) -{ - if (this->open (size, alloc) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Cache_Map_Manager::ACE_Cache_Map_Manager"))); - -} - -template -ACE_Cache_Map_Manager::~ACE_Cache_Map_Manager (void) -{ - this->close (); -} - -template int -ACE_Cache_Map_Manager::open (size_t length, - ACE_Allocator *alloc) -{ - return this->map_.open (length, - alloc); -} - -template int -ACE_Cache_Map_Manager::close (void) -{ - return this->map_.close (); -} - -template int -ACE_Cache_Map_Manager::bind (const KEY &key, - const VALUE &value) -{ - // Insert an entry which has the and the which - // is the combination of the and the attributes of the - // caching strategy. - CACHE_VALUE cache_value (value, - this->caching_strategy_.attributes ()); - - int bind_result = this->map_.bind (key, - cache_value); - - if (bind_result != -1) - { - - int result = this->caching_strategy_.notify_bind (bind_result, - cache_value.second ()); - - if (result == -1) - { - - this->map_.unbind (key); - - // Unless the notification goes thru the bind operation is - // not complete. - bind_result = -1; - - } - - } - - return bind_result; -} - - -template int -ACE_Cache_Map_Manager::rebind (const KEY &key, - const VALUE &value) -{ - CACHE_VALUE cache_value (value, - this->caching_strategy_.attributes ()); - - int rebind_result = this->map_.rebind (key, - cache_value); - - if (rebind_result != -1) - { - - int result = this->caching_strategy_.notify_rebind (rebind_result, - cache_value.second ()); - - if (result == -1) - { - - // Make sure the unbind operation is done only when the - // notification fails after a bind which is denoted by - // rebind_result = 0 - if (rebind_result == 0) - this->map_.unbind (key); - - // Unless the notification goes thru the rebind operation is - // not complete. - rebind_result = -1; - - } - - } - - return rebind_result; -} - - -template int -ACE_Cache_Map_Manager::rebind (const KEY &key, - const VALUE &value, - VALUE &old_value) -{ - CACHE_VALUE cache_value (value, - this->caching_strategy_.attributes ()); - - CACHE_VALUE old_cache_value (old_value, - this->caching_strategy_.attributes ()); - - int rebind_result = this->map_.rebind (key, - cache_value, - old_cache_value); - - if (rebind_result != -1) - { - - int result = this->caching_strategy_.notify_rebind (rebind_result, - cache_value.second ()); - - if (result == -1) - { - - // Make sure the unbind operation is done only when the - // notification fails after a bind which is denoted by - // rebind_result = 0 - if (rebind_result == 0) - this->map_.unbind (key); - - // Unless the notification goes thru the rebind operation is - // not complete. - rebind_result = -1; - - } - else - { - - old_value = old_cache_value.first (); - - } - - } - - return rebind_result; -} - -template int -ACE_Cache_Map_Manager::rebind (const KEY &key, - const VALUE &value, - KEY &old_key, - VALUE &old_value) -{ - CACHE_VALUE cache_value (value, - this->caching_strategy_.attributes ()); - - CACHE_VALUE old_cache_value (old_value, - this->caching_strategy_.attributes ()); - - int rebind_result = this->map_.rebind (key, - cache_value, - old_key, - old_cache_value); - - if (rebind_result != -1) - { - - int result = this->caching_strategy_.notify_rebind (rebind_result, - cache_value.second ()); - - if (result == -1) - { - - // Make sure the unbind operation is done only when the - // notification fails after a bind which is denoted by - // rebind_result = 0 - if (rebind_result == 0) - this->map_.unbind (key); - - // Unless the notification goes thru the rebind operation is - // not complete. - rebind_result = -1; - - } - else - { - - old_value = old_cache_value.first (); - - } - - } - - return rebind_result; -} - -template int -ACE_Cache_Map_Manager::trybind (const KEY &key, - VALUE &value) -{ - CACHE_VALUE cache_value (value, - this->caching_strategy_.attributes ()); - - int trybind_result = this->map_.trybind (key, - cache_value); - - if (trybind_result != -1) - { - - int result = this->caching_strategy_.notify_trybind (trybind_result, - cache_value.second ()); - - if (result == -1) - { - - // If the entry has got inserted into the map, it is removed - // due to failure. - if (trybind_result == 0) - this->map_.unbind (key); - - trybind_result = -1; - - } - else - { - - // If an attempt is made to bind an existing entry the value - // is overwritten with the value from the map. - if (trybind_result == 1) - value = cache_value.first (); - - } - - } - - return trybind_result; -} - -template int -ACE_Cache_Map_Manager::find (const KEY &key, - VALUE &value) -{ - // Lookup the key and populate the . - CACHE_VALUE cache_value; - - int find_result = this->map_.find (key, - cache_value); - - if (find_result != -1) - { - - int result = this->caching_strategy_.notify_find (find_result, - cache_value.second ()); - - // Unless the find and notification operations go thru, this - // method is not successful. - if (result == -1) - find_result = -1; - else - { - - // Since the has now changed after the - // notification, we need to bind to the map again. - int rebind_result = this->map_.rebind (key, - cache_value); - if (rebind_result == -1) - find_result = -1; - else - value = cache_value.first (); - - } - - } - - return find_result; -} - -template int -ACE_Cache_Map_Manager::find (const KEY &key) -{ - // Lookup the key and populate the . - CACHE_VALUE cache_value; - - int find_result = this->map_.find (key, - cache_value); - - if (find_result != -1) - { - - int result = this->caching_strategy_.notify_find (find_result, - cache_value.second ()); - - // Unless the find and notification operations go thru, this - // method is not successful. - if (result == -1) - find_result = -1; - else - { - - // Since the has now changed after the - // notification, we need to bind to the map again. - int rebind_result = this->map_.rebind (key, - cache_value); - - if (rebind_result == -1) - find_result = -1; - - } - - } - - return find_result; -} - - -template int -ACE_Cache_Map_Manager::unbind (const KEY &key) -{ - // Remove the entry from the cache. - CACHE_VALUE cache_value; - - int unbind_result = this->map_.unbind (key, - cache_value); - - if (unbind_result != -1) - { - - int result = this->caching_strategy_.notify_unbind (unbind_result, - cache_value.second ()); - - if (result == -1) - unbind_result = -1; - - } - - return unbind_result; -} - -template int -ACE_Cache_Map_Manager::unbind (const KEY &key, - VALUE &value) -{ - // Remove the entry from the cache. - CACHE_VALUE cache_value; - - int unbind_result = this->map_.unbind (key, - cache_value); - - if (unbind_result != -1) - { - - int result = this->caching_strategy_.notify_unbind (unbind_result, - cache_value.second ()); - - if (result == -1) - unbind_result = -1; - else - value = cache_value.first (); - - } - - return unbind_result; -} - -template void -ACE_Cache_Map_Manager::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - this->map_.dump (); - - this->caching_strategy_.dump (); -#endif /* ACE_HAS_DUMP */ -} - -#undef ACE_T1 -#undef ACE_T2 - -template -ACE_Cache_Map_Iterator::~ACE_Cache_Map_Iterator (void) -{ -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_CACHE_MAP_MANAGER_T_CPP */ diff --git a/ACE/ace/Cache_Map_Manager_T.h b/ACE/ace/Cache_Map_Manager_T.h deleted file mode 100644 index 0c533f7a0ae..00000000000 --- a/ACE/ace/Cache_Map_Manager_T.h +++ /dev/null @@ -1,405 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Cache_Map_Manager_T.h - * - * $Id$ - * - * @author Kirthika Parameswaran - */ -//============================================================================= - -#ifndef ACE_CACHE_MAP_MANAGER_T_H -#define ACE_CACHE_MAP_MANAGER_T_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Default_Constants.h" -#include "ace/Global_Macros.h" -#include "ace/Pair_T.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Forward declaration. -class ACE_Allocator; - -#define ACE_Cache_Map_Iterator ACMI -#define ACE_Cache_Map_Reverse_Iterator ACMRI - -template -class ACE_Cache_Map_Iterator; - -template -class ACE_Cache_Map_Reverse_Iterator; - -// For linkers that cant grok long names. -#define ACE_Cache_Map_Manager ACMM - -/** - * @class ACE_Cache_Map_Manager - * - * @brief Defines a abstraction that will purge entries from a map. - * - * The will manage the map it contains - * and provide purging on demand from the map. The strategy for - * caching is decided by the user and provided to the Cache - * Manager. The Cache Manager acts as a agent and communicates - * between the Map and the Strategy for purging entries from the - * map. - * No locking mechanism provided since locking at this level - * isn't efficient. Locking has to be provided by the - * application. - */ -template -class ACE_Cache_Map_Manager -{ -public: - - // = Traits. - typedef KEY key_type; - typedef VALUE mapped_type; - typedef CMAP_TYPE map_type; - typedef CACHING_STRATEGY caching_strategy_type; - - typedef ITERATOR_IMPL ITERATOR_IMPLEMENTATION; - typedef REVERSE_ITERATOR_IMPL REVERSE_ITERATOR_IMPLEMENTATION; - - friend class ACE_Cache_Map_Iterator; - friend class ACE_Cache_Map_Reverse_Iterator; - - // = ACE-style iterator typedefs. - typedef ACE_Cache_Map_Iterator - ITERATOR; - typedef ACE_Cache_Map_Reverse_Iterator - REVERSE_ITERATOR; - - // = STL-style iterator typedefs. - typedef ITERATOR - iterator; - typedef REVERSE_ITERATOR - reverse_iterator; - - /** - * The actual value mapped to the key in the map. The - * are used by the strategy and is transparent to the user of this - * class. - */ - typedef ACE_Pair CACHE_VALUE; - - // = Initialization and termination methods. - - /// Initialize a with and - /// @a size entries. - ACE_Cache_Map_Manager (CACHING_STRATEGY &caching_strategy, - size_t size = ACE_DEFAULT_MAP_SIZE, - ACE_Allocator *alloc = 0); - - /// Close down a and release dynamically allocated - /// resources. - virtual ~ACE_Cache_Map_Manager (void); - - /// Initialize a cache with size @a length. - int open (size_t length = ACE_DEFAULT_MAP_SIZE, - ACE_Allocator *alloc = 0); - - /// Close down a cache and release dynamically allocated resources. - int close (void); - - /** - * Associate @a key with @a value. If @a key is already in the CMAP_TYPE - * then the ENTRY is not changed. Returns 0 if a new entry is bound - * successfully, returns 1 if an attempt is made to bind an existing - * entry, and returns -1 if failures occur. - */ - int bind (const KEY &key, - const VALUE &value); - - /** - * Lookup entry in the cache. If it is not found, returns -1. - * If the @a key is located in the CMAP_TYPE object, the CACHING_STRATEGY is - * notified of it via notify_find (int result, ATTRIBUTES &attribute). - * If notify_find also returns 0 (success), then this function returns - * 0 (success) and sets the cached value in @a value. - */ - int find (const KEY &key, - VALUE &value); - - /** - * Lookup entry in the cache. If it is not found, returns -1. - * If the @a key is located in the CMAP_TYPE object, the CACHING_STRATEGY is - * notified of it via notify_find (int result, ATTRIBUTES &attribute). - * If notify_find also returns 0 (success), then this function returns - * 0 (success). - */ - int find (const KEY &key); - - /** - * Reassociate the @a key with @a value. If the @a key already exists - * in the cache then returns 1, on a new bind returns 0 and returns - * -1 in case of any failures. - */ - int rebind (const KEY &key, - const VALUE &value); - - /** - * Reassociate @a key with @a value, storing the old value into the - * "out" parameter @a old_value. The function fails if @a key is not - * in the cache for caches that do not allow user specified keys. - * However, for caches that allow user specified keys, if the key is - * not in the cache, a new @a key / @a value association is created. - */ - int rebind (const KEY &key, - const VALUE &value, - VALUE &old_value); - - /** - * Reassociate @a key with @a value, storing the old key and value - * into the "out" parameters @a old_key and @a old_value. The - * function fails if @a key is not in the cache for caches that do - * not allow user specified keys. However, for caches that allow - * user specified keys, if the key is not in the cache, a new - * @a key / @a value association is created. - */ - int rebind (const KEY &key, - const VALUE &value, - KEY &old_key, - VALUE &old_value); - - /** - * Associate @a key with @a value if and only if @a key is not in the - * cache. If @a key is already in the cache, then the @a value - * parameter is overwritten with the existing value in the - * cache. Returns 0 if a new @a key / @a value association is created. - * Returns 1 if an attempt is made to bind an existing entry. This - * function fails for maps that do not allow user specified keys. - */ - int trybind (const KEY &key, - VALUE &value); - - /// Remove @a key from the cache. - int unbind (const KEY &key); - - /// Remove @a key from the cache, and return the @a value associated with - /// @a key. - int unbind (const KEY &key, - VALUE &value); - - /// Remove entries from the cache depending upon the strategy. - int purge (void); - - /// Return the current size of the cache. - size_t current_size (void) const; - - /// Return the total size of the cache. - size_t total_size (void) const; - - /// Dumps the state of the object. - void dump (void) const; - - // = STL styled iterator factory functions. - - /// Return forward iterator. - ITERATOR begin (void); - ITERATOR end (void); - - /// Return reverse iterator. - REVERSE_ITERATOR rbegin (void); - REVERSE_ITERATOR rend (void); - - /// The map managed by the Cache_Map_Manager. - CMAP_TYPE &map (void); - - /// The caching strategy used on the cache. - CACHING_STRATEGY &caching_strategy (void); - -protected: - - /// The underlying map which needs to be cached. - CMAP_TYPE map_; - - /// The strategy to be followed for caching entries in the map. - CACHING_STRATEGY &caching_strategy_; - -private: - - // = Disallow these operations. - ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Cache_Map_Manager &)) - ACE_UNIMPLEMENTED_FUNC (ACE_Cache_Map_Manager (const ACE_Cache_Map_Manager &)) - -}; - -/** - * @class ACE_Cache_Map_Iterator - * - * @brief Defines a iterator for the Cache_Map_Manager. - * - * Implementation to be provided by the iterator of the map - * managed by the ACE_Cache_Map_Manager. - */ -template -class ACE_Cache_Map_Iterator -{ - -public: - - // = Traits. - /// The actual value mapped to the key in the cache. The - /// are used by the strategy and is transperant to the cache user. - typedef ACE_Reference_Pair - value_type; - typedef ACE_Pair - CACHE_VALUE; - - // = Initialisation and termination methods. - - ACE_Cache_Map_Iterator (const IMPLEMENTATION &iterator_impl); - - /// Copy constructor. - ACE_Cache_Map_Iterator (const ACE_Cache_Map_Iterator &rhs); - - virtual ~ACE_Cache_Map_Iterator (void); - - // = Iteration methods. - - /// assignment operator. - ACE_Cache_Map_Iterator &operator= - (const ACE_Cache_Map_Iterator &rhs); - - /// Comparision operators. - bool operator== (const ACE_Cache_Map_Iterator &rhs) const; - bool operator!= (const ACE_Cache_Map_Iterator &rhs) const; - - /// Returns a reference to the internal element @c this is pointing - /// to. - ACE_Reference_Pair operator* (void) const; - - // = STL styled iteration, compare, and reference functions. - - /// Prefix advance - ACE_Cache_Map_Iterator &operator++ (void); - - /// Postfix advance. - ACE_Cache_Map_Iterator operator++ (int); - - /// Prefix reverse. - ACE_Cache_Map_Iterator &operator-- (void); - - /// Postfix reverse. - ACE_Cache_Map_Iterator operator-- (int); - - /// Returns the iterator of the internal map in the custody of the - /// Cache_Map_Manager. - IMPLEMENTATION &iterator_implementation (void); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - /// The actual iterator which iterates internally on the map - /// belonging to the Cache_Map_Manager. - IMPLEMENTATION iterator_implementation_; -}; - -/** - * @class ACE_Cache_Map_Reverse_Iterator - * - * @brief Defines a reverse iterator for the Cache_Map_Manager. - * - * Implementation to be provided by the reverse iterator of the map - * managed by thr Cache_Map_manager. - */ -template -class ACE_Cache_Map_Reverse_Iterator -{ -public: - - // = Traits. - /// The actual value mapped to the key in the cache. The - /// are used by the strategy and is transperant to the cache user. - typedef ACE_Reference_Pair value_type; - typedef ACE_Pair CACHE_VALUE; - - // = Initialisation and termination methods. - - ACE_Cache_Map_Reverse_Iterator (const REVERSE_IMPLEMENTATION &iterator_impl); - - /// Copy constructor. - ACE_Cache_Map_Reverse_Iterator (const ACE_Cache_Map_Reverse_Iterator &rhs); - - ~ACE_Cache_Map_Reverse_Iterator (void); - - // = Iteration methods. - - /// Assignment operator. - ACE_Cache_Map_Reverse_Iterator &operator= - (const ACE_Cache_Map_Reverse_Iterator &rhs); - - /// Comparision operators. - bool operator== (const ACE_Cache_Map_Reverse_Iterator &rhs) const; - bool operator!= (const ACE_Cache_Map_Reverse_Iterator &rhs) const; - - /// Returns a reference to the internal element @c this is pointing - /// to. - ACE_Reference_Pair operator* (void) const; - - // = STL styled iteration, compare, and reference functions. - - /// Prefix advance - ACE_Cache_Map_Reverse_Iterator &operator++ (void); - - /// Postfix advance. - ACE_Cache_Map_Reverse_Iterator operator++ (int); - - /// Prefix reverse. - ACE_Cache_Map_Reverse_Iterator &operator-- (void); - - /// Postfix reverse. - ACE_Cache_Map_Reverse_Iterator operator-- (int); - - /// Returns the iterator of the internal map in the custody of the - /// Cache_Map_Manager. - REVERSE_IMPLEMENTATION &iterator_implementation (void); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - /// The actual iterator which iterates internally on the map - /// belonging to the Cache_Map_Manager. - REVERSE_IMPLEMENTATION reverse_iterator_implementation_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Cache_Map_Manager_T.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Cache_Map_Manager_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Cache_Map_Manager_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" - -#endif /* ACE_CACHE_MAP_MANAGER_T_H */ diff --git a/ACE/ace/Cache_Map_Manager_T.inl b/ACE/ace/Cache_Map_Manager_T.inl deleted file mode 100644 index ba30c528dd6..00000000000 --- a/ACE/ace/Cache_Map_Manager_T.inl +++ /dev/null @@ -1,245 +0,0 @@ -// -*- C++ -*- -// -//$Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template ACE_INLINE int -ACE_Cache_Map_Manager::purge (void) -{ - return this->caching_strategy ().caching_utility ().clear_cache (this->map_, - this->caching_strategy ().purge_percent ()); -} - -template ACE_INLINE size_t -ACE_Cache_Map_Manager::current_size (void) const -{ - return this->map_.current_size (); -} - -template ACE_INLINE size_t -ACE_Cache_Map_Manager::total_size (void) const -{ - return this->map_.total_size (); -} - -template ACE_INLINE CMAP_TYPE & -ACE_Cache_Map_Manager::map (void) -{ - return this->map_; -} - -template ACE_INLINE CACHING_STRATEGY & -ACE_Cache_Map_Manager::caching_strategy (void) -{ - return this->caching_strategy_; -} - -template ACE_INLINE ACE_Cache_Map_Iterator -ACE_Cache_Map_Manager::begin (void) -{ - return ITERATOR (this->map_.begin ()); -} - -template ACE_INLINE ACE_Cache_Map_Iterator -ACE_Cache_Map_Manager::end (void) -{ - return ITERATOR (this->map_.end ()); -} - -template ACE_INLINE ACE_Cache_Map_Reverse_Iterator -ACE_Cache_Map_Manager::rbegin (void) -{ - return REVERSE_ITERATOR (this->map_.rbegin ()); -} -template ACE_INLINE ACE_Cache_Map_Reverse_Iterator -ACE_Cache_Map_Manager::rend (void) -{ - return REVERSE_ITERATOR (this->map_.rend ()); -} - -//////////////////////////////////////////////////////////////////////////////// - -template ACE_INLINE -ACE_Cache_Map_Iterator::ACE_Cache_Map_Iterator (const ACE_Cache_Map_Iterator &rhs) - : iterator_implementation_ (rhs.iterator_implementation_) -{ -} - -template ACE_INLINE ACE_Cache_Map_Iterator & -ACE_Cache_Map_Iterator::operator= (const ACE_Cache_Map_Iterator &rhs) -{ - this->iterator_implementation_ = rhs.iterator_implementation_; - return *this; -} - -template ACE_INLINE bool -ACE_Cache_Map_Iterator::operator== (const ACE_Cache_Map_Iterator &rhs) const -{ - return this->iterator_implementation_ == rhs.iterator_implementation_; -} - -template ACE_INLINE bool -ACE_Cache_Map_Iterator::operator!= (const ACE_Cache_Map_Iterator &rhs) const -{ - return this->iterator_implementation_ != rhs.iterator_implementation_; -} - -template ACE_INLINE ACE_Reference_Pair -ACE_Cache_Map_Iterator::operator* (void) const -{ - value_type retn ((*this->iterator_implementation_).ext_id_, - (*this->iterator_implementation_).int_id_.first ()); - return retn; -} - -template ACE_INLINE -ACE_Cache_Map_Iterator & -ACE_Cache_Map_Iterator::operator++ (void) -{ - ++this->iterator_implementation_; - return *this; -} - -template ACE_INLINE -ACE_Cache_Map_Iterator -ACE_Cache_Map_Iterator::operator++ (int) -{ - ACE_Cache_Map_Iterator retn = *this; - ++this->iterator_implementation_; - return retn; -} - -template ACE_INLINE -ACE_Cache_Map_Iterator & -ACE_Cache_Map_Iterator::operator-- (void) -{ - --this->iterator_implementation_; - return *this; -} - -template ACE_INLINE -ACE_Cache_Map_Iterator -ACE_Cache_Map_Iterator::operator-- (int) -{ - ACE_Cache_Map_Iterator retn = *this; - --this->iterator_implementation_; - return retn; -} - -template ACE_INLINE void -ACE_Cache_Map_Iterator::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - this->iterator_implementation_.dump (); -#endif /* ACE_HAS_DUMP */ -} - -template ACE_INLINE -ACE_Cache_Map_Iterator::ACE_Cache_Map_Iterator (const IMPLEMENTATION &iterator_impl) - : iterator_implementation_ (iterator_impl) -{ -} - -template ACE_INLINE IMPLEMENTATION & -ACE_Cache_Map_Iterator::iterator_implementation (void) -{ - return this->iterator_implementation_; -} - -//////////////////////////////////////////////////////////////////////////////// - -template ACE_INLINE -ACE_Cache_Map_Reverse_Iterator::ACE_Cache_Map_Reverse_Iterator (const ACE_Cache_Map_Reverse_Iterator &rhs) - : reverse_iterator_implementation_ (rhs.reverse_iterator_implementation_) -{ -} - -template ACE_INLINE -ACE_Cache_Map_Reverse_Iterator::~ACE_Cache_Map_Reverse_Iterator (void) -{ -} - -template ACE_INLINE ACE_Cache_Map_Reverse_Iterator & -ACE_Cache_Map_Reverse_Iterator::operator= (const ACE_Cache_Map_Reverse_Iterator &rhs) -{ - this->reverse_iterator_implementation_ = rhs.reverse_iterator_implementation_; - return *this; -} - -template ACE_INLINE bool -ACE_Cache_Map_Reverse_Iterator::operator== (const ACE_Cache_Map_Reverse_Iterator &rhs) const -{ - return this->reverse_iterator_implementation_ == rhs.reverse_iterator_implementation_; -} - -template ACE_INLINE bool -ACE_Cache_Map_Reverse_Iterator::operator!= (const ACE_Cache_Map_Reverse_Iterator &rhs) const -{ - return this->reverse_iterator_implementation_ != rhs.reverse_iterator_implementation_; -} - -template ACE_INLINE ACE_Reference_Pair -ACE_Cache_Map_Reverse_Iterator::operator* (void) const -{ - value_type retv ((*this->reverse_iterator_implementation_).ext_id_, - (*this->reverse_iterator_implementation_).int_id_.first ()); - return retv; -} - -template ACE_INLINE -ACE_Cache_Map_Reverse_Iterator & -ACE_Cache_Map_Reverse_Iterator::operator++ (void) -{ - ++this->reverse_iterator_implementation_; - return *this; -} - -template ACE_INLINE -ACE_Cache_Map_Reverse_Iterator -ACE_Cache_Map_Reverse_Iterator::operator++ (int) -{ - ACE_Cache_Map_Reverse_Iterator retn = *this; - ++this->reverse_iterator_implementation_; - return retn; -} - -template ACE_INLINE -ACE_Cache_Map_Reverse_Iterator & -ACE_Cache_Map_Reverse_Iterator::operator-- (void) -{ - --this->reverse_iterator_implementation_; - return *this; -} - -template ACE_INLINE -ACE_Cache_Map_Reverse_Iterator -ACE_Cache_Map_Reverse_Iterator::operator-- (int) -{ - ACE_Cache_Map_Reverse_Iterator retn = *this; - --this->reverse_iterator_implementation_; - return retn; -} - - -template ACE_INLINE void -ACE_Cache_Map_Reverse_Iterator::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - this->reverse_iterator_implementation_.dump (); -#endif /* ACE_HAS_DUMP */ -} - -template ACE_INLINE -ACE_Cache_Map_Reverse_Iterator::ACE_Cache_Map_Reverse_Iterator (const REVERSE_IMPLEMENTATION &iterator_impl) - : reverse_iterator_implementation_(iterator_impl) -{ -} - -template ACE_INLINE REVERSE_IMPLEMENTATION & -ACE_Cache_Map_Reverse_Iterator::iterator_implementation (void) -{ - return this->reverse_iterator_implementation_; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Cached_Connect_Strategy_T.cpp b/ACE/ace/Cached_Connect_Strategy_T.cpp deleted file mode 100644 index 5c4720b2085..00000000000 --- a/ACE/ace/Cached_Connect_Strategy_T.cpp +++ /dev/null @@ -1,734 +0,0 @@ -//$Id$ - -#ifndef ACE_CACHED_CONNECT_STRATEGY_T_CPP -#define ACE_CACHED_CONNECT_STRATEGY_T_CPP - -#include "ace/Cached_Connect_Strategy_T.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/ACE.h" -#include "ace/Service_Repository.h" -#include "ace/Service_Types.h" -#include "ace/Thread_Manager.h" -#include "ace/WFMO_Reactor.h" -#include "ace/Pair_T.h" - -#define ACE_T1 class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class ATTRIBUTES, class MUTEX -#define ACE_T2 SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template -ACE_Cached_Connect_Strategy_Ex::ACE_Cached_Connect_Strategy_Ex -(CACHING_STRATEGY &caching_s, - ACE_Creation_Strategy *cre_s, - ACE_Concurrency_Strategy *con_s, - ACE_Recycling_Strategy *rec_s, - MUTEX *lock, - int delete_lock) - : CCSBASE (cre_s, con_s, rec_s, lock, delete_lock), - connection_cache_ (caching_s) -{ - if (this->open (cre_s, con_s, rec_s) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Cached_Connect_Strategy_Ex\n"))); -} - -template -ACE_Cached_Connect_Strategy_Ex::~ACE_Cached_Connect_Strategy_Ex (void) -{ - cleanup (); -} - - -template int -ACE_Cached_Connect_Strategy_Ex::check_hint_i -(SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms, - ACE_Hash_Map_Entry, ACE_Pair > *&entry, - int &found) -{ - ACE_UNUSED_ARG (remote_addr); - ACE_UNUSED_ARG (timeout); - ACE_UNUSED_ARG (local_addr); - ACE_UNUSED_ARG (reuse_addr); - ACE_UNUSED_ARG (flags); - ACE_UNUSED_ARG (perms); - - found = 0; - - // Get the recycling act for the svc_handler - CONNECTION_CACHE_ENTRY *possible_entry = - (CONNECTION_CACHE_ENTRY *) sh->recycling_act (); - - // Check to see if the hint svc_handler has been closed down - if (possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_CLOSED) - { - // If close, decrement refcount - if (possible_entry->ext_id_.decrement () == 0) - { - // If refcount goes to zero, close down the svc_handler - possible_entry->int_id_.first ()->recycler (0, 0); - possible_entry->int_id_.first ()->close (); - this->purge_i (possible_entry); - } - - // Hint not successful - found = 0; - - // Reset hint - sh = 0; - } - - // If hint is not closed, see if it is connected to the correct - // address and is recyclable - else if ((possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_AND_PURGABLE || - possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE) && - possible_entry->ext_id_.subject () == remote_addr) - { - // Hint successful - found = 1; - - // Tell the that it should prepare itself for - // being recycled. - this->prepare_for_recycling (sh); - - // - // Update the caching attributes directly since we don't do a - // find() on the cache map. - // - - // Indicates successful find. - int find_result = 0; - - int result = this->caching_strategy ().notify_find (find_result, - possible_entry->int_id_.second ()); - - if (result == -1) - return result; - } - else - { - // This hint will not be used. - possible_entry->ext_id_.decrement (); - - // Hint not successful - found = 0; - - // If is not connected to the correct address or is busy, - // we will not use it. - sh = 0; - } - - if (found) - entry = possible_entry; - - return 0; -} - -template int -ACE_Cached_Connect_Strategy_Ex::find_or_create_svc_handler_i -(SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms, - ACE_Hash_Map_Entry, ACE_Pair > *&entry, - int &found) -{ - REFCOUNTED_HASH_RECYCLABLE_ADDRESS search_addr (remote_addr); - - // Try to find the address in the cache. Only if we don't find it - // do we create a new and connect it with the server. - while (this->find (search_addr, entry) != -1) - { - // We found a cached svc_handler. - // Get the cached - sh = entry->int_id_.first (); - - // Is the connection clean? - int state_result = - ACE::handle_ready (sh->peer ().get_handle (), - &ACE_Time_Value::zero, - 1, // read ready - 0, // write ready - 1);// exception ready - - if (state_result == 1) - { - - if (sh->close () == -1) - return -1; - - sh = 0; - - // Cycle it once again.. - } - else if ((state_result == -1) && (errno == ETIME)) - { - // Found!!! - // Set the flag - found = 1; - - // Tell the that it should prepare itself for - // being recycled. - if (this->prepare_for_recycling (sh) == -1) - return -1; - - return 0; - } - else - { - return -1; - } - } - - // Not found... - - // Set the flag - found = 0; - - // We need to use a temporary variable here since we are not - // allowed to change because other threads may use this - // when we let go of the lock during the OS level connect. - // - // Note that making a new svc_handler, connecting remotely, - // binding to the map, and assigning of the hint and recycler - // should be atomic to the outside world. - SVC_HANDLER *potential_handler = 0; - - // Create a new svc_handler - if (this->make_svc_handler (potential_handler) == -1) - return -1; - - // Connect using the svc_handler. - if (this->cached_connect (potential_handler, - remote_addr, - timeout, - local_addr, - reuse_addr, - flags, - perms) == -1) - { - // Close the svc handler. - potential_handler->close (0); - - return -1; - } - else - { - // Insert the new SVC_HANDLER instance into the cache. - if (this->connection_cache_.bind (search_addr, - potential_handler, - entry) == -1) - { - // Close the svc handler and reset . - potential_handler->close (0); - - return -1; - } - - // Everything succeeded as planned. Assign to - // . - sh = potential_handler; - - // Set the recycler and the recycling act - - this->assign_recycler (sh, this, entry); - } - - return 0; -} - -template int -ACE_Cached_Connect_Strategy_Ex::cached_connect (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms) -{ - // Actively establish the connection. This is a timed blocking - // connect. - if (this->new_connection (sh, - remote_addr, - timeout, - local_addr, - reuse_addr, - flags, - perms) == -1) - { - // If connect() failed because of timeouts, we have to reject - // the connection entirely. This is necessary since currently - // there is no way for the non-blocking connects to complete and - // for the to notify the cache of the completion of - // connect(). - - if (errno == EWOULDBLOCK || errno == ETIMEDOUT) - errno = ENOTSUP; - else if (ACE::out_of_handles (errno) || errno == EADDRINUSE) - { - // If the connect failed due to the process running out of - // file descriptors then, auto_purging of some connections - // are done from the CONNECTION_CACHE. This frees the - // descriptors which get used in the connect process and - // hence the same method is called again! - if (this->purge_connections () == -1) - return -1; - - // Try connecting again. - if (this->new_connection (sh, - remote_addr, - timeout, - local_addr, - reuse_addr, - flags, - perms) == -1) - { - if (errno == EWOULDBLOCK || errno == ETIMEDOUT) - errno = ENOTSUP; - return -1; - } - } - else - { - return -1; - } - } - - return 0; - -} - - -template int -ACE_Cached_Connect_Strategy_Ex::connect_svc_handler_i -(SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms, - int& found) -{ - CONNECTION_CACHE_ENTRY *entry = 0; - - // Check if the user passed a hint svc_handler - if (sh != 0) - { - int result = this->check_hint_i (sh, - remote_addr, - timeout, - local_addr, - reuse_addr, - flags, - perms, - entry, - found); - if (result != 0) - return result; - } - - // If not found - if (!found) - { - int result = this->find_or_create_svc_handler_i (sh, - remote_addr, - timeout, - local_addr, - reuse_addr, - flags, - perms, - entry, - found); - - if (result != 0) - return result; - - // Increment the refcount - entry->ext_id_.increment (); - } - - // For all successful cases: mark the in the cache - // as being . Therefore recyclable is BUSY. - entry->ext_id_.recycle_state (ACE_RECYCLABLE_BUSY); - - return 0; -} - - -template int -ACE_Cached_Connect_Strategy_Ex::cache_i (const void *recycling_act) -{ - // The wonders and perils of ACT - CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act; - - // Mark the in the cache as not being . - // Therefore recyclable is IDLE. - entry->ext_id_.recycle_state (ACE_RECYCLABLE_IDLE_AND_PURGABLE); - - return 0; -} - -template int -ACE_Cached_Connect_Strategy_Ex::recycle_state_i (const void *recycling_act, - ACE_Recyclable_State new_state) -{ - // The wonders and perils of ACT - CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act; - - // Mark the in the cache as not being . - // Therefore recyclable is IDLE. - entry->ext_id_.recycle_state (new_state); - - return 0; -} - -template ACE_Recyclable_State -ACE_Cached_Connect_Strategy_Ex::recycle_state_i (const void *recycling_act) const -{ - // The wonders and perils of ACT - CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act; - - // Mark the in the cache as not being . - // Therefore recyclable is IDLE. - return entry->ext_id_.recycle_state (); -} - -template int -ACE_Cached_Connect_Strategy_Ex::purge_i (const void *recycling_act) -{ - // The wonders and perils of ACT - CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act; - - return this->connection_cache_.unbind (entry); -} - - -template int -ACE_Cached_Connect_Strategy_Ex::mark_as_closed_i (const void *recycling_act) -{ - // The wonders and perils of ACT - CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act; - - // Mark the in the cache as CLOSED. - entry->ext_id_.recycle_state (ACE_RECYCLABLE_CLOSED); - - return 0; -} - -template int -ACE_Cached_Connect_Strategy_Ex::cleanup_hint_i (const void *recycling_act, - void **act_holder) -{ - // Reset the <*act_holder> in the confines and protection of the - // lock. - if (act_holder) - *act_holder = 0; - - // The wonders and perils of ACT - CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act; - - // Decrement the refcount on the . - int refcount = entry->ext_id_.decrement (); - - // If the svc_handler state is closed and the refcount == 0, call - // close() on svc_handler. - if (entry->ext_id_.recycle_state () == ACE_RECYCLABLE_CLOSED && - refcount == 0) - { - entry->int_id_.first ()->recycler (0, 0); - entry->int_id_.first ()->close (); - this->purge_i (entry); - } - - return 0; -} - -template int -ACE_Cached_Connect_Strategy_Ex::purge_connections (void) -{ - return this->connection_cache_.purge (); -} - -template CACHING_STRATEGY & -ACE_Cached_Connect_Strategy_Ex::caching_strategy (void) -{ - return this->connection_cache_.caching_strategy (); -} - -template int -ACE_Cached_Connect_Strategy_Ex::find (ACE_Refcounted_Hash_Recyclable &search_addr, - ACE_Hash_Map_Entry, ACE_Pair > *&entry) -{ - typedef ACE_Hash_Map_Bucket_Iterator, - ACE_Hash, - ACE_Equal_To, - ACE_Null_Mutex> - CONNECTION_CACHE_BUCKET_ITERATOR; - - CONNECTION_CACHE_BUCKET_ITERATOR iterator (this->connection_cache_.map (), - search_addr); - - CONNECTION_CACHE_BUCKET_ITERATOR end (this->connection_cache_.map (), - search_addr, - 1); - - for (; - iterator != end; - ++iterator) - { - REFCOUNTED_HASH_RECYCLABLE_ADDRESS &addr = (*iterator).ext_id_; - - if (addr.recycle_state () != ACE_RECYCLABLE_IDLE_AND_PURGABLE && - addr.recycle_state () != ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE) - continue; - - if (addr.subject () != search_addr.subject ()) - continue; - - entry = &(*iterator); - - // - // Update the caching attributes directly since we don't do a - // find() on the cache map. - // - - // Indicates successful find. - int find_result = 0; - - int result = this->caching_strategy ().notify_find (find_result, - entry->int_id_.second ()); - - if (result == -1) - return result; - - return 0; - } - - return -1; -} - -template void -ACE_Cached_Connect_Strategy_Ex::cleanup (void) -{ - // Excluded other threads from changing the cache while we cleanup - ACE_GUARD (MUTEX, ace_mon, *this->lock_); - - // Close down all cached service handlers. - typename CONNECTION_CACHE::ITERATOR iter = this->connection_cache_.begin (); - while (iter != this->connection_cache_.end ()) - { - if ((*iter).second () != 0) - { - // save entry for future use - CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) - (*iter).second ()->recycling_act (); - - // close handler - (*iter).second ()->recycler (0, 0); - (*iter).second ()->close (); - - // remember next iter - typename CONNECTION_CACHE::ITERATOR next_iter = iter; - ++next_iter; - - // purge the item from the hash - this->purge_i (entry); - - // assign next iter - iter = next_iter; - } - else - ++iter; - } -} - -ACE_ALLOC_HOOK_DEFINE(ACE_Cached_Connect_Strategy_Ex) -///////////////////////////////////////////////////////////////////////// - -template -ACE_Bounded_Cached_Connect_Strategy::ACE_Bounded_Cached_Connect_Strategy -(size_t max_size, - CACHING_STRATEGY &caching_s, - ACE_Creation_Strategy *cre_s, - ACE_Concurrency_Strategy *con_s, - ACE_Recycling_Strategy *rec_s, - MUTEX *lock, - int delete_lock) - : CCSEBASE (caching_s, cre_s, con_s, rec_s, lock, delete_lock), - max_size_ (max_size) -{ -} - -template -ACE_Bounded_Cached_Connect_Strategy::~ACE_Bounded_Cached_Connect_Strategy(void) -{ -} - -template -int -ACE_Bounded_Cached_Connect_Strategy::find_or_create_svc_handler_i -(SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms, - ACE_Hash_Map_Entry, - ACE_Pair > *&entry, - int &found) -{ - - REFCOUNTED_HASH_RECYCLABLE_ADDRESS search_addr (remote_addr); - - // Try to find the address in the cache. Only if we don't find it - // do we create a new and connect it with the server. - while (this->find (search_addr, entry) != -1) - { - // We found a cached svc_handler. - // Get the cached - sh = entry->int_id_.first (); - - // Is the connection clean? - int state_result= ACE::handle_ready (sh->peer ().get_handle (), - &ACE_Time_Value::zero, - 1, // read ready - 0, // write ready - 1);// exception ready - - if (state_result == 1) - { - // The connection was disconnected during idle. - // close the svc_handler down. - if (sh->close () == -1) - { - ACE_ASSERT (0); - return -1; - } - sh = 0; - // and rotate once more... - } - else if ((state_result == -1) && (errno == ETIME)) - { - // Found!!! - // Set the flag - found = 1; - - // Tell the that it should prepare itself for - // being recycled. - if (this->prepare_for_recycling (sh) == -1) - { - ACE_ASSERT (0); - return -1; - } - - return 0; - } - else // some other return value or error... - { - ACE_ASSERT (0); // just to see it coming - - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("(%t)ACE_Bounded_Cached_Connect_Strategy<>::") - ACE_TEXT ("find_or_create_svc_handler_i - ") - ACE_TEXT ("error polling server socket state.\n"))); - - return -1; - } - } - - // Not found... - - // Set the flag - found = 0; - - // Check the limit of handlers... - if ((this->max_size_ > 0) && - (this->connection_cache_.current_size () >= this->max_size_)) - { - // Try to purge idle connections - if (this->purge_connections () == -1) - return -1; - - // Check limit again. - if (this->connection_cache_.current_size () >= this->max_size_) - // still too much! - return -1; - - // OK, we have room now... - } - - // We need to use a temporary variable here since we are not - // allowed to change because other threads may use this - // when we let go of the lock during the OS level connect. - // - // Note that making a new svc_handler, connecting remotely, - // binding to the map, and assigning of the hint and recycler - // should be atomic to the outside world. - SVC_HANDLER *potential_handler = 0; - - // Create a new svc_handler - if (this->make_svc_handler (potential_handler) == -1) - return -1; - - // Connect using the svc_handler. - if (this->cached_connect (potential_handler, - remote_addr, - timeout, - local_addr, - reuse_addr, - flags, - perms) == -1) - { - // Close the svc handler. - potential_handler->close (0); - return -1; - } - else - { - // Insert the new SVC_HANDLER instance into the cache. - if (this->connection_cache_.bind (search_addr, - potential_handler, - entry) == -1) - { - // Close the svc handler and reset . - potential_handler->close (0); - - return -1; - } - - // Everything succeeded as planned. Assign to - // . - sh = potential_handler; - - // Set the recycler and the recycling act - this->assign_recycler (sh, this, entry); - } - - return 0; -} - -ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Cached_Connect_Strategy) - -ACE_END_VERSIONED_NAMESPACE_DECL - -#undef ACE_T1 -#undef ACE_T2 - -#endif /* ACE_CACHED_CONNECT_STRATEGY_T_CPP */ diff --git a/ACE/ace/Cached_Connect_Strategy_T.h b/ACE/ace/Cached_Connect_Strategy_T.h deleted file mode 100644 index f5543727824..00000000000 --- a/ACE/ace/Cached_Connect_Strategy_T.h +++ /dev/null @@ -1,262 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Cached_Connect_Strategy_T.h - * - * $Id$ - * - * @author Kirthika Parameswaran - */ -//============================================================================= - -#ifndef CACHED_CONNECT_STRATEGY_T_H -#define CACHED_CONNECT_STRATEGY_T_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Strategies_T.h" -#include "ace/Hash_Cache_Map_Manager_T.h" -#include "ace/Caching_Strategies_T.h" -#include "ace/Functor_T.h" -#include "ace/Pair_T.h" - -// For linkers which cant grok long names... -#define ACE_Cached_Connect_Strategy_Ex ACCSE - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Cached_Connect_Strategy_Ex - * - * @brief A connection strategy which caches connections to peers - * (represented by SVC_HANDLER instances), thereby allowing - * subsequent re-use of unused, but available, connections. - * - * is intended to be used as a - * plug-in connection strategy for ACE_Strategy_Connector. - * It's added value is re-use of established connections and - * tweaking the role of the cache as per the caching strategy. - */ -template -class ACE_Cached_Connect_Strategy_Ex - : public ACE_Cached_Connect_Strategy -{ -public: - /// Constructor - ACE_Cached_Connect_Strategy_Ex ( - CACHING_STRATEGY &caching_s, - ACE_Creation_Strategy *cre_s = 0, - ACE_Concurrency_Strategy *con_s = 0, - ACE_Recycling_Strategy *rec_s = 0, - MUTEX *lock = 0, - int delete_lock = 0); - - /// Destructor - virtual ~ACE_Cached_Connect_Strategy_Ex (void); - - /// Explicit purging of connection entries from the connection cache. - virtual int purge_connections (void); - - /// Mark as closed (non-locking version). This is used during the cleanup of the - /// connections purged. - virtual int mark_as_closed_i (const void *recycling_act); - - /** - * Since g++ version < 2.8 arent happy with templates, this special - * method had to be devised to avoid memory leaks and perform - * cleanup of the . - */ - void cleanup (void); - - // = Typedefs for managing the map - typedef ACE_Refcounted_Hash_Recyclable - REFCOUNTED_HASH_RECYCLABLE_ADDRESS; - typedef ACE_Hash_Cache_Map_Manager, - ACE_Equal_To, - CACHING_STRATEGY, - ATTRIBUTES> - CONNECTION_CACHE; - typedef typename CONNECTION_CACHE::CACHE_ENTRY CONNECTION_CACHE_ENTRY; - typedef typename CONNECTION_CACHE::key_type KEY; - typedef typename CONNECTION_CACHE::mapped_type VALUE; - - typedef ACE_Recyclable_Handler_Cleanup_Strategy, - ACE_Hash_Map_Manager_Ex, - ACE_Hash, - ACE_Equal_To, - MUTEX> > - CLEANUP_STRATEGY; - - typedef ACE_Cached_Connect_Strategy - CCSBASE; - - // = Accessor. - CACHING_STRATEGY &caching_strategy (void); - -protected: - - /// Find an idle handle. - int find (ACE_Refcounted_Hash_Recyclable &search_addr, - ACE_Hash_Map_Entry, ACE_Pair > *&entry); - - /// Remove from cache (non-locking version). - virtual int purge_i (const void *recycling_act); - - /// Add to cache (non-locking version). - virtual int cache_i (const void *recycling_act); - - /// Get/Set (non-locking version). - virtual int recycle_state_i (const void *recycling_act, - ACE_Recyclable_State new_state); - virtual ACE_Recyclable_State recycle_state_i (const void *recycling_act) const; - - /// Cleanup hint and reset <*act_holder> to zero if . - virtual int cleanup_hint_i (const void *recycling_act, - void **act_holder); - - // = Helpers - int check_hint_i (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms, - ACE_Hash_Map_Entry, ACE_Pair > *&entry, - int &found); - - virtual int find_or_create_svc_handler_i (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms, - ACE_Hash_Map_Entry, ACE_Pair > *&entry, - int &found); - - virtual int connect_svc_handler_i (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms, - int &found); - - /** - * Connection of the svc_handler with the remote host. This method - * also encapsulates the connection done with auto_purging under the - * hood. If the connect failed due to the process running out of - * file descriptors then, auto_purging of some connections are done - * from the CONNECTION_CACHE. This frees the descriptors which get - * used in the connect process and hence the connect operation can - * succeed. - */ - virtual int cached_connect (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms); - - /// Table that maintains the cache of connected SVC_HANDLERs. - CONNECTION_CACHE connection_cache_; -}; - -///////////////////////////////////////////////////////////////////////////// - -// For linkers which cant grok long names... -#define ACE_Bounded_Cached_Connect_Strategy ABCCS - -/** - * @class ACE_Bounded_Cached_Connect_Strategy - * - * @brief A connection strategy which caches connections to peers - * (represented by SVC_HANDLER instances), thereby allowing - * subsequent re-use of unused, but available, connections. - * This strategy should be used when the cache is bounded by - * maximum size. - * - * is intended to be used as a - * plug-in connection strategy for ACE_Strategy_Connector. - * It's added value is re-use of established connections and - * tweaking the role of the cache as per the caching strategy. - * Thanks to Edan Ayal for contributing this - * class and Susan Liebeskind for - * brainstorming about it. - */ -template -class ACE_Bounded_Cached_Connect_Strategy - : public ACE_Cached_Connect_Strategy_Ex -{ - - typedef ACE_Cached_Connect_Strategy_Ex - CCSEBASE; - - // = Typedefs for managing the map - typedef ACE_Refcounted_Hash_Recyclable - REFCOUNTED_HASH_RECYCLABLE_ADDRESS; - -public: - - /// Constructor - ACE_Bounded_Cached_Connect_Strategy (size_t max_size, - CACHING_STRATEGY &caching_s, - ACE_Creation_Strategy *cre_s = 0, - ACE_Concurrency_Strategy *con_s = 0, - ACE_Recycling_Strategy *rec_s = 0, - MUTEX *lock = 0, - int delete_lock = 0); - - /// Destructor - virtual ~ACE_Bounded_Cached_Connect_Strategy (void); - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - - virtual int find_or_create_svc_handler_i (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms, - ACE_Hash_Map_Entry, - ACE_Pair > *&entry, - int &found); - -protected: - - /// max items in the cache, used as a bound for the creation of svc_handlers. - size_t max_size_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Cached_Connect_Strategy_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Cached_Connect_Strategy_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" -#endif /* CACHED_CONNECT_STRATEGY_T_H */ diff --git a/ACE/ace/Caching_Strategies_T.cpp b/ACE/ace/Caching_Strategies_T.cpp deleted file mode 100644 index db2f9067ec9..00000000000 --- a/ACE/ace/Caching_Strategies_T.cpp +++ /dev/null @@ -1,59 +0,0 @@ -//$Id$ - -#ifndef ACE_CACHING_STRATEGIES_T_CPP -#define ACECACHING_STRATEGIES_T_CPP - -#include "ace/Caching_Strategies_T.h" -#include "ace/Log_Msg.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Caching_Strategies_T.inl" -#endif /* __ACE_INLINE__ */ - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template -ACE_Caching_Strategy::~ACE_Caching_Strategy (void) -{ -} - -////////////////////////////////////////////////////////////////////////////////// - -template -ACE_LRU_Caching_Strategy::ACE_LRU_Caching_Strategy (void) - : timer_ (0), - purge_percent_ (10) -{ -} - -//////////////////////////////////////////////////////////////////////////////////////////////// - -template -ACE_LFU_Caching_Strategy::ACE_LFU_Caching_Strategy (void) - : purge_percent_ (10) -{ -} - -//////////////////////////////////////////////////////////////////////////////////////////////// - -template -ACE_FIFO_Caching_Strategy::ACE_FIFO_Caching_Strategy (void) - : order_ (0), - purge_percent_ (10) -{ -} - -//////////////////////////////////////////////////////////////////////////////////////////////// - -ACE_ALLOC_HOOK_DEFINE(ACE_LRU_Caching_Strategy) -ACE_ALLOC_HOOK_DEFINE(ACE_LFU_Caching_Strategy) -ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Caching_Strategy) -ACE_ALLOC_HOOK_DEFINE(ACE_Null_Caching_Strategy) - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_CACHING_STRATEGIES_T_CPP */ diff --git a/ACE/ace/Caching_Strategies_T.h b/ACE/ace/Caching_Strategies_T.h deleted file mode 100644 index 6d23824ba31..00000000000 --- a/ACE/ace/Caching_Strategies_T.h +++ /dev/null @@ -1,552 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Caching_Strategies_T.h - * - * $Id$ - * - * @author Kirthika Parameswaran - */ -//============================================================================= - -#ifndef ACE_CACHING_STRATEGIES_H -#define ACE_CACHING_STRATEGIES_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" -#include "ace/Caching_Utility_T.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined(_MSC_VER) -#pragma warning(disable:4503) -#endif /* _MSC_VER */ - -// For linkers that cant grok long names. -#define ACE_Caching_Strategy ACS - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Caching_Strategy - * - * @brief This class is an abstract base class for a caching strategy. - * - * This class consists of all the interfaces a caching strategy should - * have and is used in association with the - * ACE_Caching_Strategy_Adaptor. - */ -template -class ACE_Caching_Strategy -{ -public: - /// Destructor. - virtual ~ACE_Caching_Strategy (void); - - /// Accessor method for the timer attributes. - virtual ATTRIBUTES attributes (void) = 0; - - /// Get the percentage of entries to purge. - virtual double purge_percent (void) = 0; - - /// Set the percentage of entries to purge. - virtual void purge_percent (double percentage) = 0; - - // = Strategy related Operations - - /// This method acts as a notification about the CONTAINERs bind - /// method call. - virtual int notify_bind (int result, - const ATTRIBUTES &attr) = 0; - - /// This method acts as a notification about the CONTAINERs find - /// method call - virtual int notify_find (int result, - ATTRIBUTES &attr) = 0; - - /// This method acts as a notification about the CONTAINERs unbind - /// method call - virtual int notify_unbind (int result, - const ATTRIBUTES &attr) = 0; - - /// This method acts as a notification about the CONTAINERs trybind - /// method call - virtual int notify_trybind (int result, - ATTRIBUTES &attr) = 0; - - /// This method acts as a notification about the CONTAINERs rebind - /// method call - virtual int notify_rebind (int result, - const ATTRIBUTES &attr) = 0; - - /// Purge the cache. - virtual CACHING_UTILITY &caching_utility (void) = 0; - - /// Dumps the state of the object. - virtual void dump (void) const = 0; -}; - -////////////////////////////////////////////////////////////////////////// - -#define ACE_Caching_Strategy_Adapter ACSA - -/** - * @class ACE_Caching_Strategy_Adapter - * - * @brief This class follows the Adaptor pattern and is used to provide - * External Polymorphism by deriving from ACE_Caching_Strategy. - * - * This class simply delegates all requests to the - * IMPLEMNETATION object within. This class should be passed in - * place of the the abstract base ACE_Caching_Strategy class as - * part of the External Polymorphism pattern. - */ -template -class ACE_Caching_Strategy_Adapter - : public ACE_Caching_Strategy -{ - -public: - - /// Constructor. - ACE_Caching_Strategy_Adapter (IMPLEMENTATION *implementation = 0, - bool delete_implementation = false); - - /// Destructor. - ~ACE_Caching_Strategy_Adapter (void); - - /// Accessor method for the timer attributes. - ATTRIBUTES attributes (void); - - /// Get the percentage of entries to purge. - double purge_percent (void); - - /// Set the percentage of entries to purge. - void purge_percent (double percentage); - - // = Strategy related Operations - - /// This method acts as a notification about the CONTAINERs bind - /// method call. - int notify_bind (int result, - const ATTRIBUTES &attr); - - /// This method acts as a notification about the CONTAINERs find - /// method call - int notify_find (int result, - ATTRIBUTES &attr); - - /// This method acts as a notification about the CONTAINERs unbind - /// method call - int notify_unbind (int result, - const ATTRIBUTES &attr); - - /// This method acts as a notification about the CONTAINERs trybind - /// method call - int notify_trybind (int result, - ATTRIBUTES &attr); - - /// This method acts as a notification about the CONTAINERs rebind - /// method call - int notify_rebind (int result, - const ATTRIBUTES &attr); - - /// Accessor to the implementation. - IMPLEMENTATION &implementation (void); - - /// Purge the cache. - CACHING_UTILITY &caching_utility (void); - - /// Dumps the state of the object. - void dump (void) const; - -private: - - /// Implementation class. - IMPLEMENTATION *implementation_; - - /// Do we need to delete the implementation? - bool delete_implementation_; -}; - -////////////////////////////////////////////////////////////////////////// -#define ACE_LRU_Caching_Strategy ALRU - -/** - * @class ACE_LRU_Caching_Strategy - * - * @brief Defines a Least Recently Used strategy which will decide on - * the item to be removed from the cache. - * - * This is a strategy which makes use of a virtual timer which - * is updated whenever an item is inserted or looked up in the - * container. When the need of purging entries arises, the items - * with the lowest timer values are removed. - * Explanation of the template parameter list: - * CONTAINER is any map with entries of type . - * The ATTRIBUTES are the deciding factor for purging of entries - * and should logically be included with the VALUE. Some ways of - * doing this are: As being a member of the VALUE or VALUE being - * ACE_Pair. The CACHING_UTILITY is the - * class which can be plugged in and which decides the entries - * to purge. - */ -template -class ACE_LRU_Caching_Strategy -{ -public: - - // Traits. - typedef ATTRIBUTES CACHING_ATTRIBUTES; - - // = Initialisation and termination. - - /** - * The is the map in which the entries reside. The - * timer attribute is initialed to zero in this constructor. And - * the field denotes the percentage of the entries - * in the cache which can be purged automagically and by default is - * set to 10%. - */ - ACE_LRU_Caching_Strategy (void); - - // = Operations of the strategy. - - /// Accessor method for the timer attributes. - ATTRIBUTES attributes (void); - - /// Get the percentage of entries to purge. - double purge_percent (void); - - /// Set the percentage of entries to purge. - void purge_percent (double percentage); - - // = Strategy related Operations - - /// This method acts as a notification about the CONTAINERs bind - /// method call. - int notify_bind (int result, - const ATTRIBUTES &attr); - - /// This method acts as a notification about the CONTAINERs find - /// method call - int notify_find (int result, - ATTRIBUTES &attr); - - /// This method acts as a notification about the CONTAINERs unbind - /// method call - int notify_unbind (int result, - const ATTRIBUTES &attr); - - - /// This method acts as a notification about the CONTAINERs trybind - /// method call - int notify_trybind (int result, - ATTRIBUTES &attr); - - /// This method acts as a notification about the CONTAINERs rebind - /// method call - int notify_rebind (int result, - const ATTRIBUTES &attr); - - /// Purge the cache. - CACHING_UTILITY &caching_utility (void); - - /// Dumps the state of the object. - void dump (void) const; - -private: - - /// This element is the one which is the deciding factor for purging - /// of an ITEM. - ATTRIBUTES timer_; - - /// The level about which the purging will happen automagically. - double purge_percent_; - - /// This is the helper class which will decide and expunge entries - /// from the cache. - CACHING_UTILITY caching_utility_; -}; - -////////////////////////////////////////////////////////////////////////// -#define ACE_LFU_Caching_Strategy ALFU - -/** - * @class ACE_LFU_Caching_Strategy - * - * @brief Defines a Least Frequently Used strategy for which will decide on - * the item to be removed from the cache. - * - * A attribute is tagged to each item which increments whenever - * the item is bound or looked up in the cache. Thus it denotes - * the frequency of use. According to the value of the attribute - * the item is removed from the CONTAINER i.e cache. - * Explanation of the template parameter list: - * CONTAINER is any map with entries of type . - * The ATTRIBUTES are the deciding factor for purging of entries - * and should logically be included with the VALUE. Some ways of - * doing this are: As being a member of the VALUE or VALUE being - * ACE_Pair. The CACHING_UTILITY is the - * class which can be plugged in and which decides the entries - * to purge. - */ -template -class ACE_LFU_Caching_Strategy -{ - -public: - - // Traits. - typedef ATTRIBUTES CACHING_ATTRIBUTES; - - // = Initialisation and termination methods. - - /** - * The is the map in which the entries reside. The - * timer attribute is initialed to zero in this constructor. And - * the field denotes the percentage of the entries - * in the cache which can be purged automagically and by default is - * set to 10%. - */ - ACE_LFU_Caching_Strategy (void); - - // = Strategy methods. - - /// Access the attributes. - ATTRIBUTES attributes (void); - - /// Get the percentage of entries to purge. - double purge_percent (void); - - /// Set the percentage of entries to purge. - void purge_percent (double percentage); - - // = Strategy related Operations - - /// This method acts as a notification about the CONTAINERs bind - /// method call. - int notify_bind (int result, - const ATTRIBUTES &attr); - - /// Lookup notification. - int notify_find (int result, - ATTRIBUTES &attr); - - /// This method acts as a notification about the CONTAINERs unbind - /// method call - int notify_unbind (int result, - const ATTRIBUTES &attr); - - /// This method acts as a notification about the CONTAINERs trybind - /// method call - int notify_trybind (int result, - ATTRIBUTES &attr); - - /// This method acts as a notification about the CONTAINERs rebind - /// method call - int notify_rebind (int result, - const ATTRIBUTES &attr); - - /// Purge the cache. - CACHING_UTILITY &caching_utility (void); - - /// Dumps the state of the object. - void dump (void) const; - -private: - - /// The level about which the purging will happen automagically. - double purge_percent_; - - /// This is the helper class which will decide and expunge entries - /// from the cache. - CACHING_UTILITY caching_utility_; -}; - -///////////////////////////////////////////////////////////// -#define ACE_FIFO_Caching_Strategy AFIFO - -/** - * @class ACE_FIFO_Caching_Strategy - * - * @brief The First In First Out strategy is implemented wherein each - * item is ordered. - * - * The order tag of each item is used to decide the item to be - * removed from the cache. The items with least order are removed. - * Explanation of the template parameter list: - * CONTAINER is any map with entries of type . - * The ATTRIBUTES are the deciding factor for purging of entries - * and should logically be included with the VALUE. Some ways of - * doing this are: As being a member of the VALUE or VALUE being - * ACE_Pair. The CACHING_UTILITY is the - * class which can be plugged in and which decides the entries - * to purge. - */ -template -class ACE_FIFO_Caching_Strategy -{ - -public: - - typedef ATTRIBUTES CACHING_ATTRIBUTES; - - // = Initialisation and termination. - - /** - * The is the map in which the entries reside. The - * timer attribute is initialed to zero in this constructor. And - * the field denotes the percentage of the entries - * in the cache which can be purged automagically and by default is - * set to 10%. - */ - ACE_FIFO_Caching_Strategy (void); - - // = Strategy methods. - - /// Accessor method. - ATTRIBUTES attributes (void); - - /// Get the percentage of entries to purge. - double purge_percent (void); - - /// Set the percentage of entries to purge. - void purge_percent (double percentage); - - // = Strategy related Operations - - /// Notification for an item getting bound into the cache. - int notify_bind (int result, - const ATTRIBUTES &attr); - - /// This method acts as a notification about the CONTAINERs find - /// method call - int notify_find (int result, - ATTRIBUTES &attr); - - /// This method acts as a notification about the CONTAINERs unbind - /// method call - int notify_unbind (int result, - const ATTRIBUTES &attr); - - /// This method acts as a notification about the CONTAINERs trybind - /// method call - int notify_trybind (int result, - ATTRIBUTES &attr); - - /// Notification for an item getting bound again into the cache. - int notify_rebind (int result, - const ATTRIBUTES &attr); - - /// Purge the cache. - CACHING_UTILITY &caching_utility (void); - - /// Dumps the state of the object. - void dump (void) const; - -private: - - /// The order is the deciding factor for the item to be removed from - /// the cache. - ATTRIBUTES order_; - - /// The level about which the purging will happen automagically. - double purge_percent_; - - /// This is the helper class which will decide and expunge entries - /// from the cache. - CACHING_UTILITY caching_utility_; -}; - -////////////////////////////////////////////////////////////////////// -#define ACE_Null_Caching_Strategy ANULL - -/** - * @class ACE_Null_Caching_Strategy - * - * @brief The is a special caching strategy which doesnt have the purging - * feature. - * - * No purging provided. To be used when purging might be too expensive - * an operation. - */ -template -class ACE_Null_Caching_Strategy -{ - -public: - - // = Traits. - typedef ATTRIBUTES CACHING_ATTRIBUTES; - - // = Strategy methods. All are NO_OP methods!!! - - /// Accessor method. - ATTRIBUTES attributes (void); - - /// Get the percentage of entries to purge. - double purge_percent (void); - - /// Set the percentage of entries to purge. - void purge_percent (double percentage); - - // = Strategy related Operations - - /// Notification for an item getting bound into the cache. - int notify_bind (int result, - const ATTRIBUTES &attr); - - /// This method acts as a notification about the CONTAINERs find - /// method call - int notify_find (int result, - ATTRIBUTES &attr); - - /// This method acts as a notification about the CONTAINERs unbind - /// method call - int notify_unbind (int result, - const ATTRIBUTES &attr); - - /// This method acts as a notification about the CONTAINERs trybind - /// method call - int notify_trybind (int result, - ATTRIBUTES &attr); - - /// Notification for an item getting bound again into the cache. - int notify_rebind (int result, - const ATTRIBUTES &attr); - - /// Purge the cache. - CACHING_UTILITY &caching_utility (void); - - /// Dumps the state of the object. - void dump (void) const; - -private: - - /// This is the helper class which will decide and expunge entries - /// from the cache. - CACHING_UTILITY caching_utility_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Caching_Strategies_T.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Caching_Strategies_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Caching_Strategies_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" - -#endif /* ACE_CACHING_STRATEGIES_H */ diff --git a/ACE/ace/Caching_Strategies_T.inl b/ACE/ace/Caching_Strategies_T.inl deleted file mode 100644 index 69f1ac99807..00000000000 --- a/ACE/ace/Caching_Strategies_T.inl +++ /dev/null @@ -1,456 +0,0 @@ -// -*-C++-*- -// -//$Id$ - -////////////////////////////////////////////////////////////////////////////////// - -#include "ace/OS_Memory.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template ACE_INLINE -ACE_Caching_Strategy_Adapter::ACE_Caching_Strategy_Adapter (IMPLEMENTATION *implementation, - bool delete_implementation) - : implementation_ (implementation), - delete_implementation_ (delete_implementation) -{ - if (this->implementation_ == 0) - { - ACE_NEW (this->implementation_, - IMPLEMENTATION); - this->delete_implementation_ = true; - } -} - -template ACE_INLINE -ACE_Caching_Strategy_Adapter::~ACE_Caching_Strategy_Adapter (void) -{ - if (this->delete_implementation_) - { - delete this->implementation_; - this->delete_implementation_ = false; - this->implementation_ = 0; - } -} - -template ACE_INLINE ATTRIBUTES -ACE_Caching_Strategy_Adapter::attributes (void) -{ - return this->implementation_->attributes (); -} - -template ACE_INLINE double -ACE_Caching_Strategy_Adapter::purge_percent (void) -{ - return this->implementation_->purge_percent (); -} - -template ACE_INLINE void -ACE_Caching_Strategy_Adapter::purge_percent (double percentage) -{ - this->implementation_->purge_percent (percentage); -} - -template ACE_INLINE int -ACE_Caching_Strategy_Adapter::notify_bind (int result, - const ATTRIBUTES &attr) -{ - return this->implementation_->notify_bind (result, - attr); -} - -template ACE_INLINE int -ACE_Caching_Strategy_Adapter::notify_find (int result, - ATTRIBUTES &attr) -{ - return this->implementation_->notify_find (result, - attr); -} - -template ACE_INLINE int -ACE_Caching_Strategy_Adapter::notify_unbind (int result, - const ATTRIBUTES &attr) -{ - return this->implementation_->notify_unbind (result, - attr); -} - -template ACE_INLINE int -ACE_Caching_Strategy_Adapter::notify_trybind (int result, - ATTRIBUTES &attr) -{ - return this->implementation_->notify_trybind (result, - attr); -} - -template ACE_INLINE int -ACE_Caching_Strategy_Adapter::notify_rebind (int result, - const ATTRIBUTES &attr) -{ - return this->implementation_->notify_rebind (result, - attr); -} - -template ACE_INLINE IMPLEMENTATION & -ACE_Caching_Strategy_Adapter::implementation (void) -{ - return *this->implementation_; -} - -template ACE_INLINE CACHING_UTILITY & -ACE_Caching_Strategy_Adapter::caching_utility (void) -{ - return this->implementation_->caching_utility (); -} - -template ACE_INLINE void -ACE_Caching_Strategy_Adapter::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Caching_Strategy_Adapter::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -////////////////////////////////////////////////////////////////////////////////// - -template ACE_INLINE ATTRIBUTES -ACE_LRU_Caching_Strategy::attributes (void) -{ - return this->timer_; -} - -template ACE_INLINE double -ACE_LRU_Caching_Strategy::purge_percent (void) -{ - return this->purge_percent_; -} - -template ACE_INLINE void -ACE_LRU_Caching_Strategy::purge_percent (double percentage) -{ - this->purge_percent_ = percentage; -} - -template ACE_INLINE int -ACE_LRU_Caching_Strategy::notify_bind ( - int result, - const ATTRIBUTES & /* attr */) -{ - if (result == 0) - ++this->timer_; - - return result; -} - -template ACE_INLINE int -ACE_LRU_Caching_Strategy::notify_find ( - int result, - ATTRIBUTES &attr) -{ - if (result == 0) - { - attr = this->timer_; - ++this->timer_; - } - - return result; -} - -template ACE_INLINE int -ACE_LRU_Caching_Strategy::notify_unbind ( - int result, - const ATTRIBUTES & /* attr */) -{ - return result; -} - -template ACE_INLINE int -ACE_LRU_Caching_Strategy::notify_trybind ( - int result, - ATTRIBUTES & /* attr */) -{ - return result; -} - -template ACE_INLINE int -ACE_LRU_Caching_Strategy::notify_rebind ( - int result, - const ATTRIBUTES & /* attr */) -{ - if (result == 0) - ++this->timer_; - - return result; -} - -template ACE_INLINE CACHING_UTILITY & -ACE_LRU_Caching_Strategy::caching_utility (void) -{ - return this->caching_utility_; -} - -template ACE_INLINE void -ACE_LRU_Caching_Strategy::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_LRU_Caching_Strategy::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("timer_ = %d "), this->timer_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -////////////////////////////////////////////////////////////////////////////////// - -template ACE_INLINE ATTRIBUTES -ACE_LFU_Caching_Strategy::attributes (void) -{ - return 0; -} - -template ACE_INLINE double -ACE_LFU_Caching_Strategy::purge_percent (void) -{ - return this->purge_percent_; -} - -template ACE_INLINE void -ACE_LFU_Caching_Strategy::purge_percent (double percentage) -{ - this->purge_percent_ = percentage; -} - -template ACE_INLINE int -ACE_LFU_Caching_Strategy::notify_bind (int result, - const ATTRIBUTES & /* attr */) -{ - - return result; -} - -template ACE_INLINE int -ACE_LFU_Caching_Strategy::notify_find (int result, - ATTRIBUTES &attr) -{ - if (result == 0) - ++attr; - - return result; -} - -template ACE_INLINE int -ACE_LFU_Caching_Strategy::notify_trybind (int result, - ATTRIBUTES & /* attr */) -{ - return result; -} - -template ACE_INLINE int -ACE_LFU_Caching_Strategy::notify_rebind (int result, - const ATTRIBUTES & /* attr */) -{ - return result; -} - -template ACE_INLINE int -ACE_LFU_Caching_Strategy::notify_unbind (int result, - const ATTRIBUTES & /* attr */) -{ - return result; -} - -template ACE_INLINE CACHING_UTILITY & -ACE_LFU_Caching_Strategy::caching_utility (void) -{ - return this->caching_utility_; -} - -template ACE_INLINE void -ACE_LFU_Caching_Strategy::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_LFU_Caching_Strategy::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -////////////////////////////////////////////////////////////////////////////////////// - -template ACE_INLINE ATTRIBUTES -ACE_FIFO_Caching_Strategy::attributes (void) -{ - return this->order_; -} - -template ACE_INLINE double -ACE_FIFO_Caching_Strategy::purge_percent (void) -{ - return this->purge_percent_; -} - -template ACE_INLINE void -ACE_FIFO_Caching_Strategy::purge_percent (double percentage) -{ - this->purge_percent_ = percentage; -} - -template ACE_INLINE int -ACE_FIFO_Caching_Strategy::notify_bind (int result, - const ATTRIBUTES &attr) -{ - ACE_UNUSED_ARG (attr); - - if (result == 0) - ++this->order_; - - return result; -} - -template ACE_INLINE int -ACE_FIFO_Caching_Strategy::notify_find (int result, - ATTRIBUTES &attr) -{ - ACE_UNUSED_ARG (attr); - - return result; -} - -template ACE_INLINE int -ACE_FIFO_Caching_Strategy::notify_unbind (int result, - const ATTRIBUTES &attr) -{ - ACE_UNUSED_ARG (attr); - - return result; -} - -template ACE_INLINE int -ACE_FIFO_Caching_Strategy::notify_trybind (int result, - ATTRIBUTES &attr) -{ - ACE_UNUSED_ARG (attr); - - return result; -} - -template ACE_INLINE int -ACE_FIFO_Caching_Strategy::notify_rebind (int result, - const ATTRIBUTES &attr) -{ - ACE_UNUSED_ARG (attr); - - if (result == 0) - ++this->order_; - - return result; -} - -template ACE_INLINE CACHING_UTILITY & -ACE_FIFO_Caching_Strategy::caching_utility (void) -{ - return this->caching_utility_; -} - -template ACE_INLINE void -ACE_FIFO_Caching_Strategy::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_FIFO_Caching_Strategy::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("order_ = %d "), this->order_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -////////////////////////////////////////////////////////////////////////////////// - -template ACE_INLINE ATTRIBUTES -ACE_Null_Caching_Strategy::attributes (void) -{ - return 0; -} - -template ACE_INLINE double -ACE_Null_Caching_Strategy::purge_percent (void) -{ - return 0; -} - -template ACE_INLINE void -ACE_Null_Caching_Strategy::purge_percent (double percentage) -{ - ACE_UNUSED_ARG (percentage); -} - -template ACE_INLINE int -ACE_Null_Caching_Strategy::notify_bind (int result, - const ATTRIBUTES &attr) -{ - ACE_UNUSED_ARG (attr); - - return result; -} - -template ACE_INLINE int -ACE_Null_Caching_Strategy::notify_find (int result, - ATTRIBUTES &attr) -{ - ACE_UNUSED_ARG (attr); - - return result; -} - -template ACE_INLINE int -ACE_Null_Caching_Strategy::notify_unbind (int result, - const ATTRIBUTES &attr) -{ - ACE_UNUSED_ARG (attr); - - return result; -} - -template ACE_INLINE int -ACE_Null_Caching_Strategy::notify_trybind (int result, - ATTRIBUTES &attr) -{ - ACE_UNUSED_ARG (attr); - - return result; -} - -template ACE_INLINE int -ACE_Null_Caching_Strategy::notify_rebind (int result, - const ATTRIBUTES &attr) -{ - ACE_UNUSED_ARG (attr); - - return result; -} - -template ACE_INLINE CACHING_UTILITY & -ACE_Null_Caching_Strategy::caching_utility (void) -{ - return this->caching_utility_; -} - -template ACE_INLINE void -ACE_Null_Caching_Strategy::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Null_Caching_Strategy::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -////////////////////////////////////////////////////////////////////////////////// diff --git a/ACE/ace/Caching_Utility_T.cpp b/ACE/ace/Caching_Utility_T.cpp deleted file mode 100644 index c8b7a48e807..00000000000 --- a/ACE/ace/Caching_Utility_T.cpp +++ /dev/null @@ -1,499 +0,0 @@ -// $Id$ - -#ifndef ACE_CACHING_UTILITY_T_CPP -#define ACE_CACHING_UTILITY_T_CPP - -#include "ace/Caching_Utility_T.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Min_Max.h" -#include "ace/OS_Memory.h" -#include "ace/Recyclable.h" - -////////////////////////////////////////////////////////////////////////////// - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template -ACE_Pair_Caching_Utility::ACE_Pair_Caching_Utility (ACE_Cleanup_Strategy *cleanup_strategy, - int delete_cleanup_strategy) - : cleanup_strategy_ (cleanup_strategy), - delete_cleanup_strategy_ (delete_cleanup_strategy) -{ - if (cleanup_strategy == 0) - { - ACE_NEW (this->cleanup_strategy_, - CLEANUP_STRATEGY); - this->delete_cleanup_strategy_ = 1; - } -} - -template -ACE_Pair_Caching_Utility::~ACE_Pair_Caching_Utility (void) -{ - if (this->delete_cleanup_strategy_) - delete this->cleanup_strategy_; -} - -template int -ACE_Pair_Caching_Utility::clear_cache (CONTAINER &container, - double purge_percent) -{ - // Check that the purge_percent is non-zero. - if (purge_percent == 0) - return 0; - - // Get the number of entries in the container. - size_t current_map_size = container.current_size (); - - // Also whether the number of entries in the cache! - // Oops! then there is no way out but exiting. So return an error. - if (current_map_size == 0) - return 0; - - // Calculate the no of entries to remove from the cache depending - // upon the . - size_t const entries_to_remove - = ACE_MAX (static_cast (1), - static_cast (static_cast (purge_percent) - / 100 * current_map_size)); - KEY *key_to_remove = 0; - VALUE *value_to_remove = 0; - - for (size_t i = 0; i < entries_to_remove ; ++i) - { - this->minimum (container, - key_to_remove, - value_to_remove); - - // Simply verifying that the key is non-zero. - // This is important for strategies where the minimum - // entry cant be found due to constraints on the type of entry - // to remove. - if (key_to_remove == 0) - return 0; - - if (this->cleanup_strategy_->cleanup (container, - key_to_remove, - value_to_remove) == -1) - return -1; - - } - - return 0; -} - -template void -ACE_Pair_Caching_Utility::minimum (CONTAINER &container, - KEY *&key_to_remove, - VALUE *&value_to_remove) -{ - // Starting values. - ITERATOR iter = container.begin (); - ITERATOR end = container.end (); - ATTRIBUTES min = (*iter).int_id_.second (); - key_to_remove = &(*iter).ext_id_; - value_to_remove = &(*iter).int_id_; - - // The iterator moves thru the container searching for the entry - // with the lowest ATTRIBUTES. - for (++iter; - iter != end; - ++iter) - { - if (min > (*iter).int_id_.second ()) - { - // Ah! an item with lower ATTTRIBUTES... - min = (*iter).int_id_.second (); - key_to_remove = &(*iter).ext_id_; - value_to_remove = &(*iter).int_id_; - } - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////// - -template -ACE_Recyclable_Handler_Caching_Utility::ACE_Recyclable_Handler_Caching_Utility (ACE_Cleanup_Strategy *cleanup_strategy, - int delete_cleanup_strategy) - : cleanup_strategy_ (cleanup_strategy), - delete_cleanup_strategy_ (delete_cleanup_strategy) -{ - if (cleanup_strategy == 0) - { - ACE_NEW (this->cleanup_strategy_, - CLEANUP_STRATEGY); - this->delete_cleanup_strategy_ = 1; - } -} - -template -ACE_Recyclable_Handler_Caching_Utility::~ACE_Recyclable_Handler_Caching_Utility (void) -{ - if (this->delete_cleanup_strategy_) - delete this->cleanup_strategy_; -} - -template int -ACE_Recyclable_Handler_Caching_Utility::clear_cache (CONTAINER &container, - double purge_percent) -{ - // Check that the purge_percent is non-zero. - if (purge_percent == 0) - return 0; - - // Get the number of entries in the container. - size_t current_map_size = container.current_size (); - - // Also whether the number of entries in the cache is just one! - // Oops! then there is no way out but exiting. So return an error. - // if (current_map_size <= 1) - if (current_map_size == 0) - return 0; - - // Calculate the no of entries to remove from the cache depending - // upon the . - size_t const entries_to_remove - = ACE_MAX (static_cast (1), - static_cast (static_cast (purge_percent) - / 100 * current_map_size)); - - KEY *key_to_remove = 0; - VALUE *value_to_remove = 0; - - for (size_t i = 0; i < entries_to_remove ; ++i) - { - this->minimum (container, - key_to_remove, - value_to_remove); - - // Simply verifying that the key is non-zero. - // This is important for strategies where the minimum - // entry cant be found due to constraints on the type of entry - // to remove. - if (key_to_remove == 0) - return 0; - - if (this->cleanup_strategy_->cleanup (container, - key_to_remove, - value_to_remove) == -1) - return -1; - } - - return 0; -} - -template void -ACE_Recyclable_Handler_Caching_Utility::minimum (CONTAINER &container, - KEY *&key_to_remove, - VALUE *&value_to_remove) -{ - // Starting values. - ITERATOR end = container.end (); - ITERATOR iter = container.begin (); - ATTRIBUTES min = (*iter).int_id_.second (); - key_to_remove = 0; - value_to_remove = 0; - // Found the minimum entry to be purged? - int found = 0; - - // The iterator moves thru the container searching for the entry - // with the lowest ATTRIBUTES. - for (; - iter != end; - ++iter) - { - // If the entry isnt IDLE_AND_PURGABLE continue until you reach - // the first entry which can be purged. This is the minimum with - // which you will compare the rest of the purgable entries. - if ((*iter).ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_AND_PURGABLE || - (*iter).ext_id_.recycle_state () == ACE_RECYCLABLE_PURGABLE_BUT_NOT_IDLE) - { - if (found == 0) - { - min = (*iter).int_id_.second (); - key_to_remove = &(*iter).ext_id_; - value_to_remove = &(*iter).int_id_; - found = 1; - } - else - { - // Ah! an entry with lower ATTTRIBUTES... - if (min > (*iter).int_id_.second ()) - { - min = (*iter).int_id_.second (); - key_to_remove = &(*iter).ext_id_; - value_to_remove = &(*iter).int_id_; - } - } - } - } -} - -//////////////////////////////////////////////////////////////////////////////// - -template -ACE_Refcounted_Recyclable_Handler_Caching_Utility::ACE_Refcounted_Recyclable_Handler_Caching_Utility (ACE_Cleanup_Strategy *cleanup_strategy, - int delete_cleanup_strategy) - : cleanup_strategy_ (cleanup_strategy), - delete_cleanup_strategy_ (delete_cleanup_strategy), - marked_as_closed_entries_ (0) -{ - if (cleanup_strategy == 0) - { - ACE_NEW (this->cleanup_strategy_, - CLEANUP_STRATEGY); - this->delete_cleanup_strategy_ = 1; - } -} - -template -ACE_Refcounted_Recyclable_Handler_Caching_Utility::~ACE_Refcounted_Recyclable_Handler_Caching_Utility (void) -{ - if (this->delete_cleanup_strategy_) - delete this->cleanup_strategy_; -} - -template int -ACE_Refcounted_Recyclable_Handler_Caching_Utility::clear_cache (CONTAINER &container, - double purge_percent) -{ - // Check that the purge_percent is non-zero. - if (purge_percent == 0) - return 0; - - // Get the number of entries in the container which can be considered for purging. - size_t const available_entries = - container.current_size () - this->marked_as_closed_entries_; - - // Also whether the number of entries in the cache zero. - // Oops! then there is no way out but exiting. - if (available_entries <= 0) - return 0; - - // Calculate the no of entries to remove from the cache depending - // upon the . - size_t entries_to_remove - = ACE_MAX (static_cast (1), - static_cast (static_cast (purge_percent) - / 100 * available_entries)); - - if (entries_to_remove >= available_entries || entries_to_remove == 0) - entries_to_remove = available_entries - 1; - - KEY *key_to_remove = 0; - VALUE *value_to_remove = 0; - - for (size_t i = 0; i < entries_to_remove ; ++i) - { - this->minimum (container, - key_to_remove, - value_to_remove); - - // Simply verifying that the key is non-zero. - // This is important for strategies where the minimum - // entry cant be found due to constraints on the type of entry - // to remove. - if (key_to_remove == 0) - return 0; - - if (this->cleanup_strategy_->cleanup (container, - key_to_remove, - value_to_remove) == -1) - return -1; - - ++this->marked_as_closed_entries_; - } - - return 0; -} - -template void -ACE_Refcounted_Recyclable_Handler_Caching_Utility::minimum (CONTAINER &container, - KEY *&key_to_remove, - VALUE *&value_to_remove) -{ - // Starting values. - ITERATOR end = container.end (); - ITERATOR iter = container.begin (); - ATTRIBUTES min = (*iter).int_id_.second (); - key_to_remove = 0; - value_to_remove = 0; - // Found the minimum entry to be purged? - int found = 0; - - // The iterator moves thru the container searching for the entry - // with the lowest ATTRIBUTES. - for (; - iter != end; - ++iter) - { - // If the entry isnt IDLE_AND_PURGABLE continue until you reach - // the first entry which can be purged. This is the minimum with - // which you will compare the rest of the purgable entries. - if ((*iter).ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_AND_PURGABLE || - (*iter).ext_id_.recycle_state () == ACE_RECYCLABLE_PURGABLE_BUT_NOT_IDLE) - { - if (found == 0) - { - min = (*iter).int_id_.second (); - key_to_remove = &(*iter).ext_id_; - value_to_remove = &(*iter).int_id_; - found = 1; - } - else - { - // Ah! an entry with lower ATTTRIBUTES... - if (min > (*iter).int_id_.second ()) - { - min = (*iter).int_id_.second (); - key_to_remove = &(*iter).ext_id_; - value_to_remove = &(*iter).int_id_; - } - } - } - } -} - -//////////////////////////////////////////////////////////////////////////////// - -template -ACE_Handler_Caching_Utility::ACE_Handler_Caching_Utility (ACE_Cleanup_Strategy *cleanup_strategy, - int delete_cleanup_strategy) - : cleanup_strategy_ (cleanup_strategy), - delete_cleanup_strategy_ (delete_cleanup_strategy) -{ - if (cleanup_strategy == 0) - { - ACE_NEW (this->cleanup_strategy_, - CLEANUP_STRATEGY); - this->delete_cleanup_strategy_ = 1; - } -} - -template -ACE_Handler_Caching_Utility::~ACE_Handler_Caching_Utility (void) -{ - if (this->delete_cleanup_strategy_) - delete this->cleanup_strategy_; -} - -template int -ACE_Handler_Caching_Utility::clear_cache (CONTAINER &container, - double purge_percent) -{ - // Check that the purge_percent is non-zero. - if (purge_percent == 0) - return 0; - - // Get the number of entries in the container. - size_t current_map_size = container.current_size (); - - // Also whether the number of entries in the cache is just one! - // Oops! then there is no way out but exiting. So return an error. - if (current_map_size == 0) - return 0; - - // Calculate the no of entries to remove from the cache depending - // upon the . - size_t entries_to_remove - = ACE_MAX (static_cast (1), - static_cast (static_cast (purge_percent) - / 100 * current_map_size)); - - KEY *key_to_remove = 0; - VALUE *value_to_remove = 0; - - for (size_t i = 0; i < entries_to_remove ; ++i) - { - this->minimum (container, - key_to_remove, - value_to_remove); - - if (this->cleanup_strategy_->cleanup (container, - key_to_remove, - value_to_remove) == -1) - return -1; - } - - return 0; -} - -template void -ACE_Handler_Caching_Utility::minimum (CONTAINER &container, - KEY *&key_to_remove, - VALUE *&value_to_remove) -{ - // Starting values. - ITERATOR iter = container.begin (); - ITERATOR end = container.end (); - ATTRIBUTES min = (*iter).int_id_->caching_attributes (); - key_to_remove = &(*iter).ext_id_; - value_to_remove = &(*iter).int_id_; - - // The iterator moves thru the container searching for the entry - // with the lowest ATTRIBUTES. - for (++iter; - iter != end; - ++iter) - { - if (min > (*iter).int_id_->caching_attributes () && - (*iter).int_id_->active () != 1) - { - // Ah! an item with lower ATTTRIBUTES... - min = (*iter).int_id_->caching_attributes (); - key_to_remove = &(*iter).ext_id_; - value_to_remove = &(*iter).int_id_; - } - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////// - -template -ACE_Null_Caching_Utility::ACE_Null_Caching_Utility (ACE_Cleanup_Strategy *cleanup_strategy, - int delete_cleanup_strategy) - : cleanup_strategy_ (cleanup_strategy), - delete_cleanup_strategy_ (delete_cleanup_strategy) -{ - if (cleanup_strategy == 0) - { - ACE_NEW (this->cleanup_strategy_, - CLEANUP_STRATEGY); - this->delete_cleanup_strategy_ = 1; - } -} - -template -ACE_Null_Caching_Utility::~ACE_Null_Caching_Utility (void) -{ - if (this->delete_cleanup_strategy_) - delete this->cleanup_strategy_; -} - -template int -ACE_Null_Caching_Utility::clear_cache (CONTAINER &container, - double purge_percent) -{ - ACE_UNUSED_ARG (container); - ACE_UNUSED_ARG (purge_percent); - - return 0; -} - -template void -ACE_Null_Caching_Utility::minimum (CONTAINER &container, - KEY *&key_to_remove, - VALUE *&value_to_remove) -{ - ACE_UNUSED_ARG (container); - ACE_UNUSED_ARG (key_to_remove); - ACE_UNUSED_ARG (value_to_remove); -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_CACHING_UTILITY_T_CPP */ diff --git a/ACE/ace/Caching_Utility_T.h b/ACE/ace/Caching_Utility_T.h deleted file mode 100644 index 1c1ce48894a..00000000000 --- a/ACE/ace/Caching_Utility_T.h +++ /dev/null @@ -1,347 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Caching_Utility_T.h - * - * $Id$ - * - * @author Kirthika Parameswaran - */ -//============================================================================= - -#ifndef ACE_CACHING_UTILITY_H -#define ACE_CACHING_UTILITY_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Global_Macros.h" -#include "ace/Cleanup_Strategies_T.h" - -// For linkers that cant grok long names. -#define ACE_Pair_Caching_Utility APUTIL - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Pair_Caching_Utility - * - * @brief Defines a helper class for the Caching Strategies. - * - * This class defines the methods commonly used by the different - * caching strategies. For instance: method which - * decides and purges the entry from the container. @note This - * class helps in the caching_strategies using a container - * containing entries of > - * kind. The attributes helps in deciding the entries to be - * purged. The Cleanup_Strategy is the callback class to which the - * entries to be cleaned up will be delegated. - */ -template -class ACE_Pair_Caching_Utility -{ -public: - - typedef ACE_Cleanup_Strategy CLEANUP_STRATEGY; - - /// Constructor. - ACE_Pair_Caching_Utility (ACE_Cleanup_Strategy *cleanup_strategy = 0, - int delete_cleanup_strategy = 0); - - /// Destructor. - ~ACE_Pair_Caching_Utility (void); - - /** - * Purge entries from the @a container. The Cleanup_Strategy will do the - * actual job of cleanup once the entries to be cleaned up are decided. - */ - int clear_cache (CONTAINER &container, - double purge_percent); - -protected: - - /// Find the entry with minimum caching attributes. - void minimum (CONTAINER &container, - KEY *&key_to_remove, - VALUE *&value_to_remove); - - /// The cleanup strategy which can be used to destroy the entries of - /// the container. - CLEANUP_STRATEGY *cleanup_strategy_; - - /// Whether the cleanup_strategy should be destroyed or not. - int delete_cleanup_strategy_; - - ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Pair_Caching_Utility &)) - ACE_UNIMPLEMENTED_FUNC (ACE_Pair_Caching_Utility (const ACE_Pair_Caching_Utility &)) -}; - -//////////////////////////////////////////////////////////////////////////////// -#define ACE_Recyclable_Handler_Caching_Utility ARHUTIL - -/** - * @class ACE_Recyclable_Handler_Caching_Utility - * - * @brief Defines a helper class for the Caching Strategies. - * - * This class defines the methods commonly used by the different - * caching strategies. For instance: method which - * decides and purges the entry from the container. @note This - * class helps in the caching_strategies using a container - * containing entries of kind. The attributes - * helps in deciding the entries to be purged. The - * Cleanup_Strategy is the callback class to which the entries to - * be cleaned up will be delegated. - */ -template -class ACE_Recyclable_Handler_Caching_Utility -{ - -public: - - typedef ACE_Recyclable_Handler_Cleanup_Strategy CLEANUP_STRATEGY; - typedef ACE_Cleanup_Strategy CLEANUP_STRATEGY_BASE; - - /// Constructor. - ACE_Recyclable_Handler_Caching_Utility (ACE_Cleanup_Strategy *cleanup_strategy = 0, - int delete_cleanup_strategy = 0); - - /// Destructor. - ~ACE_Recyclable_Handler_Caching_Utility (void); - - /** - * Purge entries from the . The Cleanup_Strategy will do - * the actual job of cleanup once the entries to be cleaned up are - * decided. - */ - int clear_cache (CONTAINER &container, - double purge_percent); - -protected: - - /// Find the entry with minimum caching attributes. - void minimum (CONTAINER &container, - KEY *&key_to_remove, - VALUE *&value_to_remove); - - /// This is the default Cleanup Strategy for this utility. - CLEANUP_STRATEGY_BASE *cleanup_strategy_; - - /// Whether the cleanup_strategy should be destroyed or not. - int delete_cleanup_strategy_; - -private: - ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Recyclable_Handler_Caching_Utility &)) - ACE_UNIMPLEMENTED_FUNC (ACE_Recyclable_Handler_Caching_Utility (const ACE_Recyclable_Handler_Caching_Utility &)) -}; - -/////////////////////////////////////////////////////////////////////////// -#define ACE_Refcounted_Recyclable_Handler_Caching_Utility ARRHUTIL - -/** - * @class ACE_Refcounted_Recyclable_Handler_Caching_Utility - * - * @brief Defines a helper class for the Caching Strategies. - * - * This class defines the methods commonly used by the different - * caching strategies. For instance: clear_cache () method which - * decides and purges the entry from the container. @note This - * class helps in the caching_strategies using a container - * containing entries of kind. The attributes helps in - * deciding the entries to be purged. The Cleanup_Strategy is the - * callback class to which the entries to be cleaned up will be - * delegated. - */ -template -class ACE_Refcounted_Recyclable_Handler_Caching_Utility -{ - -public: - - typedef ACE_Refcounted_Recyclable_Handler_Cleanup_Strategy CLEANUP_STRATEGY; - typedef ACE_Cleanup_Strategy CLEANUP_STRATEGY_BASE; - - /// Constructor. - ACE_Refcounted_Recyclable_Handler_Caching_Utility (ACE_Cleanup_Strategy *cleanup_strategy = 0, - int delete_cleanup_strategy = 0); - - /// Destructor. - ~ACE_Refcounted_Recyclable_Handler_Caching_Utility (void); - - /** - * Purge entries from the . The Cleanup_Strategy will do - * the actual job of cleanup once the entries to be cleaned up are - * decided. - */ - int clear_cache (CONTAINER &container, - double purge_percent); - -protected: - - /// Find the entry with minimum caching attributes. - void minimum (CONTAINER &container, - KEY *&key_to_remove, - VALUE *&value_to_remove); - - /// This is the default Cleanup Strategy for this utility. - CLEANUP_STRATEGY_BASE *cleanup_strategy_; - - /// Whether the cleanup_strategy should be destroyed or not. - int delete_cleanup_strategy_; - - /** - * This figure denotes the number of entries are there in the - * container which have been marked as closed already but might - * not have been unbound from the container. - */ - size_t marked_as_closed_entries_; - -private: - ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Refcounted_Recyclable_Handler_Caching_Utility &)) - ACE_UNIMPLEMENTED_FUNC (ACE_Refcounted_Recyclable_Handler_Caching_Utility (const ACE_Refcounted_Recyclable_Handler_Caching_Utility &)) -}; - -//////////////////////////////////////////////////////////////////////////////////////// - -/** - * @class ACE_Handler_Caching_Utility - * - * @brief Defines a helper class for the Caching Strategies. - * - * This class defines the methods commonly used by the different - * caching strategies. For instance: method which - * decides and purges the entry from the container. @note This - * class helps in the caching_strategies using a container - * containing entries of kind where the HANDLER - * contains the caching attributes which help in deciding the - * entries to be purged. The Cleanup_Strategy is the callback - * class to which the entries to be cleaned up will be delegated. - */ -template -class ACE_Handler_Caching_Utility -{ -public: - - typedef ACE_Handler_Cleanup_Strategy CLEANUP_STRATEGY; - typedef ACE_Cleanup_Strategy CLEANUP_STRATEGY_BASE; - - /// Constructor. - ACE_Handler_Caching_Utility (ACE_Cleanup_Strategy *cleanup_strategy = 0, - int delete_cleanup_strategy = 0); - - /// Destructor. - ~ACE_Handler_Caching_Utility (void); - - /** - * Purge entries from the . The Cleanup_Strategy will do - * the actual job of cleanup once the entries to be cleaned up are - * decided. - */ - int clear_cache (CONTAINER &container, - double purge_percent); - -protected: - - /** - * Find the entry with minimum caching attributes. This is handler - * specific since this utility is to be used very specifically for - * handler who have caching_attributes for server side acched - * connection management. - */ - void minimum (CONTAINER &container, - KEY *&key_to_remove, - VALUE *&value_to_remove); - - /// The cleanup strategy which can be used to destroy the entries of - /// the container. - CLEANUP_STRATEGY_BASE *cleanup_strategy_; - - /// Whether the cleanup_strategy should be destroyed or not. - int delete_cleanup_strategy_; - -private: - ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Handler_Caching_Utility &)) - ACE_UNIMPLEMENTED_FUNC (ACE_Handler_Caching_Utility (const ACE_Handler_Caching_Utility &)) -}; - -/////////////////////////////////////////////////////////////////////////// -#define ACE_Null_Caching_Utility ANUTIL -/** - * @class ACE_Null_Caching_Utility - * - * @brief Defines a dummy helper class for the Caching Strategies. - * - * This class defines the methods commonly used by the different - * caching strategies. For instance: method which - * decides and purges the entry from the container. @note This - * class is be used with the Null_Caching_Strategy. The - * Cleanup_Strategy is the callback class to which the entries to - * be cleaned up will be delegated. - */ -template -class ACE_Null_Caching_Utility -{ -public: - - typedef ACE_Null_Cleanup_Strategy CLEANUP_STRATEGY; - typedef ACE_Cleanup_Strategy CLEANUP_STRATEGY_BASE; - - /// Constructor. - ACE_Null_Caching_Utility (ACE_Cleanup_Strategy *cleanup_strategy = 0, - int delete_cleanup_strategy = 0); - - /// Destructor. - ~ACE_Null_Caching_Utility (void); - - /** - * Purge entries from the . The Cleanup_Strategy will do - * the actual job of cleanup once the entries to be cleaned up are - * decided. @note Here it is a no-op. - */ - int clear_cache (CONTAINER &container, - double purge_percent); - -protected: - - /** - * Find the entry with minimum caching attributes. This is handler - * specific since this utility is to be used very specifically for - * handler who have caching_attributes for server side acched - * connection management.@note Here it is a no-op. - */ - void minimum (CONTAINER &container, - KEY *&key_to_remove, - VALUE *&value_to_remove); - - /// The cleanup strategy which can be used to destroy the entries of - /// the container. - CLEANUP_STRATEGY_BASE *cleanup_strategy_; - - /// Whether the cleanup_strategy should be destroyed or not. - int delete_cleanup_strategy_; - -private: - ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Null_Caching_Utility &)) - ACE_UNIMPLEMENTED_FUNC (ACE_Null_Caching_Utility (const ACE_Null_Caching_Utility &)) -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Caching_Utility_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Caching_Utility_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" - -#endif /* ACE_CACHING_UTILITY_H */ diff --git a/ACE/ace/Capabilities.cpp b/ACE/ace/Capabilities.cpp deleted file mode 100644 index 04587194a77..00000000000 --- a/ACE/ace/Capabilities.cpp +++ /dev/null @@ -1,355 +0,0 @@ -#include "ace/Capabilities.h" -#include "ace/OS_NS_ctype.h" -#include "ace/OS_Memory.h" -#include "ace/OS_NS_string.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Capabilities.inl" -#endif /* !__ACE_INLINE__ */ - -#include "ace/OS_NS_stdio.h" - -ACE_RCSID (ace, - Capabilities, - "$Id$") - - -#define ACE_ESC ((ACE_TCHAR)0x1b) - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_CapEntry::~ACE_CapEntry (void) -{ -} - -ACE_Capabilities::ACE_Capabilities (void) - : caps_ () -{ -} - -ACE_Capabilities::~ACE_Capabilities (void) -{ - this->resetcaps (); -} - -const ACE_TCHAR * -ACE_Capabilities::parse (const ACE_TCHAR *buf, ACE_TString &cap) -{ - while (*buf != ACE_TEXT ('\0') && *buf != ACE_TEXT (',')) - { - if (*buf == ACE_TEXT ('\\')) - { - ++buf; - if (*buf == ACE_TEXT ('E') || *buf == ACE_TEXT ('e')) - { - cap += ACE_ESC; - ++buf; - continue; - } - else if (*buf == ACE_TEXT ('r')) - { - cap += ACE_TEXT ('\r'); - ++buf; - continue; - } - else if (*buf == ACE_TEXT ('n')) - { - cap += ACE_TEXT ('\n'); - ++buf; - continue; - } - else if (*buf == ACE_TEXT ('t')) - { - cap += ACE_TEXT ('\t'); - ++buf; - continue; - } - else if (*buf == ACE_TEXT ('\\')) - { - cap += *buf++; - continue; - } - if (ACE_OS::ace_isdigit(*buf)) - { - // @@ UNICODE Does this work with unicode? - int oc = 0; - for (int i = 0; - i < 3 && *buf && ACE_OS::ace_isdigit (*buf); - i++) - oc = oc * 8 + (*buf++ - ACE_TEXT ('0')); - - cap += (ACE_TCHAR) oc; - continue; - } - } - cap += *buf++; - } - return buf; -} - -const ACE_TCHAR * -ACE_Capabilities::parse (const ACE_TCHAR *buf, int &cap) -{ - int n = 0; - - while (*buf && ACE_OS::ace_isdigit (*buf)) - n = n * 10 + (*buf++ - ACE_TEXT ('0')); - - cap = n; - - return buf; -} - -void -ACE_Capabilities::resetcaps (void) -{ - for (CAPABILITIES_MAP::ITERATOR iter (this->caps_); - !iter.done (); - iter.advance ()) - { - CAPABILITIES_MAP::ENTRY *entry = 0; - iter.next (entry); - delete entry->int_id_; - } - - this->caps_.close (); - this->caps_.open (); -} - -int -ACE_Capabilities::fillent (const ACE_TCHAR *buf) -{ - this->resetcaps (); - while (*buf) - { - ACE_TString s; - int n; - ACE_TString name; - ACE_CapEntry *ce; - - // Skip blanks - while (*buf && ACE_OS::ace_isspace(*buf)) buf++; - // If we get end of line return - - if (*buf == ACE_TEXT ('\0')) - break; - - if (*buf == ACE_TEXT ('#')) - { - while (*buf && *buf != ACE_TEXT ('\n')) - buf++; - if (*buf == ACE_TEXT ('\n')) - buf++; - continue; - } - while(*buf && *buf != ACE_TEXT ('=') - && *buf!= ACE_TEXT ('#') - && *buf != ACE_TEXT (',')) - name += *buf++; - - // If name is null. - switch (*buf) - { - case ACE_TEXT ('='): - // String property - buf = this->parse (buf + 1, s); - ACE_NEW_RETURN (ce, - ACE_StringCapEntry (s), - -1); - if (this->caps_.bind (name, ce) == -1) - { - delete ce; - return -1; - } - break; - case ACE_TEXT ('#'): - // Integer property - buf = this->parse (buf + 1, n); - ACE_NEW_RETURN (ce, - ACE_IntCapEntry (n), - -1); - if (this->caps_.bind (name, ce) == -1) - { - delete ce; - return -1; - } - break; - case ACE_TEXT (','): - // Boolean - ACE_NEW_RETURN (ce, - ACE_BoolCapEntry (1), - -1); - if (this->caps_.bind (name, ce) == -1) - { - delete ce; - return -1; - } - break; - default: - return 0; - } - - if (*buf++ != ACE_TEXT (',')) - return -1; - } - - return 0; -} - -int -ACE_Capabilities::is_entry (const ACE_TCHAR *name, const ACE_TCHAR *line) -{ - for (;;) - { - // Skip blanks or irrelevant characters - while (*line && ACE_OS::ace_isspace(*line)) - ++line; - - // End of line reached - if (*line == ACE_TEXT ('\0')) - break; - - // Build the entry name - ACE_TString nextname; - while (*line && *line != ACE_TEXT ('|') && *line != ACE_TEXT (',')) - nextname += *line++; - - // We have found the required entry? - if (ACE_OS::strcmp (nextname.c_str (), name) == 0) - return 1; - - // Skip puntuaction char if neccesary. - if (*line == ACE_TEXT ('|') || *line == ACE_TEXT (',')) - ++line; - else - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Invalid entry\n"))); - break; - } - } - return 0; -} - -int -ACE_Capabilities::getline (FILE *fp, ACE_TString &line) -{ - int ch; - - line.set (0, 0); - - while ((ch = ACE_OS::fgetc (fp)) != EOF && ch != ACE_TEXT ('\n')) - line += (ACE_TCHAR) ch; - - if (ch == EOF && line.length () == 0) - return -1; - else - return 0; -} - -int -ACE_Capabilities::getval (const ACE_TCHAR *keyname, ACE_TString &val) -{ - ACE_CapEntry* cap = 0; - if (this->caps_.find (keyname, cap) == -1) - return -1; - - ACE_StringCapEntry *scap = - dynamic_cast (cap); - if (scap == 0) - return -1; - - val = scap->getval (); - return 0; -} - -int -ACE_Capabilities::getval (const ACE_TCHAR *keyname, int &val) -{ - ACE_CapEntry *cap = 0; - if (this->caps_.find (keyname, cap) == -1) - return -1; - - ACE_IntCapEntry *icap = - dynamic_cast (cap); - if (icap != 0) - { - val = icap->getval (); - return 0; - } - - ACE_BoolCapEntry *bcap = - dynamic_cast (cap); - - if (bcap == 0) - return -1; - - val = bcap->getval (); - return 0; -} - -#if !defined (ACE_IS_SPLITTING) -static int -is_empty (const ACE_TCHAR *line) -{ - while (*line && ACE_OS::ace_isspace (*line)) - ++line; - - return *line == ACE_TEXT ('\0') || *line == ACE_TEXT ('#'); -} - -static int -is_line (const ACE_TCHAR *line) -{ - while (*line && ACE_OS::ace_isspace (*line)) - ++line; - - return *line != ACE_TEXT ('\0'); -} -#endif /* !ACE_IS_SPLITTING */ - -int -ACE_Capabilities::getent (const ACE_TCHAR *fname, const ACE_TCHAR *name) -{ - FILE *fp = ACE_OS::fopen (fname, ACE_TEXT ("r")); - - if (fp == 0) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("Can't open %s file\n"), - fname), - -1); - - int done; - ACE_TString line; - - while (0 == (done = (this->getline (fp, line) == -1)) - && is_empty (line.c_str ())) - continue; - - while (!done) - { - ACE_TString newline; - ACE_TString description; - - while (0 == (done = (this->getline (fp, newline) == -1))) - if (is_line (newline.c_str ())) - description += newline; - else - break; - - if (this->is_entry (name, line.c_str())) - { - ACE_OS::fclose (fp); - return this->fillent (description.c_str ()); - } - - line = newline; - while (!done && is_empty (line.c_str ())) - done = this->getline (fp, line) == -1; - } - - ACE_OS::fclose (fp); - return -1; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Capabilities.h b/ACE/ace/Capabilities.h deleted file mode 100644 index 4c26b9cb83a..00000000000 --- a/ACE/ace/Capabilities.h +++ /dev/null @@ -1,221 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file Capabilities.h - * - * $Id$ - * - * @author Arturo Montes - */ -//============================================================================= - - -#ifndef ACE_CAPABILITIES_H -#define ACE_CAPABILITIES_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Null_Mutex.h" -#include "ace/Hash_Map_Manager_T.h" -#include "ace/Containers.h" -#include "ace/SString.h" -#include "ace/Functor_String.h" - -#if defined (ACE_IS_SPLITTING) -# include "ace/OS_NS_ctype.h" -#endif /* ACE_IS_SPLITTING */ - - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_CapEntry - * - * @brief This class is the base class for all ACE Capabilities entry - * subclasses. - * - * This class is not instantiable and does not provide accessors - * or methods. If you want to add a new kind of attribute subclass - * this class and dynamic_cast to proper subclass. - */ -class ACE_Export ACE_CapEntry -{ -public: - - virtual ~ACE_CapEntry (void); - -protected: - - enum - { - ACE_INTCAP = 0, - ACE_STRINGCAP = 1, - ACE_BOOLCAP = 2 - }; - - ACE_CapEntry (int captype); - -protected: - - int captype_; - -}; - -/** - * @class ACE_IntCapEntry - * - * @brief This class implement the ACE Integer Capability subclass. - * - * This is a container class for ACE Capabilities integer container - * values. - */ -class ACE_Export ACE_IntCapEntry : public ACE_CapEntry -{ -public: - ACE_IntCapEntry (int val); - int getval (void) const; - -protected: - int val_; -}; - -/** - * @class ACE_StringCapEntry - * - * @brief This class implement the ACE String Capability subclass. - * - * This is a container class for ACE Capabilities String container - * values. - */ -class ACE_Export ACE_StringCapEntry : public ACE_CapEntry -{ -public: - ACE_StringCapEntry (const ACE_TString &val); - ACE_TString getval (void) const; - -protected: - ACE_TString val_; -}; - -/** - * @class ACE_BoolCapEntry - * - * @brief This class implement the ACE Bool Capability subclass. - * - * This is a container class for ACE Capabilities bool container - * values. - */ -class ACE_Export ACE_BoolCapEntry : public ACE_CapEntry -{ -public: - ACE_BoolCapEntry (int val); - int getval (void) const; - -protected: - int val_; -}; - -/** - * @class ACE_Capabilities - * - * @brief This class implement the ACE Capabilities. - * - * This is a container class for ACE Capabilities - * values. Currently exist three different capability values: - * (integer), (bool) and - * (String). An ACE_Capabilities is a - * unordered set of pair = (, *). Where - * the first component is the name of capability and the second - * component is a pointer to the capability value container. A - * is a container for ACE_Capabilities, the - * ACE_Capabilities has a name in the file, as a termcap file. - */ -class ACE_Export ACE_Capabilities -{ -public: - - typedef ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex> CAPABILITIES_MAP; - - /// The Constructor - ACE_Capabilities (void); - - /// The Destructor - ~ACE_Capabilities(void); - -public: - - /// Get a string entry. - int getval (const ACE_TCHAR *ent, ACE_TString &val); - - /// Get an integer entry. - int getval (const ACE_TCHAR *ent, int &val); - - /// Get the ACE_Capabilities name from FILE fname and load the - /// associated capabitily entries in map. - int getent (const ACE_TCHAR *fname, const ACE_TCHAR *name); - -protected: - - /// Parse an integer property - const ACE_TCHAR *parse (const ACE_TCHAR *buf, int &cap); - - /// Parse a string property - const ACE_TCHAR *parse (const ACE_TCHAR *buf, ACE_TString &cap); - - /// Fill the ACE_Capabilities with description in ent. - int fillent(const ACE_TCHAR *ent); - - /// Parse a cap entry - int parseent (const ACE_TCHAR *name, ACE_TCHAR *line); - - /// Get a line from FILE input stream - int getline (FILE* fp, - ACE_TString &line); - - /// Is a valid entry - int is_entry (const ACE_TCHAR *name, const ACE_TCHAR *line); - - /// Reset the set of capabilities - void resetcaps (void); - -private: - - /// This is the set of ACE_CapEntry. - CAPABILITIES_MAP caps_; - -}; - -#if defined (ACE_IS_SPLITTING) -int -is_empty (const ACE_TCHAR *line) -{ - while (*line && ACE_OS::ace_isspace (*line)) - ++line; - - return *line == ACE_TEXT ('\0') || *line == ACE_TEXT ('#'); -} - -int -is_line (const ACE_TCHAR *line) -{ - while (*line && ACE_OS::ace_isspace (*line)) - ++line; - - return *line != ACE_TEXT ('\0'); -} -#endif /* ACE_IS_SPLITTING */ - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Capabilities.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* __ACE_CAPABILITIES_H__ */ diff --git a/ACE/ace/Capabilities.inl b/ACE/ace/Capabilities.inl deleted file mode 100644 index 053e0ecf7b6..00000000000 --- a/ACE/ace/Capabilities.inl +++ /dev/null @@ -1,52 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_CapEntry::ACE_CapEntry (int captype) - : captype_ (captype) -{ -} - -ACE_INLINE -ACE_IntCapEntry::ACE_IntCapEntry (int val) - : ACE_CapEntry (ACE_INTCAP), - val_ (val) -{ -} - -ACE_INLINE int -ACE_IntCapEntry::getval (void) const -{ - return val_; -} - -ACE_INLINE -ACE_StringCapEntry::ACE_StringCapEntry (const ACE_TString &val) - : ACE_CapEntry (ACE_STRINGCAP), - val_ (val) -{ -} - -ACE_INLINE ACE_TString -ACE_StringCapEntry::getval (void) const -{ - return val_; -} - -ACE_INLINE -ACE_BoolCapEntry::ACE_BoolCapEntry (int val) - : ACE_CapEntry (ACE_BOOLCAP), - val_(val) -{ -} - -ACE_INLINE int -ACE_BoolCapEntry::getval (void) const -{ - return val_; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Cleanup.cpp b/ACE/ace/Cleanup.cpp deleted file mode 100644 index a6fc5de6a78..00000000000 --- a/ACE/ace/Cleanup.cpp +++ /dev/null @@ -1,192 +0,0 @@ -// $Id$ - -#include "ace/Cleanup.h" - -ACE_RCSID (ace, - Cleanup, - "$Id$") - -#if !defined (ACE_HAS_INLINED_OSCALLS) -# include "ace/Cleanup.inl" -#endif /* ACE_HAS_INLINED_OSCALLS */ - -#include "ace/OS_Memory.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -void -ACE_Cleanup::cleanup (void *) -{ - delete this; -} - - -ACE_Cleanup::~ACE_Cleanup (void) -{ -} - -/*****************************************************************************/ - -extern "C" void -ACE_CLEANUP_DESTROYER_NAME (ACE_Cleanup *object, void *param) -{ - object->cleanup (param); -} - -/*****************************************************************************/ - -ACE_Cleanup_Info::ACE_Cleanup_Info (void) - : object_ (0), - cleanup_hook_ (0), - param_ (0) -{ -} - -bool -ACE_Cleanup_Info::operator== (const ACE_Cleanup_Info &o) const -{ - return o.object_ == this->object_ - && o.cleanup_hook_ == this->cleanup_hook_ - && o.param_ == this->param_; -} - -bool -ACE_Cleanup_Info::operator!= (const ACE_Cleanup_Info &o) const -{ - return !(*this == o); -} - -/*****************************************************************************/ - -/** - * @class ACE_Cleanup_Info_Node - * - * @brief For maintaining a list of ACE_Cleanup_Info items. - * - * For internal use by ACE_Object_Manager. - */ -class ACE_Cleanup_Info_Node -{ -public: - ACE_Cleanup_Info_Node (void); - ACE_Cleanup_Info_Node (const ACE_Cleanup_Info &new_info, - ACE_Cleanup_Info_Node *next); - ~ACE_Cleanup_Info_Node (void); - ACE_Cleanup_Info_Node *insert (const ACE_Cleanup_Info &); -private: - ACE_Cleanup_Info cleanup_info_; - ACE_Cleanup_Info_Node *next_; - - friend class ACE_OS_Exit_Info; -}; - -ACE_Cleanup_Info_Node::ACE_Cleanup_Info_Node (void) - : cleanup_info_ (), - next_ (0) -{ -} - -ACE_Cleanup_Info_Node::ACE_Cleanup_Info_Node (const ACE_Cleanup_Info &new_info, - ACE_Cleanup_Info_Node *next) - : cleanup_info_ (new_info), - next_ (next) -{ -} - -ACE_Cleanup_Info_Node::~ACE_Cleanup_Info_Node (void) -{ - delete next_; -} - -ACE_Cleanup_Info_Node * -ACE_Cleanup_Info_Node::insert (const ACE_Cleanup_Info &new_info) -{ - ACE_Cleanup_Info_Node *new_node = 0; - - ACE_NEW_RETURN (new_node, - ACE_Cleanup_Info_Node (new_info, this), - 0); - - return new_node; -} - -/*****************************************************************************/ - -ACE_OS_Exit_Info::ACE_OS_Exit_Info (void) -{ - ACE_NEW (registered_objects_, ACE_Cleanup_Info_Node); -} - -ACE_OS_Exit_Info::~ACE_OS_Exit_Info (void) -{ - delete registered_objects_; - registered_objects_ = 0; -} - -int -ACE_OS_Exit_Info::at_exit_i (void *object, - ACE_CLEANUP_FUNC cleanup_hook, - void *param) -{ - ACE_Cleanup_Info new_info; - new_info.object_ = object; - new_info.cleanup_hook_ = cleanup_hook; - new_info.param_ = param; - - // Return -1 and sets errno if unable to allocate storage. Enqueue - // at the head and dequeue from the head to get LIFO ordering. - - ACE_Cleanup_Info_Node *new_node = 0; - - if ((new_node = registered_objects_->insert (new_info)) == 0) - return -1; - else - { - registered_objects_ = new_node; - return 0; - } -} - -int -ACE_OS_Exit_Info::find (void *object) -{ - // Check for already in queue, and return 1 if so. - for (ACE_Cleanup_Info_Node *iter = registered_objects_; - iter && iter->next_ != 0; - iter = iter->next_) - { - if (iter->cleanup_info_.object_ == object) - { - // The object has already been registered. - return 1; - } - } - - return 0; -} - -void -ACE_OS_Exit_Info::call_hooks (void) -{ - // Call all registered cleanup hooks, in reverse order of - // registration. - for (ACE_Cleanup_Info_Node *iter = registered_objects_; - iter && iter->next_ != 0; - iter = iter->next_) - { - ACE_Cleanup_Info &info = iter->cleanup_info_; - if (info.cleanup_hook_ == reinterpret_cast ( - ACE_CLEANUP_DESTROYER_NAME)) - // The object is an ACE_Cleanup. - ACE_CLEANUP_DESTROYER_NAME ( - reinterpret_cast (info.object_), - info.param_); - else if (info.object_ == &ace_exit_hook_marker) - // The hook is an ACE_EXIT_HOOK. - (* reinterpret_cast (info.cleanup_hook_)) (); - else - (*info.cleanup_hook_) (info.object_, info.param_); - } -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Cleanup.h b/ACE/ace/Cleanup.h deleted file mode 100644 index 7acff23ab79..00000000000 --- a/ACE/ace/Cleanup.h +++ /dev/null @@ -1,137 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Cleanup.h - * - * $Id$ - * - * @author Douglas C. Schmidt - * @author Jesper S. M|ller - * @author and a cast of thousands... - * - * Originally in OS.h. - */ -//============================================================================= - -#ifndef ACE_CLEANUP_H -# define ACE_CLEANUP_H - -# include /**/ "ace/pre.h" - -# include "ace/config-lite.h" - -# if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -# endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include /**/ "ace/ACE_export.h" - -#if (defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1) -# include "ace/Global_Macros.h" -# define ACE_CLEANUP_DESTROYER_NAME ACE_PREPROC_CONCATENATE(ACE_VERSIONED_NAMESPACE_NAME, _ace_cleanup_destroyer) -#else -# define ACE_CLEANUP_DESTROYER_NAME ace_cleanup_destroyer -#endif /* ACE_HAS_VERSIONED_NAMESPACE == 1 */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Cleanup - * - * @brief Base class for objects that are cleaned by ACE_Object_Manager. - */ -class ACE_Export ACE_Cleanup -{ -public: - /// No-op constructor. - ACE_Cleanup (void); - - /// Destructor. - virtual ~ACE_Cleanup (void); - - /// Cleanup method that, by default, simply deletes itself. - virtual void cleanup (void *param = 0); -}; - -// Adapter for cleanup, used by ACE_Object_Manager. -extern "C" ACE_Export -void ACE_CLEANUP_DESTROYER_NAME (ACE_Cleanup *, void *param = 0); - -/** - * @class ACE_Cleanup_Info - * - * @brief Hold cleanup information for thread/process - */ -class ACE_Export ACE_Cleanup_Info -{ -public: - /// Default constructor. - ACE_Cleanup_Info (void); - - /// Equality operator. - bool operator== (const ACE_Cleanup_Info &o) const; - - /// Inequality operator. - bool operator!= (const ACE_Cleanup_Info &o) const; - - /// Point to object that gets passed into the . - void *object_; - - /// Cleanup hook that gets called back. - ACE_CLEANUP_FUNC cleanup_hook_; - - /// Parameter passed to the . - void *param_; -}; - -class ACE_Cleanup_Info_Node; - -/** - * @class ACE_OS_Exit_Info - * - * @brief Hold Object Manager cleanup (exit) information. - * - * For internal use by the ACE library, only. - */ -class ACE_Export ACE_OS_Exit_Info -{ -public: - /// Default constructor. - ACE_OS_Exit_Info (void); - - /// Destructor. - ~ACE_OS_Exit_Info (void); - - /// Use to register a cleanup hook. - int at_exit_i (void *object, ACE_CLEANUP_FUNC cleanup_hook, void *param); - - /// Look for a registered cleanup hook object. Returns 1 if already - /// registered, 0 if not. - int find (void *object); - - /// Call all registered cleanup hooks, in reverse order of - /// registration. - void call_hooks (); - -private: - /** - * Keeps track of all registered objects. The last node is only - * used to terminate the list (it doesn't contain a valid - * ACE_Cleanup_Info). - */ - ACE_Cleanup_Info_Node *registered_objects_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -# if defined (ACE_HAS_INLINED_OSCALLS) -# if defined (ACE_INLINE) -# undef ACE_INLINE -# endif /* ACE_INLINE */ -# define ACE_INLINE inline -# include "ace/Cleanup.inl" -# endif /* ACE_HAS_INLINED_OSCALLS */ - -# include /**/ "ace/post.h" -#endif /* ACE_CLEANUP_H */ diff --git a/ACE/ace/Cleanup.inl b/ACE/ace/Cleanup.inl deleted file mode 100644 index 02d3c223f8d..00000000000 --- a/ACE/ace/Cleanup.inl +++ /dev/null @@ -1,12 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_Cleanup::ACE_Cleanup (void) -{ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Cleanup_Strategies_T.cpp b/ACE/ace/Cleanup_Strategies_T.cpp deleted file mode 100644 index 10804ba21ca..00000000000 --- a/ACE/ace/Cleanup_Strategies_T.cpp +++ /dev/null @@ -1,95 +0,0 @@ -//$Id$ - -#ifndef ACE_CLEANUP_STRATEGIES_T_CPP -#define ACE_CLEANUP_STRATEGIES_T_CPP - -#include "ace/Cleanup_Strategies_T.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -//////////////////////////////////////////////////////////////////////////// - -template -ACE_Cleanup_Strategy::~ACE_Cleanup_Strategy (void) -{ -} - -template int -ACE_Cleanup_Strategy::cleanup (CONTAINER &container, - KEY *key, - VALUE *) -{ - return container.unbind (*key); -} - -//////////////////////////////////////////////////////////////////////////// - -template int -ACE_Recyclable_Handler_Cleanup_Strategy::cleanup ( - CONTAINER &container, - KEY *key, - VALUE *) -{ - VALUE value; - - if (container.unbind (*key, value) == -1) - return -1; - - value.first ()->recycler (0, 0); - - value.first ()->close (); - - return 0; -} - -///////////////////////////////////////////////////////////////////////////// - -template int -ACE_Refcounted_Recyclable_Handler_Cleanup_Strategy::cleanup ( - CONTAINER &, - KEY *, - VALUE *value) -{ - return value->first ()->handle_close_i (); -} - -//////////////////////////////////////////////////////////////////////////// - -template int -ACE_Handler_Cleanup_Strategy::cleanup ( - CONTAINER &container, - KEY *key, - VALUE *value) -{ - // Remove the item from cache only if the handler isnt in use. - if ((*value)->active () == 0) - { - (*value)->close (); - - if (container.unbind (*key) == -1) - return -1; - - } - - return 0; -} - -//////////////////////////////////////////////////////////////////////////// - -template int -ACE_Null_Cleanup_Strategy::cleanup (CONTAINER &, - KEY *, - VALUE *) -{ - return 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_CLEANUP_STRATEGIES_T_CPP */ diff --git a/ACE/ace/Cleanup_Strategies_T.h b/ACE/ace/Cleanup_Strategies_T.h deleted file mode 100644 index 9a574ed2bcd..00000000000 --- a/ACE/ace/Cleanup_Strategies_T.h +++ /dev/null @@ -1,155 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Cleanup_Strategies_T.h - * - * $Id$ - * - * @author Kirthika Parameswaran - */ -//============================================================================= - - -#ifndef CLEANUP_STRATEGIES_H -#define CLEANUP_STRATEGIES_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -// For linkers that cant grok long names. -#define ACE_Cleanup_Strategy ACLE - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Cleanup_Strategy - * - * @brief Defines a default strategy to be followed for cleaning up - * entries from a map which is the container. - * - * By default the entry to be cleaned up is removed from the - * container. - */ -template -class ACE_Cleanup_Strategy -{ - -public: - - /// Destructor. - virtual ~ACE_Cleanup_Strategy (void); - - /// The method which will do the cleanup of the entry in the container. - virtual int cleanup (CONTAINER &container, KEY *key, VALUE *value); -}; - -////////////////////////////////////////////////////////////////////// -#define ACE_Recyclable_Handler_Cleanup_Strategy ARHCLE - -/** - * @class ACE_Recyclable_Handler_Cleanup_Strategy - * - * @brief Defines a strategy to be followed for cleaning up - * entries which are svc_handlers from a container. - * - * The entry to be cleaned up is removed from the container. - * Here, since we are dealing with svc_handlers specifically, we - * perform a couple of extra operations. @note To be used when - * the handler is recyclable. - */ -template -class ACE_Recyclable_Handler_Cleanup_Strategy : public ACE_Cleanup_Strategy -{ - -public: - - /// The method which will do the cleanup of the entry in the container. - virtual int cleanup (CONTAINER &container, KEY *key, VALUE *value); -}; - -////////////////////////////////////////////////////////////////////// -#define ACE_Refcounted_Recyclable_Handler_Cleanup_Strategy ARRHCLE - -/** - * @class ACE_Refcounted_Recyclable_Handler_Cleanup_Strategy - * - * @brief Defines a strategy to be followed for cleaning up - * entries which are svc_handlers from a container. - * - * The entry to be cleaned up is removed from the container. - * Here, since we are dealing with recyclable svc_handlers with - * addresses which are refcountable specifically, we perform a - * couple of extra operations and do so without any locking. - */ -template -class ACE_Refcounted_Recyclable_Handler_Cleanup_Strategy : public ACE_Cleanup_Strategy -{ - -public: - - /// The method which will do the cleanup of the entry in the container. - virtual int cleanup (CONTAINER &container, KEY *key, VALUE *value); -}; - -////////////////////////////////////////////////////////////////////// - -/** - * @class ACE_Handler_Cleanup_Strategy - * - * @brief Defines a strategy to be followed for cleaning up - * entries which are svc_handlers from a container. - * - * The entry to be cleaned up is removed from the container. - * Here, since we are dealing with svc_handlers specifically, we - * perform a couple of extra operations. @note This cleanup strategy - * should be used in the case when the handler has the caching - * attributes. - */ -template -class ACE_Handler_Cleanup_Strategy : public ACE_Cleanup_Strategy -{ - -public: - - /// The method which will do the cleanup of the entry in the container. - virtual int cleanup (CONTAINER &container, KEY *key, VALUE *value); -}; - -////////////////////////////////////////////////////////////////////// -#define ACE_Null_Cleanup_Strategy ANCLE - -/** - * @class ACE_Null_Cleanup_Strategy - * - * @brief Defines a do-nothing implementation of the cleanup strategy. - * - * This class simply does nothing at all! Can be used to nullify - * the effect of the Cleanup Strategy. - */ -template -class ACE_Null_Cleanup_Strategy : public ACE_Cleanup_Strategy -{ - -public: - - /// The dummy cleanup method. - virtual int cleanup (CONTAINER &container, KEY *key, VALUE *value); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Cleanup_Strategies_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Cleanup_Strategies_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" -#endif /* CLEANUP_STRATEGIES_H */ diff --git a/ACE/ace/Codecs.cpp b/ACE/ace/Codecs.cpp deleted file mode 100644 index 505c5fc9916..00000000000 --- a/ACE/ace/Codecs.cpp +++ /dev/null @@ -1,234 +0,0 @@ -#include "ace/Codecs.h" -#include "ace/Log_Msg.h" -#include "ace/OS_Memory.h" -#include "ace/OS_NS_ctype.h" - -ACE_RCSID (ace, - Codecs, - "$Id$") - -namespace -{ - // Just in case ... -#undef alphabet -#undef pad -#undef max_columns - - // Symbols which form the Base64 alphabet (Defined as per RFC 2045) - ACE_Byte const alphabet[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - - // The padding character used in the encoding - ACE_Byte const pad = '='; - - // Number of columns per line of encoded output (Can have a maximum - // value of 76). - int const max_columns = 72; -} - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -bool ACE_Base64::init_ = false; - -ACE_Byte ACE_Base64::decoder_[256]; - -ACE_Byte ACE_Base64::member_[256]; - -ACE_Byte* -ACE_Base64::encode (const ACE_Byte* input, - const size_t input_len, - size_t* output_len, - bool is_chunked) -{ - if (!ACE_Base64::init_) - ACE_Base64::init(); - - if (!input) - return 0; - - ACE_Byte* result = 0; - - size_t length = ((input_len + 2) / 3) * 4; - size_t num_lines = length / max_columns + 1; - length += num_lines + 1; - ACE_NEW_RETURN (result, ACE_Byte[length], 0); - - int char_count = 0; - int bits = 0; - size_t pos = 0; - int cols = 0; - - for (size_t i = 0; i < input_len; ++i) - { - bits += input[i]; - ++char_count; - - if (char_count == 3) - { - result[pos++] = alphabet[bits >> 18]; - result[pos++] = alphabet[(bits >> 12) & 0x3f]; - result[pos++] = alphabet[(bits >> 6) & 0x3f]; - result[pos++] = alphabet[bits & 0x3f]; - cols += 4; - if (cols == max_columns) { - if (is_chunked) - result[pos++] = '\n'; - cols = 0; - } - bits = 0; - char_count = 0; - } - else - { - bits <<= 8; - } - } - - if (char_count != 0) - { - bits <<= (16 - (8 * char_count)); - result[pos++] = alphabet[bits >> 18]; - result[pos++] = alphabet[(bits >> 12) & 0x3f]; - cols += 2; - if (char_count == 1) - { - result[pos++] = pad; - result[pos++] = pad; - cols += 2; - } - else - { - result[pos++] = alphabet[(bits >> 6) & 0x3f]; - result[pos++] = pad; - cols += 2; - } - } - - if (cols > 0 && is_chunked) - result[pos++] = '\n'; - - result[pos] = 0; - *output_len = pos; - return result; -} - -size_t -ACE_Base64::length (const ACE_Byte* input) -{ - if (!ACE_Base64::init_) - ACE_Base64::init(); - - ACE_Byte* ptr = const_cast (input); - while (*ptr != 0 && - (member_[*(ptr)] == 1 || *ptr == pad - || ACE_OS::ace_isspace (*ptr))) - ++ptr; - size_t len = ptr - input; - len = ((len + 3) / 4) * 3 + 1 ; - return len; -} - -ACE_Byte* -ACE_Base64::decode (const ACE_Byte* input, size_t* output_len) -{ - if (!ACE_Base64::init_) - ACE_Base64::init(); - - if (!input) - return 0; - - size_t result_len = ACE_Base64::length (input); - ACE_Byte* result = 0; - ACE_NEW_RETURN (result, ACE_Byte[result_len], 0); - - ACE_Byte* ptr = const_cast (input); - while (*ptr != 0 && - (member_[*(ptr)] == 1 || *ptr == pad - || ACE_OS::ace_isspace (*ptr))) - ++ptr; - size_t input_len = ptr - input; - - int char_count = 0; - int bits = 0; - size_t pos = 0; - - size_t i = 0; - for (; i < input_len; ++i) - { - if (input[i] == pad) - break; - if (!ACE_Base64::member_[input[i]]) - continue; - bits += decoder_[input[i]]; - ++char_count; - - if (char_count == 4) - { - result[pos++] = static_cast (bits >> 16); - result[pos++] = static_cast ((bits >> 8) & 0xff); - result[pos++] = static_cast (bits & 0xff); - bits = 0; - char_count = 0; - } - else - { - bits <<= 6; - } - } - - int errors = 0; - if ( i == input_len) - { - if (char_count) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("Decoding incomplete: atleast %d bits truncated\n"), - (4 - char_count) * 6)); - ++errors; - } - } - else - { - switch (char_count) - { - case 1: - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("Decoding incomplete: atleast 2 bits missing\n"))); - ++errors; - break; - case 2: - result[pos++] = static_cast (bits >> 10); - break; - case 3: - result[pos++] = static_cast (bits >> 16); - result[pos++] = static_cast ((bits >> 8) & 0xff); - break; - } - } - - if (errors) - { - delete[] result; - return 0; - } - result[pos] = 0; - *output_len = pos; - return result; -} - -void -ACE_Base64::init () -{ - if (!ACE_Base64::init_) - { - for (ACE_Byte i = 0; i < sizeof (alphabet); ++i) - { - ACE_Base64::decoder_[alphabet[i]] = i; - ACE_Base64::member_ [alphabet[i]] = 1; - } - ACE_Base64::init_ = true; - } - return; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Codecs.h b/ACE/ace/Codecs.h deleted file mode 100644 index 85447b75e06..00000000000 --- a/ACE/ace/Codecs.h +++ /dev/null @@ -1,121 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Codecs.h - * - * $Id$ - * - * @author Krishnakumar B - * - * Codecs is a generic wrapper for various encoding and decoding - * mechanisms. Currently it includes Base64 content transfer-encoding as - * specified by RFC 2045, Multipurpose Internet Mail Extensions (MIME) Part - * One: Format of Internet Message Bodies. - * - */ -//============================================================================= - -#ifndef ACE_CODECS_H -#define ACE_CODECS_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Basic_Types.h" -#include "ace/Global_Macros.h" - - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Base64 - * - * @brief Encode/Decode a stream of bytes according to Base64 encoding. - * - * This class provides methods to encode or decode a stream of bytes - * to/from Base64 encoding. It doesn't convert the input stream to a - * canonical form before encoding. - * - */ -class ACE_Export ACE_Base64 -{ -public: - - //@{ - - /** - * Encodes a stream of bytes to Base64 data - * - * @param input Binary data in byte stream. - * @param input_len Length of the byte stream. - * @param output_len Length of the encoded Base64 byte stream. - * @param is_chunked If true, terminate 72 character blocks with newline - * @return Encoded Base64 data in byte stream or NULL if input data cannot - * be encoded. - */ - - static ACE_Byte* encode (const ACE_Byte* input, - const size_t input_len, - size_t* output_len, - bool is_chunked = true); - /** - * Decodes a stream of Base64 to bytes data - * - * @param input Encoded Base64 data in byte stream. - * @param output_len Length of the binary byte stream. - * @return Binary data in byte stream or NULL if input data cannot - * be encoded. - */ - static ACE_Byte* decode (const ACE_Byte* input, - size_t* output_len); - - /** - * Return the length of the encoded input data - * - * @param input Encoded Base64 data in byte stream. - * @return Length of the encoded Base64 data. - * - */ - static size_t length (const ACE_Byte* input); - - //@} - -protected: - - // Prevent default construction. - ACE_Base64 (void) {} - -private: - - // Preventing copying and assignment. - ACE_Base64 (ACE_Base64 const &); - ACE_Base64 & operator= (ACE_Base64 const &); - - /// Initialize the tables for encoding/decoding. - static void init (void); - -private: - - /// Alphabet used for decoding i.e decoder_[alphabet_[i = 0..63]] = i - static ACE_Byte decoder_[]; - - /// Alphabet used to check valid range of encoded input i.e - /// member_[alphabet_[0..63]] = 1 - static ACE_Byte member_[]; - - /// Boolean to denote whether initialization is complete - static bool init_; - -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#include /**/ "ace/post.h" - -#endif /* ACE_CODECS_H */ diff --git a/ACE/ace/Codeset_IBM1047.cpp b/ACE/ace/Codeset_IBM1047.cpp deleted file mode 100644 index 5e208fd373f..00000000000 --- a/ACE/ace/Codeset_IBM1047.cpp +++ /dev/null @@ -1,312 +0,0 @@ - -//============================================================================= -/** - * @file Codeset_IBM1047.cpp - * - * $Id$ - * - * Defines the arrays required to convert between ISO8859 (aka - * Latin/1) and IBM1047 (aka EBCDIC). - * - * - * @author Jim Rogers (jrogers@viasoft.com) - */ -//============================================================================= - - -#include "ace/Codeset_IBM1047.h" - -#if defined (ACE_HAS_EBCDIC) - -ACE_RCSID (ace, - Codeset_IBM1047, - "$Id$") - -#include "ace/OS_Memory.h" -#include "ace/OS_NS_string.h" - -namespace -{ - char const to_IBM1047[] = - { - "\x00\x01\x02\x03\x37\x2D\x2E\x2F\x16\x05\x25\x0B\x0C\x0D\x0E\x0F" // 00-0F - "\x10\x11\x12\x13\x3C\x3D\x32\x26\x18\x19\x3F\x27\x22\x1D\x35\x1F" // 10-1F - "\x40\x5A\x7F\x7B\x5B\x6C\x50\x7D\x4D\x5D\x5C\x4E\x6B\x60\x4B\x61" // 20-2F - "\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\x7A\x5E\x4C\x7E\x6E\x6F" // 30-3F - "\x7C\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xD1\xD2\xD3\xD4\xD5\xD6" // 40-4F - "\xD7\xD8\xD9\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xAD\xE0\xBD\x5F\x6D" // 50-5F - "\x79\x81\x82\x83\x84\x85\x86\x87\x88\x89\x91\x92\x93\x94\x95\x96" // 60-6F - "\x97\x98\x99\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xC0\x4F\xD0\xA1\x07" // 70-7F - "\x43\x20\x21\x1C\x23\xEB\x24\x9B\x71\x28\x38\x49\x90\xBA\xEC\xDF" // 80-8F - "\x45\x29\x2A\x9D\x72\x2B\x8A\x9A\x67\x56\x64\x4A\x53\x68\x59\x46" // 90-9F - "\xEA\xDA\x2C\xDE\x8B\x55\x41\xFE\x58\x51\x52\x48\x69\xDB\x8E\x8D" // A0-AF - "\x73\x74\x75\xFA\x15\xB0\xB1\xB3\xB4\xB5\x6A\xB7\xB8\xB9\xCC\xBC" // B0-BF - "\xAB\x3E\x3B\x0A\xBF\x8F\x3A\x14\xA0\x17\xCB\xCA\x1A\x1B\x9C\x04" // C0-CF - "\x34\xEF\x1E\x06\x08\x09\x77\x70\xBE\xBB\xAC\x54\x63\x65\x66\x62" // D0-DF - "\x30\x42\x47\x57\xEE\x33\xB6\xE1\xCD\xED\x36\x44\xCE\xCF\x31\xAA" // E0-EF - "\xFC\x9E\xAE\x8C\xDD\xDC\x39\xFB\x80\xAF\xFD\x78\x76\xB2\x9F\xFF" // F0-FF -}; - - char const from_IBM1047[] = - { - "\x00\x01\x02\x03\xCF\x09\xD3\x7F\xD4\xD5\xC3\x0B\x0C\x0D\x0E\x0F" // 00-0F - "\x10\x11\x12\x13\xC7\xB4\x08\xC9\x18\x19\xCC\xCD\x83\x1D\xD2\x1F" // 10-1F - "\x81\x82\x1C\x84\x86\x0A\x17\x1B\x89\x91\x92\x95\xA2\x05\x06\x07" // 20-2F - "\x20\xEE\x16\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\xC1\x1A" // 30-3F - "\x20\xA6\xE1\x80\xEB\x90\x9F\xE2\xAB\x8B\x9B\x2E\x3C\x28\x2B\x7C" // 40-4F - "\x26\xA9\xAA\x9C\xDB\xA5\x99\xE3\xA8\x9E\x21\x24\x2A\x29\x3B\x5E" // 50-5F - "\x2D\x2F\xDF\xDC\x9A\xDD\xDE\x98\x9D\xAC\xBA\x2C\x25\x5F\x3E\x3F" // 60-6F - "\xD7\x88\x94\xB0\xB1\xB2\xFC\xD6\xFB\x60\x3A\x23\x40\x27\x3D\x22" // 70-7F - "\xF8\x61\x62\x63\x64\x65\x66\x67\x68\x69\x96\xA4\xF3\xAF\xAE\xC5" // 80-8F - "\x8C\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x97\x87\xCE\x93\xF1\xFE" // 90-9F - "\xC8\x7E\x73\x74\x75\x76\x77\x78\x79\x7A\xEF\xC0\xDA\x5B\xF2\xF9" // A0-AF - "\xB5\xB6\xFD\xB7\xB8\xB9\xE6\xBB\xBC\xBD\x8D\xD9\xBF\x5D\xD8\xC4" // B0-BF - "\x7B\x41\x42\x43\x44\x45\x46\x47\x48\x49\xCB\xCA\xBE\xE8\xEC\xED" // C0-CF - "\x7D\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\xA1\xAD\xF5\xF4\xA3\x8F" // D0-DF - "\x5C\xE7\x53\x54\x55\x56\x57\x58\x59\x5A\xA0\x85\x8E\xE9\xE4\xD1" // E0-EF - "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\xB3\xF7\xF0\xFA\xA7\xFF" // F0-FF - }; -} - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_IBM1047_ISO8859::ACE_IBM1047_ISO8859 (void) -{ -} - -ACE_IBM1047_ISO8859::~ACE_IBM1047_ISO8859 (void) -{ -} - -ACE_CDR::ULong -ACE_IBM1047_ISO8859::ncs () -{ - return 0x10020417; -} - -ACE_CDR::ULong -ACE_IBM1047_ISO8859::tcs () -{ - return 0x00010001; -} - -ACE_CDR::Boolean -ACE_IBM1047_ISO8859::read_char (ACE_InputCDR &in, - ACE_CDR::Char &x) -{ - if (this->read_1 (in, reinterpret_cast (&x))) - { - x = to_IBM1047[x]; - return 1; - } - return 0; -} - -ACE_CDR::Boolean -ACE_IBM1047_ISO8859::read_string (ACE_InputCDR& in, - ACE_CDR::Char *& x) -{ - ACE_CDR::ULong len; - - in.read_ulong (len); - - if (len > 0) - { - ACE_NEW_RETURN (x, - ACE_CDR::Char[len], - 0); - - if (this->read_char_array (in, x, len)) - return 1; - - delete [] x; - } - - x = 0; - return 0; -} - -ACE_CDR::Boolean -ACE_IBM1047_ISO8859::read_char_array (ACE_InputCDR& in, - ACE_CDR::Char* x, - ACE_CDR::ULong len) -{ - if (this->read_array (in, - x, - ACE_CDR::OCTET_SIZE, - ACE_CDR::OCTET_ALIGN, - len)) - { - for (ACE_CDR::ULong i = 0; i != len; ++i) - x[i] = to_IBM1047[x[i]]; - - return 1; - } - - return 0; -} - -ACE_CDR::Boolean -ACE_IBM1047_ISO8859::write_char (ACE_OutputCDR& out, - ACE_CDR::Char x) -{ - return - this->write_1 (out, - reinterpret_cast (&from_IBM1047[x])); -} - -ACE_CDR::Boolean -ACE_IBM1047_ISO8859::write_string (ACE_OutputCDR& out, - ACE_CDR::ULong len, - const ACE_CDR::Char* x) -{ - if (out.write_ulong (len + 1)) - return this->write_char_array (out, x, len + 1); - return 0; -} - -ACE_CDR::Boolean -ACE_IBM1047_ISO8859::write_char_array (ACE_OutputCDR& out, - const ACE_CDR::Char* x, - ACE_CDR::ULong len) -{ - char *buf = 0; - if (this->adjust (out, len, 1, buf) == 0) - { - ACE_OS::memcpy (buf, x, len); - - for (ACE_CDR::ULong i = 0; i != len; ++i) - buf[i] = from_IBM1047[buf[i]]; - - return 1; - } - - this->good_bit(out, 0); - return 0; -} - -// **************************************************************** - -ACE_ISO8859_IBM1047::ACE_ISO8859_IBM1047 (void) -{ -} - -ACE_ISO8859_IBM1047::~ACE_ISO8859_IBM1047 (void) -{ -} - -ACE_CDR::ULong -ACE_ISO8859_IBM1047::ncs () -{ - return 0x00010001; -} - -ACE_CDR::ULong -ACE_ISO8859_IBM1047::tcs () -{ - return 0x10020417; -} - -ACE_CDR::Boolean -ACE_ISO8859_IBM1047::read_char (ACE_InputCDR& in, - ACE_CDR::Char& x) -{ - if (this->read_1 (in, reinterpret_cast (&x))) - { - x = from_IBM1047[x]; - return 1; - } - return 0; -} - -ACE_CDR::Boolean -ACE_ISO8859_IBM1047::read_string (ACE_InputCDR &in, - ACE_CDR::Char *&x) -{ - ACE_CDR::ULong len; - - in.read_ulong (len); - - if (len > 0) - { - ACE_NEW_RETURN (x, - ACE_CDR::Char[len], - 0); - - if (this->read_char_array (in, x, len)) - return 1; - - delete [] x; - } - - x = 0; - return 0; -} - -ACE_CDR::Boolean -ACE_ISO8859_IBM1047::read_char_array (ACE_InputCDR &in, - ACE_CDR::Char *x, - ACE_CDR::ULong len) -{ - if (this->read_array (in, - x, - ACE_CDR::OCTET_SIZE, - ACE_CDR::OCTET_ALIGN, - len)) - { - for (ACE_CDR::ULong i = 0; i != len; ++i) - x[i] = from_IBM1047[x[i]]; - - return 1; - } - - return 0; -} - -ACE_CDR::Boolean -ACE_ISO8859_IBM1047::write_char (ACE_OutputCDR &out, - ACE_CDR::Char x) -{ - return - this->write_1 (out, - reinterpret_cast (&to_IBM1047[x])); -} - -ACE_CDR::Boolean -ACE_ISO8859_IBM1047::write_string (ACE_OutputCDR& out, - ACE_CDR::ULong len, - const ACE_CDR::Char* x) -{ - if (out.write_ulong (len + 1)) - return this->write_char_array (out, x, len + 1); - else - return 0; -} - -ACE_CDR::Boolean -ACE_ISO8859_IBM1047::write_char_array (ACE_OutputCDR &out, - const ACE_CDR::Char *x, - ACE_CDR::ULong len) -{ - char *buf = 0; - - if (this->adjust (out, len, 1, buf) == 0) - { - ACE_OS::memcpy (buf, x, len); - - for (ACE_CDR::ULong i = 0; i != len; ++i) - buf[i] = to_IBM1047[buf[i]]; - - return 1; - } - - this->good_bit (out, 0); - return 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#elif defined (__HP_aCC) -// Make aC++ stop complaining about an empty translation unit -static int const shut_up_aCC = 0; -#endif /* ACE_HAS_EBCDIC */ diff --git a/ACE/ace/Codeset_IBM1047.h b/ACE/ace/Codeset_IBM1047.h deleted file mode 100644 index c5bfdafcd49..00000000000 --- a/ACE/ace/Codeset_IBM1047.h +++ /dev/null @@ -1,128 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Codeset_IBM1047.h - * - * $Id$ - * - * Declares the arrays required to convert between ISO8859 (aka - * Latin/1) and IBM1047 (aka EBCDIC). - * - * - * @author Jim Rogers (jrogers@viasoft.com) - */ -//============================================================================= - - -#ifndef ACE_CODESET_IMB1047_H -#define ACE_CODESET_IMB1047_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_EBCDIC) - -#include "ace/CDR_Stream.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// **************************************************************** - -/** - * @class ACE_IBM1047_ISO8859 - * - * @brief Codeset translation specialization. - * - * This class performs the codeset translation: - * - Native: IBM_1047 (i.e. EBCDIC) - * - Stream: ISO-8859 (i.e. Latin/1) - */ -class ACE_Export ACE_IBM1047_ISO8859 : public ACE_Char_Codeset_Translator -{ -public: - /// A do nothing constructor. - ACE_IBM1047_ISO8859 (void); - - /// Virtual destruction - virtual ~ACE_IBM1047_ISO8859 (void); - - // = Documented in $ACE_ROOT/ace/CDR_Stream.h - virtual ACE_CDR::Boolean read_char (ACE_InputCDR &, - ACE_CDR::Char &); - virtual ACE_CDR::Boolean read_string (ACE_InputCDR &, - ACE_CDR::Char *&); - virtual ACE_CDR::Boolean read_char_array (ACE_InputCDR &, - ACE_CDR::Char *, - ACE_CDR::ULong); - virtual ACE_CDR::Boolean write_char (ACE_OutputCDR &, - ACE_CDR::Char); - virtual ACE_CDR::Boolean write_string (ACE_OutputCDR &, - ACE_CDR::ULong, - const ACE_CDR::Char *); - virtual ACE_CDR::Boolean write_char_array (ACE_OutputCDR &, - const ACE_CDR::Char *, - ACE_CDR::ULong); - - /// return the native codeset ID as defined in the OSF code and character - /// set registry, 0x10020417 - virtual ACE_CDR::ULong ncs (); - /// return the translated codeset ID as defined in the OSF code and character - /// set registry, 0x00010001 - virtual ACE_CDR::ULong tcs (); -}; - -/** - * @class ACE_ISO8859_IBM1047 - * - * @brief Codeset translation specialization. - * - * This class performs the codeset translation: - * - Native: ISO-8859 (i.e. Latin/1) - * - Stream: IBM-1047 (i.e. EBCDIC) - */ -class ACE_Export ACE_ISO8859_IBM1047 : public ACE_Char_Codeset_Translator -{ -public: - /// A do nothing constructor. - ACE_ISO8859_IBM1047 (void); - - /// Virtual destruction - virtual ~ACE_ISO8859_IBM1047 (void); - - // = Documented in $ACE_ROOT/ace/CDR_Stream.h - virtual ACE_CDR::Boolean read_char (ACE_InputCDR &, - ACE_CDR::Char &); - virtual ACE_CDR::Boolean read_string (ACE_InputCDR &, - ACE_CDR::Char *&); - virtual ACE_CDR::Boolean read_char_array (ACE_InputCDR &, - ACE_CDR::Char *, - ACE_CDR::ULong); - virtual ACE_CDR::Boolean write_char (ACE_OutputCDR &, - ACE_CDR::Char); - virtual ACE_CDR::Boolean write_string (ACE_OutputCDR &, - ACE_CDR::ULong, - const ACE_CDR::Char *); - virtual ACE_CDR::Boolean write_char_array (ACE_OutputCDR &, - const ACE_CDR::Char *, - ACE_CDR::ULong); - - /// return the native codeset ID as defined in the OSF code and character - /// set registry, 0x00010001 - virtual ACE_CDR::ULong ncs (); - /// return the translated codeset ID as defined in the OSF code and character - /// set registry, 0x10020417 - virtual ACE_CDR::ULong tcs (); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_EBCDIC */ - -#include /**/ "ace/post.h" - -#endif /* ACE_CODESET_IMB1047_H */ diff --git a/ACE/ace/Codeset_Registry.cpp b/ACE/ace/Codeset_Registry.cpp deleted file mode 100644 index b98a1dd7e89..00000000000 --- a/ACE/ace/Codeset_Registry.cpp +++ /dev/null @@ -1,111 +0,0 @@ -//============================================================================= -/** - * @file Codeset_Registry.cpp - * - * $Id$ - * - * emulated codset regstry functions - * - * - * @author Phil Mesnier - */ -//============================================================================= - -#include "ace/Codeset_Registry.h" -#include "ace/OS_Memory.h" -#include "ace/OS_NS_string.h" - -// $Id$ - -#if !defined (__ACE_INLINE__) -#include "ace/Codeset_Registry.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID (ace, - Codeset_Registry, - "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -int -ACE_Codeset_Registry::locale_to_registry_i (const ACE_CString &locale, - ACE_CDR::ULong &codeset_id, - ACE_CDR::UShort *num_sets, - ACE_CDR::UShort **char_sets) -{ - registry_entry const *element = 0; - for (size_t i = 0; element == 0 && i < num_registry_entries_; i++) - if (ACE_OS::strcmp (registry_db_[i].loc_name_, locale.c_str ()) == 0) - element = ®istry_db_[i]; - if (element == 0) - return 0; - codeset_id = element->codeset_id_; - if (num_sets != 0) - *num_sets = element->num_sets_; - if (char_sets != 0) - { - ACE_NEW_RETURN (*char_sets,ACE_CDR::UShort[element->num_sets_],0); - ACE_OS::memcpy (*char_sets, element->char_sets_, - element->num_sets_ * sizeof (ACE_CDR::UShort)); - } - return 1; -} - -int -ACE_Codeset_Registry::registry_to_locale_i (ACE_CDR::ULong codeset_id, - ACE_CString &locale, - ACE_CDR::UShort *num_sets, - ACE_CDR::UShort **char_sets) -{ - registry_entry const *element = 0; - for (size_t i = 0; element == 0 && i < num_registry_entries_; i++) - if (codeset_id == registry_db_[i].codeset_id_) - element = ®istry_db_[i]; - if (element == 0) - return 0; - locale.set (element->loc_name_); - if (num_sets != 0) - *num_sets = element->num_sets_; - if (char_sets != 0) - { - ACE_NEW_RETURN (*char_sets,ACE_CDR::UShort[element->num_sets_],0); - ACE_OS::memcpy (*char_sets, element->char_sets_, - element->num_sets_ * sizeof (ACE_CDR::UShort)); - } - return 1; -} - -int -ACE_Codeset_Registry::is_compatible_i (ACE_CDR::ULong codeset_id, - ACE_CDR::ULong other) -{ - registry_entry const *lhs = 0; - registry_entry const *rhs = 0; - for (size_t i = 0; (lhs == 0 || rhs == 0) && i < num_registry_entries_; i++) - { - if (codeset_id == registry_db_[i].codeset_id_) - lhs = ®istry_db_[i]; - if (other == registry_db_[i].codeset_id_) - rhs = ®istry_db_[i]; - } - - if (lhs == 0 || rhs == 0) - return 0; - - for (ACE_CDR::UShort l = 0; l < lhs->num_sets_; l++) - for (ACE_CDR::UShort r = 0; r < rhs->num_sets_; r++) - if (rhs->char_sets_[r] == lhs->char_sets_[l]) - return 1; - return 0; -} - -ACE_CDR::Short -ACE_Codeset_Registry::get_max_bytes_i (ACE_CDR::ULong codeset_id) -{ - for (size_t i = 0; i < num_registry_entries_; i++) - if (codeset_id == registry_db_[i].codeset_id_) - return registry_db_[i].max_bytes_; - return 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Codeset_Registry.h b/ACE/ace/Codeset_Registry.h deleted file mode 100644 index eb8d013d4af..00000000000 --- a/ACE/ace/Codeset_Registry.h +++ /dev/null @@ -1,104 +0,0 @@ -// -*- C++ -*- -//============================================================================= -/** - * @file Codeset_Registry.h - * - * $Id$ - * - * ACE wrapper around access functions for the OSF's DCE codeset registry - * access functions - * - * For environments that intrinsicly support the DCE defined access functions, - * the methods in this class are simply wrappers. On other platforms, emulation - * is provided. The motivation for this class is to support interoperability - * via translators and the CDR streams, primarily in TAO, but this capability - * is not restricted to CORBA. - * - * The emulated functionalty supports Open Group RFC #40, currently RFC 40.2, - * www.opengroup.org/tech/rfc/rfc40.2.html - * - * @author Phil Mesnier - */ -//============================================================================= - -#ifndef ACE_CODESET_REGISTRY_H -#define ACE_CODESET_REGISTRY_H - -#include /**/ "ace/pre.h" -#include "ace/SString.h" -#include "ace/CDR_Base.h" -#include "ace/Codeset_Symbols.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_DCE_CODESET_REGISTRY) -#include /**/ -#endif /* ACE_HAS_DCE_CODESET_REGISTRY */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -class ACE_Export ACE_Codeset_Registry -{ -public: - - /// Based on a locale string, find the registry value and optional codeset - /// collection. This wraps the dce_cs_loc_to_rgy function, or emulates it. - static int locale_to_registry (const ACE_CString &locale, - ACE_CDR::ULong &codeset_id, - ACE_CDR::UShort * = 0, - ACE_CDR::UShort ** = 0); - - /// Based on a registry value, find the locale string and optional codeset - /// collection. This wraps the dce_cs_rgy_to_loc function, or emulates it. - static int registry_to_locale (ACE_CDR::ULong codeset_id, - ACE_CString &locale, - ACE_CDR::UShort * = 0, - ACE_CDR::UShort ** = 0); - - /// Tell if two codesets are compatible. This wraps the - /// rpc_cs_char_set_compat_check function. - static int is_compatible (ACE_CDR::ULong codeset_id, - ACE_CDR::ULong other); - - /// Return the max number of bytes required to represent a single character. - /// This wraps the rpc_rgy_get_max_bytes function. - static ACE_CDR::Short get_max_bytes (ACE_CDR::ULong codeset_id); - - enum {max_charsets_ = 5}; -protected: - typedef struct { - const char * desc_; - const char * loc_name_; - ACE_CDR::ULong codeset_id_; - ACE_CDR::UShort num_sets_; - ACE_CDR::UShort char_sets_[max_charsets_]; - ACE_CDR::UShort max_bytes_; - } registry_entry; - -private: - static size_t const num_registry_entries_; - static registry_entry const registry_db_[]; - - static int locale_to_registry_i (const ACE_CString &locale, - ACE_CDR::ULong &codeset_id, - ACE_CDR::UShort * = 0, - ACE_CDR::UShort ** = 0); - static int registry_to_locale_i (ACE_CDR::ULong codeset_id, - ACE_CString &locale, - ACE_CDR::UShort * = 0, - ACE_CDR::UShort ** = 0); - static int is_compatible_i (ACE_CDR::ULong codeset_id, - ACE_CDR::ULong other); - static ACE_CDR::Short get_max_bytes_i (ACE_CDR::ULong codeset_id); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Codeset_Registry.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_CODESET_REGISTRY_H */ diff --git a/ACE/ace/Codeset_Registry.inl b/ACE/ace/Codeset_Registry.inl deleted file mode 100644 index d24e07cc83b..00000000000 --- a/ACE/ace/Codeset_Registry.inl +++ /dev/null @@ -1,102 +0,0 @@ -// -*- C++ -*- -//============================================================================= -/** - * @file Codeset_Registry.inl - * - * $Id$ - * - * ACE wrapper around access functions for the OSF's DCE codeset registry - * access functions - the inline functions either call the system supplied - * DCE based codeset regsitry function, or calls the emulation - * - * - * @author Phil Mesnier - */ -//============================================================================= - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -int -ACE_Codeset_Registry::locale_to_registry(const ACE_CString &locale, - ACE_CDR::ULong &codeset_id, - ACE_CDR::UShort *num_sets, - ACE_CDR::UShort **char_sets) -{ -#if defined (ACE_HAS_DCE_CODESET_REGISTRY) - error_status_t result; - dce_cs_loc_to_rgy (locale.c_str(), - &codeset_id, - num_sets, - char_sets, - &result); - return (result == dce_cs_c_ok) ? 1 : 0; -#else - return ACE_Codeset_Registry::locale_to_registry_i (locale, - codeset_id, - num_sets, - char_sets); -#endif /* ACE_HAS_DCE_CODESET_REGISTRY */ -} - -// based on a registry value, find the locale string and optional codeset -// collection. This wraps the dce_cs_rgy_to_loc function, or emulates it. -ACE_INLINE -int -ACE_Codeset_Registry::registry_to_locale(ACE_CDR::ULong codeset_id, - ACE_CString &locale, - ACE_CDR::UShort *num_sets, - ACE_CDR::UShort **char_sets) -{ -#if defined (ACE_HAS_DCE_CODESET_REGISTRY) - error_status_t result; - char *buffer; - dce_cs_rgy_to_loc (codeset_id, - &buffer, - num_sets, - char_sets, - &result); - locale.set(buffer); // does a copy :-( - free (buffer); - return (result == dce_cs_c_ok) ? 1 : 0; -#else - return ACE_Codeset_Registry::registry_to_locale_i (codeset_id, - locale, - num_sets, - char_sets); -#endif /* ACE_HAS_DCE_CODESET_REGISTRY */ -} - -// Tell if two codesets are compatible. This wraps the -// rpc_cs_char_set_compat_check function. -ACE_INLINE -int -ACE_Codeset_Registry::is_compatible (ACE_CDR::ULong codeset_id, - ACE_CDR::ULong other) -{ -#if defined (ACE_HAS_DCE_CODESET_REGISTRY) - error_status_t result; - rpc_cs_char_set_compat_check(codeset_id,other,&result); - return (result == rpc_s_ok) ? 1 : 0; -#else - return ACE_Codeset_Registry::is_compatible_i (codeset_id,other); -#endif /* ACE_HAS_DCE_CODESET_REGISTRY */ -} - -// Return the max number of bytes required to represent a single character. -// This wraps the rpc_rgy_get_max_bytes function. -ACE_INLINE -ACE_CDR::Short -ACE_Codeset_Registry::get_max_bytes (ACE_CDR::ULong codeset_id) -{ -#if defined (ACE_HAS_DCE_CODESET_REGISTRY) - error_status_t result; - short max_bytes; - rpc_rgy_get_max_bytes(codeset_id,&max_bytes,&result); - return (result == rpc_s_ok) ? (short)max_bytes : 0; -#else - return ACE_Codeset_Registry::get_max_bytes_i (codeset_id); -#endif /* ACE_HAS_DCE_CODESET_REGISTRY */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Codeset_Registry_db.cpp b/ACE/ace/Codeset_Registry_db.cpp deleted file mode 100644 index 8b1ef176576..00000000000 --- a/ACE/ace/Codeset_Registry_db.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* $Id$ - * Codeset registry DB, generated Fri Feb 28 21:01:30 2003 - * source: code_set_registry1.2g.txt - * - * To populate the registry_db, construct a codeset registry text file based - * on the OSF's Character and Code Set Registry. See DCE RFC 40.1 for details - * on obtaining the full text for the current registry. Once you have composed - * a text file containing all the desired codeset information, build and run - * mkcsregdb. The source is in $ACE_ROOT/apps/mkcsregdb. It will generate a new - * copy of this file, with the registry_db_ array properly initialized. - */ - -#include "ace/Codeset_Registry.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_Codeset_Registry::registry_entry const -ACE_Codeset_Registry::registry_db_[] = -{ - {"ISO 8859-1:1987; Latin Alphabet No. 1","ASCII",0x00010001,1,{0x0011},1}, - {"IBM-1047 (CCSID 01047); Latin-1 Open System","EBCDIC",0x10020417,1,{0x0011},1}, - {"ISO/IEC 10646-1:1993; UCS-4, Level 1","UCS-4",0x00010104,1,{0x1000},4}, - {"ISO/IEC 10646-1:1993; UTF-16, UCS Transformation Format 16-bit form","Unicode",0x00010109,1,{0x1000},2}, - {"X/Open UTF-8; UCS Transformation Format 8 (UTF-8)","UTF-8",0x05010001,1,{0x1000},6} -}; - -size_t const ACE_Codeset_Registry::num_registry_entries_ = 5; - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Codeset_Symbols.h b/ACE/ace/Codeset_Symbols.h deleted file mode 100644 index d2d20ce036b..00000000000 --- a/ACE/ace/Codeset_Symbols.h +++ /dev/null @@ -1,220 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Codeset_Symbols.h - * - * $Id$ - * - * Symbolic names for codeset ids. - * - * @author Dale Wilson (wilson_d@ociweb.com) - */ -//============================================================================= -#ifndef CODESET_SYMBOLS_H -#define CODESET_SYMBOLS_H - -// These numbers are assigned by the OpenGroup, a database is -// available at -// -// ftp://ftp.opengroup.org/pub/code_set_registry/ -// -// Alas, the database is in a semi-regular text file -- difficult to use. -// The following C/C++-friendly version of the codeset ids was captured -// from Version 1.2g of the registry. -// -#define ACE_CODESET_ID_ISO_8859_1 0x00010001U -#define ACE_CODESET_ID_ISO_8859_2 0x00010002U -#define ACE_CODESET_ID_ISO_8859_3 0x00010003U -#define ACE_CODESET_ID_ISO_8859_4 0x00010004U -#define ACE_CODESET_ID_ISO_8859_5 0x00010005U -#define ACE_CODESET_ID_ISO_8859_6 0x00010006U -#define ACE_CODESET_ID_ISO_8859_7 0x00010007U -#define ACE_CODESET_ID_ISO_8859_8 0x00010008U -#define ACE_CODESET_ID_ISO_8859_9 0x00010009U -#define ACE_CODESET_ID_ISO_8859_10 0x0001000AU -#define ACE_CODESET_ID_ISO_8859_15 0x0001000FU -#define ACE_CODESET_ID_ISO_646 0x00010020U -#define ACE_CODESET_ID_ISO_UCS_2_LEVEL_1 0x00010100U -#define ACE_CODESET_ID_ISO_UCS_2_LEVEL_2 0x00010101U -#define ACE_CODESET_ID_ISO_UCS_2_LEVEL_3 0x00010102U -#define ACE_CODESET_ID_ISO_UCS_4_LEVEL_1 0x00010104U -#define ACE_CODESET_ID_ISO_UCS_4_LEVEL_2 0x00010105U -#define ACE_CODESET_ID_ISO_UCS_4_LEVEL_3 0x00010106U -#define ACE_CODESET_ID_ISO_UTF_8 0x00010108U -#define ACE_CODESET_ID_ISO_UTF_16 0x00010109U -#define ACE_CODESET_ID_JIS_X0201 0x00030001U -#define ACE_CODESET_ID_JIS_X0208_1978 0x00030004U -#define ACE_CODESET_ID_JIS_X0208_1983 0x00030005U -#define ACE_CODESET_ID_JIS_X0208_1990 0x00030006U -#define ACE_CODESET_ID_JIS_X0212 0x0003000AU -#define ACE_CODESET_ID_JIS_EUCJP 0x00030010U -#define ACE_CODESET_ID_KS_C5601 0x00040001U -#define ACE_CODESET_ID_KS_C5657 0x00040002U -#define ACE_CODESET_ID_KS_EUCKR 0x0004000AU -#define ACE_CODESET_ID_CNS_11643_1986 0x00050001U -#define ACE_CODESET_ID_CNS_11643_1992 0x00050002U -#define ACE_CODESET_ID_CNS_EUCTW_1991 0x0005000AU -#define ACE_CODESET_ID_CNS_EUCTW_1993 0x00050010U -#define ACE_CODESET_ID_TIS_620_25290X000B0001U -#define ACE_CODESET_ID_TTB_CCDC 0x000D0001U -#define ACE_CODESET_ID_OSF_JAPANESE_UJIS 0x05000010U -#define ACE_CODESET_ID_OSF_JAPANESE_SJIS_1 0x05000011U -#define ACE_CODESET_ID_OSF_JAPANESE_SJIS_2 0x05000012U -#define ACE_CODESET_ID_XOPEN_UTF_8 0x05010001U -#define ACE_CODESET_ID_JVC_EUCJP 0x05020001U -#define ACE_CODESET_ID_JVC_SJIS 0x05020002U -#define ACE_CODESET_ID_DEC_KANJI 0x10000001U -#define ACE_CODESET_ID_SUPER_DEC_KANJI 0x10000002U -#define ACE_CODESET_ID_DEC_SHIFT_JIS 0x10000003U -#define ACE_CODESET_ID_HP_ROMAN8 0x10010001U -#define ACE_CODESET_ID_HP_KANA8 0x10010002U -#define ACE_CODESET_ID_HP_ARABIC8 0x10010003U -#define ACE_CODESET_ID_HP_GREEK8 0x10010004U -#define ACE_CODESET_ID_HP_HEBREW8 0x10010005U -#define ACE_CODESET_ID_HP_TURKISH8 0x10010006U -#define ACE_CODESET_ID_HP15CN 0x10010007U -#define ACE_CODESET_ID_HP_BIG5 0x10010008U -#define ACE_CODESET_ID_HP_JAPANESE15__SJIS_ 0x10010009U -#define ACE_CODESET_ID_HP_SJISHI 0x1001000AU -#define ACE_CODESET_ID_HP_SJISPC 0x1001000BU -#define ACE_CODESET_ID_HP_UJIS 0x1001000CU -#define ACE_CODESET_ID_IBM_037 0x10020025U -#define ACE_CODESET_ID_IBM_273 0x10020111U -#define ACE_CODESET_ID_IBM_277 0x10020115U -#define ACE_CODESET_ID_IBM_278 0x10020116U -#define ACE_CODESET_ID_IBM_280 0x10020118U -#define ACE_CODESET_ID_IBM_282 0x1002011AU -#define ACE_CODESET_ID_IBM_284 0x1002011CU -#define ACE_CODESET_ID_IBM_285 0x1002011DU -#define ACE_CODESET_ID_IBM_290 0x10020122U -#define ACE_CODESET_ID_IBM_297 0x10020129U -#define ACE_CODESET_ID_IBM_300 0x1002012CU -#define ACE_CODESET_ID_IBM_301 0x1002012DU -#define ACE_CODESET_ID_IBM_420 0x100201A4U -#define ACE_CODESET_ID_IBM_424 0x100201A8U -#define ACE_CODESET_ID_IBM_437 0x100201B5U -#define ACE_CODESET_ID_IBM_500 0x100201F4U -#define ACE_CODESET_ID_IBM_833 0x10020341U -#define ACE_CODESET_ID_IBM_834 0x10020342U -#define ACE_CODESET_ID_IBM_835 0x10020343U -#define ACE_CODESET_ID_IBM_836 0x10020344U -#define ACE_CODESET_ID_IBM_837 0x10020345U -#define ACE_CODESET_ID_IBM_838 0x10020346U -#define ACE_CODESET_ID_IBM_839 0x10020347U -#define ACE_CODESET_ID_IBM_850 0x10020352U -#define ACE_CODESET_ID_IBM_852 0x10020354U -#define ACE_CODESET_ID_IBM_855 0x10020357U -#define ACE_CODESET_ID_IBM_856 0x10020358U -#define ACE_CODESET_ID_IBM_857 0x10020359U -#define ACE_CODESET_ID_IBM_861 0x1002035DU -#define ACE_CODESET_ID_IBM_862 0x1002035EU -#define ACE_CODESET_ID_IBM_863 0x1002035FU -#define ACE_CODESET_ID_IBM_864 0x10020360U -#define ACE_CODESET_ID_IBM_866 0x10020362U -#define ACE_CODESET_ID_IBM_868 0x10020364U -#define ACE_CODESET_ID_IBM_869 0x10020365U -#define ACE_CODESET_ID_IBM_870 0x10020366U -#define ACE_CODESET_ID_IBM_871 0x10020367U -#define ACE_CODESET_ID_IBM_874 0x1002036AU -#define ACE_CODESET_ID_IBM_875 0x1002036BU -#define ACE_CODESET_ID_IBM_880 0x10020370U -#define ACE_CODESET_ID_IBM_891 0x1002037BU -#define ACE_CODESET_ID_IBM_896 0x10020380U -#define ACE_CODESET_ID_IBM_897 0x10020381U -#define ACE_CODESET_ID_IBM_903 0x10020387U -#define ACE_CODESET_ID_IBM_904 0x10020388U -#define ACE_CODESET_ID_IBM_918 0x10020396U -#define ACE_CODESET_ID_IBM_921 0x10020399U -#define ACE_CODESET_ID_IBM_922 0x1002039AU -#define ACE_CODESET_ID_IBM_926 0x1002039EU -#define ACE_CODESET_ID_IBM_927 0x1002039FU -#define ACE_CODESET_ID_IBM_928 0x100203A0U -#define ACE_CODESET_ID_IBM_929 0x100203A1U -#define ACE_CODESET_ID_IBM_930 0x100203A2U -#define ACE_CODESET_ID_IBM_932 0x100203A4U -#define ACE_CODESET_ID_IBM_933 0x100203A5U -#define ACE_CODESET_ID_IBM_934 0x100203A6U -#define ACE_CODESET_ID_IBM_935 0x100203A7U -#define ACE_CODESET_ID_IBM_936 0x100203A8U -#define ACE_CODESET_ID_IBM_937 0x100203A9U -#define ACE_CODESET_ID_IBM_938 0x100203AAU -#define ACE_CODESET_ID_IBM_939 0x100203ABU -#define ACE_CODESET_ID_IBM_941 0x100203ADU -#define ACE_CODESET_ID_IBM_942 0x100203AEU -#define ACE_CODESET_ID_IBM_943 0x100203AFU -#define ACE_CODESET_ID_IBM_946 0x100203B2U -#define ACE_CODESET_ID_IBM_947 0x100203B3U -#define ACE_CODESET_ID_IBM_948 0x100203B4U -#define ACE_CODESET_ID_IBM_949 0x100203B5U -#define ACE_CODESET_ID_IBM_950 0x100203B6U -#define ACE_CODESET_ID_IBM_951 0x100203B7U -#define ACE_CODESET_ID_IBM_955 0x100203BBU -#define ACE_CODESET_ID_IBM_964 0x100203C4U -#define ACE_CODESET_ID_IBM_970 0x100203CAU -#define ACE_CODESET_ID_IBM_1006 0x100203EEU -#define ACE_CODESET_ID_IBM_1025 0x10020401U -#define ACE_CODESET_ID_IBM_1026 0x10020402U -#define ACE_CODESET_ID_IBM_1027 0x10020403U -#define ACE_CODESET_ID_IBM_1040 0x10020410U -#define ACE_CODESET_ID_IBM_1041 0x10020411U -#define ACE_CODESET_ID_IBM_1043 0x10020413U -#define ACE_CODESET_ID_IBM_1046 0x10020416U -#define ACE_CODESET_ID_IBM_1047 0x10020417U -#define ACE_CODESET_ID_IBM_1088 0x10020440U -#define ACE_CODESET_ID_IBM_1097 0x10020449U -#define ACE_CODESET_ID_IBM_1098 0x1002044AU -#define ACE_CODESET_ID_IBM_1112 0x10020458U -#define ACE_CODESET_ID_IBM_1114 0x1002045AU -#define ACE_CODESET_ID_IBM_1115 0x1002045BU -#define ACE_CODESET_ID_IBM_1122 0x10020462U -#define ACE_CODESET_ID_IBM_1250 0x100204E2U -#define ACE_CODESET_ID_IBM_1251 0x100204E3U -#define ACE_CODESET_ID_IBM_1252 0x100204E4U -#define ACE_CODESET_ID_IBM_1253 0x100204E5U -#define ACE_CODESET_ID_IBM_1254 0x100204E6U -#define ACE_CODESET_ID_IBM_1255 0x100204E7U -#define ACE_CODESET_ID_IBM_1256 0x100204E8U -#define ACE_CODESET_ID_IBM_1257 0x100204E9U -#define ACE_CODESET_ID_IBM_1380 0x10020564U -#define ACE_CODESET_ID_IBM_1381 0x10020565U -#define ACE_CODESET_ID_IBM_1383 0x10020567U -#define ACE_CODESET_ID_IBM_4396 0x1002112CU -#define ACE_CODESET_ID_IBM_4946 0x10021352U -#define ACE_CODESET_ID_IBM_4948 0x10021354U -#define ACE_CODESET_ID_IBM_4951 0x10021357U -#define ACE_CODESET_ID_IBM_4952 0x10021358U -#define ACE_CODESET_ID_IBM_4953 0x10021359U -#define ACE_CODESET_ID_IBM_4960 0x10021360U -#define ACE_CODESET_ID_IBM_4964 0x10021364U -#define ACE_CODESET_ID_IBM_4965 0x10021365U -#define ACE_CODESET_ID_IBM_5026 0x100213A2U -#define ACE_CODESET_ID_IBM_5031 0x100213A7U -#define ACE_CODESET_ID_IBM_5035 0x100213ABU -#define ACE_CODESET_ID_IBM_5048 0x100213B8U -#define ACE_CODESET_ID_IBM_5049 0x100213B9U -#define ACE_CODESET_ID_IBM_5067 0x100213CBU -#define ACE_CODESET_ID_IBM_8612 0x100221A4U -#define ACE_CODESET_ID_IBM_9025 0x10022341U -#define ACE_CODESET_ID_IBM_9026 0x10022342U -#define ACE_CODESET_ID_IBM_9030 0x10022346U -#define ACE_CODESET_ID_IBM_9056 0x10022360U -#define ACE_CODESET_ID_IBM_9066 0x1002236AU -#define ACE_CODESET_ID_IBM_9125 0x100223A5U -#define ACE_CODESET_ID_IBM_25426 0x10026352U -#define ACE_CODESET_ID_IBM_25432 0x10026358U -#define ACE_CODESET_ID_IBM_1042 0x10026412U -#define ACE_CODESET_ID_IBM_28709 0x10027025U -#define ACE_CODESET_ID_IBM_33624 0x10028358U -#define ACE_CODESET_ID_IBM_33722 0x100283BAU -#define ACE_CODESET_ID_HTCSJIS 0x10030001U -#define ACE_CODESET_ID_HTCUJIS 0x10030002U -#define ACE_CODESET_ID_FUJITSU_U90 0x10040001U -#define ACE_CODESET_ID_FUJITSU_S90 0x10040002U -#define ACE_CODESET_ID_FUJITSU_R90 0x10040003U -#define ACE_CODESET_ID_EBCDIC_ASCII_AND_JEF 0x10040004U -#define ACE_CODESET_ID_EBCDIC_KATAKANA_AND_JEF 0x10040005U -#define ACE_CODESET_ID_EBCDIC_JAPANESE_ENGLISH_AND_JEF 0x10040006U - -#define ACE_CODESET_ID_TAO_BACKWARD_COMPATIBLE 0xf54414F0U -#endif // CODESET_SYMBOLS_H diff --git a/ACE/ace/Condition_Recursive_Thread_Mutex.cpp b/ACE/ace/Condition_Recursive_Thread_Mutex.cpp deleted file mode 100644 index af80f4bfbfd..00000000000 --- a/ACE/ace/Condition_Recursive_Thread_Mutex.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// -*- C++ -*- - -/** - * @file Condition_Recursive_Thread_Mutex.cpp - * - * $Id$ - * - * Originally in Synch.cpp - * - * @author Douglas C. Schmidt - */ - -#include "ace/Condition_Recursive_Thread_Mutex.h" - -#if defined (ACE_HAS_THREADS) - -#if defined (ACE_HAS_DUMP) -# include "ace/Log_Msg.h" -#endif /* ACE_HAS_DUMP */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -int -ACE_Condition::remove (void) -{ - return ACE_OS::cond_destroy (&this->cond_); -} - -void -ACE_Condition::dump (void) const -{ -#if defined (ACE_HAS_DUMP) -// ACE_TRACE ("ACE_Condition::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - // No dump method for ACE_cond_t even in emulated mode. - // cond_.dump (); - this->mutex_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_Condition::~ACE_Condition (void) -{ - this->remove (); -} - -ACE_Condition::ACE_Condition (ACE_Recursive_Thread_Mutex &m) - : mutex_ (m) -{ - ACE_OS::cond_init (&this->cond_); -} - -int -ACE_Condition::wait (const ACE_Time_Value *abstime) -{ - return this->wait (this->mutex_, abstime); -} - -int -ACE_Condition::wait (ACE_Recursive_Thread_Mutex &mutex, - const ACE_Time_Value *abstime) -{ - ACE_recursive_mutex_state mutex_state_holder; - ACE_recursive_thread_mutex_t &recursive_mutex = mutex.mutex (); - - if (ACE_OS::recursive_mutex_cond_unlock (&recursive_mutex, - mutex_state_holder) == -1) - return -1; - - // We wait on the condition, specifying the nesting mutex. For platforms - // with ACE_HAS_RECURSIVE_MUTEXES, this is the recursive mutex itself, - // and is the same as recursive_mutex, above. The caller should have been - // holding the lock on entry to this method, and it is still held. - // For other platforms, this is the nesting mutex that guards the - // ACE_recursive_mutex_t internals, and recursive_mutex_cond_unlock() - // returned with the lock held, but waiters primed and waiting to be - // released. At cond_wait below, the mutex will be released. - // On return, it will be reacquired. - const int result = abstime == 0 - ? ACE_OS::cond_wait (&this->cond_, - &mutex.get_nesting_mutex ()) - : ACE_OS::cond_timedwait (&this->cond_, - &mutex.get_nesting_mutex (), - const_cast (abstime)); - // We are holding the mutex, whether the wait succeeded or failed. - // Stash errno (in case it failed) and then we need to reset the - // recursive mutex state to what it was on entry to this method. - // Resetting it may require a wait for another thread to release - // the ACE_recursive_thread_mutex_t if this is a platform without - // ACE_HAS_RECURSIVE_MUTEXES, and recursive_mutex_cond_relock() takes - // care of that. - { - ACE_Errno_Guard error (errno); - ACE_OS::recursive_mutex_cond_relock (&recursive_mutex, - mutex_state_holder); - } - - return result; -} - -int -ACE_Condition::signal (void) -{ - return ACE_OS::cond_signal (&this->cond_); -} - -int -ACE_Condition::broadcast (void) -{ - return ACE_OS::cond_broadcast (&this->cond_); -} - -ACE_Recursive_Thread_Mutex & -ACE_Condition::mutex (void) -{ - return this->mutex_; -} - -ACE_Condition_Recursive_Thread_Mutex::ACE_Condition_Recursive_Thread_Mutex ( - ACE_Recursive_Thread_Mutex &m) : - ACE_Condition (m) -{ -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_THREADS */ diff --git a/ACE/ace/Condition_Recursive_Thread_Mutex.h b/ACE/ace/Condition_Recursive_Thread_Mutex.h deleted file mode 100644 index cfcd46a9551..00000000000 --- a/ACE/ace/Condition_Recursive_Thread_Mutex.h +++ /dev/null @@ -1,118 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file Condition_Recursive_Thread_Mutex.h - * - * $Id$ - * - * Moved from Synch.h. - * - * @author Douglas C. Schmidt - */ -//========================================================================== - -#ifndef ACE_CONDITION_RECURSIVE_THREAD_MUTEX_H -#define ACE_CONDITION_RECURSIVE_THREAD_MUTEX_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (ACE_HAS_THREADS) -# include "ace/Null_Condition.h" -#else /* ACE_HAS_THREADS */ -#include "ace/Recursive_Thread_Mutex.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template class ACE_Condition; - -/** - * @class ACE_Condition - * - * @brief ACE_Condition template specialization written using - * @a ACE_Recursive_Thread_Mutex. This allows threads to block until - * shared data changes state using recursive mutexes. - */ -template<> -class ACE_Export ACE_Condition -{ -public: - /// Initialize the condition variable with a recursive mutex. - ACE_Condition (ACE_Recursive_Thread_Mutex &m); - - /// Implicitly destroy the condition variable. - ~ACE_Condition (void); - - /** - * Explicitly destroy the condition variable. Note that only one - * thread should call this method since it doesn't protect against - * race conditions. - */ - int remove (void); - - /** - * Block on condition, or until absolute time-of-day has passed. If - * abstime == 0 use "blocking" semantics. Else, if - * != 0 and the call times out before the condition is signaled - * returns -1 and sets errno to ETIME. - */ - int wait (const ACE_Time_Value *abstime = 0); - - /** - * Block on condition or until absolute time-of-day has passed. If - * abstime == 0 use "blocking" wait() semantics on the recursive @a mutex - * passed as a parameter (this is useful if you need to store the - * in shared memory). Else, if != 0 and the - * call times out before the condition is signaled returns -1 - * and sets errno to ETIME. - */ - int wait (ACE_Recursive_Thread_Mutex &mutex, - const ACE_Time_Value *abstime = 0); - - /// Signal one waiting thread. - int signal (void); - - /// Signal *all* waiting threads. - int broadcast (void); - - /// Returns a reference to the underlying mutex; - ACE_Recursive_Thread_Mutex &mutex (void); - - /// Dump the state of an object. - void dump (void) const; - -private: - - // = Prevent assignment and copying. - void operator= (const ACE_Condition &); - ACE_Condition (const ACE_Condition &); - -private: - - /// A normal (i.e., non-recursive) condition variable. - ACE_cond_t cond_; - - /// Reference to the recursive mutex. - ACE_Recursive_Thread_Mutex &mutex_; - -}; - -class ACE_Export ACE_Condition_Recursive_Thread_Mutex - : public ACE_Condition -{ -public: - /// Initialize the condition variable with a recursive mutex. - ACE_Condition_Recursive_Thread_Mutex (ACE_Recursive_Thread_Mutex &m); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* !ACE_HAS_THREADS */ - -#include /**/ "ace/post.h" -#endif /* ACE_CONDITION_RECURSIVE_THREAD_MUTEX_H */ diff --git a/ACE/ace/Condition_T.cpp b/ACE/ace/Condition_T.cpp deleted file mode 100644 index fa0dab4e80a..00000000000 --- a/ACE/ace/Condition_T.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// $Id$ - -#ifndef ACE_CONDITION_T_CPP -#define ACE_CONDITION_T_CPP - -#include "ace/Condition_T.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_THREADS) - -#include "ace/Log_Msg.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Condition_T.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_Condition) - -template void -ACE_Condition::dump (void) const -{ -#if defined (ACE_HAS_DUMP) -// ACE_TRACE ("ACE_Condition::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -template -ACE_Thread_Condition::ACE_Thread_Condition (MUTEX &m, - const ACE_TCHAR *name, - void *arg) - : ACE_Condition (m, USYNC_THREAD, name, arg) -{ -// ACE_TRACE ("ACE_Thread_Condition::ACE_Thread_Condition"); -} - -template void -ACE_Thread_Condition::dump (void) const -{ -#if defined (ACE_HAS_DUMP) -// ACE_TRACE ("ACE_Thread_Condition::dump"); - - ACE_Condition::dump (); -#endif /* ACE_HAS_DUMP */ -} - -template -ACE_Condition::ACE_Condition (MUTEX &m, - int type, - const ACE_TCHAR *name, - void *arg) - : - mutex_ (m) -{ - // ACE_TRACE ("ACE_Condition::ACE_Condition"); - - if (ACE_OS::cond_init (&this->cond_, - (short) type, - name, - arg) != 0) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Condition::ACE_Condition"))); -} - -template -ACE_Condition::~ACE_Condition (void) -{ - // ACE_TRACE ("ACE_Condition::~ACE_Condition"); - - if (this->remove () == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Condition::~ACE_Condition"))); -} - -template int -ACE_Condition::wait (void) -{ - // ACE_TRACE ("ACE_Condition::wait"); - return ACE_OS::cond_wait (&this->cond_, - &this->mutex_.lock_); -} - -template int -ACE_Condition::wait (MUTEX &mutex, - const ACE_Time_Value *abstime) -{ -// ACE_TRACE ("ACE_Condition::wait"); - if (abstime == 0) - return this->wait (); - else - { - return ACE_OS::cond_timedwait (&this->cond_, - &mutex.lock_, - (ACE_Time_Value *) abstime); - } -} - -// Peform an "alertable" timed wait. If the argument ABSTIME == 0 -// then we do a regular cond_wait(), else we do a timed wait for up to -// ABSTIME using the Solaris cond_timedwait() function. - -template int -ACE_Condition::wait (const ACE_Time_Value *abstime) -{ -// ACE_TRACE ("ACE_Condition::wait"); - return this->wait (this->mutex_, abstime); -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_THREADS */ - -#endif /* ACE_CONDITION_T_CPP */ diff --git a/ACE/ace/Condition_T.h b/ACE/ace/Condition_T.h deleted file mode 100644 index 535642a77e8..00000000000 --- a/ACE/ace/Condition_T.h +++ /dev/null @@ -1,167 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file Condition_T.h - * - * $Id$ - * - * Moved from Synch.h. - * - * @author Douglas C. Schmidt - */ -//========================================================================== - -#ifndef ACE_CONDITION_T_H -#define ACE_CONDITION_T_H - -#include /**/ "ace/pre.h" - -#include "ace/OS_NS_Thread.h" -#include "ace/Lock.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_THREADS) /* ACE platform supports some form of threading. */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -class ACE_Time_Value; - -/** - * @class ACE_Condition - * - * @brief ACE_Condition variable wrapper, which allows threads to block - * until shared data changes state. - * - * A condition variable enables threads to atomically block and - * test the condition under the protection of a mutual exclu- - * sion lock (mutex) until the condition is satisfied. That is, - * the mutex must have been held by the thread before calling - * wait or signal on the condition. If the condition is false, - * a thread blocks on a condition variable and atomically - * releases the mutex that is waiting for the condition to - * change. If another thread changes the condition, it may wake - * up waiting threads by signaling the associated condition - * variable. The waiting threads, upon awakening, reacquire the - * mutex and re-evaluate the condition. - * Note, you can only parameterize with - * @a ACE_Thread_Mutex, @a ACE_Recursive_Thread_Mutex, or @a ACE_Null_Mutex. - */ -template -class ACE_Condition -{ -public: - // = Initialiation and termination methods. - /// Initialize the condition variable. - ACE_Condition (MUTEX &m, int type = USYNC_THREAD, - const ACE_TCHAR *name = 0, void *arg = 0); - - /// Implicitly destroy the condition variable. - ~ACE_Condition (void); - - // = Lock accessors. - /** - * Block on condition, or until absolute time-of-day has passed. If - * abstime == 0 use "blocking" semantics. Else, if - * != 0 and the call times out before the condition is signaled - * returns -1 and sets errno to ETIME. - */ - int wait (const ACE_Time_Value *abstime); - - /// Block on condition. - int wait (void); - - /** - * Block on condition or until absolute time-of-day has passed. If - * abstime == 0 use "blocking" wait() semantics on the - * passed as a parameter (this is useful if you need to store the - * in shared memory). Else, if != 0 and the - * call times out before the condition is signaled returns -1 - * and sets errno to ETIME. - */ - int wait (MUTEX &mutex, const ACE_Time_Value *abstime = 0); - - /// Signal one waiting thread. - int signal (void); - - /// Signal *all* waiting threads. - int broadcast (void); - - // = Utility methods. - /// Explicitly destroy the condition variable. - int remove (void); - - /// Returns a reference to the underlying mutex_; - MUTEX &mutex (void); - - /// Dump the state of an object. - void dump (void) const; - - // ACE_ALLOC_HOOK_DECLARE; - // Declare the dynamic allocation hooks. - -protected: - /// Condition variable. - ACE_cond_t cond_; - - /// Reference to mutex lock. - MUTEX &mutex_; - -private: - // = Prevent assignment and initialization. - ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Condition &)) - ACE_UNIMPLEMENTED_FUNC (ACE_Condition (const ACE_Condition &)) -}; - -/** - * @class ACE_Thread_Condition - * - * @brief ACE_Condition variable wrapper that works within processes. - * - * A condition variable enables threads to atomically block and - * test the condition under the protection of a mutual exclu- - * sion lock (mutex) until the condition is satisfied. That is, - * the mutex must have been held by the thread before calling - * wait or signal on the condition. If the condition is false, - * a thread blocks on a condition variable and atomically - * releases the mutex that is waiting for the condition to - * change. If another thread changes the condition, it may wake - * up waiting threads by signaling the associated condition - * variable. The waiting threads, upon awakening, reacquire the - * mutex and re-evaluate the condition. - */ -template -class ACE_Thread_Condition : public ACE_Condition -{ -public: - // = Initialization method. - ACE_Thread_Condition (MUTEX &m, const ACE_TCHAR *name = 0, void *arg = 0); - - /// Dump the state of an object. - void dump (void) const; - - // ACE_ALLOC_HOOK_DECLARE; - // Declare the dynamic allocation hooks. -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Condition_T.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Condition_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Condition_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#endif /* ACE_HAS_THREADS */ - -#include /**/ "ace/post.h" -#endif /* ACE_CONDITION_T_H */ diff --git a/ACE/ace/Condition_T.inl b/ACE/ace/Condition_T.inl deleted file mode 100644 index fd7bdb7abdc..00000000000 --- a/ACE/ace/Condition_T.inl +++ /dev/null @@ -1,51 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template ACE_INLINE int -ACE_Condition::remove (void) -{ - // ACE_TRACE ("ACE_Condition::remove"); - - // cond_destroy() is called in a loop if the condition variable is - // BUSY. This avoids a condition where a condition is signaled and - // because of some timing problem, the thread that is to be signaled - // has called the cond_wait routine after the signal call. Since - // the condition signal is not queued in any way, deadlock occurs. - - int result = 0; - - while ((result = ACE_OS::cond_destroy (&this->cond_)) == -1 - && errno == EBUSY) - { - ACE_OS::cond_broadcast (&this->cond_); - ACE_OS::thr_yield (); - } - - return result; -} - -template ACE_INLINE MUTEX & -ACE_Condition::mutex (void) -{ - // ACE_TRACE ("ACE_Condition::mutex"); - return this->mutex_; -} - -template ACE_INLINE int -ACE_Condition::signal (void) -{ -// ACE_TRACE ("ACE_Condition::signal"); - return ACE_OS::cond_signal (&this->cond_); -} - -template ACE_INLINE int -ACE_Condition::broadcast (void) -{ -// ACE_TRACE ("ACE_Condition::broadcast"); - return ACE_OS::cond_broadcast (&this->cond_); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Condition_Thread_Mutex.cpp b/ACE/ace/Condition_Thread_Mutex.cpp deleted file mode 100644 index 1535b4c87f3..00000000000 --- a/ACE/ace/Condition_Thread_Mutex.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- C++ -*- */ -/** - * @file Condition_Thread_Mutex.cpp - * - * $Id$ - * - * Originally in Synch.cpp - * - * @author Douglas C. Schmidt - */ - -#include "ace/Condition_Thread_Mutex.h" - -#if defined (ACE_HAS_THREADS) - -#if !defined (__ACE_INLINE__) -#include "ace/Condition_Thread_Mutex.inl" -#endif /* __ACE_INLINE__ */ - -#include "ace/Log_Msg.h" - -ACE_RCSID(ace, Condition_Thread_Mutex, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_Condition_Thread_Mutex) - -void -ACE_Condition_Thread_Mutex::dump (void) const -{ -#if defined (ACE_HAS_DUMP) -// ACE_TRACE ("ACE_Condition_Thread_Mutex::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); -#if defined (ACE_WIN32) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("waiters = %d\n"), - this->cond_.waiters ())); -#endif /* ACE_WIN32 */ - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex (ACE_Thread_Mutex &m, - const ACE_TCHAR *name, - void *arg) - : mutex_ (m), - removed_ (false) -{ -// ACE_TRACE ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex"); - if (ACE_OS::cond_init (&this->cond_, - (short) USYNC_THREAD, - name, - arg) != 0) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex"))); -} - -ACE_Condition_Thread_Mutex:: -ACE_Condition_Thread_Mutex (ACE_Thread_Mutex &m, - ACE_Condition_Attributes &attributes, - const ACE_TCHAR *name, - void *arg) - : mutex_ (m), - removed_ (false) -{ -// ACE_TRACE ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex"); - if (ACE_OS::cond_init (&this->cond_, attributes.attributes_, - name, arg) != 0) - ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex"))); -} - -ACE_Condition_Thread_Mutex::~ACE_Condition_Thread_Mutex (void) -{ -// ACE_TRACE ("ACE_Condition_Thread_Mutex::~ACE_Condition_Thread_Mutex"); - this->remove (); -} - -// Peform an "alertable" timed wait. If the argument == 0 -// then we do a regular , else we do a timed wait for up to -// using the function. - -int -ACE_Condition_Thread_Mutex::wait (void) -{ -// ACE_TRACE ("ACE_Condition_Thread_Mutex::wait"); - return ACE_OS::cond_wait (&this->cond_, &this->mutex_.lock_); -} - -int -ACE_Condition_Thread_Mutex::wait (ACE_Thread_Mutex &mutex, - const ACE_Time_Value *abstime) -{ -// ACE_TRACE ("ACE_Condition_Thread_Mutex::wait"); - return ACE_OS::cond_timedwait (&this->cond_, - &mutex.lock_, - const_cast (abstime)); -} - -int -ACE_Condition_Thread_Mutex::wait (const ACE_Time_Value *abstime) -{ -// ACE_TRACE ("ACE_Condition_Thread_Mutex::wait"); - return this->wait (this->mutex_, abstime); -} - -int -ACE_Condition_Thread_Mutex::signal (void) -{ -// ACE_TRACE ("ACE_Condition_Thread_Mutex::signal"); - return ACE_OS::cond_signal (&this->cond_); -} - -int -ACE_Condition_Thread_Mutex::broadcast (void) -{ -// ACE_TRACE ("ACE_Condition_Thread_Mutex::broadcast"); - return ACE_OS::cond_broadcast (&this->cond_); -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_THREADS */ diff --git a/ACE/ace/Condition_Thread_Mutex.h b/ACE/ace/Condition_Thread_Mutex.h deleted file mode 100644 index 2806f03691e..00000000000 --- a/ACE/ace/Condition_Thread_Mutex.h +++ /dev/null @@ -1,190 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file Condition_Thread_Mutex.h - * - * $Id$ - * - * Moved from Synch.h. - * - * @author Douglas C. Schmidt - */ -//========================================================================== - -#ifndef ACE_CONDITION_THREAD_MUTEX_H -#define ACE_CONDITION_THREAD_MUTEX_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (ACE_HAS_THREADS) -# include "ace/Null_Condition.h" -#else /* ACE_HAS_THREADS */ -// ACE platform supports some form of threading. - -#include "ace/Thread_Mutex.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -class ACE_Time_Value; - -class ACE_Export ACE_Condition_Attributes -{ -public: - /// Constructor - ACE_Condition_Attributes (int type = ACE_DEFAULT_SYNCH_TYPE); - - /// Destructor - ~ACE_Condition_Attributes (void); - -private: - friend class ACE_Condition_Thread_Mutex; - - /// The attributes - ACE_condattr_t attributes_; - -private: - // = Prevent assignment and initialization. - void operator= (const ACE_Condition_Attributes &); - ACE_Condition_Attributes (const ACE_Condition_Attributes &); -}; - -/** - * @class ACE_Condition_Thread_Mutex - * - * @brief ACE_Condition variable wrapper written using ACE_Mutexes This - * allows threads to block until shared data changes state. - * A condition variable enables threads to atomically block and - * test the condition under the protection of a mutual exclu- - * sion lock (mutex) until the condition is satisfied. That is, - * the mutex must have been held by the thread before calling - * wait or signal on the condition. If the condition is false, - * a thread blocks on a condition variable and atomically - * releases the mutex that is waiting for the condition to - * change. If another thread changes the condition, it may wake - * up waiting threads by signaling the associated condition - * variable. The waiting threads, upon awakening, reacquire the - * mutex and re-evaluate the condition. - * - * This should be an instantiation of ACE_Condition but problems - * with compilers precludes this... - */ -class ACE_Export ACE_Condition_Thread_Mutex -{ -public: - /// Initialize the condition variable. - ACE_Condition_Thread_Mutex (ACE_Thread_Mutex &m, - const ACE_TCHAR *name = 0, - void *arg = 0); - - /// Initialize the condition variable. - ACE_Condition_Thread_Mutex (ACE_Thread_Mutex &m, - ACE_Condition_Attributes &attributes, - const ACE_TCHAR *name = 0, - void *arg = 0); - - /// Implicitly destroy the condition variable. - ~ACE_Condition_Thread_Mutex (void); - - /** - * Explicitly destroy the condition variable. Note that only one - * thread should call this method since it doesn't protect against - * race conditions. - */ - int remove (void); - - /** - * Block on condition, or until absolute time-of-day has passed. If - * abstime == 0 use "blocking" semantics. Else, if @a abstime - * != 0 and the call times out before the condition is signaled - * returns -1 and sets errno to ETIME. - */ - int wait (const ACE_Time_Value *abstime); - - /// Block on condition. - int wait (void); - - /** - * Block on condition or until absolute time-of-day has passed. If - * abstime == 0 use "blocking" wait() semantics on the - * passed as a parameter (this is useful if you need to store the - * in shared memory). Else, if @a abstime != 0 and the - * call times out before the condition is signaled returns -1 - * and sets errno to ETIME. - */ - int wait (ACE_Thread_Mutex &mutex, const ACE_Time_Value *abstime = 0); - - /// Signal one waiting thread. - int signal (void); - - /// Signal *all* waiting threads. - int broadcast (void); - - /// Returns a reference to the underlying mutex; - ACE_Thread_Mutex &mutex (void); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - /// Condition variable. - ACE_cond_t cond_; - - /// Reference to mutex lock. - ACE_Thread_Mutex &mutex_; - - /// Keeps track of whether has been called yet to avoid - /// multiple calls, e.g., explicitly and implicitly in the - /// destructor. This flag isn't protected by a lock, so make sure - /// that you don't have multiple threads simultaneously calling - /// on the same object, which is a bad idea anyway... - bool removed_; - -private: - // = Prevent assignment and initialization. - void operator= (const ACE_Condition_Thread_Mutex &); - ACE_Condition_Thread_Mutex (const ACE_Condition_Thread_Mutex &); -}; - -#if 0 -// The following class is commented out since there doesn't -// appear to be a portable and robust means of implementing this -// functionality across platforms. If you know of a portable and -// robust way to implement this functionality please let us know. - -/** - * @class ACE_Process_Condition - * - * @brief ACE_Condition variable wrapper that works across processes. - */ -class ACE_Export ACE_Process_Condition -{ -public: - ACE_Process_Condition (MUTEX &m, const ACE_TCHAR *name = 0, void *arg = 0); - - /// Dump the state of an object. - void dump (void) const; - - // ACE_ALLOC_HOOK_DECLARE; - // Declare the dynamic allocation hooks. -}; -#endif /* 0 */ - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Condition_Thread_Mutex.inl" -#endif /* __ACE_INLINE__ */ - -#endif /* !ACE_HAS_THREADS */ - -#include /**/ "ace/post.h" -#endif /* ACE_CONDITION_THREAD_MUTEX_H */ diff --git a/ACE/ace/Condition_Thread_Mutex.inl b/ACE/ace/Condition_Thread_Mutex.inl deleted file mode 100644 index 12cc18a1bad..00000000000 --- a/ACE/ace/Condition_Thread_Mutex.inl +++ /dev/null @@ -1,74 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_Condition_Attributes::ACE_Condition_Attributes (int type) -{ - (void) ACE_OS::condattr_init (this->attributes_, type); -} - -ACE_INLINE -ACE_Condition_Attributes::~ACE_Condition_Attributes (void) -{ - ACE_OS::condattr_destroy (this->attributes_); -} - -ACE_INLINE int -ACE_Condition_Thread_Mutex::remove (void) -{ -// ACE_TRACE ("ACE_Condition_Thread_Mutex::remove"); - - // is called in a loop if the condition variable is - // BUSY. This avoids a condition where a condition is signaled and - // because of some timing problem, the thread that is to be signaled - // has called the cond_wait routine after the signal call. Since - // the condition signal is not queued in any way, deadlock occurs. - - int result = 0; - - if (!this->removed_) - { - this->removed_ = true; - - while ((result = ACE_OS::cond_destroy (&this->cond_)) == -1 - && errno == EBUSY) - { - ACE_OS::cond_broadcast (&this->cond_); - ACE_OS::thr_yield (); - } - } - return result; -} - -ACE_INLINE ACE_Thread_Mutex & -ACE_Condition_Thread_Mutex::mutex (void) -{ -// ACE_TRACE ("ACE_Condition_Thread_Mutex::mutex"); - return this->mutex_; -} - -#if 0 -template void -ACE_Process_Condition::dump (void) const -{ -#if defined (ACE_HAS_DUMP) -// ACE_TRACE ("ACE_Process_Condition::dump"); - - ACE_Condition::dump (); -#endif /* ACE_HAS_DUMP */ -} - -template -ACE_Process_Condition::ACE_Process_Condition (MUTEX &m, - const ACE_TCHAR *name, - void *arg) - : ACE_Condition (m, USYNC_PROCESS, name, arg) -{ -// ACE_TRACE ("ACE_Process_Condition::ACE_Process_Condition"); -} -#endif /* 0 */ - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Configuration.cpp b/ACE/ace/Configuration.cpp deleted file mode 100644 index b54308ade7d..00000000000 --- a/ACE/ace/Configuration.cpp +++ /dev/null @@ -1,2148 +0,0 @@ -// $Id$ -#include "ace/Configuration.h" -#include "ace/Auto_Ptr.h" -#include "ace/SString.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_strings.h" - -// Can remove this when import_config and export_config are removed from -// ACE_Configuration. They're deprecated at ACE 5.2. -#include "ace/Configuration_Import_Export.h" - -#if !defined (ACE_LACKS_ACCESS) -# include "ace/OS_NS_unistd.h" -#endif /* ACE_LACKS_ACCESS */ - -#if !defined (__ACE_INLINE__) -#include "ace/Configuration.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_Section_Key_Internal::ACE_Section_Key_Internal (void) - : ref_count_ (0) -{ -} - -ACE_Section_Key_Internal::~ACE_Section_Key_Internal (void) -{ -} - -int -ACE_Section_Key_Internal::add_ref (void) -{ - ++ref_count_; - return 0; -} - -int -ACE_Section_Key_Internal::dec_ref (void) -{ - if (!--ref_count_) - delete this; - return 0; -} - -ACE_Configuration_Section_Key::ACE_Configuration_Section_Key (void) - : key_ (0) -{ -} - -ACE_Configuration_Section_Key::~ACE_Configuration_Section_Key (void) -{ - if (key_) - key_->dec_ref (); -} - -ACE_Configuration_Section_Key::ACE_Configuration_Section_Key (ACE_Section_Key_Internal* key) - : key_ (key) -{ - if (key_) - key_->add_ref (); -} - -ACE_Configuration_Section_Key::ACE_Configuration_Section_Key (const ACE_Configuration_Section_Key& rhs) - : key_ (rhs.key_) -{ - if (key_) - key_->add_ref (); -} - -ACE_Configuration_Section_Key& -ACE_Configuration_Section_Key::operator= (const ACE_Configuration_Section_Key& rhs) -{ - if (this != &rhs) - { - if (key_) - key_->dec_ref (); - - key_ = rhs.key_; - - if (key_) - key_->add_ref (); - } - return *this; -} - -////////////////////////////////////////////////////////////////////////////// - -ACE_TCHAR ACE_Configuration::NULL_String_ = '\0'; - -ACE_Configuration::ACE_Configuration (void) - : root_ () -{ -} - -ACE_Configuration::~ACE_Configuration (void) -{ -} - -ACE_Section_Key_Internal* -ACE_Configuration::get_internal_key (const ACE_Configuration_Section_Key& key) -{ - return key.key_; -} - -int -ACE_Configuration::expand_path (const ACE_Configuration_Section_Key& key, - const ACE_TString& path_in, - ACE_Configuration_Section_Key& key_out, - int create) -{ - // Make a copy of key - ACE_Configuration_Section_Key current_section = key; - ACE_Auto_Basic_Array_Ptr pData (path_in.rep ()); - ACE_Tokenizer parser (pData.get ()); - parser.delimiter_replace ('\\', '\0'); - parser.delimiter_replace ('/', '\0'); - - for (ACE_TCHAR *temp = parser.next (); - temp != 0; - temp = parser.next ()) - { - // Open the section - if (open_section (current_section, - temp, - create, - key_out)) - return -1; - - current_section = key_out; - } - - return 0; - -} - -// import_config and export_config are here for backward compatibility, -// and have been deprecated. -int -ACE_Configuration::export_config (const ACE_TCHAR* filename) -{ - ACE_Registry_ImpExp exporter (*this); - return exporter.export_config (filename); -} - -int -ACE_Configuration::import_config (const ACE_TCHAR* filename) -{ - ACE_Registry_ImpExp importer (*this); - return importer.import_config (filename); -} - -int -ACE_Configuration::validate_name (const ACE_TCHAR* name, int allow_path) -{ - // Invalid character set - const ACE_TCHAR* reject = - allow_path ? ACE_TEXT ("][") : ACE_TEXT ("\\]["); - - // Position of the first invalid character or terminating null. - size_t const pos = ACE_OS::strcspn (name, reject); - - // Check if it is an invalid character. - if (name[pos] != ACE_TEXT ('\0')) - { - errno = EINVAL; - return -1; - } - - // The first character can never be a path separator. - if (name[0] == ACE_TEXT ('\\')) - { - errno = EINVAL; - return -1; - } - - // Validate length. - if (pos == 0 || pos > 255) - { - errno = ENAMETOOLONG; - return -1; - } - - return 0; -} - -int -ACE_Configuration::validate_value_name (const ACE_TCHAR* name) -{ - if (name == 0 || *name == this->NULL_String_) - return 0; - - return this->validate_name (name); -} - -const ACE_Configuration_Section_Key& -ACE_Configuration::root_section (void) const -{ - return root_; -} - -/** - * Determine if the contents of this object is the same as the - * contents of the object on the right hand side. - * Returns 1 (True) if they are equal and 0 (False) if they are not equal - */ -bool -ACE_Configuration::operator== (const ACE_Configuration& rhs) const -{ - bool rc = true; - int sectionIndex = 0; - ACE_TString sectionName; - ACE_Configuration *nonconst_this = const_cast (this); - ACE_Configuration &nonconst_rhs = const_cast (rhs); - - const ACE_Configuration_Section_Key& rhsRoot = rhs.root_section (); - ACE_Configuration_Section_Key rhsSection; - ACE_Configuration_Section_Key thisSection; - - // loop through each section in this object - while ((rc) && (nonconst_this->enumerate_sections (this->root_, - sectionIndex, - sectionName) == 0)) - { - // find that section in the rhs object - if (nonconst_rhs.open_section (rhsRoot, - sectionName.c_str (), - 0, - rhsSection) != 0) - { - // If the rhs object does not contain the section then we are - // not equal. - rc = false; - } - else if (nonconst_this->open_section (this->root_, - sectionName.c_str (), - 0, - thisSection) != 0) - { - // if there is some error opening the section in this object - rc = false; - } - else - { - // Well the sections match - int valueIndex = 0; - ACE_TString valueName; - VALUETYPE valueType; - VALUETYPE rhsType; - - // Enumerate each value in this section - while ((rc) && nonconst_this->enumerate_values (thisSection, - valueIndex, - valueName, - valueType) == 0) - { - // look for the same value in the rhs section - if (nonconst_rhs.find_value (rhsSection, - valueName.c_str (), - rhsType) != 0) - { - // We're not equal if the same value cannot - // be found in the rhs object. - rc = false; - } - else if (valueType != rhsType) - { - // we're not equal if the types do not match. - rc = false; - } - else - { - // finally compare values. - if (valueType == STRING) - { - ACE_TString thisString, rhsString; - if (nonconst_this->get_string_value (thisSection, - valueName.c_str (), - thisString) != 0) - { - // we're not equal if we cannot get this string - rc = false; - } - else if (nonconst_rhs.get_string_value ( - rhsSection, - valueName.c_str (), - rhsString) != 0) - { - // we're not equal if we cannot get rhs string - rc = false; - } - rc = (thisString == rhsString); - } - else if (valueType == INTEGER) - { - u_int thisInt = 0; - u_int rhsInt = 0; - if (nonconst_this->get_integer_value ( - thisSection, - valueName.c_str (), - thisInt) != 0) - { - // we're not equal if we cannot get this int - rc = false; - } - else if (nonconst_rhs.get_integer_value ( - rhsSection, - valueName.c_str (), - rhsInt) != 0) - { - // we're not equal if we cannot get rhs int - rc = false; - } - rc = (thisInt == rhsInt); - } - else if (valueType == BINARY) - { - void* thisData = 0; - void* rhsData = 0; - size_t thisLength = 0; - size_t rhsLength = 0; - if (nonconst_this->get_binary_value (thisSection, - valueName.c_str (), - thisData, - thisLength) != 0) - { - // we're not equal if we cannot get this data - rc = false; - } - else if (nonconst_rhs.get_binary_value ( - rhsSection, - valueName.c_str (), - rhsData, - rhsLength) != 0) - { - // we're not equal if we cannot get this data - rc = false; - } - - rc = (thisLength == rhsLength); - // are the length's the same? - - if (rc) - { - unsigned char* thisCharData = - (unsigned char*)thisData; - unsigned char* rhsCharData = (unsigned char*)rhsData; - // yes, then check each element - for (size_t count = 0; - (rc) && (count < thisLength); - count++) - { - rc = (* (thisCharData + count) == * (rhsCharData + count)); - } - - delete [] thisCharData; - delete [] rhsCharData; - }// end if the length's match - } - // We should never have valueTypes of INVALID, therefore - // we're not comparing them. How would we since we have - // no get operation for invalid types. - // So, if we have them, we guess they are equal. - - }// end else if values match. - - ++valueIndex; - - }// end value while loop - - // look in the rhs for values not in this - valueIndex = 0; - while ((rc) && (nonconst_rhs.enumerate_values (rhsSection, - valueIndex, - valueName, - rhsType) == 0)) - { - // look for the same value in this section - if (nonconst_this->find_value (thisSection, - valueName.c_str (), - valueType) != 0) - { - // We're not equal if the same value cannot - // be found in the rhs object. - rc = false; - } - ++valueIndex; - }// end while for rhs values not in this. - - }// end else if sections match. - - ++sectionIndex; - - }// end section while loop - - // Finally, make sure that there are no sections in rhs that do not - // exist in this - sectionIndex = 0; - while ((rc) - && (nonconst_rhs.enumerate_sections (rhsRoot, - sectionIndex, - sectionName) == 0)) - { - // find the section in this - if (nonconst_this->open_section (this->root_, - sectionName.c_str (), - 0, - thisSection) != 0) - { - // if there is some error opening the section in this object - rc = false; - } - else if (nonconst_rhs.open_section (rhsRoot, - sectionName.c_str (), - 0, - rhsSection) != 0) - { - // If the rhs object does not contain the section then we - // are not equal. - rc = false; - } - ++sectionIndex; - } - return rc; -} - -bool -ACE_Configuration::operator!= (const ACE_Configuration& rhs) const -{ - return !(*this == rhs); -} - -////////////////////////////////////////////////////////////////////////////// - -#if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_REGISTRY) - -static const int ACE_DEFAULT_BUFSIZE = 256; - -static const ACE_TCHAR *temp_name (const ACE_TCHAR *name) -{ - if (name && *name == ACE_Configuration::NULL_String_) - return 0; - return name; -} - -ACE_Section_Key_Win32::ACE_Section_Key_Win32 (HKEY hKey) - : hKey_ (hKey) -{ -} - -ACE_Section_Key_Win32::~ACE_Section_Key_Win32 (void) -{ - ::RegCloseKey (hKey_); -} - -////////////////////////////////////////////////////////////////////////////// - -bool -ACE_Configuration_Win32Registry::operator== (const ACE_Configuration_Win32Registry &rhs) const -{ - ACE_UNUSED_ARG (rhs); - return true; -} - -bool -ACE_Configuration_Win32Registry::operator!= (const ACE_Configuration_Win32Registry &rhs) const -{ - ACE_UNUSED_ARG (rhs); - return true; -} - -ACE_Configuration_Win32Registry::ACE_Configuration_Win32Registry (HKEY hKey) -{ - ACE_Section_Key_Win32 *temp = 0; - - ACE_NEW (temp, ACE_Section_Key_Win32 (hKey)); - - root_ = ACE_Configuration_Section_Key (temp); -} - - -ACE_Configuration_Win32Registry::~ACE_Configuration_Win32Registry (void) -{ -} - -int -ACE_Configuration_Win32Registry::open_section (const ACE_Configuration_Section_Key& base, - const ACE_TCHAR* sub_section, - int create, - ACE_Configuration_Section_Key& result) -{ - if (validate_name (sub_section, 1)) - return -1; - - HKEY base_key; - if (load_key (base, base_key)) - return -1; - - int errnum; - HKEY result_key; - if ((errnum = ACE_TEXT_RegOpenKeyEx (base_key, - sub_section, - 0, - KEY_ALL_ACCESS, - &result_key)) != ERROR_SUCCESS) - { - if (!create) - { - errno = errnum; - return -1; - } - - if ((errnum = ACE_TEXT_RegCreateKeyEx (base_key, - sub_section, - 0, - 0, - REG_OPTION_NON_VOLATILE, - KEY_ALL_ACCESS, - 0, - &result_key, -#if defined (__MINGW32__) - (PDWORD) 0 -#else - 0 -#endif /* __MINGW32__ */ - )) != ERROR_SUCCESS) - { - errno = errnum; - return -1; - } - } - - ACE_Section_Key_Win32 *temp; - - ACE_NEW_RETURN (temp, ACE_Section_Key_Win32 (result_key), -1); - result = ACE_Configuration_Section_Key (temp); - return 0; -} - -int -ACE_Configuration_Win32Registry::remove_section (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* sub_section, - int recursive) -{ - if (validate_name (sub_section)) - return -1; - - HKEY base_key; - if (load_key (key, base_key)) - return -1; - - if (recursive) - { - ACE_Configuration_Section_Key section; - if (open_section (key, sub_section, 0, section)) - return -1; - - HKEY sub_key; - if (load_key (section, sub_key)) - return -1; - - ACE_TCHAR name_buffer[ACE_DEFAULT_BUFSIZE]; - DWORD buffer_size = ACE_DEFAULT_BUFSIZE; - // Note we don't increment the index because the - // enumeration becomes invalid if we change the - // subkey, which we do when we delete it. By leaving - // it 0, we always delete the top entry - while (ACE_TEXT_RegEnumKeyEx (sub_key, - 0, - name_buffer, - &buffer_size, - 0, - 0, - 0, - 0) == ERROR_SUCCESS) - { - remove_section (section, name_buffer, 1); - buffer_size = ACE_DEFAULT_BUFSIZE; - } - } - - int errnum; - errnum = ACE_TEXT_RegDeleteKey (base_key, sub_section); - if (errnum != ERROR_SUCCESS) - { - errno = errnum; - return -1; - } - - return 0; -} - -int -ACE_Configuration_Win32Registry::enumerate_values (const ACE_Configuration_Section_Key& key, - int index, - ACE_TString& name, - VALUETYPE& type) -{ - HKEY base_key; - if (load_key (key, base_key)) - return -1; - - ACE_TCHAR name_buffer[ACE_DEFAULT_BUFSIZE]; - DWORD buffer_size = ACE_DEFAULT_BUFSIZE; - DWORD value_type; - - int rc = ACE_TEXT_RegEnumValue (base_key, - index, - name_buffer, - &buffer_size, - 0, - &value_type, - 0, - 0); - if (rc == ERROR_NO_MORE_ITEMS) - return 1; - else if (rc != ERROR_SUCCESS) - { - errno = rc; - return -1; - } - - name = name_buffer; - - switch (value_type) - { - case REG_BINARY: - type = BINARY; - break; - case REG_SZ: - type = STRING; - break; - case REG_DWORD: - type = INTEGER; - break; - default: - type = INVALID; - } - - return 0; -} - -int -ACE_Configuration_Win32Registry::enumerate_sections (const ACE_Configuration_Section_Key& key, - int index, - ACE_TString& name) -{ - HKEY base_key; - if (load_key (key, base_key)) - return -1; - - ACE_TCHAR name_buffer[ACE_DEFAULT_BUFSIZE]; - DWORD buffer_size = ACE_DEFAULT_BUFSIZE; - int rc = ACE_TEXT_RegEnumKeyEx (base_key, - index, - name_buffer, - &buffer_size, - 0, - 0, - 0, - 0); - if (rc == ERROR_NO_MORE_ITEMS) - return 1; - else if (rc != ERROR_MORE_DATA && rc != ERROR_SUCCESS) - { - errno = rc; - return -1; - } - - name = name_buffer; - - return 0; -} - -int -ACE_Configuration_Win32Registry::set_string_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - const ACE_TString& value) -{ - const ACE_TCHAR *t_name = temp_name (name); - if (validate_value_name (t_name)) - return -1; - - HKEY base_key; - if (load_key (key, base_key)) - return -1; - - int errnum; - DWORD len = static_cast (value.length () + 1); - len *= sizeof (ACE_TCHAR); - if ((errnum = ACE_TEXT_RegSetValueEx (base_key, - t_name, - 0, - REG_SZ, - (BYTE *) value.fast_rep (), - len)) - != ERROR_SUCCESS) - { - errno = errnum; - return -1; - } - - return 0; -} - -int -ACE_Configuration_Win32Registry::set_integer_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - u_int value) -{ - const ACE_TCHAR *t_name = temp_name (name); - if (validate_value_name (t_name)) - return -1; - - HKEY base_key; - if (load_key (key, base_key)) - return -1; - - int errnum; - if ((errnum = ACE_TEXT_RegSetValueEx (base_key, - t_name, - 0, - REG_DWORD, - (BYTE *) &value, - sizeof (value))) != ERROR_SUCCESS) - { - errno = errnum; - return -1; - } - - return 0; -} - -int -ACE_Configuration_Win32Registry::set_binary_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - const void* data, - size_t length) -{ - const ACE_TCHAR *t_name = temp_name (name); - if (validate_value_name (t_name)) - return -1; - - HKEY base_key; - if (load_key (key, base_key)) - return -1; - - int errnum; - if ((errnum = ACE_TEXT_RegSetValueEx (base_key, - t_name, - 0, - REG_BINARY, - (BYTE *) data, - static_cast (length))) - != ERROR_SUCCESS) - { - errno = errnum; - return -1; - } - - return 0; -} - -int -ACE_Configuration_Win32Registry::get_string_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - ACE_TString& value) -{ - const ACE_TCHAR *t_name = temp_name (name); - if (validate_value_name (t_name)) - return -1; - - HKEY base_key; - if (load_key (key, base_key)) - return -1; - - // Get the size of the binary data from windows - int errnum; - DWORD buffer_length = 0; - DWORD type; - if ((errnum = ACE_TEXT_RegQueryValueEx (base_key, - t_name, - 0, - &type, - (BYTE *) 0, - &buffer_length)) != ERROR_SUCCESS) - { - errno = errnum; - return -1; - } - - if (type != REG_SZ) - { - errno = ERROR_INVALID_DATATYPE; - return -1; - } - - ACE_TCHAR *temp = 0; - ACE_NEW_RETURN (temp, - ACE_TCHAR[buffer_length], - -1); - - ACE_Auto_Basic_Array_Ptr buffer (temp); - - if ((errnum = ACE_TEXT_RegQueryValueEx (base_key, - t_name, - 0, - &type, - (BYTE *) buffer.get (), - &buffer_length)) != ERROR_SUCCESS) - { - errno = errnum; - return -1; - } - - value = buffer.get (); - return 0; -} - -int -ACE_Configuration_Win32Registry::get_integer_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - u_int& value) -{ - const ACE_TCHAR *t_name = temp_name (name); - if (validate_value_name (t_name)) - return -1; - - HKEY base_key; - if (load_key (key, base_key)) - return -1; - - int errnum; - DWORD length = sizeof (value); - DWORD type; - if ((errnum = ACE_TEXT_RegQueryValueEx (base_key, - t_name, - 0, - &type, - (BYTE *) &value, - &length)) != ERROR_SUCCESS) - { - errno = errnum; - return -1; - } - - if (type != REG_DWORD) - { - errno = ERROR_INVALID_DATATYPE; - return -1; - } - - return 0; -} - -int -ACE_Configuration_Win32Registry::get_binary_value ( - const ACE_Configuration_Section_Key &key, - const ACE_TCHAR *name, - void *&data, - size_t &length) -{ - const ACE_TCHAR *t_name = temp_name (name); - if (validate_value_name (t_name)) - return -1; - - HKEY base_key; - if (load_key (key, base_key)) - return -1; - - // Get the size of the binary data from windows - int errnum; - DWORD buffer_length = 0; - DWORD type; - if ((errnum = ACE_TEXT_RegQueryValueEx (base_key, - t_name, - 0, - &type, - (BYTE *) 0, - &buffer_length)) != ERROR_SUCCESS) - { - errno = errnum; - return -1; - } - - if (type != REG_BINARY) - { - errno = ERROR_INVALID_DATATYPE; - return -1; - } - - length = buffer_length; - - BYTE * the_data = 0; - ACE_NEW_RETURN (the_data, BYTE[length], -1); - ACE_Auto_Basic_Array_Ptr safe_data (the_data); - - if ((errnum = ACE_TEXT_RegQueryValueEx (base_key, - t_name, - 0, - &type, - the_data, - &buffer_length)) != ERROR_SUCCESS) - { - data = 0; - errno = errnum; - return -1; - } - - data = safe_data.release (); - - return 0; -} - -int -ACE_Configuration_Win32Registry::find_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - VALUETYPE& type_out) -{ - const ACE_TCHAR *t_name = temp_name (name); - if (validate_value_name (t_name)) - return -1; - - HKEY base_key; - if (load_key (key, base_key)) - return -1; - - DWORD buffer_length=0; - DWORD type; - int result=ACE_TEXT_RegQueryValueEx (base_key, - t_name, - 0, - &type, - 0, - &buffer_length); - if (result != ERROR_SUCCESS) - { - errno = result; - return -1; - } - - switch (type) - { - case REG_SZ: - type_out = STRING; - break; - case REG_DWORD: - type_out = INTEGER; - break; - case REG_BINARY: - type_out = BINARY; - break; - default: - return -1; // unknown type - } - - return 0; -} - -int -ACE_Configuration_Win32Registry::remove_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name) -{ - const ACE_TCHAR *t_name = temp_name (name); - if (validate_value_name (t_name)) - return -1; - - HKEY base_key; - if (load_key (key, base_key)) - return -1; - - int errnum; - if ((errnum = ACE_TEXT_RegDeleteValue (base_key, t_name)) != ERROR_SUCCESS) - { - errno = errnum; - return -1; - } - - return 0; -} - - -int -ACE_Configuration_Win32Registry::load_key (const ACE_Configuration_Section_Key& key, - HKEY& hKey) -{ - ACE_Section_Key_Win32* pKey = dynamic_cast (get_internal_key (key)); - if (!pKey) - return -1; - - hKey = pKey->hKey_; - return 0; -} - -HKEY -ACE_Configuration_Win32Registry::resolve_key (HKEY hKey, - const ACE_TCHAR* path, - int create) -{ - HKEY result = 0; - // Make a copy of hKey - int errnum; -#if defined (ACE_HAS_WINCE) - if ((errnum = RegOpenKeyEx (hKey, 0, 0, 0, &result)) != ERROR_SUCCESS) -#else - if ((errnum = RegOpenKey (hKey, 0, &result)) != ERROR_SUCCESS) -#endif // ACE_HAS_WINCE - { - errno = errnum; - return 0; - } - - // recurse through the path - ACE_TCHAR *temp_path = 0; - ACE_NEW_RETURN (temp_path, - ACE_TCHAR[ACE_OS::strlen (path) + 1], - 0); - ACE_Auto_Basic_Array_Ptr pData (temp_path); - ACE_OS::strcpy (pData.get (), path); - ACE_Tokenizer parser (pData.get ()); - parser.delimiter_replace ('\\', '\0'); - parser.delimiter_replace ('/', '\0'); - - for (ACE_TCHAR *temp = parser.next (); - temp != 0; - temp = parser.next ()) - { - // Open the key - HKEY subkey; - -#if defined (ACE_HAS_WINCE) - if ((errnum = ACE_TEXT_RegOpenKeyEx (result, - temp, - 0, - 0, - &subkey)) != ERROR_SUCCESS) -#else - if ((errnum = ACE_TEXT_RegOpenKey (result, - temp, - &subkey)) != ERROR_SUCCESS) -#endif // ACE_HAS_WINCE - { - // try creating it - if (!create || (errnum = ACE_TEXT_RegCreateKeyEx (result, - temp, - 0, - 0, - 0, - KEY_ALL_ACCESS, - 0, - &subkey, -#if defined (__MINGW32__) - (PDWORD) 0 -#else - 0 -#endif /* __MINGW32__ */ - )) !=ERROR_SUCCESS) - { - errno = errnum; - // error - ::RegCloseKey (result); - return 0; - } - } - // release our open key handle - ::RegCloseKey (result); - result = subkey; - } - - return result; -} - -#endif /* ACE_WIN32 && !ACE_LACKS_WIN32_REGISTRY */ - -/////////////////////////////////////////////////////////////// - -ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId (void) - : type_ (ACE_Configuration::INVALID), - length_ (0) -{ - this->data_.ptr_ = 0; -} - -ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId (ACE_TCHAR* string) - : type_ (ACE_Configuration::STRING), - length_ (0) -{ - this->data_.ptr_ = string; -} - -ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId (u_int integer) - : type_ (ACE_Configuration::INTEGER), - length_ (0) -{ - this->data_.int_ = integer; -} - -ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId (void* data, size_t length) - : type_ (ACE_Configuration::BINARY), - length_ (length) -{ - this->data_.ptr_ = data; -} - -ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId (const ACE_Configuration_Value_IntId& rhs) - : type_ (rhs.type_), - data_ (rhs.data_), - length_ (rhs.length_) -{ -} - -ACE_Configuration_Value_IntId::~ACE_Configuration_Value_IntId (void) -{ -} - -ACE_Configuration_Value_IntId& ACE_Configuration_Value_IntId::operator= (const ACE_Configuration_Value_IntId& rhs) -{ - if (this != &rhs) - { - type_ = rhs.type_; - data_ = rhs.data_; - length_ = rhs.length_; - } - return *this; -} - -void -ACE_Configuration_Value_IntId::free (ACE_Allocator *alloc) -{ - if (this->type_ == ACE_Configuration::STRING - || this->type_ == ACE_Configuration::BINARY) - alloc->free (data_.ptr_); - // Do nothing in other cases... -} - -ACE_Configuration_ExtId::ACE_Configuration_ExtId (void) - : name_ (0) -{ -} - -ACE_Configuration_ExtId::ACE_Configuration_ExtId (const ACE_TCHAR* name) - : name_ (name) -{ -} - -ACE_Configuration_ExtId::ACE_Configuration_ExtId (const ACE_Configuration_ExtId& rhs) - : name_ (rhs.name_) -{ -} - -ACE_Configuration_ExtId::~ACE_Configuration_ExtId (void) -{ -} - -ACE_Configuration_ExtId& ACE_Configuration_ExtId::operator= (const ACE_Configuration_ExtId& rhs) -{ - if (this != &rhs) - name_ = rhs.name_; - - return *this; -} - -bool -ACE_Configuration_ExtId::operator== (const ACE_Configuration_ExtId& rhs) const -{ - return (ACE_OS::strcasecmp (name_, rhs.name_) == 0); -} - -bool -ACE_Configuration_ExtId::operator!= (const ACE_Configuration_ExtId& rhs) const -{ - return !this->operator== (rhs); -} - -u_long -ACE_Configuration_ExtId::hash (void) const -{ - ACE_TString temp (name_, 0, false); - return temp.hash (); -} - -void -ACE_Configuration_ExtId::free (ACE_Allocator *alloc) -{ - alloc->free ((void *) (name_)); -} - -/////////////////////////////////////////////////////////////////////// - -ACE_Configuration_Section_IntId::ACE_Configuration_Section_IntId (void) - : value_hash_map_ (0), - section_hash_map_ (0) -{ -} - -ACE_Configuration_Section_IntId::ACE_Configuration_Section_IntId (VALUE_MAP* value_hash_map, SUBSECTION_MAP* section_hash_map) - : value_hash_map_ (value_hash_map), - section_hash_map_ (section_hash_map) -{ -} - -ACE_Configuration_Section_IntId::ACE_Configuration_Section_IntId (const ACE_Configuration_Section_IntId& rhs) - : value_hash_map_ (rhs.value_hash_map_), - section_hash_map_ (rhs.section_hash_map_) -{ - -} - -ACE_Configuration_Section_IntId::~ACE_Configuration_Section_IntId () -{ -} - -ACE_Configuration_Section_IntId& -ACE_Configuration_Section_IntId::operator= (const ACE_Configuration_Section_IntId& rhs) -{ - if (this != &rhs) - { - value_hash_map_ = rhs.value_hash_map_; - section_hash_map_ = rhs.section_hash_map_; - } - return *this; -} - -void -ACE_Configuration_Section_IntId::free (ACE_Allocator *alloc) -{ - alloc->free ((void *) (value_hash_map_)); - alloc->free ((void *) (section_hash_map_)); -} - -ACE_Configuration_Section_Key_Heap::ACE_Configuration_Section_Key_Heap (const ACE_TCHAR* path) - : path_ (0), - value_iter_ (0), - section_iter_ (0) -{ - path_ = ACE_OS::strdup (path); -} - -ACE_Configuration_Section_Key_Heap::~ACE_Configuration_Section_Key_Heap () -{ - delete value_iter_; - delete section_iter_; - ACE_OS::free (path_); -} - -////////////////////////////////////////////////////////////////////////////// - -ACE_Configuration_Heap::ACE_Configuration_Heap (void) - : allocator_ (0), - index_ (0), - default_map_size_ (0) -{ - ACE_Configuration_Section_Key_Heap *temp = 0; - - ACE_NEW (temp, ACE_Configuration_Section_Key_Heap (ACE_TEXT (""))); - root_ = ACE_Configuration_Section_Key (temp); -} - -ACE_Configuration_Heap::~ACE_Configuration_Heap (void) -{ - if (allocator_) - allocator_->sync (); - - delete allocator_; -} - -int -ACE_Configuration_Heap::open (size_t default_map_size) -{ - default_map_size_ = default_map_size; - // Create the allocator with the appropriate options. - // The name used for the lock is the same as one used - // for the file. - ACE_NEW_RETURN (this->allocator_, - HEAP_ALLOCATOR (), - -1); - return create_index (); -} - - -int -ACE_Configuration_Heap::open (const ACE_TCHAR* file_name, - void* base_address, - size_t default_map_size) -{ - default_map_size_ = default_map_size; - - // Make sure that the file name is of the legal length. - if (ACE_OS::strlen (file_name) >= MAXNAMELEN + MAXPATHLEN) - { - errno = ENAMETOOLONG; - return -1; - } - - ACE_MMAP_Memory_Pool::OPTIONS options (base_address); - - // Create the allocator with the appropriate options. The name used - // for the lock is the same as one used for the file. - ACE_NEW_RETURN (this->allocator_, - PERSISTENT_ALLOCATOR (file_name, - file_name, - &options), - -1); - -#if !defined (ACE_LACKS_ACCESS) - // Now check if the backing store has been created successfully. - if (ACE_OS::access (file_name, F_OK) != 0) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("create_index\n")), - -1); -#endif /* ACE_LACKS_ACCESS */ - - return create_index (); -} - -int -ACE_Configuration_Heap::create_index (void) -{ - void *section_index = 0; - - // This is the easy case since if we find hash table in the - // memory-mapped file we know it's already initialized. - if (this->allocator_->find (ACE_CONFIG_SECTION_INDEX, section_index) == 0) - this->index_ = (SECTION_MAP *) section_index; - - // Create a new (because we've just created a new - // memory-mapped file). - else - { - size_t index_size = sizeof (SECTION_MAP); - section_index = this->allocator_->malloc (index_size); - - if (section_index == 0 - || create_index_helper (section_index) == -1 - || this->allocator_->bind (ACE_CONFIG_SECTION_INDEX, - section_index) == -1) - { - // Attempt to clean up. - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("create_index failed\n"))); - this->allocator_->remove (); - return -1; - } - // Add the root section - return new_section (ACE_TEXT (""), root_); - } - return 0; -} - -int -ACE_Configuration_Heap::create_index_helper (void *buffer) -{ - ACE_ASSERT (this->allocator_); - this->index_ = new (buffer) SECTION_MAP (this->allocator_); - return 0; -} - -int -ACE_Configuration_Heap::load_key (const ACE_Configuration_Section_Key& key, - ACE_TString& name) -{ - ACE_ASSERT (this->allocator_); - ACE_Configuration_Section_Key_Heap* pKey = - dynamic_cast (get_internal_key (key)); - - if (!pKey) - { - return -1; - } - - ACE_TString temp (pKey->path_, 0, false); - name.assign_nocopy (temp); - return 0; -} - - -int -ACE_Configuration_Heap::add_section (const ACE_Configuration_Section_Key& base, - const ACE_TCHAR* sub_section, - ACE_Configuration_Section_Key& result) -{ - ACE_ASSERT (this->allocator_); - ACE_TString section; - if (load_key (base, section)) - return -1; - - // Find the base section - ACE_Configuration_ExtId ExtId (section.fast_rep ()); - ACE_Configuration_Section_IntId IntId; - if (index_->find (ExtId, IntId, allocator_)) - return -1; - - // See if this section already exists - ACE_Configuration_ExtId SubSectionExtId (sub_section); - int ignored = 0; - - if (!IntId.section_hash_map_->find (SubSectionExtId, ignored, allocator_)) - { - // already exists! - errno = EEXIST; - return -1; - } - - // Create the new section name - // only prepend a separater if were not at the root - if (section.length ()) - section += ACE_TEXT ("\\"); - - section += sub_section; - - // Add it to the base section - ACE_TCHAR* pers_name = (ACE_TCHAR *) allocator_->malloc ((ACE_OS::strlen (sub_section) + 1) * sizeof (ACE_TCHAR)); - ACE_OS::strcpy (pers_name, sub_section); - ACE_Configuration_ExtId SSExtId (pers_name); - if (IntId.section_hash_map_->bind (SSExtId, ignored, allocator_)) - { - allocator_->free (pers_name); - return -1; - } - return (new_section (section, result)); -} - -int -ACE_Configuration_Heap::new_section (const ACE_TString& section, - ACE_Configuration_Section_Key& result) -{ - ACE_ASSERT (this->allocator_); - // Create a new section and add it to the global list - - // Allocate memory for items to be stored in the table. - size_t section_len = section.length () + 1; - ACE_TCHAR *ptr = (ACE_TCHAR*) this->allocator_->malloc (section_len * sizeof (ACE_TCHAR)); - - int return_value = -1; - - if (ptr == 0) - return -1; - else - { - // Populate memory with data. - ACE_OS::strcpy (ptr, section.fast_rep ()); - - void *value_hash_map = 0; - size_t map_size = sizeof (VALUE_MAP); - value_hash_map = this->allocator_->malloc (map_size); - - // If allocation failed ... - if (value_hash_map == 0) - return -1; - - // Initialize allocated hash map through placement new. - if (value_open_helper (default_map_size_, value_hash_map ) == -1) - { - this->allocator_->free (value_hash_map ); - return -1; - } - - // create the section map - void* section_hash_map = 0; - map_size = sizeof (SUBSECTION_MAP); - section_hash_map = this->allocator_->malloc (map_size); - - // If allocation failed - if (section_hash_map == 0) - return -1; - - // initialize allocated hash map through placement new - if (section_open_helper (default_map_size_, section_hash_map) == -1) - { - this->allocator_->free (value_hash_map ); - this->allocator_->free (section_hash_map); - return -1; - } - - ACE_Configuration_ExtId name (ptr); - ACE_Configuration_Section_IntId entry ((VALUE_MAP*) value_hash_map, - (SUBSECTION_MAP*) section_hash_map); - - // Do a normal bind. This will fail if there's already an - // entry with the same name. - return_value = this->index_->bind (name, entry, this->allocator_); - - if (return_value == 1 /* Entry already existed so bind failed. */ - || return_value == -1 /* Unable to bind for other reasons. */) - { - // Free our dynamically allocated memory. - this->allocator_->free (static_cast (ptr)); - return return_value; - } - - // If bind () succeed, it will automatically sync - // up the map manager entry. However, we must sync up our - // name/value memory. - this->allocator_->sync (ptr, section_len); - } - - // set the result - ACE_Configuration_Section_Key_Heap *temp; - ACE_NEW_RETURN (temp, - ACE_Configuration_Section_Key_Heap (ptr), - -1); - result = ACE_Configuration_Section_Key (temp); - return return_value; -} - -int -ACE_Configuration_Heap::value_open_helper (size_t hash_table_size, - void *buffer) -{ - ACE_ASSERT (this->allocator_); - new (buffer) VALUE_MAP (hash_table_size, this->allocator_); - return 0; -} - -int -ACE_Configuration_Heap::section_open_helper (size_t hash_table_size, - void *buffer) -{ - ACE_ASSERT (this->allocator_); - new (buffer) SUBSECTION_MAP (hash_table_size, this->allocator_); - return 0; -} - -int -ACE_Configuration_Heap::open_section (const ACE_Configuration_Section_Key& base, - const ACE_TCHAR* sub_section, - int create, - ACE_Configuration_Section_Key& result) -{ - ACE_ASSERT (this->allocator_); - if (validate_name (sub_section, 1)) // 1 == allow_path - return -1; - - result = base; - - for (const ACE_TCHAR* separator; - (separator = ACE_OS::strchr (sub_section, ACE_TEXT ('\\'))) != 0; - ) - { - ACE_TString simple_section (sub_section, separator - sub_section); - int ret_val = - open_simple_section (result, simple_section.c_str (), create, result); - if (ret_val) - return ret_val; - sub_section = separator + 1; - } - - return open_simple_section (result, sub_section, create, result); -} - -int -ACE_Configuration_Heap::open_simple_section (const ACE_Configuration_Section_Key& base, - const ACE_TCHAR* sub_section, - int create, - ACE_Configuration_Section_Key& result) -{ - ACE_TString section (0, 0, false); - - if (load_key (base, section)) - { - return -1; - } - - // Only add the \\ if were not at the root - if (section.length ()) - { - section += ACE_TEXT ("\\"); - } - - section += sub_section; - - // resolve the section - ACE_Configuration_ExtId ExtId (section.fast_rep ()); - ACE_Configuration_Section_IntId IntId; - - if (index_->find (ExtId, IntId, allocator_)) - { - if (!create) - { - errno = ENOENT; - return -1; - } - - return add_section (base, sub_section, result); - } - - ACE_Configuration_Section_Key_Heap *temp; - ACE_NEW_RETURN (temp, - ACE_Configuration_Section_Key_Heap (section.fast_rep ()), - -1); - result = ACE_Configuration_Section_Key (temp); - return 0; -} - -int -ACE_Configuration_Heap::remove_section (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* sub_section, - int recursive) -{ - ACE_ASSERT (this->allocator_); - if (validate_name (sub_section)) - return -1; - - ACE_TString section; - if (load_key (key, section)) - return -1; - - // Find this key - ACE_Configuration_ExtId ParentExtId (section.fast_rep ()); - ACE_Configuration_Section_IntId ParentIntId; - if (index_->find (ParentExtId, ParentIntId, allocator_)) - return -1;// no parent key - - // Find this subkey - if (section.length ()) - section += ACE_TEXT ("\\"); - - section += sub_section; - ACE_Configuration_ExtId SectionExtId (section.fast_rep ()); - SECTION_HASH::ENTRY* section_entry; - SECTION_HASH* hashmap = index_; - if (hashmap->find (SectionExtId, section_entry)) - return -1; - - if (recursive) - { - ACE_Configuration_Section_Key section; - if (open_section (key, sub_section, 0, section)) - return -1; - - int index = 0; - ACE_TString name; - while (!enumerate_sections (section, index, name)) - { - if (remove_section (section, name.fast_rep (), 1)) - return -1; - - ++index; - } - } - - // Now make sure we dont have any subkeys - if (section_entry->int_id_.section_hash_map_->current_size ()) - { - errno = ENOTEMPTY; - return -1; - } - - // Now remove subkey from parent key - ACE_Configuration_ExtId SubSExtId (sub_section); - SUBSECTION_HASH::ENTRY* subsection_entry; - if (((SUBSECTION_HASH*)ParentIntId.section_hash_map_)-> - find (SubSExtId, subsection_entry)) - return -1; - - if (ParentIntId.section_hash_map_->unbind (SubSExtId, allocator_)) - return -1; - - subsection_entry->ext_id_.free (allocator_); - - // Remember the pointers so we can free them after we unbind - ACE_Configuration_ExtId ExtIdToFree (section_entry->ext_id_); - ACE_Configuration_Section_IntId IntIdToFree (section_entry->int_id_); - - // iterate over all values and free memory - VALUE_HASH* value_hash_map = section_entry->int_id_.value_hash_map_; - VALUE_HASH::ITERATOR value_iter = value_hash_map->begin (); - while (!value_iter.done ()) - { - VALUE_HASH::ENTRY* value_entry = 0; - if (!value_iter.next (value_entry)) - return 1; - - value_entry->ext_id_.free (allocator_); - value_entry->int_id_.free (allocator_); - - value_iter.advance (); - } - - // remove it - if (index_->unbind (SectionExtId, allocator_)) - return -1; - - value_hash_map->close (); - section_entry->int_id_.section_hash_map_->close (allocator_); - - // Free the memory - ExtIdToFree.free (allocator_); - IntIdToFree.free (allocator_); - - return 0; -} - -int -ACE_Configuration_Heap::enumerate_values (const ACE_Configuration_Section_Key& key, - int index, - ACE_TString& name, - VALUETYPE& type) -{ - ACE_ASSERT (this->allocator_); - ACE_Configuration_Section_Key_Heap* pKey = - dynamic_cast (get_internal_key (key)); - if (!pKey) - return -1; - - name = pKey->path_; - - // resolve the section - ACE_Configuration_ExtId ExtId (pKey->path_); - ACE_Configuration_Section_IntId IntId; - if (index_->find (ExtId, IntId, allocator_)) - return -1; - - // Handle iterator resets - if (index == 0) - { - ACE_Hash_Map_Manager_Ex, - ACE_Equal_To, - ACE_Null_Mutex>* hash_map = IntId.value_hash_map_; - delete pKey->value_iter_; - - ACE_NEW_RETURN (pKey->value_iter_, - VALUE_HASH::ITERATOR (hash_map->begin ()), - -1); - } - - // Get the next entry - ACE_Hash_Map_Entry* entry = 0; - - if (!pKey->value_iter_->next (entry)) - return 1; - - // Return the value of the iterator and advance it - name = entry->ext_id_.name_; - type = entry->int_id_.type_; - pKey->value_iter_->advance (); - - return 0; -} - -int -ACE_Configuration_Heap::enumerate_sections (const ACE_Configuration_Section_Key& key, - int index, - ACE_TString& name) -{ - ACE_ASSERT (this->allocator_); - // cast to a heap section key - ACE_Configuration_Section_Key_Heap* pKey = - dynamic_cast (get_internal_key (key)); - if (!pKey) - return -1; // not a heap key! - - // resolve the section - ACE_Configuration_ExtId ExtId (pKey->path_); - ACE_Configuration_Section_IntId IntId; - if (index_->find (ExtId, IntId, allocator_)) - return -1; // unknown section - - // Handle iterator resets - if (index == 0) - { - if (pKey->section_iter_) - delete pKey->section_iter_; - - ACE_NEW_RETURN (pKey->section_iter_, - SUBSECTION_HASH::ITERATOR (IntId.section_hash_map_->begin ()), - -1); - } - - // Get the next entry - ACE_Hash_Map_Entry* entry = 0; - if (!pKey->section_iter_->next (entry)) - return 1; - - // Return the value of the iterator and advance it - pKey->section_iter_->advance (); - name = entry->ext_id_.name_; - - return 0; -} - -int -ACE_Configuration_Heap::set_string_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - const ACE_TString& value) -{ - ACE_ASSERT (this->allocator_); - const ACE_TCHAR *t_name = name ? name : &this->NULL_String_; - if (validate_value_name (t_name)) - return -1; - - ACE_TString section; - if (load_key (key, section)) - return -1; - - ACE_Configuration_ExtId section_ext (section.fast_rep ()); - ACE_Configuration_Section_IntId section_int; - if (index_->find (section_ext, section_int, allocator_)) - return -1; - - // Get the entry for this item (if it exists) - VALUE_HASH::ENTRY* entry; - ACE_Configuration_ExtId item_name (t_name); - if (section_int.value_hash_map_->VALUE_HASH::find (item_name, entry) == 0) - { - // found item, replace it - // Free the old value - entry->int_id_.free (allocator_); - // Allocate the new value in this heap - ACE_TCHAR* pers_value = - (ACE_TCHAR *) allocator_->malloc ((value.length () + 1) * sizeof (ACE_TCHAR)); - ACE_OS::strcpy (pers_value, value.fast_rep ()); - ACE_Configuration_Value_IntId new_value_int (pers_value); - entry->int_id_ = new_value_int; - } - else - { - // it doesn't exist, bind it - ACE_TCHAR* pers_name = - (ACE_TCHAR *) allocator_->malloc ((ACE_OS::strlen (t_name) + 1) * sizeof (ACE_TCHAR)); - ACE_OS::strcpy (pers_name, t_name); - ACE_TCHAR* pers_value = - (ACE_TCHAR *) allocator_->malloc ((value.length () + 1) * sizeof (ACE_TCHAR)); - ACE_OS::strcpy (pers_value, value.fast_rep ()); - ACE_Configuration_ExtId item_name (pers_name); - ACE_Configuration_Value_IntId item_value (pers_value); - if (section_int.value_hash_map_->bind (item_name, item_value, allocator_)) - { - allocator_->free (pers_value); - allocator_->free (pers_name); - return -1; - } - return 0; - } - - return 0; -} - -int -ACE_Configuration_Heap::set_integer_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - u_int value) -{ - ACE_ASSERT (this->allocator_); - const ACE_TCHAR *t_name = name ? name : &this->NULL_String_; - if (validate_value_name (t_name)) - return -1; - - // Get the section name from the key - ACE_TString section; - if (load_key (key, section)) - return -1; - - // Find this section - ACE_Configuration_ExtId section_ext (section.fast_rep ()); - ACE_Configuration_Section_IntId section_int; - if (index_->find (section_ext, section_int, allocator_)) - return -1; // section does not exist - - // Get the entry for this item (if it exists) - VALUE_HASH::ENTRY* entry; - ACE_Configuration_ExtId item_name (t_name); - if (section_int.value_hash_map_->VALUE_HASH::find (item_name, entry) == 0) - { - // found item, replace it - ACE_Configuration_Value_IntId new_value_int (value); - entry->int_id_ = new_value_int; - } - else - { - // it doesn't exist, bind it - ACE_TCHAR* pers_name = - (ACE_TCHAR *) allocator_->malloc ((ACE_OS::strlen (t_name) + 1) * sizeof (ACE_TCHAR)); - ACE_OS::strcpy (pers_name, t_name); - ACE_Configuration_ExtId item_name (pers_name); - ACE_Configuration_Value_IntId item_value (value); - if (section_int.value_hash_map_->bind (item_name, item_value, allocator_)) - { - allocator_->free (pers_name); - return -1; - } - return 0; - } - - return 0; -} - -int -ACE_Configuration_Heap::set_binary_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - const void* data, - size_t length) -{ - ACE_ASSERT (this->allocator_); - const ACE_TCHAR *t_name = name ? name : &this->NULL_String_; - if (validate_value_name (t_name)) - return -1; - - // Get the section name from the key - ACE_TString section; - if (load_key (key, section)) - return -1; - - // Find this section - ACE_Configuration_ExtId section_ext (section.fast_rep ()); - ACE_Configuration_Section_IntId section_int; - if (index_->find (section_ext, section_int, allocator_)) - return -1; // section does not exist - - // Get the entry for this item (if it exists) - VALUE_HASH::ENTRY* entry; - ACE_Configuration_ExtId item_name (t_name); - if (section_int.value_hash_map_->VALUE_HASH::find (item_name, entry) == 0) - { - // found item, replace it - // Free the old value - entry->int_id_.free (allocator_); - // Allocate the new value in this heap - ACE_TCHAR* pers_value = (ACE_TCHAR *) allocator_->malloc (length); - ACE_OS::memcpy (pers_value, data, length); - ACE_Configuration_Value_IntId new_value_int (pers_value, length); - entry->int_id_ = new_value_int; - } - else - { - // it doesn't exist, bind it - ACE_TCHAR* pers_name = - (ACE_TCHAR *) allocator_->malloc ((ACE_OS::strlen (t_name) + 1) * sizeof (ACE_TCHAR)); - ACE_OS::strcpy (pers_name, t_name); - ACE_TCHAR* pers_value = (ACE_TCHAR *) allocator_->malloc (length); - ACE_OS::memcpy (pers_value, data, length); - ACE_Configuration_ExtId item_name (pers_name); - ACE_Configuration_Value_IntId item_value (pers_value, length); - if (section_int.value_hash_map_->bind (item_name, item_value, allocator_)) - { - allocator_->free (pers_value); - allocator_->free (pers_name); - return -1; - } - return 0; - } - - return 0; -} - -int -ACE_Configuration_Heap::get_string_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - ACE_TString& value) -{ - ACE_ASSERT (this->allocator_); - const ACE_TCHAR *t_name = name ? name : &this->NULL_String_; - if (validate_value_name (t_name)) - return -1; - - // Get the section name from the key - ACE_TString section; - if (load_key (key, section)) - return -1; - - // Find this section - ACE_Configuration_ExtId ExtId (section.fast_rep ()); - ACE_Configuration_Section_IntId IntId; - if (index_->find (ExtId, IntId, allocator_)) - return -1; // section does not exist - - // See if it exists first - ACE_Configuration_ExtId VExtId (t_name); - ACE_Configuration_Value_IntId VIntId; - if (IntId.value_hash_map_->find (VExtId, VIntId, allocator_)) - return -1; // unknown value - - // Check type - if (VIntId.type_ != ACE_Configuration::STRING) - { - errno = ENOENT; - return -1; - } - - // everythings ok, return the data - value = static_cast (VIntId.data_.ptr_); - return 0; -} - -int -ACE_Configuration_Heap::get_integer_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - u_int& value) -{ - ACE_ASSERT (this->allocator_); - - const ACE_TCHAR *t_name = name ? name : &this->NULL_String_; - if (validate_value_name (t_name)) - return -1; - - // Get the section name from the key - ACE_TString section (0, 0, false); - - if (this->load_key (key, section) != 0) - { - return -1; - } - - // Find this section - ACE_Configuration_ExtId ExtId (section.fast_rep ()); - ACE_Configuration_Section_IntId IntId; - - if (index_->find (ExtId, IntId, allocator_) != 0) - { - return -1; // section does not exist - } - - - // See if it exists first - ACE_Configuration_ExtId VExtId (t_name); - ACE_Configuration_Value_IntId VIntId; - - if (IntId.value_hash_map_->find (VExtId, VIntId, allocator_) != 0) - { - return -1; // unknown value - } - - // Check type - if (VIntId.type_ != ACE_Configuration::INTEGER) - { - errno = ENOENT; - return -1; - } - - // Everythings ok, return the data - value = VIntId.data_.int_; - return 0; -} - -int -ACE_Configuration_Heap::get_binary_value ( - const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - void*& data, - size_t& length) -{ - ACE_ASSERT (this->allocator_); - const ACE_TCHAR *t_name = name ? name : &this->NULL_String_; - if (validate_value_name (t_name)) - return -1; - - // Get the section name from the key - ACE_TString section; - if (load_key (key, section)) - return -1; - - // Find this section - ACE_Configuration_ExtId ExtId (section.fast_rep ()); - ACE_Configuration_Section_IntId IntId; - if (index_->find (ExtId, IntId, allocator_)) - return -1; // section does not exist - - ACE_Configuration_ExtId VExtId (t_name); - ACE_Configuration_Value_IntId VIntId; - // See if it exists first - if (IntId.value_hash_map_->find (VExtId, VIntId, allocator_)) - return -1; // unknown value - - // Check type - if (VIntId.type_ != ACE_Configuration::BINARY) - { - errno = ENOENT; - return -1; - } - - // Make a copy - ACE_NEW_RETURN (data, char[VIntId.length_], -1); - ACE_OS::memcpy (data, VIntId.data_.ptr_, VIntId.length_); - length = VIntId.length_; - return 0; -} - -int -ACE_Configuration_Heap::find_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - VALUETYPE& type_out) -{ - ACE_ASSERT (this->allocator_); - const ACE_TCHAR *t_name = name ? name : &this->NULL_String_; - if (validate_value_name (t_name)) - return -1; - - // Get the section name from the key - ACE_TString section; - if (load_key (key, section)) - return -1; - - // Find this section - ACE_Configuration_ExtId ExtId (section.fast_rep ()); - ACE_Configuration_Section_IntId IntId; - if (index_->find (ExtId, IntId, allocator_)) - return -1; // section does not exist - - // Find it - ACE_Configuration_ExtId ValueExtId (t_name); - VALUE_HASH::ENTRY* value_entry; - if (((VALUE_HASH *) IntId.value_hash_map_)->find (ValueExtId, value_entry)) - return -1; // value does not exist - - type_out = value_entry->int_id_.type_; - return 0; -} - -int -ACE_Configuration_Heap::remove_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name) -{ - ACE_ASSERT (this->allocator_); - const ACE_TCHAR *t_name = name ? name : &this->NULL_String_; - if (validate_value_name (t_name)) - return -1; - - // Get the section name from the key - ACE_TString section; - if (load_key (key, section)) - return -1; - - // Find this section - ACE_Configuration_ExtId ExtId (section.fast_rep ()); - ACE_Configuration_Section_IntId IntId; - if (index_->find (ExtId, IntId, allocator_)) - return -1; // section does not exist - - // Find it - ACE_Configuration_ExtId ValueExtId (t_name); - VALUE_HASH::ENTRY* value_entry; - if (((VALUE_HASH *) IntId.value_hash_map_)->find (ValueExtId, value_entry)) - return -1; - - // free it - value_entry->ext_id_.free (allocator_); - value_entry->int_id_.free (allocator_); - - // Unbind it - if (IntId.value_hash_map_->unbind (ValueExtId, allocator_)) - return -1; - - return 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Configuration.h b/ACE/ace/Configuration.h deleted file mode 100644 index 199d7ac166b..00000000000 --- a/ACE/ace/Configuration.h +++ /dev/null @@ -1,896 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file Configuration.h - * - * $Id$ - * - * @author Chris Hafey - * - * The ACE configuration API provides a portable abstraction for - * program configuration similar to the Microsoft Windows registry. - * The API supports a tree based hierarchy of configuration sections. Each - * section contains other sections or values. Values may contain string, - * unsigned integer and binary data. - * - * @note These classes are not thread safe, if multiple threads use these - * classes, you are responsible for serializing access. - * - * For examples of using this class, see: - * -# The test code in ACE_wrappers/test - * -# wxConfigViewer, a Windows like Registry Editor for ACE_Configuration - * -# TAO's IFR, it makes extensive use of ACE_Configuration - * - * @todo Templatize this class with an ACE_LOCK to provide thread safety - * - */ -//============================================================================= - -#ifndef ACE_CONFIGURATION_H -#define ACE_CONFIGURATION_H -#include /**/ "ace/pre.h" - -#include "ace/SStringfwd.h" -#include "ace/Hash_Map_With_Allocator_T.h" -#include "ace/Malloc_T.h" -#include "ace/MMAP_Memory_Pool.h" -#include "ace/Local_Memory_Pool.h" -#include "ace/Synch_Traits.h" - - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -// configurable parameters - -#if !defined (ACE_CONFIG_SECTION_INDEX) -# define ACE_CONFIG_SECTION_INDEX "Config_Section_Index" -#endif /* ! ACE_CONFIG_SECTION_INDEX */ - -#if !defined (ACE_DEFAULT_CONFIG_SECTION_SIZE) -#define ACE_DEFAULT_CONFIG_SECTION_SIZE 16 -#endif /* ACE_DEFAULT_CONFIG_SECTION_SIZE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Section_Key_Internal - * - * @internal - * - * @brief A base class for internal handles to section keys for - * configuration implementations - * - * Implementations subclass this base class to represent a - * section key. - * - */ -class ACE_Export ACE_Section_Key_Internal -{ -public: - /// Virtual destructor, make sure descendants are virtual! - virtual ~ACE_Section_Key_Internal (void); - - /// Increment reference count - virtual int add_ref (void); - - /// Decrement reference count. Will delete this if count gets to 0 - virtual int dec_ref (void); -protected: - ACE_Section_Key_Internal (void); - ACE_Section_Key_Internal (const ACE_Section_Key_Internal& rhs); - ACE_Section_Key_Internal& operator= (ACE_Section_Key_Internal& rhs); - - u_int ref_count_; -}; - -/** - * @class ACE_Configuration_Section_Key - * - * @brief Reference counted wrapper for ACE_Section_Key_Internal. - * - * Reference counted wrapper class for the abstract internal - * section key. A user gets one of these to represent a section - * in the configuration database. - */ -class ACE_Export ACE_Configuration_Section_Key -{ - friend class ACE_Configuration; -public: - /// Default constructor. - ACE_Configuration_Section_Key (void); - - /// Constructor that initializes to a pointer to a concrete internal key. - /** - * @param key The section key to reference. Calls add_ref() with @a key. - */ - explicit ACE_Configuration_Section_Key (ACE_Section_Key_Internal *key); - - /// Copy constructor, increments the reference count on the key. - ACE_Configuration_Section_Key (const ACE_Configuration_Section_Key &rhs); - - /// Destructor, decrements reference count on the referenced key. - ~ACE_Configuration_Section_Key (void); - - /// Assignment operator, increments reference count for this object - /// and decrements it on @a rhs. - ACE_Configuration_Section_Key & - operator= (const ACE_Configuration_Section_Key &rhs); -private: - ACE_Section_Key_Internal *key_; -}; - -/** - * @class ACE_Configuration - * - * @internal - * - * @brief Base class for configuration databases - * - * This class provides an interface for configuration databases. A concrete - * class is required that implements the interface. - * - * @sa ACE_Configuration_Heap - * @sa ACE_Configuration_Win32Registry - */ -class ACE_Export ACE_Configuration -{ -public: - /// Enumeration for the various types of values we can store. - enum VALUETYPE - { - STRING, - INTEGER, - BINARY, - INVALID - }; - - /// Destructor - virtual ~ACE_Configuration (void); - - /// Obtain a reference to the root section of this configuration. - /* - * @return Reference to the configuration's root section. Note that - * it is a const reference. - */ - virtual const ACE_Configuration_Section_Key& root_section (void) const; - - /** - * Opens a named section in an existing section. - * - * @param base Existing section in which to open the named section. - * @param sub_section Name of the section to open. - * @param create If zero, the named section must exist. If non-zero, - * the named section will be created if it does not exist. - * @param result Reference; receives the section key for the new - * section. - * - * @retval 0 for success. - * @retval -1 for error; ACE_OS::last_error() retrieves error code. - */ - virtual int open_section (const ACE_Configuration_Section_Key &base, - const ACE_TCHAR *sub_section, - int create, - ACE_Configuration_Section_Key& result) = 0; - - /// Removes a named section. - /** - * @param key Section key to remove the named section from. - * @param sub_section Name of the section to remove. - * @param recursive If non zero, any subkeys below @a sub_section are - * removed as well. - * - * @retval 0 for success. - * @retval -1 for error; ACE_OS::last_error() retrieves error code. - */ - virtual int remove_section (const ACE_Configuration_Section_Key &key, - const ACE_TCHAR *sub_section, - int recursive) = 0; - - /** - * Enumerates through the values in a section. - * - * @param key Section key to iterate through. - * @param index Iteration position. Must be zero on the first call to - * iterate through @a key. Increment @a index by one on each - * successive call to this method. - * @param name Receives the value's name. - * @param type Receives the value's data type. - * - * @note You may not delete or add values while enumerating. If the - * section is modified during enumeration, results are undefined; - * you must restart the enumeration from index 0. - * - * @retval 0 for success, @a name and @a type are valid. - * @retval 1 there are no more values in the section. - * @retval -1 for error; ACE_OS::last_error() retrieves error code. - */ - virtual int enumerate_values (const ACE_Configuration_Section_Key& key, - int index, - ACE_TString& name, - VALUETYPE& type) = 0; - - /** - * Enumerates through the subsections in a section. - * - * @param key Section key to iterate through. - * @param index Iteration position. Must be zero on the first call to - * iterate through @a key. Increment @a index by one on each - * successive call to this method. - * @param name Receives the subsection's name. - * - * @note You may not modify the @a key section while enumerating. If the - * section is modified during enumeration, results are undefined; - * you must restart the enumeration from index 0. - * - * @retval 0 for success, @a name has a valid name. - * @retval 1 there are no more subsections in the section. - * @retval -1 for error; ACE_OS::last_error() retrieves error code. - */ - virtual int enumerate_sections (const ACE_Configuration_Section_Key& key, - int index, ACE_TString& name) = 0; - - /// Sets a string-typed value. - /** - * @param key Configuration section to set the value in. - * @param name Name of the configuration value to set. If a value with - * the specified name exists, it is replaced. - * @param value The string to set the configuration value to. - * - * @retval 0 for success. - * @retval -1 for error; ACE_OS::last_error() retrieves error code. - */ - virtual int set_string_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - const ACE_TString& value) = 0; - - /// Sets a integer-typed value. - /** - * @param key Configuration section to set the value in. - * @param name Name of the configuration value to set. If a value with - * the specified name exists, it is replaced. - * @param value The integer to set the configuration value to. - * - * @retval 0 for success. - * @retval -1 for error; ACE_OS::last_error() retrieves error code. - */ - virtual int set_integer_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - u_int value) = 0; - - /// Sets a binary-typed value. - /** - * @param key Configuration section to set the value in. - * @param name Name of the configuration value to set. If a value with - * the specified name exists, it is replaced. - * @param data Pointer to the binary data for the value. - * @param length Number of bytes for the new value. - * - * @retval 0 for success. - * @retval -1 for error; ACE_OS::last_error() retrieves error code. - */ - virtual int set_binary_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - const void* data, - size_t length) = 0; - - /// Gets a string-typed value. - /** - * @param key Configuration section to get the value from. - * @param name Name of the configuration value to get. - * @param value Receives the configuration value if it exists and - * has type STRING. - * - * @retval 0 for success. - * @retval -1 for error; ACE_OS::last_error() retrieves error code. - */ - virtual int get_string_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - ACE_TString& value) = 0; - - /// Gets an integer-typed value. - /** - * @param key Configuration section to get the value from. - * @param name Name of the configuration value to get. - * @param value Receives the configuration value if it exists and - * has type INTEGER. - * - * @retval 0 for success. - * @retval -1 for error; ACE_OS::last_error() retrieves error code. - */ - virtual int get_integer_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - u_int& value) = 0; - - /// Gets a binary-typed value. - /** - * @param key Configuration section to get the value from. - * @param name Name of the configuration value to get. - * @param data Receives a pointer to memory holding the binary data - * for the value. This method allocates the memory pointed - * to using operator new[]. The caller is responsible for - * freeing the memory using operator delete[]. - * @param length Receives the number of bytes in the value. - * - * @retval 0 for success; caller is responsible for freeing the - * returned memory. - * @retval -1 for error; ACE_OS::last_error() retrieves error code. - */ - virtual int get_binary_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - void*& data, - size_t& length) = 0; - - /** - * Retrieves the type of a named configuration value. - * - * @param key Configuration section to look up the name in. - * @param name Name of the configuration value to get the type of. - * @param type Receives the data type of the named value, if it exists. - * - * @retval 0 for success. - * @retval -1 for error; ACE_OS::last_error() retrieves error code. - */ - virtual int find_value(const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - VALUETYPE& type) = 0; - - /// Removes a named value. - /** - * @param key Configuration section to remove the named value from. - * @param name Name of the configuration value to remove. - * - * @retval 0 for success. - * @retval -1 for error; ACE_OS::last_error() retrieves error code. - */ - virtual int remove_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name) = 0; - - /** - * Expands to from @a key. If create is true, - * the subsections are created. Returns 0 on success, non zero on - * error The path consists of sections separated by the backslash - * '\' or forward slash '/'. - * Returns 0 on success, -1 if - virtual ~ACE_Section_Key_Win32 (void); - - // Not used - ACE_Section_Key_Win32 (const ACE_Section_Key_Win32& rhs); - ACE_Section_Key_Win32& operator= (const ACE_Section_Key_Win32& rhs); -}; - -/** - * @class ACE_Configuration_Win32Registry - * - * @brief The win32 registry implementation of a configuration database - * - * The win32 implementation basically makes calls through to the - * registry functions. The API is very similar so very little - * work must be done - */ -class ACE_Export ACE_Configuration_Win32Registry : public ACE_Configuration -{ -public: - - /** - * Constructor for registry configuration database. hKey is the - * base registry key to attach to. This class takes ownership of - * hKey, it will invoke on it upon destruction. - */ - explicit ACE_Configuration_Win32Registry (HKEY hKey); - - /// Destructor - virtual ~ACE_Configuration_Win32Registry (void); - - virtual int open_section (const ACE_Configuration_Section_Key& base, - const ACE_TCHAR* sub_section, - int create, - ACE_Configuration_Section_Key& result); - - virtual int remove_section (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* sub_section, - int recursive); - - virtual int enumerate_values (const ACE_Configuration_Section_Key& key, - int index, - ACE_TString& name, - VALUETYPE& type); - - virtual int enumerate_sections (const ACE_Configuration_Section_Key& key, - int index, - ACE_TString& name); - - virtual int set_string_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - const ACE_TString& value); - - virtual int set_integer_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - u_int value); - - virtual int set_binary_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - const void* data, - size_t length); - - virtual int get_string_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - ACE_TString& value); - - virtual int get_integer_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - u_int& value); - - virtual int get_binary_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - void*& data, - size_t& length); - - virtual int find_value(const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - VALUETYPE& type); - - /// Removes the the value @a name from @a key. returns non zero on error - virtual int remove_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name); - - /** - * This method traverses through . It is useful when - * you want the HKEY for a specific registry key, especially when - * initializing this implementation. Caller is responsible for - * closeing this key when it is no longer used. If create is 1 - * (default) the keys are create if they don't already exist. - * Returns 0 on error - */ - static HKEY resolve_key (HKEY hKey, - const ACE_TCHAR* path, - int create = 1); - virtual bool operator== (const ACE_Configuration_Win32Registry &rhs) const; - virtual bool operator!= (const ACE_Configuration_Win32Registry &rhs) const; - -protected: - - /// Gets the HKEY for a configuration section - int load_key (const ACE_Configuration_Section_Key& key, HKEY& hKey); - - // Not used - ACE_Configuration_Win32Registry (void); - ACE_Configuration_Win32Registry (const ACE_Configuration_Win32Registry& rhs); - ACE_Configuration_Win32Registry& operator= (const ACE_Configuration_Win32Registry& rhs); -}; -#endif /* ACE_WIN32 && !ACE_LACKS_WIN32_REGISTRY */ - -// ACE_Allocator version - -typedef ACE_Allocator_Adapter > - PERSISTENT_ALLOCATOR; -typedef ACE_Allocator_Adapter > - HEAP_ALLOCATOR; - -/** - * @class ACE_Configuration_ExtId - * - * @brief External ID for the section and value hash - * - * Contains a pointer to the section or value name. - */ -class ACE_Export ACE_Configuration_ExtId -{ -public: - /// Defeault ctor - ACE_Configuration_ExtId (void); - - /// Named constructor - explicit ACE_Configuration_ExtId (const ACE_TCHAR* name); - - /// Copy ctor - ACE_Configuration_ExtId (const ACE_Configuration_ExtId& rhs); - - /// destructor - ~ACE_Configuration_ExtId (void); - - /// Assignment operator - ACE_Configuration_ExtId& operator= (const ACE_Configuration_ExtId& rhs); - - /// Equality comparison operator (must match name_). - bool operator== (const ACE_Configuration_ExtId &rhs) const; - - /// Inequality comparison operator. - bool operator!= (const ACE_Configuration_ExtId &rhs) const; - - /// Frees the name of the value. needed since we don't know the - /// allocator name_ was created in - void free (ACE_Allocator *alloc); - - /// function is required in order for this class to be usable by - /// ACE_Hash_Map_Manager. - u_long hash (void) const; - - // = Data members. - - const ACE_TCHAR * name_; - - // Accessors - const ACE_TCHAR *name (void); -}; - -typedef ACE_Hash_Map_With_Allocator - SUBSECTION_MAP; -typedef ACE_Hash_Map_Manager_Ex, - ACE_Equal_To, - ACE_Null_Mutex> - SUBSECTION_HASH; - -/// @deprecated Deprecated typedef. Use the SUBSECTION_HASH::ENTRY trait instead. -typedef SUBSECTION_HASH::ENTRY SUBSECTION_ENTRY; - -/** - * @class ACE_Configuration_Value_IntId - * - * @brief The section hash table internal value class - * - * This class is present as the internal portion of a section's - * value hash table It may store string, integer or binary data. - */ -class ACE_Export ACE_Configuration_Value_IntId -{ -public: - /// Default constructor - ACE_Configuration_Value_IntId (void); - - /// String constructor, takes ownership of string - explicit ACE_Configuration_Value_IntId (ACE_TCHAR* string); - - /// Integer constructor - explicit ACE_Configuration_Value_IntId (u_int integer); - - /// Binary constructor, takes ownership of data - ACE_Configuration_Value_IntId (void* data, size_t length); - - /// Copy ctor - ACE_Configuration_Value_IntId (const ACE_Configuration_Value_IntId& rhs); - - /// Destructor - ~ACE_Configuration_Value_IntId (void); - - /// Assignment operator - ACE_Configuration_Value_IntId& operator= ( - const ACE_Configuration_Value_IntId& rhs); - - void free (ACE_Allocator *alloc); - - // = Data members. - - /** - * Points to the string value or binary data or IS the integer - * Length is only used when type_ == BINARY - */ - ACE_Configuration::VALUETYPE type_; - union { - void * ptr_; - u_int int_; - } data_; - size_t length_; -}; - -typedef ACE_Hash_Map_With_Allocator - VALUE_MAP; -typedef ACE_Hash_Map_Manager_Ex, - ACE_Equal_To, - ACE_Null_Mutex> - VALUE_HASH; - -// Deprecated typedef. Use the VALUE_HASH::ENTRY trait instead. -typedef VALUE_HASH::ENTRY VALUE_ENTRY; - -/** - * @class ACE_Configuration_Section_IntId - * - * @brief The internal ID for a section hash table - * - * Contains a hash table containing value name/values - */ -class ACE_Export ACE_Configuration_Section_IntId -{ -public: - /// Default ctor - ACE_Configuration_Section_IntId (void); - - /// Named ctor - ACE_Configuration_Section_IntId (VALUE_MAP* value_hash_map, - SUBSECTION_MAP* section_hash_map); - - /// Copy ctor - ACE_Configuration_Section_IntId (const ACE_Configuration_Section_IntId& rhs); - - /// Destructor - ~ACE_Configuration_Section_IntId (void); - - /// Assignment operator - ACE_Configuration_Section_IntId& operator= ( - const ACE_Configuration_Section_IntId& rhs); - - /// Frees the hash table and all its values - void free (ACE_Allocator *alloc); - - // = Data Members. - VALUE_MAP* value_hash_map_; - - SUBSECTION_MAP* section_hash_map_; -}; - -typedef ACE_Hash_Map_With_Allocator - SECTION_MAP; -typedef ACE_Hash_Map_Manager_Ex, - ACE_Equal_To, - ACE_Null_Mutex> - SECTION_HASH; - -// Deprecated typedef. Use the SECTION_HASH::ENTRY trait instead. -typedef SECTION_HASH::ENTRY SECTION_ENTRY; - -/** - * @class ACE_Configuration_Section_Key_Heap - * - * @brief Internal section key class for heap based configuration - * database. - * - * Contains a value iterator and full path name of section. - */ -class ACE_Export ACE_Configuration_Section_Key_Heap - : public ACE_Section_Key_Internal -{ -public: - /// Constructor based on the full path of the section - ACE_Configuration_Section_Key_Heap (const ACE_TCHAR* path); - - /// The path itself - ACE_TCHAR* path_; - - /// The value iterator - VALUE_HASH::ITERATOR* value_iter_; - - /// The sub section iterator - SUBSECTION_HASH::ITERATOR* section_iter_; -protected: - /// Destructor - will delete the iterators - virtual ~ACE_Configuration_Section_Key_Heap (void); - - // Not used - ACE_Configuration_Section_Key_Heap (const ACE_Configuration_Section_Key_Heap& rhs); - ACE_Configuration_Section_Key_Heap& operator= (const ACE_Configuration_Section_Key_Heap& rhs); -}; - -/** - * @class ACE_Configuration_Heap - * - * @brief The concrete implementation of a allocator based - * configuration database - * - * This class uses ACE's Allocators to manage a memory - * representation of a configuraiton database. A persistent heap - * may be used to store configurations persistently - * - * @note Before using this class you must call one of the open methods. - * - * @todo - * - Need to investigate what happens if memory mapped file gets mapped to - * a location different than it was created with. - */ -class ACE_Export ACE_Configuration_Heap : public ACE_Configuration -{ -public: - - /// Default ctor - ACE_Configuration_Heap (void); - - /// Destructor - virtual ~ACE_Configuration_Heap (void); - - /// Opens a configuration based on a file name - int open (const ACE_TCHAR* file_name, - void* base_address = ACE_DEFAULT_BASE_ADDR, - size_t default_map_size = ACE_DEFAULT_CONFIG_SECTION_SIZE); - - /// Opens a heap based configuration - int open (size_t default_map_size = ACE_DEFAULT_CONFIG_SECTION_SIZE); - - virtual int open_section (const ACE_Configuration_Section_Key& base, - const ACE_TCHAR* sub_section, - int create, ACE_Configuration_Section_Key& result); - - virtual int remove_section (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* sub_section, - int recursive); - - virtual int enumerate_values (const ACE_Configuration_Section_Key& key, - int index, - ACE_TString& name, - VALUETYPE& type); - - virtual int enumerate_sections (const ACE_Configuration_Section_Key& key, - int index, - ACE_TString& name); - - virtual int set_string_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - const ACE_TString& value); - - virtual int set_integer_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - u_int value); - - virtual int set_binary_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - const void* data, - size_t length); - - virtual int get_string_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - ACE_TString& value); - - virtual int get_integer_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - u_int& value); - - virtual int get_binary_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - void* &data, - size_t &length); - - virtual int find_value(const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name, - VALUETYPE& type); - - /// Removes the the value @a name from @a key. returns non zero on error - virtual int remove_value (const ACE_Configuration_Section_Key& key, - const ACE_TCHAR* name); - -private: - /// may not contain path separators - int open_simple_section (const ACE_Configuration_Section_Key &base, - const ACE_TCHAR *sub_section, - int create, ACE_Configuration_Section_Key &result); - /// Adds a new section - int add_section (const ACE_Configuration_Section_Key &base, - const ACE_TCHAR *sub_section, - ACE_Configuration_Section_Key &result); - - /// Helper for the method. - int create_index (void); - - /// Helper for create_index() method: places hash table into an - /// allocated space. - int create_index_helper (void *buffer); - - int value_open_helper (size_t hash_table_size, void *buffer); - - int section_open_helper (size_t hash_table_size, void *buffer); - - int load_key (const ACE_Configuration_Section_Key& key, ACE_TString& name); - - int new_section (const ACE_TString& section, - ACE_Configuration_Section_Key& result); - - ACE_Configuration_Heap (const ACE_Configuration_Heap& rhs); - ACE_Configuration_Heap& operator= (const ACE_Configuration_Heap& rhs); - - ACE_Allocator *allocator_; - SECTION_MAP *index_; - size_t default_map_size_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Configuration.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_CONFIGURATION_H */ diff --git a/ACE/ace/Configuration.inl b/ACE/ace/Configuration.inl deleted file mode 100644 index b7c9af26f5c..00000000000 --- a/ACE/ace/Configuration.inl +++ /dev/null @@ -1,13 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE const ACE_TCHAR* -ACE_Configuration_ExtId::name (void) -{ - return name_; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Configuration_Import_Export.cpp b/ACE/ace/Configuration_Import_Export.cpp deleted file mode 100644 index ce4cbac84c1..00000000000 --- a/ACE/ace/Configuration_Import_Export.cpp +++ /dev/null @@ -1,670 +0,0 @@ -// $Id$ - -#include "ace/Configuration_Import_Export.h" -#include "ace/OS_Errno.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_ctype.h" -#include "ace/OS_NS_string.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_Config_ImpExp_Base::ACE_Config_ImpExp_Base (ACE_Configuration& config) - : config_ (config) -{ -} - -ACE_Config_ImpExp_Base::~ACE_Config_ImpExp_Base (void) -{ -} - -ACE_Registry_ImpExp::ACE_Registry_ImpExp (ACE_Configuration& config) - : ACE_Config_ImpExp_Base (config) -{ -} - -ACE_Registry_ImpExp::~ACE_Registry_ImpExp (void) -{ -} - -// Imports the configuration database from filename. -// No existing data is removed. -int -ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) -{ - if (0 == filename) - { - errno = EINVAL; - return -1; - } - FILE* in = ACE_OS::fopen (filename, ACE_TEXT ("r")); - if (!in) - return -1; - - u_int buffer_size = 4096; - u_int read_pos = 0; - ACE_TCHAR *buffer = 0; - ACE_NEW_NORETURN (buffer, ACE_TCHAR[buffer_size]); - if (!buffer) - { - ACE_Errno_Guard guard (errno); - (void) ACE_OS::fclose (in); - return -1; - } - ACE_Configuration_Section_Key section; - ACE_TCHAR *end = 0; - - while (ACE_OS::fgets (buffer+read_pos, buffer_size - read_pos, in)) - { - // Check if we got all the line. - end = ACE_OS::strrchr (buffer + read_pos, - ACE_TEXT ('\n')); // look for end of line - if (!end) // we havn't reach the end of the line yet - { - // allocate a new buffer - double size the previous one - ACE_TCHAR *temp_buffer; - ACE_NEW_NORETURN (temp_buffer, ACE_TCHAR[buffer_size * 2]); - if (!temp_buffer) - { - ACE_Errno_Guard guard (errno); - delete [] buffer; - (void) ACE_OS::fclose (in); - return -1; - } - - // copy the beginnning of the line - ACE_OS::memcpy (temp_buffer, buffer, buffer_size); - read_pos = buffer_size - 1; - buffer_size *= 2; - delete [] buffer; - buffer = temp_buffer; - continue; - } - read_pos = 0; - - // Check for a comment - if (buffer[0] == ACE_TEXT (';') || buffer[0] == ACE_TEXT ('#')) - continue; - - if (buffer[0] == ACE_TEXT ('[')) - { - // We have a new section here, strip out the section name - end = ACE_OS::strrchr (buffer, ACE_TEXT (']')); - if (!end) - { - ACE_OS::fclose (in); - delete [] buffer; - return -3; - } - *end = 0; - - if (config_.expand_path (config_.root_section (), buffer + 1, section, 1)) - { - ACE_OS::fclose (in); - delete [] buffer; - return -3; - } - continue; - } // end if firs char is a [ - - if (buffer[0] == ACE_TEXT ('"')) - { - // we have a value - end = ACE_OS::strchr (buffer+1, '"'); - if (!end) // no closing quote, not a value so just skip it - continue; - - // null terminate the name - *end = 0; - ACE_TCHAR* name = buffer + 1; - end+=2; - // determine the type - if (*end == '\"') - { - // string type - // truncate trailing " - ++end; - ACE_TCHAR* trailing = ACE_OS::strrchr (end, '"'); - if (trailing) - *trailing = 0; - if (config_.set_string_value (section, name, end)) - { - ACE_OS::fclose (in); - delete [] buffer; - return -4; - } - } - else if (ACE_OS::strncmp (end, ACE_TEXT ("dword:"), 6) == 0) - { - // number type - ACE_TCHAR* endptr = 0; - unsigned long value = ACE_OS::strtoul (end + 6, &endptr, 16); - if (config_.set_integer_value (section, name, value)) - { - ACE_OS::fclose (in); - delete [] buffer; - return -4; - } - } - else if (ACE_OS::strncmp (end, ACE_TEXT ("hex:"), 4) == 0) - { - // binary type - size_t string_length = ACE_OS::strlen (end + 4); - // divide by 3 to get the actual buffer length - size_t length = string_length / 3; - size_t remaining = length; - u_char* data = 0; - ACE_NEW_RETURN (data, - u_char[length], - -1); - u_char* out = data; - ACE_TCHAR* inb = end + 4; - ACE_TCHAR* endptr = 0; - while (remaining) - { - u_char charin = (u_char) ACE_OS::strtoul (inb, &endptr, 16); - *out = charin; - ++out; - --remaining; - inb += 3; - } - if (config_.set_binary_value (section, name, data, length)) - { - ACE_OS::fclose (in); - delete [] data; - delete [] buffer; - return -4; - } - else - delete [] data; - } - else - { - // invalid type, ignore - continue; - } - }// end if first char is a " - else - { - // if the first character is not a ", [, ;, or # we may be - // processing a file in the old format. - // Try and process the line as such and if it fails, - // return an error - int rc = process_previous_line_format (buffer, section); - if (rc != 0) - { - ACE_OS::fclose (in); - delete [] buffer; - return rc; - } - } // end if maybe old format - } // end while fgets - - if (ferror (in)) - { - ACE_OS::fclose (in); - delete [] buffer; - return -1; - } - - ACE_OS::fclose (in); - delete [] buffer; - return 0; -} - -// This method exports the entire configuration database to . -// Once the file is opened this method calls 'export_section' passing -// the root section. -int -ACE_Registry_ImpExp::export_config (const ACE_TCHAR* filename) -{ - if (0 == filename) - { - errno = EINVAL; - return -1; - } - int result = -1; - - FILE* out = ACE_OS::fopen (filename, ACE_TEXT ("w")); - if (out) - { - result = this->export_section (config_.root_section (), - ACE_TEXT (""), - out); - // The data may have been buffered and will be flush on close, - // so we need to check that the close succeeds. - if (ACE_OS::fclose (out) < 0) - result = -7; - } - return result; -} - -// Method provided by derived classes in order to write one section -// to the file specified. Called by export_config when exporting -// the entire configuration object. - -int -ACE_Registry_ImpExp::export_section (const ACE_Configuration_Section_Key& section, - const ACE_TString& path, - FILE* out) -{ - // don't export the root - if (path.length ()) - { - // Write out the section header - ACE_TString header = ACE_TEXT ("["); - header += path; - header += ACE_TEXT ("]"); - header += ACE_TEXT (" \n"); - if (ACE_OS::fputs (header.fast_rep (), out) < 0) - return -1; - // Write out each value - int index = 0; - ACE_TString name; - ACE_Configuration::VALUETYPE type; - ACE_TString line; - ACE_TCHAR int_value[32]; - ACE_TCHAR bin_value[3]; - void* binary_data; - size_t binary_length; - ACE_TString string_value; - while (!config_.enumerate_values (section, index, name, type)) - { - line = ACE_TEXT ("\"") + name + ACE_TEXT ("\"="); - switch (type) - { - case ACE_Configuration::INTEGER: - { - u_int value; - if (config_.get_integer_value (section, name.fast_rep (), value)) - return -2; - ACE_OS::sprintf (int_value, ACE_TEXT ("%08x"), value); - line += ACE_TEXT ("dword:"); - line += int_value; - break; - } - case ACE_Configuration::STRING: - { - if (config_.get_string_value (section, - name.fast_rep (), - string_value)) - return -2; - line += ACE_TEXT ("\""); - line += string_value + ACE_TEXT ("\""); - break; - } -#ifdef _WIN32 - case ACE_Configuration::INVALID: - break; // JDO added break. Otherwise INVALID is processed - // like BINARY. If that's correct, please remove the - // break and these comments -#endif - case ACE_Configuration::BINARY: - { - // not supported yet - maybe use BASE64 codeing? - if (config_.get_binary_value (section, - name.fast_rep (), - binary_data, - binary_length)) - return -2; - line += ACE_TEXT ("hex:"); - unsigned char* ptr = (unsigned char*)binary_data; - while (binary_length) - { - if (ptr != binary_data) - { - line += ACE_TEXT (","); - } - ACE_OS::sprintf (bin_value, ACE_TEXT ("%02x"), *ptr); - line += bin_value; - --binary_length; - ++ptr; - } - delete [] (char*) binary_data; - break; - } - default: - return -3; - } - line += ACE_TEXT ("\n"); - if (ACE_OS::fputs (line.fast_rep (), out) < 0) - return -4; - ++index; - } - } - // Export all sub sections - int index = 0; - ACE_TString name; - ACE_Configuration_Section_Key sub_key; - ACE_TString sub_section; - while (!config_.enumerate_sections (section, index, name)) - { - ACE_TString sub_section (path); - if (path.length ()) - sub_section += ACE_TEXT ("\\"); - sub_section += name; - if (config_.open_section (section, name.fast_rep (), 0, sub_key)) - return -5; - if (export_section (sub_key, sub_section.fast_rep (), out)) - return -6; - ++index; - } - return 0; -} - -// -// This method read the line format origionally used in ACE 5.1 -// -int -ACE_Registry_ImpExp::process_previous_line_format (ACE_TCHAR* buffer, - ACE_Configuration_Section_Key& section) -{ - // Chop any cr/lf at the end of the line. - ACE_TCHAR *endp = ACE_OS::strpbrk (buffer, ACE_TEXT ("\r\n")); - if (endp != 0) - *endp = '\0'; - - // assume this is a value, read in the value name - ACE_TCHAR* end = ACE_OS::strchr (buffer, '='); - if (end) // no =, not a value so just skip it - { - // null terminate the name - *end = 0; - ++end; - // determine the type - if (*end == '\"') - { - // string type - if(config_.set_string_value (section, buffer, end + 1)) - return -4; - } - else if (*end == '#') - { - // number type - u_int value = ACE_OS::atoi (end + 1); - if (config_.set_integer_value (section, buffer, value)) - return -4; - } - } - return 0; -} // end read_previous_line_format - - -ACE_Ini_ImpExp::ACE_Ini_ImpExp (ACE_Configuration& config) - : ACE_Config_ImpExp_Base (config) -{ -} - -ACE_Ini_ImpExp::~ACE_Ini_ImpExp (void) -{ -} - -// Method to read file and populate object. -int -ACE_Ini_ImpExp::import_config (const ACE_TCHAR* filename) -{ - if (0 == filename) - { - errno = EINVAL; - return -1; - } - FILE* in = ACE_OS::fopen (filename, ACE_TEXT ("r")); - if (!in) - return -1; - - // @@ Make this a dynamic size! - ACE_TCHAR buffer[4096]; - ACE_Configuration_Section_Key section; - while (ACE_OS::fgets (buffer, sizeof buffer, in)) - { - ACE_TCHAR *line = this->squish (buffer); - // Check for a comment and blank line - if (line[0] == ACE_TEXT (';') || - line[0] == ACE_TEXT ('#') || - line[0] == '\0') - continue; - - if (line[0] == ACE_TEXT ('[')) - { - // We have a new section here, strip out the section name - ACE_TCHAR* end = ACE_OS::strrchr (line, ACE_TEXT (']')); - if (!end) - { - ACE_OS::fclose (in); - return -3; - } - *end = 0; - - if (config_.expand_path (config_.root_section (), - line + 1, - section, - 1)) - { - ACE_OS::fclose (in); - return -3; - } - - continue; - } - - // We have a line; name ends at equal sign. - ACE_TCHAR *end = ACE_OS::strchr (line, ACE_TEXT ('=')); - if (end == 0) // No '=' - { - ACE_OS::fclose (in); - return -3; - } - *end++ = '\0'; - ACE_TCHAR *name = this->squish (line); -#if 0 - if (ACE_OS::strlen (name) == 0) // No name; just an '=' - { - ACE_OS::fclose (in); - return -3; - } -#endif - // Now find the start of the value - ACE_TCHAR *value = this->squish (end); - size_t value_len = ACE_OS::strlen (value); - if (value_len > 0) - { - // ACE 5.2 (and maybe earlier) exported strings may be enclosed - // in quotes. If string is quote-delimited, strip the quotes. - // Newer exported files don't have quote delimiters. - if (value[0] == ACE_TEXT ('"') && - value[value_len - 1] == ACE_TEXT ('"')) - { - // Strip quotes off both ends. - value[value_len - 1] = '\0'; - ++value; - } - } - - if (config_.set_string_value (section, name, value)) - { - ACE_OS::fclose (in); - return -4; - } - } // end while fgets - - if (ferror (in)) - { - ACE_OS::fclose (in); - return -1; - } - - ACE_OS::fclose (in); - return 0; -} - -// This method exports the entire configuration database to . -// Once the file is opened this method calls 'export_section' passing -// the root section. -int -ACE_Ini_ImpExp::export_config (const ACE_TCHAR* filename) -{ - if (0 == filename) - { - errno = EINVAL; - return -1; - } - int result = -1; - - FILE* out = ACE_OS::fopen (filename, ACE_TEXT ("w")); - if (out) - { - result = this->export_section (config_.root_section (), - ACE_TEXT (""), - out); - // The data may have been buffered and will be flush on close, - // so we need to check that the close succeeds. - if (ACE_OS::fclose (out) < 0) - result = -7; - } - return result; -} - -// Method provided by derived classes in order to write one section to the -// file specified. Called by export_config when exporting the entire -// configuration objet - -int -ACE_Ini_ImpExp::export_section (const ACE_Configuration_Section_Key& section, - const ACE_TString& path, - FILE* out) -{ - // don't export the root - if (path.length ()) - { - // Write out the section header - ACE_TString header = ACE_TEXT ("["); - header += path; - header += ACE_TEXT ("]\n"); - if (ACE_OS::fputs (header.fast_rep (), out) < 0) - return -1; - // Write out each value - int index = 0; - ACE_TString name; - ACE_Configuration::VALUETYPE type; - ACE_TString line; - ACE_TCHAR int_value[32]; - ACE_TCHAR bin_value[3]; - void* binary_data; - size_t binary_length; - ACE_TString string_value; - while (!config_.enumerate_values (section, index, name, type)) - { - line = name + ACE_TEXT ("="); - switch (type) - { - case ACE_Configuration::INTEGER: - { - u_int value; - if (config_.get_integer_value (section, name.fast_rep (), value)) - return -2; - ACE_OS::sprintf (int_value, ACE_TEXT ("%08x"), value); - line += int_value; - break; - } - case ACE_Configuration::STRING: - { - if (config_.get_string_value (section, - name.fast_rep (), - string_value)) - return -2; - line += string_value; - break; - } -#ifdef _WIN32 - case ACE_Configuration::INVALID: - break; // JDO added break. Otherwise INVALID is processed - // like BINARY. If that's correct, please remove the - // break and these comments -#endif - case ACE_Configuration::BINARY: - { - // not supported yet - maybe use BASE64 codeing? - if (config_.get_binary_value (section, - name.fast_rep (), - binary_data, - binary_length)) - return -2; - line += ACE_TEXT ("\""); - unsigned char* ptr = (unsigned char*)binary_data; - while (binary_length) - { - if (ptr != binary_data) - { - line += ACE_TEXT (","); - } - ACE_OS::sprintf (bin_value, ACE_TEXT ("%02x"), *ptr); - line += bin_value; - --binary_length; - ++ptr; - } - line += ACE_TEXT ("\""); - delete [] (char *) binary_data; - break; - } - default: - return -3; - - }// end switch on type - - line += ACE_TEXT ("\n"); - if (ACE_OS::fputs (line.fast_rep (), out) < 0) - return -4; - ++index; - }// end while enumerating values - } - // Export all sub sections - int index = 0; - ACE_TString name; - ACE_Configuration_Section_Key sub_key; - ACE_TString sub_section; - while (!config_.enumerate_sections (section, index, name)) - { - ACE_TString sub_section (path); - if (path.length ()) - sub_section += ACE_TEXT ("\\"); - sub_section += name; - if (config_.open_section (section, name.fast_rep (), 0, sub_key)) - return -5; - if (export_section (sub_key, sub_section.fast_rep (), out)) - return -6; - ++index; - } - return 0; - -} - -// Method to squish leading and trailing whitespaces from a string. -// Whitespace is defined as: spaces (' '), tabs ('\t') or end-of-line -// (cr/lf). The terminating nul is moved up to expunge trailing -// whitespace and the returned pointer points at the first -// non-whitespace character in the string, which may be the nul -// terminator if the string is all whitespace. - -ACE_TCHAR * -ACE_Ini_ImpExp::squish (ACE_TCHAR *src) -{ - ACE_TCHAR *cp = 0; - - if (src == 0) - return 0; - - // Start at the end and work backwards over all whitespace. - for (cp = src + ACE_OS::strlen (src) - 1; - cp != src; - --cp) - if (!ACE_OS::ace_isspace (*cp)) - break; - cp[1] = '\0'; // Chop trailing whitespace - - // Now start at the beginning and move over all whitespace. - for (cp = src; ACE_OS::ace_isspace (*cp); ++cp) - continue; - - return cp; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Configuration_Import_Export.h b/ACE/ace/Configuration_Import_Export.h deleted file mode 100644 index 41dc401e0c7..00000000000 --- a/ACE/ace/Configuration_Import_Export.h +++ /dev/null @@ -1,215 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file Configuration_Import_Export.h - * - * $Id$ - * - * @author Jerry D. Odenwelder Jr. - * Chris Hafey - * - * Classes defined in this file provide the ability to import and export - * ACE Configuration objects to/from disk files. The base class - * ACE_Config_ImpExp_Base provides the common functionality and the derived - * classes implement the import/export functionality for the specific format. - * - * @todo - * - Add locking for thread safety. - * - Provide ability to read file in one format and write in another. - * - See todo's in each class - */ -//============================================================================= - -#ifndef ACE_CONFIGURATION_IMPORT_EXPORT_H -#define ACE_CONFIGURATION_IMPORT_EXPORT_H -#include /**/ "ace/pre.h" - -#include "ace/Configuration.h" -#include "ace/SString.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Config_ImpExp_Base - * - * @brief Base class for file import/export configuration. - * - * This class provides base functionality for configuration objects - * that are persisted in files. It takes an ACE_Configuration - * object that it populates with the data read. - * - */ -class ACE_Export ACE_Config_ImpExp_Base -{ -public: - /// Constructor taking the ACE_Configuration to import/export to - ACE_Config_ImpExp_Base (ACE_Configuration& config); - - /** - * Destructor - */ - virtual ~ACE_Config_ImpExp_Base (void); - - /** - * Imports the configuration database from @a filename. - * No existing data is removed. - */ - virtual int import_config (const ACE_TCHAR* filename) = 0; - - /** - * This method exports the entire configuration database to @a filename. - * Once the file is opened this method calls 'export_section' passing - * the root section. - */ - virtual int export_config (const ACE_TCHAR* filename) = 0; - -protected: - ACE_Configuration &config_; - -private: - ACE_Config_ImpExp_Base (const ACE_Config_ImpExp_Base&); - ACE_Config_ImpExp_Base& operator= (const ACE_Config_ImpExp_Base&); -}; - -/** - * @class ACE_Registry_ImpExp - * - * @brief Configuration object that imports/exports data to a file formatted - * using the Win32 Registry file export format. This format looks like - * [Section] - * "key"="String Data" - * "key"=dword: numeric data in hexidecimal format - * "key"=hex: binary data - * - * @todo - * - Add dynamic buffer when importing. currently it will not allow - * importing of values greater than a fixed ammount (4096 bytes) - * - */ -class ACE_Export ACE_Registry_ImpExp : public ACE_Config_ImpExp_Base -{ -public: - /// Construction - ACE_Registry_ImpExp (ACE_Configuration&); - - /// Destruction. - virtual ~ACE_Registry_ImpExp (void); - - /** - * Imports the configuration database from filename. - * No existing data is removed. - */ - virtual int import_config (const ACE_TCHAR* filename); - - /** - * This method exports the entire configuration database to @a filename. - * Once the file is opened this method calls export_section() passing - * the root section. - */ - virtual int export_config (const ACE_TCHAR* filename); - -private: - int export_section (const ACE_Configuration_Section_Key& section, - const ACE_TString& path, - FILE* out); - - int process_previous_line_format (ACE_TCHAR* buffer, - ACE_Configuration_Section_Key& section); - - ACE_Registry_ImpExp ( const ACE_Registry_ImpExp&); - ACE_Registry_ImpExp& operator= ( const ACE_Registry_ImpExp&); -}; - -/** - * @class ACE_Ini_ImpExp - * - * @brief Imports the configuration database from filename as strings. - * Allows non-typed values. (no #, dword: hex:, etc. prefixes) and - * skips whitespace (tabs and spaces) as in standard .ini and .conf - * files. Values (to right of equal sign) can be double quote - * delimited to embed tabs and spaces in the string. - * Caller must convert string to type. - * - * This method allows for lines in the .ini or .conf file like this: - * - * TimeToLive = 100 - * Delay = FALSE - * Flags = FF34 - * Heading = "ACE - Adaptive Communication Environment" - * - * (note leading whitespace (tabs) in examples below) - * - * SeekIndex = 14 - * TraceLevel = 6 # Can comment lines like this - * Justification = left_justified - * - * The caller can then retrieve the string with the regular - * function and convert the string to the - * desired data type. - * - * @todo - * - Strings with embedded newlines cause the import to fail - * - Strings with embedded quotes " cause the import to fail - * - Importing/exporting for values in the root section does not work - * - Add dynamic buffer when importing. currently it will not allow - * importing of values greater than a fixed ammount (4096 bytes) -*/ -class ACE_Export ACE_Ini_ImpExp : public ACE_Config_ImpExp_Base -{ -public: - /** - * Construction - */ - ACE_Ini_ImpExp (ACE_Configuration&); - - /** - * Destructor - */ - virtual ~ACE_Ini_ImpExp (void); - - /** - * Imports the configuration database from filename. - * No existing data is removed. - */ - virtual int import_config (const ACE_TCHAR* filename); - - /** - * This method exports the entire configuration database to @a filename. - * Once the file is opened this method calls export_section() passing - * the root section. - */ - virtual int export_config (const ACE_TCHAR* filename); - -private: - /** - * Method provided by derived classes in order to write one section - * to the file specified. Called by export_config() when exporting - * the entire configuration object. - */ - int export_section (const ACE_Configuration_Section_Key& section, - const ACE_TString& path, - FILE* out); - - /** - * Method to squish leading and trailing whitespaces in a string. - * Whitespace is defined as: spaces (' '), tabs ('\\t') or cr/lf. - * Returns a pointer to the first non-whitespace character in the - * buffer provided, or a pointer to the terminating null if the string - * is all whitespace. The terminating null is moved forward to the - * first character past the last non-whitespace. - */ - ACE_TCHAR *squish (ACE_TCHAR *src); - - ACE_Ini_ImpExp (const ACE_Ini_ImpExp&); - ACE_Ini_ImpExp& operator= (const ACE_Ini_ImpExp&); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#include /**/ "ace/post.h" -#endif /* ACE_CONFIGURATION_IMPORT_EXPORT_H */ diff --git a/ACE/ace/Connection_Recycling_Strategy.cpp b/ACE/ace/Connection_Recycling_Strategy.cpp deleted file mode 100644 index c5bc6910d21..00000000000 --- a/ACE/ace/Connection_Recycling_Strategy.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "ace/Connection_Recycling_Strategy.h" - - -ACE_RCSID(ace, Connection_Recycling_Strategy, "$Id$") - - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_Connection_Recycling_Strategy::~ACE_Connection_Recycling_Strategy (void) -{ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Connection_Recycling_Strategy.h b/ACE/ace/Connection_Recycling_Strategy.h deleted file mode 100644 index fa9599f678c..00000000000 --- a/ACE/ace/Connection_Recycling_Strategy.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file Connection_Recycling_Strategy.h - * - * $Id$ - * - * @author Doug Schmidt - */ -//============================================================================= -#ifndef ACE_CONNECTION_RECYCLING_STRATEGY_H -#define ACE_CONNECTION_RECYCLING_STRATEGY_H -#include /**/ "ace/pre.h" - -#include "ace/Recyclable.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Connection_Recycling_Strategy - * - * @brief Defines the interface for a connection recycler. - */ -class ACE_Export ACE_Connection_Recycling_Strategy -{ -public: - /// Virtual Destructor - virtual ~ACE_Connection_Recycling_Strategy (void); - - /// Remove from cache. - virtual int purge (const void *recycling_act) = 0; - - /// Add to cache. - virtual int cache (const void *recycling_act) = 0; - - virtual int recycle_state (const void *recycling_act, - ACE_Recyclable_State new_state) = 0; - - /// Get/Set recycle_state. - virtual ACE_Recyclable_State recycle_state (const void *recycling_act) const = 0; - - /// Mark as closed. - virtual int mark_as_closed (const void *recycling_act) = 0; - - /// Mark as closed.(non-locking version) - virtual int mark_as_closed_i (const void *recycling_act) = 0; - - /// Cleanup hint and reset @a act_holder to zero if @a act_holder != 0. - virtual int cleanup_hint (const void *recycling_act, - void **act_holder = 0) = 0; - -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#include /**/ "ace/post.h" - -#endif /*ACE_CONNECTION_RECYCLING_STRATEGY*/ diff --git a/ACE/ace/Connector.cpp b/ACE/ace/Connector.cpp deleted file mode 100644 index 112fbca4003..00000000000 --- a/ACE/ace/Connector.cpp +++ /dev/null @@ -1,964 +0,0 @@ -// $Id$ - -#ifndef ACE_CONNECTOR_CPP -#define ACE_CONNECTOR_CPP - -#include "ace/Connector.h" -#include "ace/ACE.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_string.h" -#include "ace/os_include/os_fcntl.h" /* Has ACE_NONBLOCK */ - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_Connector) - -template -ACE_NonBlocking_Connect_Handler::ACE_NonBlocking_Connect_Handler -(ACE_Connector_Base &connector, - SVC_HANDLER *sh, - long id) - : connector_ (connector) - , svc_handler_ (sh) - , timer_id_ (id) -{ - ACE_TRACE ("ACE_NonBlocking_Connect_Handler::ACE_NonBlocking_Connect_Handler"); - - this->reference_counting_policy ().value - (ACE_Event_Handler::Reference_Counting_Policy::ENABLED); -} - -template SVC_HANDLER * -ACE_NonBlocking_Connect_Handler::svc_handler (void) -{ - ACE_TRACE ("ACE_NonBlocking_Connect_Handler::svc_handler"); - return this->svc_handler_; -} - -template long -ACE_NonBlocking_Connect_Handler::timer_id (void) -{ - ACE_TRACE ("ACE_NonBlocking_Connect_Handler::timer_id"); - return this->timer_id_; -} - -template void -ACE_NonBlocking_Connect_Handler::timer_id (long id) -{ - ACE_TRACE ("ACE_NonBlocking_Connect_Handler::timer_id"); - this->timer_id_ = id; -} - -template void -ACE_NonBlocking_Connect_Handler::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_NonBlocking_Connect_Handler::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("svc_handler_ = %x"), this->svc_handler_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntimer_id_ = %d"), this->timer_id_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -template bool -ACE_NonBlocking_Connect_Handler::close (SVC_HANDLER *&sh) -{ - // Make sure that we haven't already initialized the Svc_Handler. - if (!this->svc_handler_) - return false; - - { - // Exclusive access to the Reactor. - ACE_GUARD_RETURN (ACE_Lock, - ace_mon, - this->reactor ()->lock (), - 0); - - // Double check. - if (!this->svc_handler_) - return false; - - // Remember the Svc_Handler. - sh = this->svc_handler_; - ACE_HANDLE h = sh->get_handle (); - this->svc_handler_ = 0; - - // Remove this handle from the set of non-blocking handles - // in the Connector. - this->connector_.non_blocking_handles ().remove (h); - - // Cancel timer. - if (this->reactor ()->cancel_timer (this->timer_id (), - 0, - 0) == -1) - return false; - - // Remove from Reactor. - if (this->reactor ()->remove_handler ( - h, - ACE_Event_Handler::ALL_EVENTS_MASK) == -1) - return false; - } - - return true; -} - - -template int -ACE_NonBlocking_Connect_Handler::handle_timeout -(const ACE_Time_Value &tv, - const void *arg) -{ - // This method is called if a connection times out before completing. - ACE_TRACE ("ACE_NonBlocking_Connect_Handler::handle_timeout"); - - SVC_HANDLER *svc_handler = 0; - int retval = this->close (svc_handler) ? 0 : -1; - - // Forward to the SVC_HANDLER the that was passed in as a - // magic cookie during ACE_Connector::connect(). This gives the - // SVC_HANDLER an opportunity to take corrective action (e.g., wait - // a few milliseconds and try to reconnect again. - if (svc_handler != 0 && svc_handler->handle_timeout (tv, arg) == -1) - svc_handler->handle_close (svc_handler->get_handle (), - ACE_Event_Handler::TIMER_MASK); - - return retval; -} - - -template int -ACE_NonBlocking_Connect_Handler::handle_input (ACE_HANDLE) -{ - // Called when a failure occurs during asynchronous connection - // establishment. - ACE_TRACE ("ACE_NonBlocking_Connect_Handler::handle_input"); - - SVC_HANDLER *svc_handler = 0; - int const retval = this->close (svc_handler) ? 0 : -1; - - // Close Svc_Handler. - if (svc_handler != 0) - svc_handler->close (0); - - return retval; -} - -template int -ACE_NonBlocking_Connect_Handler::handle_output (ACE_HANDLE handle) -{ - // Called when a connection is establishment asynchronous. - ACE_TRACE ("ACE_NonBlocking_Connect_Handler::handle_output"); - - // Grab the connector ref before smashing ourselves in close(). - ACE_Connector_Base &connector = this->connector_; - SVC_HANDLER *svc_handler = 0; - int const retval = this->close (svc_handler) ? 0 : -1; - - if (svc_handler != 0) - connector.initialize_svc_handler (handle, svc_handler); - - return retval; -} - -template int -ACE_NonBlocking_Connect_Handler::handle_exception (ACE_HANDLE h) -{ - // On Win32, the except mask must also be set for asynchronous - // connects. - ACE_TRACE ("ACE_NonBlocking_Connect_Handler::handle_exception"); - return this->handle_output (h); -} - -template int -ACE_NonBlocking_Connect_Handler::resume_handler (void) -{ - return ACE_Event_Handler::ACE_EVENT_HANDLER_NOT_RESUMED; -} - -template void -ACE_Connector::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Connector::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nflags_ = %d"), this->flags_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -template int -ACE_Connector::make_svc_handler (SVC_HANDLER *&sh) -{ - ACE_TRACE ("ACE_Connector::make_svc_handler"); - - if (sh == 0) - ACE_NEW_RETURN (sh, - SVC_HANDLER, - -1); - - // Set the reactor of the newly created to the same - // reactor that this is using. - sh->reactor (this->reactor ()); - return 0; -} - -template int -ACE_Connector::activate_svc_handler (SVC_HANDLER *svc_handler) -{ - ACE_TRACE ("ACE_Connector::activate_svc_handler"); - // No errors initially - int error = 0; - - // See if we should enable non-blocking I/O on the 's - // peer. - if (ACE_BIT_ENABLED (this->flags_, ACE_NONBLOCK) != 0) - { - if (svc_handler->peer ().enable (ACE_NONBLOCK) == -1) - error = 1; - } - // Otherwise, make sure it's disabled by default. - else if (svc_handler->peer ().disable (ACE_NONBLOCK) == -1) - error = 1; - - // We are connected now, so try to open things up. - if (error || svc_handler->open ((void *) this) == -1) - { - // Make sure to close down the to avoid descriptor - // leaks. - svc_handler->close (0); - return -1; - } - else - return 0; -} - -template ACE_PEER_CONNECTOR & -ACE_Connector::connector (void) const -{ - return const_cast (this->connector_); -} - -template int -ACE_Connector::connect_svc_handler -(SVC_HANDLER *&svc_handler, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms) -{ - ACE_TRACE ("ACE_Connector::connect_svc_handler"); - - return this->connector_.connect (svc_handler->peer (), - remote_addr, - timeout, - local_addr, - reuse_addr, - flags, - perms); -} - -template int -ACE_Connector::connect_svc_handler -(SVC_HANDLER *&svc_handler, - SVC_HANDLER *&sh_copy, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms) -{ - ACE_TRACE ("ACE_Connector::connect_svc_handler"); - - sh_copy = svc_handler; - return this->connector_.connect (svc_handler->peer (), - remote_addr, - timeout, - local_addr, - reuse_addr, - flags, - perms); -} - -template int -ACE_Connector::open (ACE_Reactor *r, int flags) -{ - ACE_TRACE ("ACE_Connector::open"); - this->reactor (r); - this->flags_ = flags; - return 0; -} - -template -ACE_Connector::ACE_Connector (ACE_Reactor *r, - int flags) -{ - ACE_TRACE ("ACE_Connector::ACE_Connector"); - (void) this->open (r, flags); -} - -template int -ACE_Connector::connect -(SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - const ACE_Synch_Options &synch_options, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms) -{ - // Initiate connection to peer. - return this->connect_i (sh, - 0, - remote_addr, - synch_options, - local_addr, - reuse_addr, - flags, - perms); -} - -template int -ACE_Connector::connect -(SVC_HANDLER *&sh, - SVC_HANDLER *&sh_copy, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - const ACE_Synch_Options &synch_options, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms) -{ - // Initiate connection to peer. - return this->connect_i (sh, - &sh_copy, - remote_addr, - synch_options, - local_addr, - reuse_addr, - flags, - perms); -} - -template int -ACE_Connector::connect_i -(SVC_HANDLER *&sh, - SVC_HANDLER **sh_copy, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - const ACE_Synch_Options &synch_options, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms) -{ - ACE_TRACE ("ACE_Connector::connect_i"); - - // If the user hasn't supplied us with a we'll use the - // factory method to create one. Otherwise, things will remain as - // they are... - if (this->make_svc_handler (sh) == -1) - return -1; - - ACE_Time_Value *timeout = 0; - int const use_reactor = synch_options[ACE_Synch_Options::USE_REACTOR]; - - if (use_reactor) - timeout = const_cast (&ACE_Time_Value::zero); - else - timeout = const_cast (synch_options.time_value ()); - - int result; - if (sh_copy == 0) - result = this->connect_svc_handler (sh, - remote_addr, - timeout, - local_addr, - reuse_addr, - flags, - perms); - else - result = this->connect_svc_handler (sh, - *sh_copy, - remote_addr, - timeout, - local_addr, - reuse_addr, - flags, - perms); - - // Activate immediately if we are connected. - if (result != -1) - return this->activate_svc_handler (sh); - - // Delegate to connection strategy. - if (use_reactor && ACE_OS::last_error () == EWOULDBLOCK) - { - // If the connection hasn't completed and we are using - // non-blocking semantics then register - // ACE_NonBlocking_Connect_Handler with the ACE_Reactor so that - // it will call us back when the connection is complete or we - // timeout, whichever comes first... - int result; - - if (sh_copy == 0) - result = this->nonblocking_connect (sh, synch_options); - else - result = this->nonblocking_connect (*sh_copy, synch_options); - - // If for some reason the call failed, then - // will be set to the new error. If the call succeeds, however, - // we need to make sure that remains set to - // . - if (result == 0) - errno = EWOULDBLOCK; - } - else - { - // Save/restore errno. - ACE_Errno_Guard error (errno); - // Make sure to close down the service handler to avoid handle - // leaks. - if (sh_copy == 0) - { - if (sh) - sh->close (0); - } - else if (*sh_copy) - (*sh_copy)->close (0); - } - - return -1; -} - -template int -ACE_Connector::connect_n -(size_t n, - SVC_HANDLER *sh[], - ACE_PEER_CONNECTOR_ADDR remote_addrs[], - ACE_TCHAR *failed_svc_handlers, - const ACE_Synch_Options &synch_options) -{ - int result = 0; - - for (size_t i = 0; i < n; i++) - { - if (this->connect (sh[i], remote_addrs[i], synch_options) == -1 - && !(synch_options[ACE_Synch_Options::USE_REACTOR] - && errno == EWOULDBLOCK)) - { - result = -1; - if (failed_svc_handlers != 0) - // Mark this entry as having failed. - failed_svc_handlers[i] = 1; - } - else if (failed_svc_handlers != 0) - // Mark this entry as having succeeded. - failed_svc_handlers[i] = 0; - } - - return result; -} - -// Cancel a that was started asynchronously. -template int -ACE_Connector::cancel (SVC_HANDLER *sh) -{ - ACE_TRACE ("ACE_Connector::cancel"); - - ACE_Event_Handler *handler = - this->reactor ()->find_handler (sh->get_handle ()); - - if (handler == 0) - return -1; - - // find_handler() increments handler's refcount; ensure we decrement it. - ACE_Event_Handler_var safe_handler (handler); - - NBCH *nbch = - dynamic_cast (handler); - - if (nbch == 0) - return -1; - - SVC_HANDLER *tmp_sh = 0; - - if (nbch->close (tmp_sh) == false) - return -1; - - return 0; -} - -template int -ACE_Connector::nonblocking_connect -(SVC_HANDLER *sh, - const ACE_Synch_Options &synch_options) -{ - ACE_TRACE ("ACE_Connector::nonblocking_connect"); - - // Must have a valid Reactor for non-blocking connects to work. - if (this->reactor () == 0) - return -1; - - // Register the pending SVC_HANDLER so that it can be activated - // later on when the connection completes. - - ACE_HANDLE handle = sh->get_handle (); - long timer_id = -1; - ACE_Time_Value *tv = 0; - NBCH *nbch = 0; - - ACE_NEW_RETURN (nbch, - NBCH (*this, - sh, - -1), - -1); - - ACE_Event_Handler_var safe_nbch (nbch); - - // Exclusive access to the Reactor. - ACE_GUARD_RETURN (ACE_Lock, ace_mon, this->reactor ()->lock (), -1); - - // Register handle with the reactor for connection events. - ACE_Reactor_Mask mask = ACE_Event_Handler::CONNECT_MASK; - if (this->reactor ()->register_handler (handle, - nbch, - mask) == -1) - goto reactor_registration_failure; - - // Add handle to non-blocking handle set. - this->non_blocking_handles ().insert (handle); - - // If we're starting connection under timer control then we need to - // schedule a timeout with the ACE_Reactor. - tv = const_cast (synch_options.time_value ()); - if (tv != 0) - { - timer_id = - this->reactor ()->schedule_timer (nbch, - synch_options.arg (), - *tv); - if (timer_id == -1) - goto timer_registration_failure; - - // Remember timer id. - nbch->timer_id (timer_id); - } - - return 0; - - // Undo previous actions using the ol' "goto label and fallthru" - // trick... - timer_registration_failure: - - // Remove from Reactor. - this->reactor ()->remove_handler (handle, mask); - - // Remove handle from the set of non-blocking handles. - this->non_blocking_handles ().remove (handle); - - /* FALLTHRU */ - - reactor_registration_failure: - // Close the svc_handler - - sh->close (0); - - return -1; -} - -template -ACE_Connector::~ACE_Connector (void) -{ - ACE_TRACE ("ACE_Connector::~ACE_Connector"); - - this->close (); -} - -template void -ACE_Connector::initialize_svc_handler -(ACE_HANDLE handle, - SVC_HANDLER *svc_handler) -{ - // Try to find out if the reactor uses event associations for the - // handles it waits on. If so we need to reset it. - int reset_new_handle = - this->reactor ()->uses_event_associations (); - - if (reset_new_handle) - this->connector_.reset_new_handle (handle); - - // Transfer ownership of the ACE_HANDLE to the SVC_HANDLER. - svc_handler->set_handle (handle); - - ACE_PEER_CONNECTOR_ADDR raddr; - - // Check to see if we're connected. - if (svc_handler->peer ().get_remote_addr (raddr) != -1) - this->activate_svc_handler (svc_handler); - else // Somethings gone wrong, so close down... - { -#if defined (ACE_WIN32) - // Win32 (at least prior to Windows 2000) has a timing problem. - // If you check to see if the connection has completed too fast, - // it will fail - so wait 35 milliseconds to let it catch up. - ACE_Time_Value tv (0, ACE_NON_BLOCKING_BUG_DELAY); - ACE_OS::sleep (tv); - if (svc_handler->peer ().get_remote_addr (raddr) != -1) - this->activate_svc_handler (svc_handler); - else // do the svc handler close below... -#endif /* ACE_WIN32 */ - svc_handler->close (0); - } -} - -template void -ACE_Connector::reactor (ACE_Reactor *reactor) -{ - this->reactor_ = reactor; -} - -template ACE_Reactor * -ACE_Connector::reactor (void) const -{ - return this->reactor_; -} - -template ACE_Unbounded_Set & -ACE_Connector::non_blocking_handles (void) -{ - return this->non_blocking_handles_; -} - -template int -ACE_Connector::close (void) -{ - // If there are no non-blocking handle pending, return immediately. - if (this->non_blocking_handles ().size () == 0) - return 0; - - // Exclusive access to the Reactor. - ACE_GUARD_RETURN (ACE_Lock, ace_mon, this->reactor ()->lock (), -1); - - // Go through all the non-blocking handles. It is necessary to - // create a new iterator each time because we remove from the handle - // set when we cancel the Svc_Handler. - ACE_HANDLE *handle = 0; - while (1) - { - ACE_Unbounded_Set_Iterator - iterator (this->non_blocking_handles ()); - if (!iterator.next (handle)) - break; - - ACE_Event_Handler *handler = - this->reactor ()->find_handler (*handle); - if (handler == 0) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%t: Connector::close h %d, no handler\n"), - *handle)); - // Remove handle from the set of non-blocking handles. - this->non_blocking_handles ().remove (*handle); - continue; - } - - // find_handler() incremented handler's refcount; ensure it's decremented - ACE_Event_Handler_var safe_handler (handler); - NBCH *nbch = dynamic_cast (handler); - if (nbch == 0) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%t: Connector::close h %d handler %@ ") - ACE_TEXT ("not a legit handler\n"), - *handle, - handler)); - // Remove handle from the set of non-blocking handles. - this->non_blocking_handles ().remove (*handle); - continue; - } - SVC_HANDLER *svc_handler = nbch->svc_handler (); - - // Cancel the non-blocking connection. - this->cancel (svc_handler); - - // Close the associated Svc_Handler. - svc_handler->close (0); - } - - return 0; -} - -template int -ACE_Connector::fini (void) -{ - ACE_TRACE ("ACE_Connector::fini"); - - return this->close (); -} - -// Hook called by the explicit dynamic linking facility. - -template int -ACE_Connector::init (int, ACE_TCHAR *[]) -{ - ACE_TRACE ("ACE_Connector::init"); - return -1; -} - -template int -ACE_Connector::suspend (void) -{ - ACE_TRACE ("ACE_Connector::suspend"); - return -1; -} - -template int -ACE_Connector::resume (void) -{ - ACE_TRACE ("ACE_Connector::resume"); - return -1; -} - -template int -ACE_Connector::info (ACE_TCHAR **strp, size_t length) const -{ - ACE_TRACE ("ACE_Connector::info"); - ACE_TCHAR buf[BUFSIZ]; - - ACE_OS::sprintf (buf, - ACE_TEXT ("%s\t %s"), - ACE_TEXT ("ACE_Connector"), - ACE_TEXT ("# connector factory\n")); - - if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) - return -1; - else - ACE_OS::strsncpy (*strp, buf, length); - return static_cast (ACE_OS::strlen (buf)); -} - -template int -ACE_Strategy_Connector::open (ACE_Reactor *r, - int flags) -{ - ACE_TRACE ("ACE_Strategy_Connector::open"); - return this->open (r, 0, 0, 0, flags); -} - -template int -ACE_Strategy_Connector::open -(ACE_Reactor *r, - ACE_Creation_Strategy *cre_s, - ACE_Connect_Strategy *conn_s, - ACE_Concurrency_Strategy *con_s, - int flags) -{ - ACE_TRACE ("ACE_Strategy_Connector::open"); - - this->reactor (r); - - // @@ Not implemented yet. - // this->flags_ = flags; - ACE_UNUSED_ARG (flags); - - // Initialize the creation strategy. - - // First we decide if we need to clean up. - if (this->creation_strategy_ != 0 && - this->delete_creation_strategy_ && - cre_s != 0) - { - delete this->creation_strategy_; - this->creation_strategy_ = 0; - this->delete_creation_strategy_ = false; - } - - if (cre_s != 0) - this->creation_strategy_ = cre_s; - else if (this->creation_strategy_ == 0) - { - ACE_NEW_RETURN (this->creation_strategy_, - CREATION_STRATEGY, - -1); - this->delete_creation_strategy_ = true; - } - - - // Initialize the accept strategy. - - if (this->connect_strategy_ != 0 && - this->delete_connect_strategy_ && - conn_s != 0) - { - delete this->connect_strategy_; - this->connect_strategy_ = 0; - this->delete_connect_strategy_ = false; - } - - if (conn_s != 0) - this->connect_strategy_ = conn_s; - else if (this->connect_strategy_ == 0) - { - ACE_NEW_RETURN (this->connect_strategy_, - CONNECT_STRATEGY, - -1); - this->delete_connect_strategy_ = true; - } - - // Initialize the concurrency strategy. - - if (this->concurrency_strategy_ != 0 && - this->delete_concurrency_strategy_ && - con_s != 0) - { - delete this->concurrency_strategy_; - this->concurrency_strategy_ = 0; - this->delete_concurrency_strategy_ = false; - } - - if (con_s != 0) - this->concurrency_strategy_ = con_s; - else if (this->concurrency_strategy_ == 0) - { - ACE_NEW_RETURN (this->concurrency_strategy_, - CONCURRENCY_STRATEGY, - -1); - this->delete_concurrency_strategy_ = true; - } - - return 0; -} - -template -ACE_Strategy_Connector::ACE_Strategy_Connector -(ACE_Reactor *reactor, - ACE_Creation_Strategy *cre_s, - ACE_Connect_Strategy *conn_s, - ACE_Concurrency_Strategy *con_s, - int flags) - : creation_strategy_ (0), - delete_creation_strategy_ (false), - connect_strategy_ (0), - delete_connect_strategy_ (false), - concurrency_strategy_ (0), - delete_concurrency_strategy_ (false) -{ - ACE_TRACE ("ACE_Connector::ACE_Strategy_Connector"); - - if (this->open (reactor, cre_s, conn_s, con_s, flags) == -1) - ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_Strategy_Connector::ACE_Strategy_Connector"))); -} - -template -ACE_Strategy_Connector::~ACE_Strategy_Connector (void) -{ - ACE_TRACE ("ACE_Strategy_Connector::~ACE_Strategy_Connector"); - - // Close down - this->close (); -} - -template int -ACE_Strategy_Connector::close (void) -{ - if (this->delete_creation_strategy_) - delete this->creation_strategy_; - this->delete_creation_strategy_ = false; - this->creation_strategy_ = 0; - - if (this->delete_connect_strategy_) - delete this->connect_strategy_; - this->delete_connect_strategy_ = false; - this->connect_strategy_ = 0; - - if (this->delete_concurrency_strategy_) - delete this->concurrency_strategy_; - this->delete_concurrency_strategy_ = false; - this->concurrency_strategy_ = 0; - - return SUPER::close (); -} - -template int -ACE_Strategy_Connector::make_svc_handler (SVC_HANDLER *&sh) -{ - return this->creation_strategy_->make_svc_handler (sh); -} - -template int -ACE_Strategy_Connector::connect_svc_handler -(SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms) -{ - return this->connect_strategy_->connect_svc_handler (sh, - remote_addr, - timeout, - local_addr, - reuse_addr, - flags, - perms); -} - -template int -ACE_Strategy_Connector::connect_svc_handler -(SVC_HANDLER *&sh, - SVC_HANDLER *&sh_copy, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms) -{ - return this->connect_strategy_->connect_svc_handler (sh, - sh_copy, - remote_addr, - timeout, - local_addr, - reuse_addr, - flags, - perms); -} - -template int -ACE_Strategy_Connector::activate_svc_handler (SVC_HANDLER *svc_handler) -{ - return this->concurrency_strategy_->activate_svc_handler (svc_handler, this); -} - -template ACE_Creation_Strategy * -ACE_Strategy_Connector::creation_strategy (void) const -{ - return this->creation_strategy_; -} - -template ACE_Connect_Strategy * -ACE_Strategy_Connector::connect_strategy (void) const -{ - return this->connect_strategy_; -} - -template ACE_Concurrency_Strategy * -ACE_Strategy_Connector::concurrency_strategy (void) const -{ - return this->concurrency_strategy_; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_CONNECTOR_C */ diff --git a/ACE/ace/Connector.h b/ACE/ace/Connector.h deleted file mode 100644 index 0b92d55efcd..00000000000 --- a/ACE/ace/Connector.h +++ /dev/null @@ -1,563 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Connector.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_CONNECTOR_H -#define ACE_CONNECTOR_H - -#include /**/ "ace/pre.h" - -#include "ace/Service_Object.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Strategies_T.h" -#include "ace/Synch_Options.h" -#include "ace/Unbounded_Set.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Connector_Base - * - * @brief This base interface allows ACE_NonBlocking_Connect_Handler - * to only care about the SVC_HANDLER template parameter of the - * ACE_Connector. Otherwise, ACE_NonBlocking_Connect_Handler would - * have to be configured with all the template parameters that - * ACE_Connector is configured with. - */ -template -class ACE_Connector_Base -{ -public: - - virtual ~ACE_Connector_Base (void) {} - - /// Initialize the Svc_Handler. - virtual void initialize_svc_handler (ACE_HANDLE handle, - SVC_HANDLER *svc_handler) = 0; - - /// Return the handle set representing the non-blocking connects in - /// progress. - virtual ACE_Unbounded_Set &non_blocking_handles (void) = 0; -}; - -/** - * @class ACE_NonBlocking_Connect_Handler - * - * @brief Performs non-blocking connects on behalf of the Connector. - */ -template -class ACE_NonBlocking_Connect_Handler : public ACE_Event_Handler -{ -public: - - /// Constructor. - ACE_NonBlocking_Connect_Handler (ACE_Connector_Base &connector, - SVC_HANDLER *, - long timer_id); - - /// Close up and return underlying SVC_HANDLER through @c sh. - /** - * If the return value is true the close was performed succesfully, - * implying that this object was removed from the reactor and thereby - * (by means of reference counting decremented to 0) deleted. - * If the return value is false, the close was not successful. - * The @c sh does not have any connection to the return - * value. The argument will return a valid svc_handler object if a - * valid one exists within the object. Returning a valid svc_handler - * pointer also invalidates the svc_handler contained in this - * object. - */ - bool close (SVC_HANDLER *&sh); - - /// Get SVC_HANDLER. - SVC_HANDLER *svc_handler (void); - - /// Get handle. - ACE_HANDLE handle (void); - - /// Set handle. - void handle (ACE_HANDLE); - - /// Get timer id. - long timer_id (void); - - /// Set timer id. - void timer_id (long timer_id); - - /// Called by ACE_Reactor when asynchronous connections fail. - virtual int handle_input (ACE_HANDLE); - - /// Called by ACE_Reactor when asynchronous connections succeed. - virtual int handle_output (ACE_HANDLE); - - /// Called by ACE_Reactor when asynchronous connections suceeds (on - /// some platforms only). - virtual int handle_exception (ACE_HANDLE fd); - - /// This method is called if a connection times out before - /// completing. - virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg); - - /// Should Reactor resume us if we have been suspended before the upcall? - virtual int resume_handler (void); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - - /// Connector base. - ACE_Connector_Base &connector_; - - /// Associated SVC_HANDLER. - SVC_HANDLER *svc_handler_; - - /// Associated timer id. - long timer_id_; -}; - -/** - * @class ACE_Connector - * - * @brief Generic factory for actively connecting clients and creating - * service handlers (SVC_HANDLERs). - * - * Implements the strategy for actively establishing connections with - * clients. An ACE_Connector is parameterized by concrete types that - * conform to the interfaces of PEER_CONNECTOR and SVC_HANDLER. The - * PEER_CONNECTOR is instantiated with a transport mechanism that - * actively establishes connections. The SVC_HANDLER is instantiated - * with a concrete type that performs the application-specific - * service. Both blocking and non-blocking connects are supported. - * Further, non-blocking connects support timeouts. - */ -template -class ACE_Connector : public ACE_Connector_Base, public ACE_Service_Object -{ -public: - - // Useful STL-style traits. - typedef typename SVC_HANDLER::addr_type addr_type; - typedef ACE_PEER_CONNECTOR connector_type; - typedef SVC_HANDLER handler_type; - typedef typename SVC_HANDLER::stream_type stream_type; - typedef typename ACE_PEER_CONNECTOR::PEER_ADDR peer_addr_type; - typedef ACE_PEER_CONNECTOR_ADDR ACE_PEER_ADDR_TYPEDEF; - - /** - * Initialize a connector. @a flags indicates how SVC_HANDLER's - * should be initialized prior to being activated. Right now, the - * only flag that is processed is ACE_NONBLOCK, which enabled - * non-blocking I/O on the SVC_HANDLER when it is opened. - */ - ACE_Connector (ACE_Reactor *r = ACE_Reactor::instance (), - int flags = 0); - - /** - * Initialize a connector. @a flags indicates how SVC_HANDLER's - * should be initialized prior to being activated. Right now, the - * only flag that is processed is ACE_NONBLOCK, which enabled - * non-blocking I/O on the SVC_HANDLER when it is opened. - */ - virtual int open (ACE_Reactor *r = ACE_Reactor::instance (), - int flags = 0); - - /// Shutdown a connector and release resources. - virtual ~ACE_Connector (void); - - // = Connection establishment methods. - - /** - * Initiate connection of @a svc_handler to peer at @a remote_addr - * using @a synch_options. If the caller wants to designate the - * selected @a local_addr they can (and can also insist that the - * @a local_addr be reused by passing a value @a reuse_addr == - * 1). @a flags and @a perms can be used to pass any flags that are - * needed to perform specific operations such as opening a file - * within connect with certain permissions. If the connection fails - * the hook on the will be called - * automatically to prevent resource leaks. - */ - virtual int connect (SVC_HANDLER *&svc_handler, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - const ACE_Synch_Options &synch_options = ACE_Synch_Options::defaults, - const ACE_PEER_CONNECTOR_ADDR &local_addr - = (peer_addr_type &) ACE_PEER_CONNECTOR_ADDR_ANY, - int reuse_addr = 0, - int flags = O_RDWR, - int perms = 0); - - /** - * This is a variation on the previous method. On cached - * connectors the @a svc_handler_hint variable can be used as a hint - * for future lookups. Since this variable is modified in the - * context of the internal cache its use is thread-safe. But the - * actual svc_handler for the current connection is returned in the - * second parameter @a svc_handler. If the connection fails the - * hook on the will be called automatically to - * prevent resource leaks. - */ - virtual int connect (SVC_HANDLER *&svc_handler_hint, - SVC_HANDLER *&svc_handler, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - const ACE_Synch_Options &synch_options = ACE_Synch_Options::defaults, - const ACE_PEER_CONNECTOR_ADDR &local_addr - = (peer_addr_type &) ACE_PEER_CONNECTOR_ADDR_ANY, - int reuse_addr = 0, - int flags = O_RDWR, - int perms = 0); - - /** - * Initiate connection of @a n @a svc_handlers to peers at - * @a remote_addrs using @a synch_options. Returns -1 if failure - * occurs and 0 otherwise. If @a failed_svc_handlers is non-NULL, a - * 1 is placed in the corresponding index of @a failed_svc_handlers - * for each that failed to connect, else a 0 is - * placed in that index. - */ - virtual int connect_n (size_t n, - SVC_HANDLER *svc_handlers[], - ACE_PEER_CONNECTOR_ADDR remote_addrs[], - ACE_TCHAR *failed_svc_handlers = 0, - const ACE_Synch_Options &synch_options = - ACE_Synch_Options::defaults); - - /** - * Cancel the @a svc_handler that was started asynchronously. Note that - * this is the only case when the Connector does not actively close - * the @a svc_handler. It is left up to the caller of to - * decide the fate of the @a svc_handler. - */ - virtual int cancel (SVC_HANDLER *svc_handler); - - /// Close down the Connector. All pending non-blocking connects are - /// canceled and the corresponding svc_handler is closed. - virtual int close (void); - - /// Return the underlying PEER_CONNECTOR object. - virtual ACE_PEER_CONNECTOR &connector (void) const; - - /// Initialize Svc_Handler. - virtual void initialize_svc_handler (ACE_HANDLE handle, - SVC_HANDLER *svc_handler); - - /// Set Reactor. - virtual void reactor (ACE_Reactor *reactor); - - /// Get Reactor. - virtual ACE_Reactor *reactor (void) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - // = Helpful typedefs. - typedef ACE_NonBlocking_Connect_Handler NBCH; - - // = The following two methods define the Connector's strategies for - // creating, connecting, and activating SVC_HANDLER's, respectively. - - /** - * Bridge method for creating a SVC_HANDLER. The default is to - * create a new SVC_HANDLER only if @a sh == 0, else @a sh is - * unchanged. However, subclasses can override this policy to - * perform SVC_HANDLER creation in any way that they like (such as - * creating subclass instances of SVC_HANDLER, using a singleton, - * dynamically linking the handler, etc.). Returns -1 if failure, - * else 0. - */ - virtual int make_svc_handler (SVC_HANDLER *&sh); - - /** - * Bridge method for connecting the @a svc_handler to the - * @a remote_addr. The default behavior delegates to the - * . - */ - virtual int connect_svc_handler (SVC_HANDLER *&svc_handler, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms); - virtual int connect_svc_handler (SVC_HANDLER *&svc_handler, - SVC_HANDLER *&sh_copy, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms); - - /** - * Bridge method for activating a @a svc_handler with the appropriate - * concurrency strategy. The default behavior of this method is to - * activate the SVC_HANDLER by calling its method (which - * allows the SVC_HANDLER to define its own concurrency strategy). - * However, subclasses can override this strategy to do more - * sophisticated concurrency activations (such as creating the - * SVC_HANDLER as an "active object" via multi-threading or - * multi-processing). - */ - virtual int activate_svc_handler (SVC_HANDLER *svc_handler); - - /// Creates and registers ACE_NonBlocking_Connect_Handler. - int nonblocking_connect (SVC_HANDLER *, - const ACE_Synch_Options &); - - /// Implementation of the connect methods. - virtual int connect_i (SVC_HANDLER *&svc_handler, - SVC_HANDLER **sh_copy, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - const ACE_Synch_Options &synch_options, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms); - - /// Return the handle set representing the non-blocking connects in - /// progress. - ACE_Unbounded_Set &non_blocking_handles (void); - - // = Dynamic linking hooks. - /// Default version does no work and returns -1. Must be overloaded - /// by application developer to do anything meaningful. - virtual int init (int argc, ACE_TCHAR *argv[]); - - /// Calls handle_close() to shutdown the Connector gracefully. - virtual int fini (void); - - /// Default version returns address info in @a buf. - virtual int info (ACE_TCHAR **strp, size_t length) const; - - // = Service management hooks. - /// Default version does no work and returns -1. Must be overloaded - /// by application developer to do anything meaningful. - virtual int suspend (void); - - /// Default version does no work and returns -1. Must be overloaded - /// by application developer to do anything meaningful. - virtual int resume (void); - -private: - /// This is the peer connector factory. - ACE_PEER_CONNECTOR connector_; - - /** - * Flags that indicate how SVC_HANDLER's should be initialized - * prior to being activated. Right now, the only flag that is - * processed is ACE_NONBLOCK, which enabled non-blocking I/O on - * the SVC_HANDLER when it is opened. - */ - int flags_; - - /// Pointer to the Reactor. - ACE_Reactor *reactor_; - - /// Handle set representing the non-blocking connects in progress. - ACE_Unbounded_Set non_blocking_handles_; - -}; - -/** - * @class ACE_Strategy_Connector - * - * @brief Abstract factory for creating a service handler - * (SVC_HANDLER), connecting the SVC_HANDLER, and activating the - * SVC_HANDLER. - * - * Implements a flexible and extensible set of strategies for - * actively establishing connections with clients. There are - * three main strategies: (1) creating a SVC_HANDLER, (2) - * actively initiating a new connection from the client, - * and (3) activating the SVC_HANDLER with a - * particular concurrency mechanism after the connection is established. - */ -template -class ACE_Strategy_Connector - : public ACE_Connector -{ -public: - - // Useful STL-style traits. - typedef ACE_Creation_Strategy - creation_strategy_type; - typedef ACE_Connect_Strategy - connect_strategy_type; - typedef ACE_Concurrency_Strategy - concurrency_strategy_type; - typedef ACE_Connector - base_type; - - // = Define some useful (old style) traits. - typedef ACE_Creation_Strategy - CREATION_STRATEGY; - typedef ACE_Connect_Strategy - CONNECT_STRATEGY; - typedef ACE_Concurrency_Strategy - CONCURRENCY_STRATEGY; - typedef ACE_Connector - SUPER; - - /** - * Initialize a connector. @a flags indicates how 's - * should be initialized prior to being activated. Right now, the - * only flag that is processed is ACE_NONBLOCK, which enabled - * non-blocking I/O on the SVC_HANDLER when it is opened. - */ - ACE_Strategy_Connector (ACE_Reactor *r = ACE_Reactor::instance (), - ACE_Creation_Strategy * = 0, - ACE_Connect_Strategy * = 0, - ACE_Concurrency_Strategy * = 0, - int flags = 0); - - /** - * Initialize a connector. @a flags indicates how SVC_HANDLER's - * should be initialized prior to being activated. Right now, the - * only flag that is processed is ACE_NONBLOCK, which enabled - * non-blocking I/O on the SVC_HANDLER when it is opened. - * Default strategies would be created and used. - */ - virtual int open (ACE_Reactor *r, - int flags); - - /** - * Initialize a connector. @a flags indicates how SVC_HANDLER's - * should be initialized prior to being activated. Right now, the - * only flag that is processed is ACE_NONBLOCK, which enabled - * non-blocking I/O on the SVC_HANDLER when it is opened. - */ - virtual int open (ACE_Reactor *r = ACE_Reactor::instance (), - ACE_Creation_Strategy * = 0, - ACE_Connect_Strategy * = 0, - ACE_Concurrency_Strategy * = 0, - int flags = 0); - - /// Shutdown a connector and release resources. - virtual ~ACE_Strategy_Connector (void); - - /// Close down the Connector - virtual int close (void); - - // = Strategies accessors - virtual ACE_Creation_Strategy *creation_strategy (void) const; - virtual ACE_Connect_Strategy *connect_strategy (void) const; - virtual ACE_Concurrency_Strategy *concurrency_strategy (void) const; - -protected: - // = The following three methods define the 's strategies - // for creating, connecting, and activating SVC_HANDLER's, - // respectively. - - /** - * Bridge method for creating a SVC_HANDLER. The strategy for - * creating a SVC_HANDLER are configured into the Connector via - * it's . The default is to create a new - * SVC_HANDLER only if @a sh == 0, else @a sh is unchanged. - * However, subclasses can override this policy to perform - * SVC_HANDLER creation in any way that they like (such as - * creating subclass instances of SVC_HANDLER, using a singleton, - * dynamically linking the handler, etc.). Returns -1 if failure, - * else 0. - */ - virtual int make_svc_handler (SVC_HANDLER *&sh); - - /** - * Bridge method for connecting the new connection into the - * SVC_HANDLER. The default behavior delegates to the - * in the . - */ - virtual int connect_svc_handler (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms); - - /** - * Bridge method for connecting the new connection into the - * SVC_HANDLER. The default behavior delegates to the - * in the . - * @a sh_copy is used to obtain a copy of the @a sh pointer, but that - * can be kept in the stack; the motivation is a bit too long to - * include here, but basically we want to modify @a sh safely, using - * the internal locks in the Connect_Strategy, while saving a TSS - * copy in @a sh_copy, usually located in the stack. - */ - virtual int connect_svc_handler (SVC_HANDLER *&sh, - SVC_HANDLER *&sh_copy, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms); - - /** - * Bridge method for activating a SVC_HANDLER with the appropriate - * concurrency strategy. The default behavior of this method is to - * activate the SVC_HANDLER by calling its method (which - * allows the SVC_HANDLER to define its own concurrency strategy). - * However, subclasses can override this strategy to do more - * sophisticated concurrency activations (such as creating the - * SVC_HANDLER as an "active object" via multi-threading or - * multi-processing). - */ - virtual int activate_svc_handler (SVC_HANDLER *svc_handler); - - // = Strategy objects. - - /// Creation strategy for an Connector. - CREATION_STRATEGY *creation_strategy_; - - /// true if Connector created the creation strategy and thus should - /// delete it, else false. - bool delete_creation_strategy_; - - /// Connect strategy for a Connector. - CONNECT_STRATEGY *connect_strategy_; - - /// true if Connector created the connect strategy and thus should - /// delete it, else false. - bool delete_connect_strategy_; - - /// Concurrency strategy for an . - CONCURRENCY_STRATEGY *concurrency_strategy_; - - /// true if Connector created the concurrency strategy and thus should - /// delete it, else false. - bool delete_concurrency_strategy_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Connector.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Connector.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" - -#endif /* ACE_CONNECTOR_H */ diff --git a/ACE/ace/Containers.cpp b/ACE/ace/Containers.cpp deleted file mode 100644 index 2904225a3c9..00000000000 --- a/ACE/ace/Containers.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// $Id$ - -#include "ace/Containers.h" - -ACE_RCSID (ace, - Containers, - "$Id$") - -#if !defined (__ACE_INLINE__) -#include "ace/Containers.inl" -#endif /* __ACE_INLINE__ */ - diff --git a/ACE/ace/Containers.h b/ACE/ace/Containers.h deleted file mode 100644 index 8fd886394b0..00000000000 --- a/ACE/ace/Containers.h +++ /dev/null @@ -1,71 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Containers.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_CONTAINERS_H -#define ACE_CONTAINERS_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template class ACE_Double_Linked_List; -template class ACE_Double_Linked_List_Iterator_Base; -template class ACE_Double_Linked_List_Iterator; -template class ACE_Double_Linked_List_Reverse_Iterator; - -/** - * @class ACE_DLList_Node - * - * @brief Base implementation of element in a DL list. Needed for - * ACE_Double_Linked_List. - */ -class ACE_Export ACE_DLList_Node -{ -public: - friend class ACE_Double_Linked_List; - friend class ACE_Double_Linked_List_Iterator_Base; - friend class ACE_Double_Linked_List_Iterator; - friend class ACE_Double_Linked_List_Reverse_Iterator; - - ACE_DLList_Node (void *i, - ACE_DLList_Node *n = 0, - ACE_DLList_Node *p = 0); - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - - void *item_; - - ACE_DLList_Node *next_; - ACE_DLList_Node *prev_; - -protected: - ACE_DLList_Node (void); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Containers.inl" -#endif /* __ACE_INLINE__ */ - -#include "ace/Containers_T.h" - -#include /**/ "ace/post.h" - -#endif /* ACE_CONTAINERS_H */ diff --git a/ACE/ace/Containers.inl b/ACE/ace/Containers.inl deleted file mode 100644 index 01b7a243891..00000000000 --- a/ACE/ace/Containers.inl +++ /dev/null @@ -1,25 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_DLList_Node::ACE_DLList_Node (void) - : item_ (0), - next_ (0), - prev_ (0) -{ -} - -ACE_INLINE -ACE_DLList_Node::ACE_DLList_Node (void *i, - ACE_DLList_Node *n, - ACE_DLList_Node *p) - : item_ (i), - next_ (n), - prev_ (p) -{ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Containers_T.cpp b/ACE/ace/Containers_T.cpp deleted file mode 100644 index c28e3e1fc41..00000000000 --- a/ACE/ace/Containers_T.cpp +++ /dev/null @@ -1,1930 +0,0 @@ -// $Id$ - -#ifndef ACE_CONTAINERS_T_CPP -#define ACE_CONTAINERS_T_CPP - -#include "ace/Log_Msg.h" -#include "ace/Malloc_Base.h" -#include "ace/OS_Memory.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Containers.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Containers_T.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Stack) - -template void -ACE_Bounded_Stack::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Bounded_Stack::dump"); -#endif /* ACE_HAS_DUMP */ -} - -template -ACE_Bounded_Stack::ACE_Bounded_Stack (size_t size) - : size_ (size), - top_ (0) -{ - ACE_NEW (this->stack_, - T[size]); - ACE_TRACE ("ACE_Bounded_Stack::ACE_Bounded_Stack"); -} - -template -ACE_Bounded_Stack::ACE_Bounded_Stack (const ACE_Bounded_Stack &s) - : size_ (s.size_), - top_ (s.top_) -{ - ACE_NEW (this->stack_, - T[s.size_]); - - ACE_TRACE ("ACE_Bounded_Stack::ACE_Bounded_Stack"); - - for (size_t i = 0; i < this->top_; i++) - this->stack_[i] = s.stack_[i]; -} - -template void -ACE_Bounded_Stack::operator= (const ACE_Bounded_Stack &s) -{ - ACE_TRACE ("ACE_Bounded_Stack::operator="); - - if (&s != this) - { - if (this->size_ < s.size_) - { - delete [] this->stack_; - ACE_NEW (this->stack_, - T[s.size_]); - this->size_ = s.size_; - } - this->top_ = s.top_; - - for (size_t i = 0; i < this->top_; i++) - this->stack_[i] = s.stack_[i]; - } -} - -template -ACE_Bounded_Stack::~ACE_Bounded_Stack (void) -{ - ACE_TRACE ("ACE_Bounded_Stack::~ACE_Bounded_Stack"); - delete [] this->stack_; -} - -// ---------------------------------------- - -ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Stack) - -template void -ACE_Fixed_Stack::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Fixed_Stack::dump"); -#endif /* ACE_HAS_DUMP */ -} - -template -ACE_Fixed_Stack::ACE_Fixed_Stack (void) - : size_ (ACE_SIZE), - top_ (0) -{ - ACE_TRACE ("ACE_Fixed_Stack::ACE_Fixed_Stack"); -} - -template -ACE_Fixed_Stack::ACE_Fixed_Stack (const ACE_Fixed_Stack &s) - : size_ (s.size_), - top_ (s.top_) -{ - ACE_TRACE ("ACE_Fixed_Stack::ACE_Fixed_Stack"); - for (size_t i = 0; i < this->top_; i++) - this->stack_[i] = s.stack_[i]; -} - -template void -ACE_Fixed_Stack::operator= (const ACE_Fixed_Stack &s) -{ - ACE_TRACE ("ACE_Fixed_Stack::operator="); - - if (&s != this) - { - this->top_ = s.top_; - - for (size_t i = 0; i < this->top_; i++) - this->stack_[i] = s.stack_[i]; - } -} - -template -ACE_Fixed_Stack::~ACE_Fixed_Stack (void) -{ - ACE_TRACE ("ACE_Fixed_Stack::~ACE_Fixed_Stack"); -} - -//---------------------------------------- - -ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Stack) - -template void -ACE_Unbounded_Stack::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - // ACE_TRACE ("ACE_Unbounded_Stack::dump"); -#endif /* ACE_HAS_DUMP */ -} - -template -ACE_Unbounded_Stack::ACE_Unbounded_Stack (ACE_Allocator *alloc) - : head_ (0), - cur_size_ (0), - allocator_ (alloc) -{ - // ACE_TRACE ("ACE_Unbounded_Stack::ACE_Unbounded_Stack"); - if (this->allocator_ == 0) - this->allocator_ = ACE_Allocator::instance (); - - ACE_NEW_MALLOC (this->head_, - (ACE_Node *) this->allocator_->malloc (sizeof (ACE_Node)), - ACE_Node); - this->head_->next_ = this->head_; -} - -template void -ACE_Unbounded_Stack::delete_all_nodes (void) -{ - // ACE_TRACE ("ACE_Unbounded_Stack::delete_all_nodes"); - - while (this->is_empty () == 0) - { - ACE_Node *temp = this->head_->next_; - this->head_->next_ = temp->next_; - ACE_DES_FREE_TEMPLATE (temp, this->allocator_->free, - ACE_Node, ); - } - - this->cur_size_ = 0; - - ACE_ASSERT (this->head_ == this->head_->next_ - && this->is_empty ()); -} - -template void -ACE_Unbounded_Stack::copy_all_nodes (const ACE_Unbounded_Stack &s) -{ - // ACE_TRACE ("ACE_Unbounded_Stack::copy_all_nodes"); - - ACE_ASSERT (this->head_ == this->head_->next_); - - ACE_Node *temp = this->head_; - - for (ACE_Node *s_temp = s.head_->next_; - s_temp != s.head_; - s_temp = s_temp->next_) - { - ACE_Node *nptr = temp->next_; - ACE_NEW_MALLOC (temp->next_, - (ACE_Node *) this->allocator_->malloc (sizeof (ACE_Node)), - ACE_Node (s_temp->item_, nptr)); - temp = temp->next_; - } - this->cur_size_ = s.cur_size_; -} - -template -ACE_Unbounded_Stack::ACE_Unbounded_Stack (const ACE_Unbounded_Stack &s) - : head_ (0), - cur_size_ (0), - allocator_ (s.allocator_) -{ - if (this->allocator_ == 0) - this->allocator_ = ACE_Allocator::instance (); - - ACE_NEW_MALLOC (this->head_, - (ACE_Node *) this->allocator_->malloc (sizeof (ACE_Node)), - ACE_Node); - this->head_->next_ = this->head_; - - // ACE_TRACE ("ACE_Unbounded_Stack::ACE_Unbounded_Stack"); - this->copy_all_nodes (s); -} - -template void -ACE_Unbounded_Stack::operator= (const ACE_Unbounded_Stack &s) -{ - // ACE_TRACE ("ACE_Unbounded_Stack::operator="); - - if (this != &s) - { - this->delete_all_nodes (); - this->copy_all_nodes (s); - } -} - -template -ACE_Unbounded_Stack::~ACE_Unbounded_Stack (void) -{ - // ACE_TRACE ("ACE_Unbounded_Stack::~ACE_Unbounded_Stack"); - - this->delete_all_nodes (); - ACE_DES_FREE_TEMPLATE (head_, - this->allocator_->free, - ACE_Node, - ); -} - -template int -ACE_Unbounded_Stack::push (const T &new_item) -{ - // ACE_TRACE ("ACE_Unbounded_Stack::push"); - - ACE_Node *temp = 0; - - ACE_NEW_MALLOC_RETURN (temp, - static_cast *> (this->allocator_->malloc (sizeof (ACE_Node))), - ACE_Node (new_item, this->head_->next_), - -1); - this->head_->next_ = temp; - ++this->cur_size_; - return 0; -} - -template int -ACE_Unbounded_Stack::pop (T &item) -{ - // ACE_TRACE ("ACE_Unbounded_Stack::pop"); - - if (this->is_empty ()) - return -1; - else - { - ACE_Node *temp = this->head_->next_; - item = temp->item_; - this->head_->next_ = temp->next_; - - ACE_DES_FREE_TEMPLATE (temp, - this->allocator_->free, - ACE_Node, - ); - --this->cur_size_; - return 0; - } -} - -template int -ACE_Unbounded_Stack::find (const T &item) const -{ - // ACE_TRACE ("ACE_Unbounded_Stack::find"); - // Set into the dummy node. - this->head_->item_ = item; - - ACE_Node *temp = this->head_->next_; - - // Keep looping until we find the item. - while (!(temp->item_ == item)) - temp = temp->next_; - - // If we found the dummy node then it's not really there, otherwise, - // it is there. - return temp == this->head_ ? -1 : 0; -} - -template int -ACE_Unbounded_Stack::insert (const T &item) -{ - // ACE_TRACE ("ACE_Unbounded_Stack::insert"); - - if (this->find (item) == 0) - return 1; - else - return this->push (item); -} - -template int -ACE_Unbounded_Stack::remove (const T &item) -{ - // ACE_TRACE ("ACE_Unbounded_Stack::remove"); - - // Insert the item to be founded into the dummy node. - this->head_->item_ = item; - - ACE_Node *curr = this->head_; - - while (!(curr->next_->item_ == item)) - curr = curr->next_; - - if (curr->next_ == this->head_) - return -1; // Item was not found. - else - { - ACE_Node *temp = curr->next_; - // Skip over the node that we're deleting. - curr->next_ = temp->next_; - --this->cur_size_; - ACE_DES_FREE_TEMPLATE (temp, - this->allocator_->free, - ACE_Node, - ); - return 0; - } -} - -//-------------------------------------------------- -ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List_Iterator_Base) - -template -ACE_Double_Linked_List_Iterator_Base::ACE_Double_Linked_List_Iterator_Base (const ACE_Double_Linked_List &dll) - : current_ (0), dllist_ (&dll) -{ - // Do nothing -} - -template -ACE_Double_Linked_List_Iterator_Base::ACE_Double_Linked_List_Iterator_Base (const ACE_Double_Linked_List_Iterator_Base &iter) - : current_ (iter.current_), - dllist_ (iter.dllist_) -{ - // Do nothing -} - - -template T * -ACE_Double_Linked_List_Iterator_Base::next (void) const -{ - return this->not_done (); -} - -template int -ACE_Double_Linked_List_Iterator_Base::next (T *&ptr) const -{ - ptr = this->not_done (); - return ptr ? 1 : 0; -} - - -template int -ACE_Double_Linked_List_Iterator_Base::done (void) const -{ - return this->not_done () ? 0 : 1; -} - -template T & -ACE_Double_Linked_List_Iterator_Base::operator* (void) const -{ - return *(this->not_done ()); -} - -// @@ Is this a valid retasking? Make sure to check with Purify and -// whatnot that we're not leaking memory or doing any other screwing things. -template void -ACE_Double_Linked_List_Iterator_Base::reset (ACE_Double_Linked_List &dll) -{ - current_ = 0; - dllist_ = &dll; -} - - template int -ACE_Double_Linked_List_Iterator_Base::go_head (void) -{ - this->current_ = static_cast (dllist_->head_->next_); - return this->current_ ? 1 : 0; -} - -template int -ACE_Double_Linked_List_Iterator_Base::go_tail (void) -{ - this->current_ = static_cast (dllist_->head_->prev_); - return this->current_ ? 1 : 0; -} - -template T * -ACE_Double_Linked_List_Iterator_Base::not_done (void) const -{ - if (this->current_ != this->dllist_->head_) - return this->current_; - else - return 0; -} - -template T * -ACE_Double_Linked_List_Iterator_Base::do_advance (void) -{ - if (this->not_done ()) - { - this->current_ = static_cast (this->current_->next_); - return this->not_done (); - } - else - return 0; -} - -template T * -ACE_Double_Linked_List_Iterator_Base::do_retreat (void) -{ - if (this->not_done ()) - { - this->current_ = static_cast (this->current_->prev_); - return this->not_done (); - } - else - return 0; -} - -template void -ACE_Double_Linked_List_Iterator_Base::dump_i (void) const -{ - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("current_ = %x"), this->current_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -} - -//-------------------------------------------------- -ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List_Iterator) - -template -ACE_Double_Linked_List_Iterator::ACE_Double_Linked_List_Iterator (const ACE_Double_Linked_List &dll) - : ACE_Double_Linked_List_Iterator_Base (dll) -{ - this->current_ = static_cast (dll.head_->next_); - // Advance current_ out of the null area and onto the first item in - // the list -} - -template void -ACE_Double_Linked_List_Iterator::reset (ACE_Double_Linked_List &dll) -{ - this->ACE_Double_Linked_List_Iterator_Base ::reset (dll); - this->current_ = static_cast (dll.head_->next_); - // Advance current_ out of the null area and onto the first item in - // the list -} - -template int -ACE_Double_Linked_List_Iterator::first (void) -{ - return this->go_head (); -} - -template int -ACE_Double_Linked_List_Iterator::advance (void) -{ - return this->do_advance () ? 1 : 0; -} - -template T* -ACE_Double_Linked_List_Iterator::advance_and_remove (int dont_remove) -{ - T* item = 0; - if (dont_remove) - this->do_advance (); - else - { - item = this->next (); - this->do_advance (); - // It seems dangerous to remove nodes in an iterator, but so it goes... - ACE_Double_Linked_List *dllist = - const_cast *> (this->dllist_); - dllist->remove (item); - } - return item; -} - -template void -ACE_Double_Linked_List_Iterator::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - this->dump_i (); -#endif /* ACE_HAS_DUMP */ -} - -// Prefix advance. - -template -ACE_Double_Linked_List_Iterator & -ACE_Double_Linked_List_Iterator::operator++ (void) -{ - this->do_advance (); - return *this; -} - - -// Postfix advance. - -template -ACE_Double_Linked_List_Iterator -ACE_Double_Linked_List_Iterator::operator++ (int) -{ - ACE_Double_Linked_List_Iterator retv (*this); - this->do_advance (); - return retv; -} - - -// Prefix reverse. - -template -ACE_Double_Linked_List_Iterator & -ACE_Double_Linked_List_Iterator::operator-- (void) -{ - this->do_retreat (); - return *this; -} - - -// Postfix reverse. - -template -ACE_Double_Linked_List_Iterator -ACE_Double_Linked_List_Iterator::operator-- (int) -{ - ACE_Double_Linked_List_Iterator retv (*this); - this->do_retreat (); - return retv; -} - - -//-------------------------------------------------- -ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List_Reverse_Iterator) - - template -ACE_Double_Linked_List_Reverse_Iterator::ACE_Double_Linked_List_Reverse_Iterator (ACE_Double_Linked_List &dll) - : ACE_Double_Linked_List_Iterator_Base (dll) -{ - this->current_ = static_cast (dll.head_->prev_); - // Advance current_ out of the null area and onto the last item in - // the list -} - -template void -ACE_Double_Linked_List_Reverse_Iterator::reset (ACE_Double_Linked_List &dll) -{ - this->ACE_Double_Linked_List_Iterator_Base ::reset (dll); - this->current_ = static_cast (dll.head_->prev_); - // Advance current_ out of the null area and onto the last item in - // the list -} - -template int -ACE_Double_Linked_List_Reverse_Iterator::first (void) -{ - return this->go_tail (); -} - -template int -ACE_Double_Linked_List_Reverse_Iterator::advance (void) -{ - return this->do_retreat () ? 1 : 0; -} - -template T* -ACE_Double_Linked_List_Reverse_Iterator::advance_and_remove (int dont_remove) -{ - T* item = 0; - if (dont_remove) - this->do_retreat (); - else - { - item = this->next (); - this->do_retreat (); - // It seems dangerous to remove nodes in an iterator, but so it goes... - ACE_Double_Linked_List *dllist = - const_cast *> (this->dllist_); - dllist->remove (item); - } - return item; -} - -template void -ACE_Double_Linked_List_Reverse_Iterator::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - this->dump_i (); -#endif /* ACE_HAS_DUMP */ -} - -// Prefix advance. - -template -ACE_Double_Linked_List_Reverse_Iterator & -ACE_Double_Linked_List_Reverse_Iterator::operator++ (void) -{ - this->do_retreat (); - return *this; -} - - -// Postfix advance. - -template -ACE_Double_Linked_List_Reverse_Iterator -ACE_Double_Linked_List_Reverse_Iterator::operator++ (int) -{ - ACE_Double_Linked_List_Reverse_Iterator retv (*this); - this->do_retreat (); - return retv; -} - - -// Prefix reverse. - -template -ACE_Double_Linked_List_Reverse_Iterator & -ACE_Double_Linked_List_Reverse_Iterator::operator-- (void) -{ - this->do_advance (); - return *this; -} - - -// Postfix reverse. - -template -ACE_Double_Linked_List_Reverse_Iterator -ACE_Double_Linked_List_Reverse_Iterator::operator-- (int) -{ - ACE_Double_Linked_List_Reverse_Iterator retv (*this); - this->do_advance (); - return retv; -} - - -ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List) - - template -ACE_Double_Linked_List:: ACE_Double_Linked_List (ACE_Allocator *alloc) - : size_ (0), allocator_ (alloc) -{ - if (this->allocator_ == 0) - this->allocator_ = ACE_Allocator::instance (); - - ACE_NEW_MALLOC (this->head_, - (T *) this->allocator_->malloc (sizeof (T)), - T); - this->init_head (); -} - -template -ACE_Double_Linked_List::ACE_Double_Linked_List (const ACE_Double_Linked_List &cx) - : allocator_ (cx.allocator_) -{ - if (this->allocator_ == 0) - this->allocator_ = ACE_Allocator::instance (); - - ACE_NEW_MALLOC (this->head_, - (T *) this->allocator_->malloc (sizeof (T)), - T); - this->init_head (); - this->copy_nodes (cx); - this->size_ = cx.size_; -} - -template void -ACE_Double_Linked_List::operator= (const ACE_Double_Linked_List &cx) -{ - if (this != &cx) - { - this->delete_nodes (); - this->copy_nodes (cx); - } -} - -template -ACE_Double_Linked_List::~ACE_Double_Linked_List (void) -{ - this->delete_nodes (); - - ACE_DES_FREE (head_, - this->allocator_->free, - T); - - this->head_ = 0; -} - -template int -ACE_Double_Linked_List::is_empty (void) const -{ - return this->size () ? 0 : 1; -} - -template int -ACE_Double_Linked_List::is_full (void) const -{ - return 0; // We have no bound. -} - -template T * -ACE_Double_Linked_List::insert_tail (T *new_item) -{ - // Insert it before , i.e., at tail. - this->insert_element (new_item, 1); - return new_item; -} - -template T * -ACE_Double_Linked_List::insert_head (T *new_item) -{ - this->insert_element (new_item); // Insert it after , i.e., at head. - return new_item; -} - -template T * -ACE_Double_Linked_List::delete_head (void) -{ - if (this->is_empty ()) - return 0; - - T *temp = static_cast (this->head_->next_); - // Detach it from the list. - this->remove_element (temp); - return temp; -} - -template T * -ACE_Double_Linked_List::delete_tail (void) -{ - if (this->is_empty ()) - return 0; - - T *temp = static_cast (this->head_->prev_); - // Detach it from the list. - this->remove_element (temp); - return temp; -} - -template void -ACE_Double_Linked_List::reset (void) -{ - this->delete_nodes (); -} - -template int -ACE_Double_Linked_List::get (T *&item, size_t slot) -{ - ACE_Double_Linked_List_Iterator iter (*this); - - for (size_t i = 0; - i < slot && !iter.done (); - i++) - iter.advance (); - - item = iter.next (); - return item ? 0 : -1; -} - -template size_t -ACE_Double_Linked_List::size (void) const -{ - return this->size_; -} - -template void -ACE_Double_Linked_List::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - // Dump the state of an object. -#endif /* ACE_HAS_DUMP */ -} - -#if 0 -template T * -ACE_Double_Linked_List::find (const T &item) -{ - for (ACE_Double_Linked_List_Iterator iter (*this); - !iter.done (); - iter.advance ()) - { - T *temp = iter.next (); - - if (*temp == item) - return temp; - } - - return 0; -} - -template int -ACE_Double_Linked_List::remove (const T &item) -{ - T *temp = this->find (item); - - if (temp != 0) - return this->remove (temp); - else - return -1; -} -#endif /* 0 */ - -template int -ACE_Double_Linked_List::remove (T *n) -{ - return this->remove_element (n); -} - -template void -ACE_Double_Linked_List::delete_nodes (void) -{ - while (! this->is_empty ()) - { - T * temp = static_cast (this->head_->next_); - this->remove_element (temp); - ACE_DES_FREE (temp, - this->allocator_->free, - T); - } -} - -template void -ACE_Double_Linked_List::copy_nodes (const ACE_Double_Linked_List &c) -{ - for (ACE_Double_Linked_List_Iterator iter (c); - !iter.done (); - iter.advance ()) - { - T* temp = 0; - ACE_NEW_MALLOC (temp, - (T *)this->allocator_->malloc (sizeof (T)), - T (*iter.next ())); - this->insert_tail (temp); - } -} - -template void -ACE_Double_Linked_List::init_head (void) -{ - this->head_->next_ = this->head_; - this->head_->prev_ = this->head_; -} - -template int -ACE_Double_Linked_List::insert_element (T *new_item, - int before, - T *old_item) -{ - if (old_item == 0) - old_item = this->head_; - - if (before) - old_item = static_cast (old_item->prev_); - - new_item->next_ = old_item->next_; - new_item->next_->prev_ = new_item; - new_item->prev_ = old_item; - old_item->next_ = new_item; - ++this->size_; - return 0; // Well, what will cause errors here? -} - -template int -ACE_Double_Linked_List::remove_element (T *item) -{ - // Notice that you have to ensure that item is an element of this - // list. We can't do much checking here. - - if (item == this->head_ || item->next_ == 0 - || item->prev_ == 0 || this->size () == 0) // Can't remove head - return -1; - - item->prev_->next_ = item->next_; - item->next_->prev_ = item->prev_; - item->next_ = item->prev_ = 0; // reset pointers to prevent double removal. - --this->size_; - return 0; -} - -//-------------------------------------------------- -ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set) - -template size_t -ACE_Fixed_Set::size (void) const -{ - ACE_TRACE ("ACE_Fixed_Set::size"); - return this->cur_size_; -} - -template void -ACE_Fixed_Set::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Fixed_Set::dump"); -#endif /* ACE_HAS_DUMP */ -} - -template -ACE_Fixed_Set::~ACE_Fixed_Set (void) -{ - ACE_TRACE ("ACE_Fixed_Set::~ACE_Fixed_Set"); - this->cur_size_ = 0; -} - -template -ACE_Fixed_Set::ACE_Fixed_Set (const ACE_Fixed_Set &fs) - : cur_size_ (fs.cur_size_) -{ - ACE_TRACE ("ACE_Fixed_Set::ACE_Fixed_Set"); - - for (size_t i = 0, j = 0; i < fs.max_size_ && j < this->cur_size_; ++i) - if (fs.search_structure_[i].is_free_ == 0) - this->search_structure_[j++] = fs.search_structure_[i]; -} - -template void -ACE_Fixed_Set::operator= (const ACE_Fixed_Set &fs) -{ - ACE_TRACE ("ACE_Fixed_Set::operator="); - - if (this != &fs) - { - this->cur_size_ = fs.cur_size_; - - for (size_t i = 0, j = 0; i < fs.max_size_ && j < this->cur_size_; ++i) - if (fs.search_structure_[i].is_free_ == 0) - this->search_structure_[j++] = fs.search_structure_[i]; - } -} - -template -ACE_Fixed_Set::ACE_Fixed_Set (void) - : cur_size_ (0), - max_size_ (ACE_SIZE) -{ - ACE_TRACE ("ACE_Fixed_Set::ACE_Fixed_Set"); - for (size_t i = 0; i < this->max_size_; i++) - this->search_structure_[i].is_free_ = 1; -} - -template int -ACE_Fixed_Set::find (const T &item) const -{ - ACE_TRACE ("ACE_Fixed_Set::find"); - - for (size_t i = 0, j = 0; i < this->max_size_ && j < this->cur_size_; ++i) - if (this->search_structure_[i].is_free_ == 0) - { - if (this->search_structure_[i].item_ == item) - return 0; - ++j; - } - - return -1; -} - -template int -ACE_Fixed_Set::insert (const T &item) -{ - ACE_TRACE ("ACE_Fixed_Set::insert"); - ssize_t first_free = -1; // Keep track of first free slot. - size_t i; - - for (i = 0; - i < this->max_size_ && first_free == -1; - ++i) - - // First, make sure we don't allow duplicates. - - if (this->search_structure_[i].is_free_ == 0) - { - if (this->search_structure_[i].item_ == item) - return 1; - } - else - first_free = static_cast (i); - - // If we found a free spot let's reuse it. - - if (first_free > -1) - { - this->search_structure_[first_free].item_ = item; - this->search_structure_[first_free].is_free_ = 0; - this->cur_size_++; - return 0; - } - else /* No more room! */ - { - errno = ENOMEM; - return -1; - } -} - -template int -ACE_Fixed_Set::remove (const T &item) -{ - ACE_TRACE ("ACE_Fixed_Set::remove"); - - for (size_t i = 0, j = 0; - i < this->max_size_ && j < this->cur_size_; - ++i) - if (this->search_structure_[i].is_free_ == 0) - { - if (this->search_structure_[i].item_ == item) - { - // Mark this entry as being free. - this->search_structure_[i].is_free_ = 1; - - --this->cur_size_; - return 0; - } - else - ++j; - } - - return -1; -} - -//-------------------------------------------------- -ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set_Iterator_Base) - -template void -ACE_Fixed_Set_Iterator_Base::dump_i (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Fixed_Set_Iterator_Base::dump_i"); -#endif /* ACE_HAS_DUMP */ -} - -template -ACE_Fixed_Set_Iterator_Base::ACE_Fixed_Set_Iterator_Base (ACE_Fixed_Set &s) - : s_ (s), - next_ (-1), - iterated_items_ (0) -{ - ACE_TRACE ("ACE_Fixed_Set_Iterator_Base::ACE_Fixed_Set_Iterator_Base"); - this->advance (); -} - -template int -ACE_Fixed_Set_Iterator_Base::advance (void) -{ - ACE_TRACE ("ACE_Fixed_Set_Iterator_Base::advance"); - - if (this->iterated_items_ < this->s_.cur_size_) - { - for (++this->next_; - static_cast (this->next_) < this->s_.max_size_; - ++this->next_) - if (this->s_.search_structure_[this->next_].is_free_ == 0) - { - ++this->iterated_items_; - return 1; - } - } - else - ++this->next_; - - return 0; -} - -template int -ACE_Fixed_Set_Iterator_Base::first (void) -{ - ACE_TRACE ("ACE_Fixed_Set_Iterator_Base::first"); - - next_ = -1; - iterated_items_ = 0; - return this->advance (); -} - -template int -ACE_Fixed_Set_Iterator_Base::done (void) const -{ - ACE_TRACE ("ACE_Fixed_Set_Iterator_Base::done"); - - return ! (this->iterated_items_ < this->s_.cur_size_); -} - -template int -ACE_Fixed_Set_Iterator_Base::next_i (T *&item) -{ - ACE_TRACE ("ACE_Fixed_Set_Iterator_Base::next_i"); - - if (static_cast (this->next_) < this->s_.max_size_) - do - { - if (this->s_.search_structure_[this->next_].is_free_ == 0) - { - item = &this->s_.search_structure_[this->next_].item_; - this->advance (); - return 1; - } - } - while (this->advance () == 1); - - return 0; -} - -//-------------------------------------------------- -ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set_Iterator) - -template void -ACE_Fixed_Set_Iterator::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - this->dump_i (); -#endif /* ACE_HAS_DUMP */ -} - -template -ACE_Fixed_Set_Iterator::ACE_Fixed_Set_Iterator (ACE_Fixed_Set &s) - : ACE_Fixed_Set_Iterator_Base (s) -{ - ACE_TRACE ("ACE_Fixed_Set_Iterator::ACE_Fixed_Set_Iterator"); -} - -template int -ACE_Fixed_Set_Iterator::next (T *&item) -{ - ACE_TRACE ("ACE_Fixed_Set_Iterator::next"); - return this->next_i (item); -} - -template int -ACE_Fixed_Set_Iterator::remove (T *&item) -{ - ACE_TRACE ("ACE_Fixed_Set_Iterator::remove"); - - if (this->s_.search_structure_[this->next_].is_free_ == 0) - { - item = &this->s_.search_structure_[this->next_].item_; - this->s_.remove (*item); - --(this->iterated_items_); - return 1; - } - - return 0; -} - -template T& -ACE_Fixed_Set_Iterator::operator* (void) -{ - T *retv = 0; - - if (this->s_.search_structure_[this->next_].is_free_ == 0) - retv = &this->s_.search_structure_[this->next_].item_; - - ACE_ASSERT (retv != 0); - - return *retv; -} - -//-------------------------------------------------- -ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set_Const_Iterator) - -template void -ACE_Fixed_Set_Const_Iterator::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - this->dump_i (); -#endif /* ACE_HAS_DUMP */ -} - -template -ACE_Fixed_Set_Const_Iterator::ACE_Fixed_Set_Const_Iterator (const ACE_Fixed_Set &s) - : ACE_Fixed_Set_Iterator_Base (s) -{ - ACE_TRACE ("ACE_Fixed_Set_Const_Iterator::ACE_Fixed_Set_Const_Iterator"); -} - -template int -ACE_Fixed_Set_Const_Iterator::next (const T *&item) -{ - ACE_TRACE ("ACE_Fixed_Set_Const_Iterator::next"); - - return this->next_i (item); -} - -template const T& -ACE_Fixed_Set_Const_Iterator::operator* (void) const -{ - const T *retv = 0; - - if (this->s_.search_structure_[this->next_].is_free_ == 0) - retv = &this->s_.search_structure_[this->next_].item_; - - ACE_ASSERT (retv != 0); - - return *retv; -} - -//-------------------------------------------------- -ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Set) - -template void -ACE_Bounded_Set::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Bounded_Set::dump"); -#endif /* ACE_HAS_DUMP */ -} - -template -ACE_Bounded_Set::~ACE_Bounded_Set (void) -{ - ACE_TRACE ("ACE_Bounded_Set::~ACE_Bounded_Set"); - delete [] this->search_structure_; -} - -template -ACE_Bounded_Set::ACE_Bounded_Set (void) - : cur_size_ (0), - max_size_ (static_cast (ACE_Bounded_Set::DEFAULT_SIZE)) -{ - ACE_TRACE ("ACE_Bounded_Set::ACE_Bounded_Set"); - - ACE_NEW (this->search_structure_, - typename ACE_Bounded_Set::Search_Structure[this->max_size_]); - - for (size_t i = 0; i < this->max_size_; ++i) - this->search_structure_[i].is_free_ = 1; -} - -template size_t -ACE_Bounded_Set::size (void) const -{ - ACE_TRACE ("ACE_Bounded_Set::size"); - return this->cur_size_; -} - -template -ACE_Bounded_Set::ACE_Bounded_Set (const ACE_Bounded_Set &bs) - : cur_size_ (bs.cur_size_), - max_size_ (bs.max_size_) -{ - ACE_TRACE ("ACE_Bounded_Set::ACE_Bounded_Set"); - - ACE_NEW (this->search_structure_, - typename ACE_Bounded_Set::Search_Structure[this->max_size_]); - - for (size_t i = 0; i < this->cur_size_; i++) - this->search_structure_[i] = bs.search_structure_[i]; -} - -template void -ACE_Bounded_Set::operator= (const ACE_Bounded_Set &bs) -{ - ACE_TRACE ("ACE_Bounded_Set::operator="); - - if (this != &bs) - { - if (this->max_size_ < bs.cur_size_) - { - delete [] this->search_structure_; - ACE_NEW (this->search_structure_, - typename ACE_Bounded_Set::Search_Structure[bs.cur_size_]); - this->max_size_ = bs.cur_size_; - } - - this->cur_size_ = bs.cur_size_; - - for (size_t i = 0; i < this->cur_size_; i++) - this->search_structure_[i] = bs.search_structure_[i]; - } -} - -template -ACE_Bounded_Set::ACE_Bounded_Set (size_t size) - : cur_size_ (0), - max_size_ (size) -{ - ACE_TRACE ("ACE_Bounded_Set::ACE_Bounded_Set"); - ACE_NEW (this->search_structure_, - typename ACE_Bounded_Set::Search_Structure[size]); - - for (size_t i = 0; i < this->max_size_; i++) - this->search_structure_[i].is_free_ = 1; -} - -template int -ACE_Bounded_Set::find (const T &item) const -{ - ACE_TRACE ("ACE_Bounded_Set::find"); - - for (size_t i = 0; i < this->cur_size_; i++) - if (this->search_structure_[i].item_ == item - && this->search_structure_[i].is_free_ == 0) - return 0; - - return -1; -} - -template int -ACE_Bounded_Set::insert (const T &item) -{ - ACE_TRACE ("ACE_Bounded_Set::insert"); - int first_free = -1; // Keep track of first free slot. - size_t i; - - for (i = 0; i < this->cur_size_; i++) - // First, make sure we don't allow duplicates. - - if (this->search_structure_[i].item_ == item - && this->search_structure_[i].is_free_ == 0) - return 1; - else if (this->search_structure_[i].is_free_ && first_free == -1) - first_free = static_cast (i); - - if (first_free > -1) // If we found a free spot let's reuse it. - { - this->search_structure_[first_free].item_ = item; - this->search_structure_[first_free].is_free_ = 0; - return 0; - } - else if (i < this->max_size_) // Insert at the end of the active portion. - { - this->search_structure_[i].item_ = item; - this->search_structure_[i].is_free_ = 0; - this->cur_size_++; - return 0; - } - else /* No more room! */ - { - errno = ENOMEM; - return -1; - } -} - -template int -ACE_Bounded_Set::remove (const T &item) -{ - ACE_TRACE ("ACE_Bounded_Set::remove"); - for (size_t i = 0; i < this->cur_size_; i++) - if (this->search_structure_[i].item_ == item) - { - // Mark this entry as being free. - this->search_structure_[i].is_free_ = 1; - - // If we just unbound the highest entry, then we need to - // figure out where the next highest active entry is. - if (i + 1 == this->cur_size_) - { - while (i > 0 && this->search_structure_[--i].is_free_) - continue; - - if (i == 0 && this->search_structure_[i].is_free_) - this->cur_size_ = 0; - else - this->cur_size_ = i + 1; - } - return 0; - } - - return -1; -} - -ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Set_Iterator) - - template void -ACE_Bounded_Set_Iterator::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Bounded_Set_Iterator::dump"); -#endif /* ACE_HAS_DUMP */ -} - -template -ACE_Bounded_Set_Iterator::ACE_Bounded_Set_Iterator (ACE_Bounded_Set &s) - : s_ (s), - next_ (-1) -{ - ACE_TRACE ("ACE_Bounded_Set_Iterator::ACE_Bounded_Set_Iterator"); - this->advance (); -} - -template int -ACE_Bounded_Set_Iterator::advance (void) -{ - ACE_TRACE ("ACE_Bounded_Set_Iterator::advance"); - - for (++this->next_; - static_cast (this->next_) < this->s_.cur_size_ - && this->s_.search_structure_[this->next_].is_free_; - ++this->next_) - continue; - - return static_cast (this->next_) < this->s_.cur_size_; -} - -template int -ACE_Bounded_Set_Iterator::first (void) -{ - ACE_TRACE ("ACE_Bounded_Set_Iterator::first"); - - next_ = -1; - return this->advance (); -} - -template int -ACE_Bounded_Set_Iterator::done (void) const -{ - ACE_TRACE ("ACE_Bounded_Set_Iterator::done"); - - return static_cast (this->next_) >= - this->s_.cur_size_; -} - -template int -ACE_Bounded_Set_Iterator::next (T *&item) -{ - ACE_TRACE ("ACE_Bounded_Set_Iterator::next"); - if (static_cast (this->next_) < this->s_.cur_size_) - { - item = &this->s_.search_structure_[this->next_].item_; - return 1; - } - else - return 0; -} - -ACE_ALLOC_HOOK_DEFINE(ACE_DNode) - - template -ACE_DNode::ACE_DNode (const T &i, ACE_DNode *n, ACE_DNode *p) - : next_ (n), prev_ (p), item_ (i) -{ -} - -template -ACE_DNode::~ACE_DNode (void) -{ -} - -// **************************************************************** - -template void -ACE_Unbounded_Stack_Iterator::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - // ACE_TRACE ("ACE_Unbounded_Stack_Iterator::dump"); -#endif /* ACE_HAS_DUMP */ -} - -template -ACE_Unbounded_Stack_Iterator::ACE_Unbounded_Stack_Iterator (ACE_Unbounded_Stack &q) - : current_ (q.head_->next_), - stack_ (q) -{ - // ACE_TRACE ("ACE_Unbounded_Stack_Iterator::ACE_Unbounded_Stack_Iterator"); -} - -template int -ACE_Unbounded_Stack_Iterator::advance (void) -{ - // ACE_TRACE ("ACE_Unbounded_Stack_Iterator::advance"); - this->current_ = this->current_->next_; - return this->current_ != this->stack_.head_; -} - -template int -ACE_Unbounded_Stack_Iterator::first (void) -{ - // ACE_TRACE ("ACE_Unbounded_Stack_Iterator::first"); - this->current_ = this->stack_.head_->next_; - return this->current_ != this->stack_.head_; -} - -template int -ACE_Unbounded_Stack_Iterator::done (void) const -{ - ACE_TRACE ("ACE_Unbounded_Stack_Iterator::done"); - - return this->current_ == this->stack_.head_; -} - -template int -ACE_Unbounded_Stack_Iterator::next (T *&item) -{ - // ACE_TRACE ("ACE_Unbounded_Stack_Iterator::next"); - if (this->current_ == this->stack_.head_) - return 0; - else - { - item = &this->current_->item_; - return 1; - } -} - - -ACE_ALLOC_HOOK_DEFINE(ACE_Ordered_MultiSet) - - - template -ACE_Ordered_MultiSet::ACE_Ordered_MultiSet (ACE_Allocator *alloc) - : head_ (0) - , tail_ (0) - , cur_size_ (0) - , allocator_ (alloc) -{ - // ACE_TRACE ("ACE_Ordered_MultiSet::ACE_Ordered_MultiSet"); - - if (this->allocator_ == 0) - this->allocator_ = ACE_Allocator::instance (); -} - -template -ACE_Ordered_MultiSet::ACE_Ordered_MultiSet (const ACE_Ordered_MultiSet &us) - : head_ (0) - , tail_ (0) - , cur_size_ (0) - , allocator_ (us.allocator_) -{ - ACE_TRACE ("ACE_Ordered_MultiSet::ACE_Ordered_MultiSet"); - - if (this->allocator_ == 0) - this->allocator_ = ACE_Allocator::instance (); - - this->copy_nodes (us); -} - -template -ACE_Ordered_MultiSet::~ACE_Ordered_MultiSet (void) -{ - // ACE_TRACE ("ACE_Ordered_MultiSet::~ACE_Ordered_MultiSet"); - - this->delete_nodes (); -} - - -template void -ACE_Ordered_MultiSet::operator= (const ACE_Ordered_MultiSet &us) -{ - ACE_TRACE ("ACE_Ordered_MultiSet::operator="); - - if (this != &us) - { - this->delete_nodes (); - this->copy_nodes (us); - } -} - - -template int -ACE_Ordered_MultiSet::insert (const T &item) -{ - // ACE_TRACE ("ACE_Ordered_MultiSet::insert"); - - return this->insert_from (item, this->head_, 0); -} - -template int -ACE_Ordered_MultiSet::insert (const T &new_item, - ITERATOR &iter) -{ - // ACE_TRACE ("ACE_Ordered_MultiSet::insert using iterator"); - - return this->insert_from (new_item, iter.current_, &iter.current_); -} - -template int -ACE_Ordered_MultiSet::remove (const T &item) -{ - // ACE_TRACE ("ACE_Ordered_MultiSet::remove"); - - ACE_DNode *node = 0; - - int result = locate (item, 0, node); - - // if we found the node, remove from list and free it - if (node && (result == 0)) - { - if (node->prev_) - node->prev_->next_ = node->next_; - else - head_ = node->next_; - - if (node->next_) - node->next_->prev_ = node->prev_; - else - tail_ = node->prev_; - - --this->cur_size_; - - ACE_DES_FREE_TEMPLATE (node, - this->allocator_->free, - ACE_DNode, - ); - return 0; - } - - return -1; -} - -template int -ACE_Ordered_MultiSet::find (const T &item, - ITERATOR &iter) const -{ - // search an occurance of item, using iterator's current position as a hint - ACE_DNode *node = iter.current_; - int const result = locate (item, node, node); - - // if we found the node, update the iterator and indicate success - if (node && (result == 0)) - { - iter.current_ = node; - return 0; - } - - return -1; -} - - - -template void -ACE_Ordered_MultiSet::reset (void) -{ - ACE_TRACE ("reset"); - - this->delete_nodes (); -} - -template void -ACE_Ordered_MultiSet::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - // ACE_TRACE ("ACE_Ordered_MultiSet::dump"); - // - // ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhead_ = %u"), this->head_)); - // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhead_->next_ = %u"), this->head_->next_)); - // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncur_size_ = %d\n"), this->cur_size_)); - // - // T *item = 0; - // size_t count = 1; - // - // for (ACE_Ordered_MultiSet_Iterator iter (*(ACE_Ordered_MultiSet *) this); - // iter.next (item) != 0; - // iter.advance ()) - // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("count = %d\n"), count++)); - // - // ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -template int -ACE_Ordered_MultiSet::insert_from (const T &item, ACE_DNode *position, - ACE_DNode **new_position) -{ - // ACE_TRACE ("ACE_Ordered_MultiSet::insert_from"); - - // create a new node - ACE_DNode *temp = 0; - ACE_NEW_MALLOC_RETURN (temp, - static_cast*> (this->allocator_->malloc (sizeof (ACE_DNode))), - ACE_DNode (item), - -1); - // obtain approximate location of the node - int result = locate (item, position, position); - - // if there are nodes in the multiset - if (position) - { - switch (result) - { - // insert after the approximate position - case -1: - - // if there is a following node - if (position->next_) - { - // link up with the following node - position->next_->prev_ = temp; - temp->next_ = position->next_; - } - else - // appending to the end of the set - tail_ = temp; - - // link up with the preceeding node - temp->prev_ = position; - position->next_ = temp; - - break; - - // insert before the position - case 0: - case 1: - - // if there is a preceeding node - if (position->prev_) - { - // link up with the preceeding node - position->prev_->next_ = temp; - temp->prev_ = position->prev_; - } - else - // prepending to the start of the set - head_ = temp; - - // link up with the preceeding node - temp->next_ = position; - position->prev_ = temp; - - break; - - default: - return -1; - } - } - else - { - // point the head and tail to the new node. - this->head_ = temp; - this->tail_ = temp; - } - - ++this->cur_size_; - if (new_position) - *new_position = temp; - - return 0; -} - -template int -ACE_Ordered_MultiSet::locate (const T &item, ACE_DNode *start_position, - ACE_DNode *&new_position) const -{ - if (! start_position) - start_position = this->head_; - - // If starting before the item, move forward until at or just before - // item. - while (start_position && start_position->item_ < item && - start_position->next_) - start_position = start_position->next_; - - // If starting after the item, move back until at or just after item - while (start_position && item < start_position->item_ && - start_position->prev_) - start_position = start_position->prev_; - - // Save the (approximate) location in the passed pointer. - new_position = start_position; - - // Show the location is after (1), before (-1) , or at (0) the item - if (!new_position) - return 1; - else if (item < new_position->item_) - return 1; - else if (new_position->item_ < item) - return -1; - else - return 0; -} - -// Looks for first occurance of in the ordered set, using the -// passed starting position as a hint: if there is such an instance, -// it updates the new_position pointer to point to one such node and -// returns 0; if there is no such node, then if there is a node before -// where the item would have been, it updates the new_position pointer -// to point to this node and returns -1; if there is no such node, -// then if there is a node after where the item would have been, it -// updates the new_position pointer to point to this node (or 0 if -// there is no such node) and returns 1; - -template void -ACE_Ordered_MultiSet::copy_nodes (const ACE_Ordered_MultiSet &us) -{ - ACE_DNode *insertion_point = this->head_; - - for (ACE_DNode *curr = us.head_; - curr != 0; - curr = curr->next_) - this->insert_from (curr->item_, insertion_point, &insertion_point); -} - -template void -ACE_Ordered_MultiSet::delete_nodes (void) -{ - // iterate through list, deleting nodes - for (ACE_DNode *curr = this->head_; - curr != 0; - ) - { - ACE_DNode *temp = curr; - curr = curr->next_; - ACE_DES_FREE_TEMPLATE (temp, - this->allocator_->free, - ACE_DNode, - ); - } - - this->head_ = 0; - this->tail_ = 0; - this->cur_size_ = 0; -} - -ACE_ALLOC_HOOK_DEFINE(ACE_Ordered_MultiSet_Iterator) - -template -ACE_Ordered_MultiSet_Iterator::ACE_Ordered_MultiSet_Iterator (ACE_Ordered_MultiSet &s) - : current_ (s.head_), - set_ (s) -{ - // ACE_TRACE ("ACE_Ordered_MultiSet_Iterator::ACE_Ordered_MultiSet_Iterator"); -} - -template int -ACE_Ordered_MultiSet_Iterator::next (T *&item) const -{ - // ACE_TRACE ("ACE_Ordered_MultiSet_Iterator::next"); - if (this->current_) - { - item = &this->current_->item_; - return 1; - } - - return 0; -} - -template T& -ACE_Ordered_MultiSet_Iterator::operator* (void) -{ - //ACE_TRACE ("ACE_Ordered_MultiSet_Iterator::operator*"); - T *retv = 0; - - int const result = this->next (retv); - ACE_ASSERT (result != 0); - ACE_UNUSED_ARG (result); - - return *retv; -} - -ACE_ALLOC_HOOK_DEFINE (ACE_DLList_Node) - -template T * -ACE_DLList::insert_tail (T *new_item) -{ - ACE_DLList_Node *temp1 = 0; - ACE_NEW_MALLOC_RETURN (temp1, - static_cast (this->allocator_->malloc (sizeof (ACE_DLList_Node))), - ACE_DLList_Node (new_item), - 0); - ACE_DLList_Node *temp2 = ACE_DLList_Base::insert_tail (temp1); - return (T *) (temp2 ? temp2->item_ : 0); -} - -template T * -ACE_DLList::insert_head (T *new_item) -{ - ACE_DLList_Node *temp1 = 0; - ACE_NEW_MALLOC_RETURN (temp1, - (ACE_DLList_Node *) this->allocator_->malloc (sizeof (ACE_DLList_Node)), - ACE_DLList_Node (new_item), 0); - ACE_DLList_Node *temp2 = ACE_DLList_Base::insert_head (temp1); - return (T *) (temp2 ? temp2->item_ : 0); -} - -template T * -ACE_DLList::delete_head (void) -{ - ACE_DLList_Node *temp1 = ACE_DLList_Base::delete_head (); - T *temp2 = (T *) (temp1 ? temp1->item_ : 0); - ACE_DES_FREE (temp1, - this->allocator_->free, - ACE_DLList_Node); - - return temp2; -} - -template T * -ACE_DLList::delete_tail (void) -{ - ACE_DLList_Node *temp1 = ACE_DLList_Base::delete_tail (); - T *temp2 = (T *) (temp1 ? temp1->item_ : 0); - ACE_DES_FREE (temp1, - this->allocator_->free, - ACE_DLList_Node); - return temp2; -} - -// **************************************************************** - -// Compare this array with for equality. - -template bool -ACE_Array::operator== (const ACE_Array &s) const -{ - if (this == &s) - return true; - else if (this->size () != s.size ()) - return false; - - const size_t len = s.size (); - for (size_t slot = 0; slot < len; ++slot) - if ((*this)[slot] != s[slot]) - return false; - - return true; -} - -// **************************************************************** - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_CONTAINERS_T_CPP */ diff --git a/ACE/ace/Containers_T.h b/ACE/ace/Containers_T.h deleted file mode 100644 index fe0ec6e9cc0..00000000000 --- a/ACE/ace/Containers_T.h +++ /dev/null @@ -1,2024 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Containers_T.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_CONTAINERS_T_H -#define ACE_CONTAINERS_T_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -// Need by ACE_DLList_Node. -#include "ace/Containers.h" - -// Shared with "ace/Unbounded_Set.h" -#include "ace/Node.h" - -// Backwards compatibility, please include "ace/Array_Base.h" directly. -#include "ace/Array_Base.h" - -// Backwards compatibility, please include "ace/Unbounded_Set.h" directly. -#include "ace/Unbounded_Set.h" - -// Backwards compatibility, please include "ace/Unbounded_Queue.h" directly. -#include "ace/Unbounded_Queue.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -class ACE_Allocator; - - -/** - * @class ACE_Bounded_Stack - * - * @brief Implement a generic LIFO abstract data type. - * - * This implementation of a Stack uses a bounded array - * that is allocated dynamically. The Stack interface - * provides the standard constant time push, pop, and top - * operations. - * - * Requirements and Performance Characteristics - * - Internal Structure - * Dynamic array - * - Duplicates allowed? - * Yes - * - Random access allowed? - * No - * - Search speed - * N/A - * - Insert/replace speed - * N/A - * - Iterator still valid after change to container? - * N/A - * - Frees memory for removed elements? - * No - * - Items inserted by - * Value - * - Requirements for contained type - * -# Default constructor - * -# Copy constructor - * -# operator= - * - */ -template -class ACE_Bounded_Stack -{ -public: - // = Initialization, assignment, and termination methods. - - /// Initialize a new empty stack with the provided size.. - /** - * Initialize and allocate space for a new Bounded_Stack with the provided - * size. - */ - ACE_Bounded_Stack (size_t size); - - /// Initialize the stack to be a copy of the stack provided. - /** - * Initialize the stack to be an exact copy of the Bounded_Stack provided - * as a parameter. - */ - ACE_Bounded_Stack (const ACE_Bounded_Stack &s); - - /// Assignment operator - /** - * Perform a deep copy operation using the Bounded_Stack parameter. If the - * capacity of the lhs isn't sufficient for the rhs, then the underlying data - * structure will be reallocated to accomadate the larger number of elements. - */ - void operator= (const ACE_Bounded_Stack &s); - - /// Perform actions needed when stack goes out of scope. - /** - * Deallocate the memory used by the Bounded_Stack. - */ - ~ACE_Bounded_Stack (void); - - // = Classic Stack operations. - - ///Add an element to the top of the stack. - /** - * Place a new item on top of the stack. Returns -1 if the stack - * is already full, 0 if the stack is not already full, and -1 if - * failure occurs. - */ - int push (const T &new_item); - - ///Remove an item from the top of stack. - /** - * Remove and return the top stack item. Returns -1 if the stack is - * already empty, 0 if the stack is not already empty, and -1 if - * failure occurs. - */ - int pop (T &item); - - ///Examine the contents of the top of stack. - /** - * Return top stack item without removing it. Returns -1 if the - * stack is already empty, 0 if the stack is not already empty, and - * -1 if failure occurs. - */ - int top (T &item) const; - - // = Check boundary conditions. - - /// Returns 1 if the container is empty, otherwise returns 0. - /** - * Performs constant time check to determine if the stack is empty. - */ - int is_empty (void) const; - - /// Returns 1 if the container is full, otherwise returns 0. - /** - * Performs constant time check to determine if the stack is at capacity. - */ - int is_full (void) const; - - /// The number of items in the stack. - /** - * Return the number of items currently in the stack. - */ - size_t size (void) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - /// Size of the dynamically allocated data. - size_t size_; - - /// Keeps track of the current top of stack. - size_t top_; - - /// Holds the stack's contents. - T *stack_; -}; - -//---------------------------------------- - - -/** - * @class ACE_Fixed_Stack - * - * @brief Implement a generic LIFO abstract data type. - * - * This implementation of a Stack uses a fixed array - * with the size fixed at instantiation time. - * - * Requirements and Performance Characteristics - * - Internal Structure - * Fixed array - * - Duplicates allowed? - * Yes - * - Random access allowed? - * No - * - Search speed - * N/A - * - Insert/replace speed - * N/A - * - Iterator still valid after change to container? - * N/A - * - Frees memory for removed elements? - * No - * - Items inserted by - * Value - * - Requirements for contained type - * -# Default constructor - * -# Copy constructor - * -# operator= - * - */ -template -class ACE_Fixed_Stack -{ -public: - // = Initialization, assignment, and termination methods. - /// Initialize a new stack so that it is empty. - /** - * Initialize an empty stack. - */ - ACE_Fixed_Stack (void); - - /// The copy constructor (performs initialization). - /** - * Initialize the stack and copy the provided stack into the current stack. - */ - ACE_Fixed_Stack (const ACE_Fixed_Stack &s); - - /// Assignment operator (performs assignment). - /** - * Perform a deep copy of the provided stack. - */ - void operator= (const ACE_Fixed_Stack &s); - - /// Perform actions needed when stack goes out of scope. - /** - * Destroy the stack. - */ - ~ACE_Fixed_Stack (void); - - // = Classic Stack operations. - - ///Constant time placement of element on top of stack. - /** - * Place a new item on top of the stack. Returns -1 if the stack - * is already full, 0 if the stack is not already full, and -1 if - * failure occurs. - */ - int push (const T &new_item); - - ///Constant time removal of top of stack. - /** - * Remove and return the top stack item. Returns -1 if the stack is - * already empty, 0 if the stack is not already empty, and -1 if - * failure occurs. - */ - int pop (T &item); - - ///Constant time examination of top of stack. - /** - * Return top stack item without removing it. Returns -1 if the - * stack is already empty, 0 if the stack is not already empty, and - * -1 if failure occurs. - */ - int top (T &item) const; - - // = Check boundary conditions. - - /// Returns 1 if the container is empty, otherwise returns 0. - /** - * Performs constant time check to see if stack is empty. - */ - int is_empty (void) const; - - /// Returns 1 if the container is full, otherwise returns 0. - /** - * Performs constant time check to see if stack is full. - */ - int is_full (void) const; - - /// The number of items in the stack. - /** - * Constant time access to the current size of the stack. - */ - size_t size (void) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - /// Size of the allocated data. - size_t size_; - - /// Keeps track of the current top of stack. - size_t top_; - - /// Holds the stack's contents. - T stack_[ACE_SIZE]; -}; - -//---------------------------------------- - -template class ACE_Ordered_MultiSet; -template class ACE_Ordered_MultiSet_Iterator; - -/** - * @class ACE_DNode - * - * @brief Implementation element in a bilinked list. - */ -template -class ACE_DNode -{ - friend class ACE_Ordered_MultiSet; - friend class ACE_Ordered_MultiSet_Iterator; - -public: - - /// This isn't necessary, but it keeps some compilers happy. - ~ACE_DNode (void); - -private: - - // = Initialization methods - ACE_DNode (const T &i, ACE_DNode *n = 0, ACE_DNode *p = 0); - - /// Pointer to next element in the list of {ACE_DNode}s. - ACE_DNode *next_; - - /// Pointer to previous element in the list of {ACE_DNode}s. - ACE_DNode *prev_; - - /// Current value of the item in this node. - T item_; -}; - - - -/** - * @class ACE_Unbounded_Stack - * - * @brief Implement a generic LIFO abstract data type. - * - * This implementation of an unbounded Stack uses a linked list. - * If you use the {insert} or {remove} methods you should keep - * in mind that duplicate entries aren't allowed. In general, - * therefore, you should avoid the use of these methods since - * they aren't really part of the ADT stack. The stack is implemented - * as a doubly linked list. - * - * Requirements and Performance Characteristics - * - Internal Structure - * Double linked list - * - Duplicates allowed? - * No - * - Random access allowed? - * No - * - Search speed - * Linear - * - Insert/replace speed - * Linear - * - Iterator still valid after change to container? - * Yes - * - Frees memory for removed elements? - * Yes - * - Items inserted by - * Value - * - Requirements for contained type - * -# Default constructor - * -# Copy constructor - * -# operator= - * - */ -template -class ACE_Unbounded_Stack -{ -public: - friend class ACE_Unbounded_Stack_Iterator; - - // Trait definition. - typedef ACE_Unbounded_Stack_Iterator ITERATOR; - - // = Initialization, assignment, and termination methods. - /// Initialize a new stack so that it is empty. Use user defined - /// allocation strategy if specified. - /** - * Initialize an empty stack using the user specified allocation strategy - * if provided. - */ - ACE_Unbounded_Stack (ACE_Allocator *the_allocator = 0); - - /// The copy constructor (performs initialization). - /** - * Initialize this stack to be an exact copy of {s}. - */ - ACE_Unbounded_Stack (const ACE_Unbounded_Stack &s); - - /// Assignment operator (performs assignment). - /** - * Perform a deep copy of the rhs into the lhs. - */ - void operator= (const ACE_Unbounded_Stack &s); - - /// Perform actions needed when stack goes out of scope. - /** - * Destroy the underlying list for the stack. - */ - ~ACE_Unbounded_Stack (void); - - // = Classic Stack operations. - - - ///Push an element onto the top of stack. - /** - * Place a new item on top of the stack. Returns -1 if the stack - * is already full, 0 if the stack is not already full, and -1 if - * failure occurs. - */ - int push (const T &new_item); - - ///Pop the top element of the stack. - /** - * Remove and return the top stack item. Returns -1 if the stack is - * already empty, 0 if the stack is not already empty, and -1 if - * failure occurs. - */ - int pop (T &item); - - ///Examine the top of the stack. - /** - * Return top stack item without removing it. Returns -1 if the - * stack is already empty, 0 if the stack is not already empty, and - * -1 if failure occurs. - */ - int top (T &item) const; - - // = Check boundary conditions. - - /// Returns 1 if the container is empty, otherwise returns 0. - /** - * Constant time check to see if the stack is empty. - */ - int is_empty (void) const; - - /// Returns 1 if the container is full, otherwise returns 0. - /** - * Always resturns 0 since the stack is unbounded. - */ - int is_full (void) const; - - // = Auxiliary methods (not strictly part of the Stack ADT). - - ///Linear Insert of an item. - /** - * Insert {new_item} into the Stack at the head (but doesn't allow - * duplicates). Returns -1 if failures occur, 1 if item is already - * present (i.e., no duplicates are allowed), else 0. - */ - int insert (const T &new_item); - - /// Remove @a item from the Stack. Returns 0 if it removes the item, - /// -1 if it can't find the item, and -1 if a failure occurs. - /** - * Linear remove operation. - */ - int remove (const T &item); - - /// Finds if @a item occurs the set. Returns 0 if finds, else -1. - /** - * Linear find operation. - */ - int find (const T &item) const; - - /// The number of items in the stack. - /** - * Constant time access to the current stack size. - */ - size_t size (void) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - /// Delete all the nodes in the stack. - void delete_all_nodes (void); - - /// Copy all nodes from {s} to {this}. - void copy_all_nodes (const ACE_Unbounded_Stack &s); - - /// Head of the linked list of Nodes. - ACE_Node *head_; - - /// Current size of the stack. - size_t cur_size_; - - /// Allocation strategy of the stack. - ACE_Allocator *allocator_; -}; - -/** - * @class ACE_Unbounded_Stack_Iterator - * - * @brief Implement an iterator over an unbounded Stack. - */ -template -class ACE_Unbounded_Stack_Iterator -{ -public: - // = Initialization method. - /// Move to the first element in the {stack}. - ACE_Unbounded_Stack_Iterator (ACE_Unbounded_Stack &stack); - - // = Iteration methods. - - /// Pass back the @a next_item that hasn't been seen in the Stack. - /// Returns 0 when all items have been seen, else 1. - int next (T *&next_item); - - /// Move forward by one element in the Stack. Returns 0 when all the - /// items in the Stack have been seen, else 1. - int advance (void); - - /// Move to the first element in the Stack. Returns 0 if the - /// Stack is empty, else 1. - int first (void); - - /// Returns 1 when all items have been seen, else 0. - int done (void) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - /// Pointer to the current node in the iteration. - ACE_Node *current_; - - /// Pointer to the Stack we're iterating over. - ACE_Unbounded_Stack &stack_; -}; - -template -class ACE_Double_Linked_List; - -/** - * @class ACE_Double_Linked_List_Iterator_Base - * - * @brief Implements a common base class for iterators for a double - * linked list ADT - */ -template -class ACE_Double_Linked_List_Iterator_Base -{ -public: - // = Iteration methods. - - /// Passes back the {entry} under the iterator. Returns 0 if the - /// iteration has completed, otherwise 1 - int next (T *&) const; - - /** - * @deprecated Return the address of next (current) unvisited item in - * the list. 0 if there is no more element available. - */ - T *next (void) const; - - /// Returns 1 when all items have been seen, else 0. - int done (void) const; - - /// STL-like iterator dereference operator: returns a reference - /// to the node underneath the iterator. - T & operator* (void) const ; - - /** - * Retasks the iterator to iterate over a new - * Double_Linked_List. This allows clients to reuse an iterator - * without incurring the constructor overhead. If you do use this, - * be aware that if there are more than one reference to this - * iterator, the other "clients" may be very bothered when their - * iterator changes. @@ Here be dragons. Comments? - */ - void reset (ACE_Double_Linked_List &); - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - // = Initialization methods. - - /// Constructor - ACE_Double_Linked_List_Iterator_Base (const ACE_Double_Linked_List &); - - /// Copy constructor. - ACE_Double_Linked_List_Iterator_Base (const - ACE_Double_Linked_List_Iterator_Base - &iter); - - // = Iteration methods. - /** - * Move to the first element of the list. Returns 0 if the list is - * empty, else 1. - * @note the head of the ACE_DLList is actually a null entry, so the - * first element is actually the 2n'd entry - */ - int go_head (void); - - /// Move to the last element of the list. Returns 0 if the list is - /// empty, else 1. - int go_tail (void); - - /** - * Check if we reach the end of the list. Can also be used to get - * the *current* element in the list. Return the address of the - * current item if there are still elements left , 0 if we run out - * of element. - */ - T *not_done (void) const ; - - /// Advance to the next element in the list. Return the address of the - /// next element if there are more, 0 otherwise. - T *do_advance (void); - - /// Retreat to the previous element in the list. Return the address - /// of the previous element if there are more, 0 otherwise. - T *do_retreat (void); - - /// Dump the state of an object. - void dump_i (void) const; - - /// Remember where we are. - T *current_; - - const ACE_Double_Linked_List *dllist_; -}; - -/** - * @class ACE_Double_Linked_List_Iterator - * - * @brief Implements an iterator for a double linked list ADT - * - * Iterate thru the double-linked list. This class provides - * an interface that let users access the internal element - * addresses directly. Notice {class T} must declare - * ACE_Double_Linked_List<T>, - * ACE_Double_Linked_List_Iterator_Base <T> and - * ACE_Double_Linked_List_Iterator as friend classes and class T - * should also have data members T* next_ and T* prev_. - */ -template -class ACE_Double_Linked_List_Iterator : public ACE_Double_Linked_List_Iterator_Base -{ -public: - // = Initialization method. - ACE_Double_Linked_List_Iterator (const ACE_Double_Linked_List &); - - /** - * Retasks the iterator to iterate over a new - * Double_Linked_List. This allows clients to reuse an iterator - * without incurring the constructor overhead. If you do use this, - * be aware that if there are more than one reference to this - * iterator, the other "clients" may be very bothered when their - * iterator changes. - * @@ Here be dragons. Comments? - */ - void reset (ACE_Double_Linked_List &); - - /// Move to the first element in the list. Returns 0 if the - /// list is empty, else 1. - int first (void); - - /// Move forward by one element in the list. Returns 0 when all the - /// items in the list have been seen, else 1. - int advance (void); - - /** - * Advance the iterator while removing the original item from the - * list. Return a pointer points to the original (removed) item. - * If {dont_remove} equals 0, this function behaves like {advance} - * but return 0 (NULL) instead. - */ - T* advance_and_remove (int dont_remove); - - // = STL-style iteration methods - - /// Prefix advance. - ACE_Double_Linked_List_Iterator & operator++ (void); - - /// Postfix advance. - ACE_Double_Linked_List_Iterator operator++ (int); - - /// Prefix reverse. - ACE_Double_Linked_List_Iterator & operator-- (void); - - /// Postfix reverse. - ACE_Double_Linked_List_Iterator operator-- (int); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; -}; - -/** - * @class ACE_Double_Linked_List_Reverse_Iterator - * - * @brief Implements a reverse iterator for a double linked list ADT - * - * Iterate backwards over the double-linked list. This class - * provide an interface that let users access the internal - * element addresses directly, which seems to break the - * encapsulation. Notice {class T} must declare - * ACE_Double_Linked_List<T>, - * ACE_Double_Linked_List_Iterator_Base <T> and - * ACE_Double_Linked_List_Iterator as friend classes and class T - * should also have data members T* next_ and T* prev_. - */ -template -class ACE_Double_Linked_List_Reverse_Iterator : public ACE_Double_Linked_List_Iterator_Base -{ -public: - // = Initialization method. - ACE_Double_Linked_List_Reverse_Iterator (ACE_Double_Linked_List &); - - /** - * Retasks the iterator to iterate over a new - * Double_Linked_List. This allows clients to reuse an iterator - * without incurring the constructor overhead. If you do use this, - * be aware that if there are more than one reference to this - * iterator, the other "clients" may be very bothered when their - * iterator changes. - * @@ Here be dragons. Comments? - */ - void reset (ACE_Double_Linked_List &); - - /// Move to the first element in the list. Returns 0 if the - /// list is empty, else 1. - int first (void); - - /// Move forward by one element in the list. Returns 0 when all the - /// items in the list have been seen, else 1. - int advance (void); - - /** - * Advance the iterator while removing the original item from the - * list. Return a pointer points to the original (removed) item. - * If {dont_remove} equals 0, this function behaves like {advance} - * but return 0 (NULL) instead. - */ - T* advance_and_remove (int dont_remove); - - // = STL-style iteration methods - - /// Prefix advance. - ACE_Double_Linked_List_Reverse_Iterator & operator++ (void); - - /// Postfix advance. - ACE_Double_Linked_List_Reverse_Iterator operator++ (int); - - /// Prefix reverse. - ACE_Double_Linked_List_Reverse_Iterator & operator-- (void); - - /// Postfix reverse. - ACE_Double_Linked_List_Reverse_Iterator operator-- (int); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; -}; - - -/** - * @class ACE_Double_Linked_List - * - * @brief A double-linked list implementation. - * - * This implementation of an unbounded double-linked list uses a - * circular linked list with a dummy node. It is pretty much - * like the {ACE_Unbounded_Queue} except that it allows removing - * of a specific element from a specific location. - * Notice that this class is an implementation of a very simple - * data structure. This is *NOT* a container class. You can use the - * class to implement other contains classes but it is *NOT* a - * general purpose container class. - * The parameter class *MUST* have members T* prev and T* next - * and users of this class are responsible to follow the general - * rules of using double-linked lists to maintaining the list - * integrity. - * If you need a double linked container class, use the DLList - * class which is a container but delegates to the Double_Linked_List - * class. - * - * Requirements and Performance Characteristics - * - Internal Structure - * Double Linked List - * - Duplicates allowed? - * Yes - * - Random access allowed? - * No - * - Search speed - * N/A - * - Insert/replace speed - * Linear - * - Iterator still valid after change to container? - * Yes - * - Frees memory for removed elements? - * No - * - Items inserted by - * Value - * - Requirements for contained type - * -# Default constructor - * -# Copy constructor - * -# operator= - * - */ -template -class ACE_Double_Linked_List -{ -public: - friend class ACE_Double_Linked_List_Iterator_Base; - friend class ACE_Double_Linked_List_Iterator; - friend class ACE_Double_Linked_List_Reverse_Iterator; - - // Trait definition. - typedef ACE_Double_Linked_List_Iterator ITERATOR; - typedef ACE_Double_Linked_List_Reverse_Iterator REVERSE_ITERATOR; - - // = Initialization and termination methods. - /// construction. Use user specified allocation strategy - /// if specified. - /** - * Initialize an empy list using the allocation strategy specified by the user. - * If none is specified, then use default allocation strategy. - */ - ACE_Double_Linked_List (ACE_Allocator *the_allocator = 0); - - /// Copy constructor. - /** - * Create a double linked list that is a copy of the provided - * parameter. - */ - ACE_Double_Linked_List (const ACE_Double_Linked_List &); - - /// Assignment operator. - /** - * Perform a deep copy of the provided list by first deleting the nodes of the - * lhs and then copying the nodes of the rhs. - */ - void operator= (const ACE_Double_Linked_List &); - - /// Destructor. - /** - * Clean up the memory allocated for the nodes of the list. - */ - ~ACE_Double_Linked_List (void); - - // = Check boundary conditions. - - /// Returns 1 if the container is empty, 0 otherwise. - /** - * Performs constant time check to determine if the list is empty. - */ - int is_empty (void) const; - - /// The list is unbounded, so this always returns 0. - /** - * Since the list is unbounded, the method simply returns 0. - */ - int is_full (void) const; - - // = Classic queue operations. - - /// Adds @a new_item to the tail of the list. Returns the new item - /// that was inserted. - /** - * Provides constant time insertion at the end of the list structure. - */ - T *insert_tail (T *new_item); - - /// Adds @a new_item to the head of the list.Returns the new item that - /// was inserted. - /** - * Provides constant time insertion at the head of the list. - */ - T *insert_head (T *new_item); - - /// Removes the head of the list and returns a pointer to that item. - /** - * Removes and returns the first {item} in the list. Returns - * internal node's address on success, 0 if the queue was empty. - * This method will *not* free the internal node. - */ - T* delete_head (void); - - /// Removes the tail of the list and returns a pointer to that item. - /** - * Removes and returns the last {item} in the list. Returns - * internal nodes's address on success, 0 if the queue was - * empty. This method will *not* free the internal node. - */ - T *delete_tail (void); - - // = Additional utility methods. - - ///Empty the list. - /** - * Reset the {ACE_Double_Linked_List} to be empty. - * Notice that since no one is interested in the items within, - * This operation will delete all items. - */ - void reset (void); - - /// Get the {slot}th element in the set. Returns -1 if the element - /// isn't in the range {0..{size} - 1}, else 0. - /** - * Iterates through the list to the desired index and assigns the provides pointer - * with the address of the node occupying that index. - */ - int get (T *&item, size_t slot = 0); - - /// The number of items in the queue. - /** - * Constant time call to return the current size of the list. - */ - size_t size (void) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Use DNode address directly. - /** - * Constant time removal of an item from the list using it's address. - */ - int remove (T *n); - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - /// Delete all the nodes in the list. - /** - * Removes and deallocates memory for all of the list nodes. - */ - void delete_nodes (void); - - /// Copy nodes from {rhs} into this list. - /** - * Copy the elements of the provided list by allocated new nodes and assigning - * them with the proper data. - */ - void copy_nodes (const ACE_Double_Linked_List &rhs); - - /// Setup header pointer. Called after we create the head node in ctor. - /** - * Initialize the head pointer so that the list has a dummy node. - */ - void init_head (void); - - ///Constant time insert a new item into the list structure. - /** - * Insert a @a new_item into the list. It will be added before - * or after @a old_item. Default is to insert the new item *after* - * {head_}. Return 0 if succeed, -1 if error occured. - */ - int insert_element (T *new_item, - int before = 0, - T *old_item = 0); - - ///Constant time delete an item from the list structure. - /** - * Remove @a item from the list. Return 0 if succeed, -1 otherwise. - * Notice that this function checks if item is {head_} and either its - * {next_} or {prev_} is NULL. The function resets item's {next_} and - * {prev_} to 0 to prevent clobbering the double-linked list if a user - * tries to remove the same node again. - */ - int remove_element (T *item); - - /// Head of the circular double-linked list. - T *head_; - - /// Size of this list. - size_t size_; - - /// Allocation Strategy of the queue. - ACE_Allocator *allocator_; -}; - - -template class ACE_DLList; -template class ACE_DLList_Iterator; -template class ACE_DLList_Reverse_Iterator; - -typedef ACE_Double_Linked_List ACE_DLList_Base; - -//typedef ACE_Double_Linked_List_Iterator -// ACE_DLList_Iterator_Base; -//typedef ACE_Double_Linked_List_Reverse_Iterator -// ACE_DLList_Reverse_Iterator_Base; -//@@ These two typedefs (inherited from James Hu's original design) -// have been removed because Sun CC 4.2 had problems with it. I guess -// having the DLList_Iterators inheriting from a class which is -// actually a typedef leads to problems. #define'ing rather than -// typedef'ing worked, but as per Carlos's reccomendation, I'm just -// replacing all references to the base classes with their actual -// type. Matt Braun (6/15/99) - -/** - * @class ACE_DLList - * - * @brief A double-linked list container class. - * - * This implementation uses ACE_Double_Linked_List to perform - * the logic behind this container class. It delegates all of its - * calls to ACE_Double_Linked_List. - */ -template -class ACE_DLList : public ACE_DLList_Base -{ - friend class ACE_DLList_Node; - friend class ACE_Double_Linked_List_Iterator; - friend class ACE_DLList_Iterator; - friend class ACE_DLList_Reverse_Iterator; - -public: - - /// Delegates to ACE_Double_Linked_List. - void operator= (const ACE_DLList &l); - - // = Classic queue operations. - - /// Delegates to ACE_Double_Linked_List. - T *insert_tail (T *new_item); - - /// Delegates to ACE_Double_Linked_List. - T *insert_head (T *new_item); - - /// Delegates to ACE_Double_Linked_List. - T *delete_head (void); - - /// Delegates to ACE_Double_Linked_List. - T *delete_tail (void); - - // = Additional utility methods. - - /** - * Delegates to {ACE_Double_Linked_List}, but where - * {ACE_Double_Linked_List} returns the node as the item, this get - * returns the contents of the node in item. - */ - int get (T *&item, size_t slot = 0); - - /// Delegates to ACE_Double_Linked_List. - void dump (void) const; - - /// Delegates to ACE_Double_Linked_List. - int remove (ACE_DLList_Node *n); - - // = Initialization and termination methods. - - /// Delegates to ACE_Double_Linked_List. - ACE_DLList (ACE_Allocator *the_allocator = 0); - - /// Delegates to ACE_Double_Linked_List. - ACE_DLList (const ACE_DLList &l); - - /// Deletes the list starting from the head. - ~ACE_DLList (void); -}; - -/** - * @class ACE_DLList_Iterator - * - * @brief A double-linked list container class iterator. - * - * This implementation uses ACE_Double_Linked_List_Iterator to - * perform the logic behind this container class. It delegates - * all of its calls to ACE_Double_Linked_List_Iterator. - */ -template -class ACE_DLList_Iterator : public ACE_Double_Linked_List_Iterator -{ - - friend class ACE_DLList; - friend class ACE_DLList_Node; - -public: - - // = Initialization method. - ACE_DLList_Iterator (ACE_DLList &l); - - /** - * Retasks the iterator to iterate over a new - * Double_Linked_List. This allows clients to reuse an iterator - * without incurring the constructor overhead. If you do use this, - * be aware that if there are more than one reference to this - * iterator, the other "clients" may be very bothered when their - * iterator changes. - * @@ Here be dragons. Comments? - */ - void reset (ACE_DLList &l); - - // = Iteration methods. - /// Move forward by one element in the list. Returns 0 when all the - /// items in the list have been seen, else 1. - int advance (void); - - /// Pass back the {next_item} that hasn't been seen in the list. - /// Returns 0 when all items have been seen, else 1. - int next (T *&); - - /** - * @deprecated Delegates to ACE_Double_Linked_List_Iterator, except that - * whereas the Double_Linked_List version of next returns the node, this next - * returns the contents of the node - */ - T *next (void) const; - - /** - * Removes the current item (i.e., {next}) from the list. - * Note that DLList iterators do not support {advance_and_remove} - * directly (defined in its base class) and you will need to - * release the element returned by it. - */ - int remove (void); - - /// Delegates to ACE_Double_Linked_List_Iterator. - void dump (void) const; - -private: - ACE_DLList *list_; -}; - -/** - * @class ACE_DLList_Reverse_Iterator - * - * @brief A double-linked list container class iterator. - * - * This implementation uses ACE_Double_Linked_List_Iterator to - * perform the logic behind this container class. It delegates - * all of its calls to ACE_Double_Linked_List_Iterator. - */ -template -class ACE_DLList_Reverse_Iterator : public ACE_Double_Linked_List_Reverse_Iterator -{ - - friend class ACE_DLList; - friend class ACE_DLList_Node; - -public: - - // = Initialization method. - ACE_DLList_Reverse_Iterator (ACE_DLList &l); - - /** - * Retasks the iterator to iterate over a new - * Double_Linked_List. This allows clients to reuse an iterator - * without incurring the constructor overhead. If you do use this, - * be aware that if there are more than one reference to this - * iterator, the other "clients" may be very bothered when their - * iterator changes. - * @@ Here be dragons. Comments? - */ - void reset (ACE_DLList &l); - - // = Iteration methods. - /// Move forward by one element in the list. Returns 0 when all the - /// items in the list have been seen, else 1. - int advance (void); - - /// Pass back the {next_item} that hasn't been seen in the list. - /// Returns 0 when all items have been seen, else 1. - int next (T *&); - - /// @deprecated Delegates to ACE_Double_Linked_List_Iterator. - T *next (void) const; - - /// Removes the current item (i.e., {next}) from the list. - /// Note that DLList iterators do not support {advance_and_remove} - /// directly (defined in its base class) and you will need to - /// release the element returned by it. - int remove (void); - - /// Delegates to ACE_Double_Linked_List_Iterator. - void dump (void) const; - -private: - ACE_DLList *list_; -}; - -// Forward declaration. -template -class ACE_Fixed_Set; - -/** - * @class ACE_Fixed_Set_Iterator_Base - * - * @brief Implements a common base class for iterators for a unordered set. - */ -template -class ACE_Fixed_Set_Iterator_Base -{ -public: - // = Iteration methods. - - /// Pass back the {next_item} that hasn't been seen in the Set. - /// Returns 0 when all items have been seen, else 1. - int next (T *&next_item); - - /// Move forward by one element in the set. Returns 0 when all the - /// items in the set have been seen, else 1. - int advance (void); - - /// Move to the first element in the set. Returns 0 if the - /// set is empty, else 1. - int first (void); - - /// Returns 1 when all items have been seen, else 0. - int done (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - // = Initialization method. - ACE_Fixed_Set_Iterator_Base (ACE_Fixed_Set &s); - - /// Set we are iterating over. - ACE_Fixed_Set &s_; - - /// How far we've advanced over the set. - ssize_t next_; - - /// The number of non free items that the iterator had pointed at. - size_t iterated_items_; - - /// Dump the state of an object. - void dump_i (void) const; - - /// Pass back the {next_item} that hasn't been seen in the Set. - /// Returns 0 when all items have been seen, else 1. - int next_i (T *&next_item); -}; - -/** - * @class ACE_Fixed_Set_Iterator - * - * @brief Iterates through an unordered set. - * - * This implementation of an unordered set uses a fixed array. - * Allows deletions while iteration is occurring. - */ -template -class ACE_Fixed_Set_Iterator : public ACE_Fixed_Set_Iterator_Base -{ -public: - // = Initialization method. - ACE_Fixed_Set_Iterator (ACE_Fixed_Set &s); - - // = Iteration methods. - - /// Pass back the {next_item} that hasn't been seen in the Set. - /// Returns 0 when all items have been seen, else 1. - int next (T *&next_item); - - /// Dump the state of an object. - void dump (void) const; - - /// Remove the item where the itearetor is located at. - /// Returns 1 if it removes a item, else 0. - /// Pass back the removed {item}. - int remove (T *&item); - - /// STL-like iterator dereference operator: returns a reference - /// to the node underneath the iterator. - T & operator* (void); - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; -}; - -/** - * @class ACE_Fixed_Set_Const_Iterator - * - * @brief Iterates through a const unordered set. - * - * This implementation of an unordered set uses a fixed array. - */ -template -class ACE_Fixed_Set_Const_Iterator : public ACE_Fixed_Set_Iterator_Base -{ -public: - // = Initialization method. - ACE_Fixed_Set_Const_Iterator (const ACE_Fixed_Set &s); - - // = Iteration methods. - - /// Pass back the {next_item} that hasn't been seen in the Set. - /// Returns 0 when all items have been seen, else 1. - int next (const T *&next_item); - - /// Dump the state of an object. - void dump (void) const; - - /// STL-like iterator dereference operator: returns a reference - /// to the node underneath the iterator. - const T & operator* (void) const ; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; -}; - -/** - * @class ACE_Fixed_Set - * - * @brief Implement a simple unordered set of {T} with maximum {ACE_SIZE}. - * - * This implementation of an unordered set uses a fixed array. - * It does not allow duplicate members. The set provides linear insertion/deletion - * operations. - * - * Requirements and Performance Characteristics - * - Internal Structure - * Fixed array - * - Duplicates allowed? - * No - * - Random access allowed? - * No - * - Search speed - * Linear - * - Insert/replace speed - * Linear - * - Iterator still valid after change to container? - * Yes - * - Frees memory for removed elements? - * No - * - Items inserted by - * Value - * - Requirements for contained type - * -# Default constructor - * -# Copy constructor - * -# operator= - * -# operator== - * - */ -template -class ACE_Fixed_Set -{ -public: - friend class ACE_Fixed_Set_Iterator_Base; - friend class ACE_Fixed_Set_Iterator; - friend class ACE_Fixed_Set_Const_Iterator; - - // Trait definitions. - typedef ACE_Fixed_Set_Iterator ITERATOR; - typedef ACE_Fixed_Set_Const_Iterator CONST_ITERATOR; - - // = Initialization and termination methods. - /// Default Constructor. - /** - * Creates an empy set - */ - ACE_Fixed_Set (void); - - /// Copy constructor. - /** - * Initializes a set to be a copy of the set parameter. - */ - ACE_Fixed_Set (const ACE_Fixed_Set &); - - /// Assignment operator. - /** - * Deep copy of one set to another. - */ - void operator= (const ACE_Fixed_Set &); - - /// Destructor. - /** - * Destroys a set. - */ - ~ACE_Fixed_Set (void); - - // = Check boundary conditions. - - /// Returns 1 if the container is empty, otherwise returns 0. - /** - * Performs constant time check to determine if a set is empty. - */ - int is_empty (void) const; - - /// Returns 1 if the container is full, otherwise returns 0. - /** - * Performs a constant time check to see if the set is full. - */ - int is_full (void) const; - - // = Classic unordered set operations. - - ///Linear time insertion of an item unique to the set. - /** - * Insert @a new_item into the set (doesn't allow duplicates). - * Returns -1 if failures occur, 1 if item is already present, else - * 0. - */ - int insert (const T &new_item); - - ///Linear time removal operation of an item. - /** - * Remove first occurrence of {item} from the set. Returns 0 if - * it removes the item, -1 if it can't find the item, and -1 if a - * failure occurs. Removal doesn't reclaim memory for the @a item. - */ - int remove (const T &item); - - /// Finds if @a item occurs in the set. Returns 0 if finds, else -1. - /** - * Performs a linear find operation for the specified @a item. - */ - int find (const T &item) const; - - /// Size of the set. - /** - * Returns the current size of the set. - */ - size_t size (void) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - /// Holds the contents of the set. - struct - { - /// Item in the set. - T item_; - - /// Keeps track of whether this item is in use or not. - int is_free_; - } search_structure_[ACE_SIZE]; - - /// Current size of the set. - size_t cur_size_; - - /// Maximum size of the set. - size_t max_size_; -}; - -// Forward declaration. -template -class ACE_Bounded_Set; - -/** - * @class ACE_Bounded_Set_Iterator - * - * @brief Iterates through an unordered set. - * - * This implementation of an unordered set uses a Bounded array. - * Allows deletions while iteration is occurring. - */ -template -class ACE_Bounded_Set_Iterator -{ -public: - // = Initialization method. - ACE_Bounded_Set_Iterator (ACE_Bounded_Set &s); - - // = Iteration methods. - - /// Pass back the {next_item} that hasn't been seen in the Set. - /// Returns 0 when all items have been seen, else 1. - int next (T *&next_item); - - /// Move forward by one element in the set. Returns 0 when all the - /// items in the set have been seen, else 1. - int advance (void); - - /// Move to the first element in the set. Returns 0 if the - /// set is empty, else 1. - int first (void); - - /// Returns 1 when all items have been seen, else 0. - int done (void) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - /// Set we are iterating over. - ACE_Bounded_Set &s_; - - /// How far we've advanced over the set. - ssize_t next_; -}; - - -/** - * @class ACE_Bounded_Set - * - * @brief Implement a simple unordered set of {T} with maximum - * set at creation time. - * - * This implementation of an unordered set uses a Bounded array. - * This implementation does not allow duplicates. It provides - * linear insert/remove/find operations. Insertion/removal does not - * invalidate iterators, but caution should be taken to ensure - * expected behavior. Once initialized, the object has a maximum size - * which can only be increased by the assignment of another larger Bounded_Set. - * - * Requirements and Performance Characteristics - * - Internal Structure - * Bounded array which can grow via assignment - * - Duplicates allowed? - * No - * - Random access allowed? - * No - * - Search speed - * Linear - * - Insert/replace speed - * Linear - * - Iterator still valid after change to container? - * Yes - * - Frees memory for removed elements? - * No - * - Items inserted by - * Value - * - Requirements for contained type - * -# Default constructor - * -# Copy constructor - * -# operator= - * -# operator== - * - */ -template -class ACE_Bounded_Set -{ -public: - friend class ACE_Bounded_Set_Iterator; - - // Trait definition. - typedef ACE_Bounded_Set_Iterator ITERATOR; - - enum - { - DEFAULT_SIZE = 10 - }; - - // = Initialization and termination methods. - /// Construct a Bounded_Set using the default size. - /** - * The default constructor initializes the Bounded_Set to a maximum size - * specified by the DEFAULT_SIZE. - */ - ACE_Bounded_Set (void); - - /// Construct a Bounded_Set with the provided sizeB. - /** - * Initialize the Bounded_Set to have a maximum size equal to the size - * parameter specified. - */ - ACE_Bounded_Set (size_t size); - - /// Construct a Bounded_Set that is a copy of the provides Bounded_Set. - /** - * Initialize the Bounded_Set to be a copy of the Bounded_Set parameter. - */ - ACE_Bounded_Set (const ACE_Bounded_Set &); - - /// Assignment operator. - /** - * The assignment will make a deep copy of the Bounded_Set provided. If the - * rhs has more elements than the capacity of the lhs, then the lhs will be - * deleted and reallocated to accomadate the larger number of elements. - */ - void operator= (const ACE_Bounded_Set &); - - /// Destructor - /** - * Clean up the underlying dynamically allocated memory that is used by - * the Bounded_Set. - */ - ~ACE_Bounded_Set (void); - - // = Check boundary conditions. - - /// Returns 1 if the container is empty, otherwise returns 0. - /** - * A constant time check is performed to determine if the Bounded_Set is - * empty. - */ - int is_empty (void) const; - - /// Returns 1 if the container is full, otherwise returns 0. - /** - * Performs a constant time check to determine if the Bounded_Set is at - * capacity. - */ - int is_full (void) const; - - // = Classic unordered set operations. - - ///Inserts a new element unique to the set. - /** - * Insert @a new_item into the set (doesn't allow duplicates) in linear - * time. - * Returns -1 if failures occur, 1 if item is already present, else - * 0. - */ - int insert (const T &new_item); - - ///Finds the specified element and removes it from the set. - /** - * Remove first occurrence of @a item from the set. Returns 0 if it - * removes the item, -1 if it can't find the item, and -1 if a - * failure occurs. The linear remove operation does not reclaim the - * memory associated with the removed item. - */ - int remove (const T &item); - - /// Finds if @a item occurs in the set. Returns 0 if finds, else -1. - /** - * find preforms a linear search for {item} and returns 0 on successful - * find and -1 otherwise. - */ - int find (const T &item) const; - - /// Size of the set. - /** - * Returns a size_t representing the current size of the set. - */ - size_t size (void) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - struct Search_Structure - { - /// Item in the set. - T item_; - - /// Keeps track of whether this item is in use or not. - int is_free_; - }; - - /// Holds the contents of the set. - Search_Structure *search_structure_; - - /// Current size of the set. - size_t cur_size_; - - /// Maximum size of the set. - size_t max_size_; -}; - -/** - * @class ACE_Ordered_MultiSet_Iterator - * - * @brief Implement a bidirectional iterator over an ordered multiset. - * This class template requires that < operator semantics be - * defined for the parameterized type {T}, but does not impose - * any restriction on how that ordering operator is implemented. - */ -template -class ACE_Ordered_MultiSet_Iterator -{ -public: - friend class ACE_Ordered_MultiSet; - - // = Initialization method. - ACE_Ordered_MultiSet_Iterator (ACE_Ordered_MultiSet &s); - - // = Iteration methods. - - /// Pass back the {next_item} that hasn't been seen in the ordered multiset. - /// Returns 0 when all items have been seen, else 1. - int next (T *&next_item) const; - - /// Repositions the iterator at the first item in the ordered multiset - /// Returns 0 if the list is empty else 1. - int first (void); - - /// Repositions the iterator at the last item in the ordered multiset - /// Returns 0 if the list is empty else 1. - int last (void); - - /// Move forward by one element in the set. Returns 0 when all the - /// items in the set have been seen, else 1. - int advance (void); - - /// Move backward by one element in the set. Returns 0 when all the - /// items in the set have been seen, else 1. - int retreat (void); - - /// Returns 1 when all items have been seen, else 0. - int done (void) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Returns a reference to the internal element {this} is pointing to. - T& operator* (void); - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - - /// Pointer to the current node in the iteration. - ACE_DNode *current_; - - /// Pointer to the set we're iterating over. - ACE_Ordered_MultiSet &set_; -}; - - -/** - * @class ACE_Ordered_MultiSet - * - * @brief Implement a simple ordered multiset of {T} of unbounded size - * that allows duplicates. This class template requires that < - * operator semantics be defined for the parameterized type {T}, but - * does not impose any restriction on how that ordering operator is - * implemented. The set is implemented as a linked list. - * - * - * Requirements and Performance Characteristics - * - Internal Structure - * Double linked list - * - Duplicates allowed? - * Yes - * - Random access allowed? - * No - * - Search speed - * Linear - * - Insert/replace speed - * Linear - * - Iterator still valid after change to container? - * Yes - * - Frees memory for removed elements? - * Yes - * - Items inserted by - * Value - * - Requirements for contained type - * -# Default constructor - * -# Copy constructor - * -# operator= - * -# operator== - * -# operator< - * - * - */ -template -class ACE_Ordered_MultiSet -{ -public: - friend class ACE_Ordered_MultiSet_Iterator; - - // Trait definition. - typedef ACE_Ordered_MultiSet_Iterator ITERATOR; - - // = Initialization and termination methods. - /// Constructor. Use user specified allocation strategy - /// if specified. - /** - * Initialize the set using the allocation strategy specified. If none, use the - * default strategy. - */ - ACE_Ordered_MultiSet (ACE_Allocator *the_allocator = 0); - - /// Copy constructor. - /** - * Initialize the set to be a copy of the provided set. - */ - ACE_Ordered_MultiSet (const ACE_Ordered_MultiSet &); - - /// Destructor. - /** - * Delete the nodes of the set. - */ - ~ACE_Ordered_MultiSet (void); - - /// Assignment operator. - /** - * Delete the nodes in lhs, and copy the nodes from the rhs. - */ - void operator= (const ACE_Ordered_MultiSet &); - - // = Check boundary conditions. - - /// Returns 1 if the container is empty, otherwise returns 0. - /** - * Constant time check to determine if the set is empty. - */ - int is_empty (void) const; - - /// Size of the set. - /** - * Constant time check to determine the size of the set. - */ - size_t size (void) const; - - // = Classic unordered set operations. - - /// Insert @a new_item into the ordered multiset. - /// Returns -1 if failures occur, else 0. - /** - * Linear time, order preserving insert into the set beginning at the head. - */ - int insert (const T &new_item); - - ///Linear time insert beginning at the point specified by the provided iterator. - /** - * Insert @a new_item into the ordered multiset, starting its search at - * the node pointed to by the iterator, and if insertion was successful, - * updates the iterator to point to the newly inserted node. - * Returns -1 if failures occur, else 0. - */ - int insert (const T &new_item, ITERATOR &iter); - - /// Remove first occurrence of @a item from the set. Returns 0 if - /// it removes the item, -1 if it can't find the item. - /** - * Linear time search operation which removes the item from the set if found . - */ - int remove (const T &item); - - ///Linear find operation. - /** - * Finds first occurrence of @a item in the multiset, using the iterator's - * current position as a hint to improve performance. If find succeeds, - * it positions the iterator at that node and returns 0, or if it cannot - * locate the node, it leaves the iterator alone and just returns -1. - */ - int find (const T &item, ITERATOR &iter) const; - - /// Reset the ACE_Ordered_MultiSet to be empty. - /** - * Delete the nodes inside the set. - */ - void reset (void); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - - /** - * Insert @a item, starting its search at the position given, - * and if successful updates the passed pointer to point to - * the newly inserted item's node. - */ - int insert_from (const T &item, ACE_DNode *start_position, - ACE_DNode **new_position); - - /** - * Looks for first occurance of @a item in the ordered set, using the - * passed starting position as a hint: if there is such an instance, it - * updates the new_position pointer to point to this node and returns 0; - * if there is no such node, then if there is a node before where the - * item would have been, it updates the new_position pointer to point - * to this node and returns -1; if there is no such node, then if there - * is a node after where the item would have been, it updates the - * new_position pointer to point to this node (or 0 if there is no such - * node) and returns 1; - */ - int locate (const T &item, ACE_DNode *start_position, - ACE_DNode *&new_position) const; - - /// Delete all the nodes in the Set. - void delete_nodes (void); - - /// Copy nodes into this set. - void copy_nodes (const ACE_Ordered_MultiSet &); - - /// Head of the bilinked list of Nodes. - ACE_DNode *head_; - - /// Head of the bilinked list of Nodes. - ACE_DNode *tail_; - - /// Current size of the set. - size_t cur_size_; - - /// Allocation strategy of the set. - ACE_Allocator *allocator_; -}; - -// **************************************************************** - -/** - * @class ACE_Array - * - * @brief A dynamic array class. - * - * This class extends ACE_Array_Base, adding comparison operators. - * - * Requirements and Performance Characteristics - * - Internal Structure - * Dynamic array - * - Duplicates allowed? - * Yes - * - Random access allowed? - * Yes - * - Search speed - * N/A - * - Insert/replace speed - * O(1) - * - Iterator still valid after change to container? - * - In general, yes. - * - If array size is changed during iteration, no. - * - Frees memory for removed elements? - * No - * - Items inserted by - * Value - * - Requirements for contained type - * -# Default constructor - * -# Copy constructor - * -# operator= - * -# operator!= - * - * @sa ACE_Array_Base. This class inherits its operations and requirements. - */ -template -class ACE_Array : public ACE_Array_Base -{ -public: - // Define a "trait" - typedef T TYPE; - - typedef ACE_Array_Iterator ITERATOR; - - // = Exceptions. - - // = Initialization and termination methods. - - /// Dynamically create an uninitialized array. - /** - * Initialize an empty array of the specified size using the provided - * allocation strategy. - */ - ACE_Array (size_t size = 0, - ACE_Allocator* alloc = 0); - - /// Dynamically initialize the entire array to the {default_value}. - /** - * Initialize an array the given size placing the default_value in each index. - */ - ACE_Array (size_t size, - const T &default_value, - ACE_Allocator* alloc = 0); - - ///Copy constructor. - /** - * The copy constructor performs initialization by making an exact - * copy of the contents of parameter {s}, i.e., *this == s will - * return true. - */ - ACE_Array (const ACE_Array &s); - - ///Assignment operator - /** - * Assignment operator performs an assignment by making an exact - * copy of the contents of parameter {s}, i.e., *this == s will - * return true. Note that if the {max_size_} of {array_} is >= than - * {s.max_size_} we can copy it without reallocating. However, if - * {max_size_} is < {s.max_size_} we must delete the {array_}, - * reallocate a new {array_}, and then copy the contents of {s}. - */ - void operator= (const ACE_Array &s); - - // = Compare operators - - ///Equality comparison operator. - /** - * Compare this array with {s} for equality. Two arrays are equal - * if their {size}'s are equal and all the elements from 0 .. {size} - * are equal. - */ - bool operator== (const ACE_Array &s) const; - - ///Inequality comparison operator. - /** - * Compare this array with {s} for inequality such that {*this} != - * {s} is always the complement of the boolean return value of - * {*this} == {s}. - */ - bool operator!= (const ACE_Array &s) const; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Containers_T.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Containers_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Containers_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" - -#endif /* ACE_CONTAINERS_T_H */ diff --git a/ACE/ace/Containers_T.inl b/ACE/ace/Containers_T.inl deleted file mode 100644 index 425d6e167e8..00000000000 --- a/ACE/ace/Containers_T.inl +++ /dev/null @@ -1,479 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template ACE_INLINE int -ACE_Bounded_Stack::is_empty (void) const -{ - ACE_TRACE ("ACE_Bounded_Stack::is_empty"); - return this->top_ == 0; -} - -template ACE_INLINE int -ACE_Bounded_Stack::is_full (void) const -{ - ACE_TRACE ("ACE_Bounded_Stack::is_full"); - return this->top_ >= this->size_; -} - -template ACE_INLINE int -ACE_Bounded_Stack::push (const T &new_item) -{ - ACE_TRACE ("ACE_Bounded_Stack::push"); - if (this->is_full () == 0) - { - this->stack_[this->top_++] = new_item; - return 0; - } - else - return -1; -} - -template ACE_INLINE int -ACE_Bounded_Stack::pop (T &item) -{ - ACE_TRACE ("ACE_Bounded_Stack::pop"); - if (this->is_empty () == 0) - { - item = this->stack_[--this->top_]; - return 0; - } - else - return -1; -} - -template ACE_INLINE int -ACE_Bounded_Stack::top (T &item) const -{ - ACE_TRACE ("ACE_Bounded_Stack::top"); - if (this->is_empty () == 0) - { - item = this->stack_[this->top_ - 1]; - return 0; - } - else - return -1; -} - -template ACE_INLINE size_t -ACE_Bounded_Stack::size (void) const -{ - return this->size_; -} - -//---------------------------------------- - -template ACE_INLINE int -ACE_Fixed_Stack::is_empty (void) const -{ - ACE_TRACE ("ACE_Fixed_Stack::is_empty"); - return this->top_ == 0; -} - -template ACE_INLINE int -ACE_Fixed_Stack::is_full (void) const -{ - ACE_TRACE ("ACE_Fixed_Stack::is_full"); - return this->top_ >= this->size_; -} - -template ACE_INLINE int -ACE_Fixed_Stack::push (const T &new_item) -{ - ACE_TRACE ("ACE_Fixed_Stack::push"); - if (this->is_full () == 0) - { - this->stack_[this->top_++] = new_item; - return 0; - } - else - return -1; -} - -template ACE_INLINE int -ACE_Fixed_Stack::pop (T &item) -{ - ACE_TRACE ("ACE_Fixed_Stack::pop"); - if (this->is_empty () == 0) - { - item = this->stack_[--this->top_]; - return 0; - } - else - return -1; -} - -template ACE_INLINE int -ACE_Fixed_Stack::top (T &item) const -{ - ACE_TRACE ("ACE_Fixed_Stack::top"); - if (this->is_empty () == 0) - { - item = this->stack_[this->top_ - 1]; - return 0; - } - else - return -1; -} - -template ACE_INLINE size_t -ACE_Fixed_Stack::size (void) const -{ - return this->size_; -} - -template ACE_INLINE int -ACE_Unbounded_Stack::is_empty (void) const -{ - // ACE_TRACE ("ACE_Unbounded_Stack::is_empty"); - return this->head_ == this->head_->next_; -} - -template ACE_INLINE int -ACE_Unbounded_Stack::top (T &item) const -{ - ACE_TRACE ("ACE_Unbounded_Stack::top"); - if (this->is_empty () == 0) - { - item = this->head_->next_->item_; - return 0; - } - else - return -1; -} - -template ACE_INLINE int -ACE_Unbounded_Stack::is_full (void) const -{ - ACE_TRACE ("ACE_Unbounded_Stack::is_full"); - return 0; // ??? -} - -template ACE_INLINE size_t -ACE_Unbounded_Stack::size (void) const -{ - return this->cur_size_; -} - -// --- - - -// --- - -template ACE_INLINE int -ACE_Fixed_Set::is_empty (void) const -{ - ACE_TRACE ("ACE_Fixed_Set::is_empty"); - return this->cur_size_ == 0; -} - -template ACE_INLINE int -ACE_Fixed_Set::is_full (void) const -{ - ACE_TRACE ("ACE_Fixed_Set::is_full"); - return this->cur_size_ == this->max_size_; -} - -// --- - -template ACE_INLINE int -ACE_Bounded_Set::is_empty (void) const -{ - ACE_TRACE ("ACE_Bounded_Set::is_empty"); - return this->cur_size_ == 0; -} - -template ACE_INLINE int -ACE_Bounded_Set::is_full (void) const -{ - ACE_TRACE ("ACE_Bounded_Set::is_full"); - return this->cur_size_ == this->max_size_; -} - -// -- - -template ACE_INLINE int -ACE_Ordered_MultiSet_Iterator::first (void) -{ - ACE_TRACE ("ACE_Ordered_MultiSet_Iterator::first"); - current_ = set_.head_; - - return (current_ ? 1 : 0); -} - -template ACE_INLINE int -ACE_Ordered_MultiSet_Iterator::last (void) -{ - ACE_TRACE ("ACE_Ordered_MultiSet_Iterator::last"); - current_ = set_.tail_; - - return (current_ ? 1 : 0); -} - -template ACE_INLINE int -ACE_Ordered_MultiSet_Iterator::advance (void) -{ - ACE_TRACE ("ACE_Ordered_MultiSet_Iterator::advance"); - - current_ = current_ ? current_->next_ : 0; - - return (current_ ? 1 : 0); -} - -template ACE_INLINE int -ACE_Ordered_MultiSet_Iterator::retreat (void) -{ - ACE_TRACE ("ACE_Ordered_MultiSet_Iterator::retreat"); - - current_ = current_ ? current_->prev_ : 0; - - return (current_ ? 1 : 0); -} - -template ACE_INLINE int -ACE_Ordered_MultiSet_Iterator::done (void) const -{ - ACE_TRACE ("ACE_Ordered_MultiSet_Iterator::done"); - - return (current_ ? 0 : 1); -} - -template ACE_INLINE void -ACE_Ordered_MultiSet_Iterator::dump (void) const -{ -#if defined (ACE_HAS_DUMP) -// ACE_TRACE ("ACE_Ordered_MultiSet_Iterator::dump"); -#endif /* ACE_HAS_DUMP */ -} - - - -// -- - -template ACE_INLINE int -ACE_Ordered_MultiSet::is_empty (void) const -{ - ACE_TRACE ("ACE_Ordered_MultiSet::is_empty"); - return this->cur_size_ > 0 ? 0 : 1; -} - -template ACE_INLINE size_t -ACE_Ordered_MultiSet::size (void) const -{ -// ACE_TRACE ("ACE_Ordered_MultiSet::size"); - return this->cur_size_; -} - -// **************************************************************** - -template ACE_INLINE -ACE_Array::ACE_Array (size_t size, - ACE_Allocator *alloc) - : ACE_Array_Base (size, alloc) -{ -} - -template ACE_INLINE -ACE_Array::ACE_Array (size_t size, - const T &default_value, - ACE_Allocator *alloc) - : ACE_Array_Base (size, default_value, alloc) -{ -} - -// The copy constructor (performs initialization). - -template ACE_INLINE -ACE_Array::ACE_Array (const ACE_Array &s) - : ACE_Array_Base (s) -{ -} - -// Assignment operator (performs assignment). - -template ACE_INLINE void -ACE_Array::operator= (const ACE_Array &s) -{ - // Check for "self-assignment". - - if (this != &s) - this->ACE_Array_Base::operator= (s); -} - -// Compare this array with for inequality. - -template ACE_INLINE bool -ACE_Array::operator!= (const ACE_Array &s) const -{ - return !(*this == s); -} - -// **************************************************************** - - -// **************************************************************** - -template ACE_INLINE void -ACE_DLList::operator= (const ACE_DLList &l) -{ - *(ACE_DLList_Base *) this = l; -} - -template ACE_INLINE int -ACE_DLList::get (T *&item, size_t index) -{ - ACE_DLList_Node *node; - int result = ACE_DLList_Base::get (node, index); - if (result != -1) - item = (T *) node->item_; - return result; -} - -template ACE_INLINE void -ACE_DLList::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_DLList_Base::dump (); -#endif /* ACE_HAS_DUMP */ -} - -template ACE_INLINE int -ACE_DLList::remove (ACE_DLList_Node *n) -{ - int result = ACE_DLList_Base::remove (n); - ACE_DES_FREE (n, - this->allocator_->free, - ACE_DLList_Node); - return result; -} - -template ACE_INLINE -ACE_DLList::ACE_DLList (ACE_Allocator *alloc) - : ACE_DLList_Base (alloc) -{ -} - -template ACE_INLINE -ACE_DLList::ACE_DLList (const ACE_DLList &l) - : ACE_DLList_Base ((ACE_DLList &) l) -{ -} - -template ACE_INLINE -ACE_DLList::~ACE_DLList (void) -{ - while (this->delete_head ()) ; -} - -template ACE_INLINE int -ACE_DLList_Iterator::remove (void) -{ - ACE_DLList_Node *temp = this->ACE_Double_Linked_List_Iterator ::next (); - this->ACE_Double_Linked_List_Iterator ::advance (); - return list_->remove (temp); -} - -template ACE_INLINE -ACE_DLList_Iterator::ACE_DLList_Iterator (ACE_DLList &l) - : ACE_Double_Linked_List_Iterator ((ACE_DLList_Base &)l), - list_ (&l) -{ -} - -template ACE_INLINE void -ACE_DLList_Iterator::reset (ACE_DLList &l) -{ - list_ = &l; - this->ACE_Double_Linked_List_Iterator ::reset ((ACE_DLList_Base &)l); -} - -template ACE_INLINE int -ACE_DLList_Iterator::next (T *&ptr) -{ - ACE_DLList_Node *temp = - ACE_Double_Linked_List_Iterator ::next (); - if (temp) - ptr = (T *) temp->item_; - return temp ? 1 : 0; -} - -template ACE_INLINE T * -ACE_DLList_Iterator::next (void) const -{ - ACE_DLList_Node *temp = ACE_Double_Linked_List_Iterator ::next (); - return (T *) (temp ? temp->item_ : 0); -} - -template ACE_INLINE int -ACE_DLList_Iterator::advance (void) -{ - return this->ACE_Double_Linked_List_Iterator ::advance (); -} - -template ACE_INLINE void -ACE_DLList_Iterator::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_Double_Linked_List_Iterator ::dump (); -#endif /* ACE_HAS_DUMP */ -} - - -template ACE_INLINE int -ACE_DLList_Reverse_Iterator::remove (void) -{ - ACE_DLList_Node *temp = ACE_Double_Linked_List_Reverse_Iterator ::next (); - this->ACE_Double_Linked_List_Reverse_Iterator ::advance (); - return list_->remove (temp); -} - -template ACE_INLINE -ACE_DLList_Reverse_Iterator::ACE_DLList_Reverse_Iterator (ACE_DLList &l) - : ACE_Double_Linked_List_Reverse_Iterator ((ACE_DLList_Base &)l), - list_ (&l) -{ -} - -template ACE_INLINE void -ACE_DLList_Reverse_Iterator::reset (ACE_DLList &l) -{ - list_ = &l; - this->ACE_Double_Linked_List_Reverse_Iterator ::reset ((ACE_DLList_Base &)l); -} - -template ACE_INLINE int -ACE_DLList_Reverse_Iterator::advance (void) -{ - return ACE_Double_Linked_List_Reverse_Iterator ::advance (); -} - -template ACE_INLINE int -ACE_DLList_Reverse_Iterator::next (T *&ptr) -{ - ACE_DLList_Node *temp = - ACE_Double_Linked_List_Reverse_Iterator ::next (); - if (temp == 0) - return 0; - ptr = (T *) temp->item_; - return 1; -} - -template ACE_INLINE T * -ACE_DLList_Reverse_Iterator::next (void) const -{ - ACE_DLList_Node *temp = ACE_Double_Linked_List_Reverse_Iterator ::next (); - return (T *) (temp ? temp->item_ : 0); -} - - -template ACE_INLINE void -ACE_DLList_Reverse_Iterator::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_Double_Linked_List_Reverse_Iterator ::dump (); -#endif /* ACE_HAS_DUMP */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Copy_Disabled.cpp b/ACE/ace/Copy_Disabled.cpp deleted file mode 100644 index d2fb124a182..00000000000 --- a/ACE/ace/Copy_Disabled.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @file Copy_Disabled.cpp - * - * $Id$ - * - * @author Carlos O'Ryan - */ - -#include "ace/Copy_Disabled.h" - - -ACE_RCSID (ace, - Copy_Disabled, - "$Id$") - - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_Copy_Disabled::ACE_Copy_Disabled (void) -{ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Copy_Disabled.h b/ACE/ace/Copy_Disabled.h deleted file mode 100644 index 835b3c20f91..00000000000 --- a/ACE/ace/Copy_Disabled.h +++ /dev/null @@ -1,65 +0,0 @@ -// -*- C++ -*- - -//=========================================================================== -/** - * @file Copy_Disabled.h - * - * $Id$ - * - * @author Carlos O'Ryan - */ -//=========================================================================== - -#ifndef ACE_COPY_DISABLED_H -#define ACE_COPY_DISABLED_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Copy_Disabled - * - * @brief Helper class to disable copy construction and assignment - * - * Classes used to control OS and other resources are not "canonical", - * i.e. they have their copy constructor and assignment operators - * disabled. - * This is often done by making the copy constructor and assignment - * operators private, effectively disallowing copying by clients of - * the class (including derived classes). If the copy constructor and - * assingment operators are left unimplemented then the class itself - * cannot make any copies of its instances, because it would result in - * link errors. - * - * To use this class simply use private inheritance: - * - * class Foo : private ACE_Copy_Disabled - * { - * // code here - * }; - * - */ -class ACE_Export ACE_Copy_Disabled -{ -public: - - /// Default constructor - ACE_Copy_Disabled (void); - -private: - ACE_Copy_Disabled (const ACE_Copy_Disabled &); - ACE_Copy_Disabled &operator= (const ACE_Copy_Disabled &); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#include /**/ "ace/post.h" - -#endif /* ACE_COPY_DISABLED_H */ diff --git a/ACE/ace/Countdown_Time.cpp b/ACE/ace/Countdown_Time.cpp deleted file mode 100644 index 4c95e2acfa1..00000000000 --- a/ACE/ace/Countdown_Time.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "ace/Countdown_Time.h" -#include "ace/OS_NS_sys_time.h" - -ACE_RCSID (ace, - Countdown_Time, - "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_Countdown_Time::ACE_Countdown_Time (ACE_Time_Value *max_wait_time) - : max_wait_time_ (max_wait_time), - stopped_ (false) -{ - this->start (); -} - -ACE_Countdown_Time::~ACE_Countdown_Time (void) -{ - this->stop (); -} - -void -ACE_Countdown_Time::start (void) -{ - if (this->max_wait_time_ != 0) - { - this->start_time_ = ACE_OS::gettimeofday (); - this->stopped_ = false; - } -} - -bool -ACE_Countdown_Time::stopped (void) const -{ - return stopped_; -} - -void -ACE_Countdown_Time::stop (void) -{ - if (this->max_wait_time_ != 0 && this->stopped_ == false) - { - ACE_Time_Value elapsed_time = ACE_OS::gettimeofday () - this->start_time_; - - if (*this->max_wait_time_ > elapsed_time) - { - *this->max_wait_time_ -= elapsed_time; - } - else - { - // Used all of timeout. - *this->max_wait_time_ = ACE_Time_Value::zero; - // errno = ETIME; - } - this->stopped_ = true; - } -} - -void -ACE_Countdown_Time::update (void) -{ - this->stop (); - this->start (); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Countdown_Time.h b/ACE/ace/Countdown_Time.h deleted file mode 100644 index 207b9045fcc..00000000000 --- a/ACE/ace/Countdown_Time.h +++ /dev/null @@ -1,80 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Countdown_Time.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_COUNTDOWN_TIME_H -#define ACE_COUNTDOWN_TIME_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Time_Value.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Countdown_Time - * - * @brief Keeps track of the amount of elapsed time. - * - * This class has a side-effect on the @c max_wait_time -- every - * time the stop() method is called the @c max_wait_time is - * updated. - */ -class ACE_Export ACE_Countdown_Time -{ -public: - /// Cache the @a max_wait_time and call @c start(). - ACE_Countdown_Time (ACE_Time_Value *max_wait_time); - - /// Destructor, makes sure the max_wait_time that got passed as pointer - /// to the constructor is updated with the time elapsed. - ~ACE_Countdown_Time (void); - - /// Cache the current time and enter a start state. - void start (void); - - /// Subtract the elapsed time from max_wait_time_ and enter a stopped - /// state. - void stop (void); - - /// Calls stop and then start. max_wait_time_ is modified by the - /// call to stop. - void update (void); - - /// Returns true if we've already been stopped, else false. - bool stopped (void) const; - -private: - /// Maximum time we were willing to wait. - ACE_Time_Value *max_wait_time_; - - /// Beginning of the start time. - ACE_Time_Value start_time_; - - /// Keeps track of whether we've already been stopped. - bool stopped_; - - // Prevent copying - ACE_Countdown_Time (const ACE_Countdown_Time &); - ACE_Countdown_Time &operator= (const ACE_Countdown_Time &); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#include /**/ "ace/post.h" - -#endif /* ACE_COUNTDOWN_TIME_H */ diff --git a/ACE/ace/DEV.cpp b/ACE/ace/DEV.cpp deleted file mode 100644 index 1ae27fc558e..00000000000 --- a/ACE/ace/DEV.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// $Id$ - -#include "ace/DEV.h" - -#include "ace/OS_NS_unistd.h" - -#if !defined (__ACE_INLINE__) -#include "ace/DEV.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, DEV, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_DEV) - -void -ACE_DEV::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_DEV::dump"); -#endif /* ACE_HAS_DUMP */ -} - -// This is the do-nothing constructor. - -ACE_DEV::ACE_DEV (void) -{ - ACE_TRACE ("ACE_DEV::ACE_DEV"); -} - -// Close the device - -int -ACE_DEV::close (void) -{ - ACE_TRACE ("ACE_DEV::close"); - int result = ACE_OS::close (this->get_handle ()); - this->set_handle (ACE_INVALID_HANDLE); - return result; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/DEV.h b/ACE/ace/DEV.h deleted file mode 100644 index 8b0c585ddf7..00000000000 --- a/ACE/ace/DEV.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file DEV.h - * - * $Id$ - * - * @author Gerhard Lenzer - */ -//============================================================================= - - -#ifndef ACE_DEV_H -#define ACE_DEV_H -#include /**/ "ace/pre.h" - -#include "ace/IO_SAP.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/DEV_Addr.h" - -// The following is necessary since many C++ compilers don't support -// typedef'd types inside of classes used as formal template -// arguments... ;-(. Luckily, using the C++ preprocessor I can hide -// most of this nastiness! - -#if defined (ACE_HAS_TEMPLATE_TYPEDEFS) -#define ACE_DEV_CONNECTOR ACE_DEV_Connector -#define ACE_DEV_STREAM ACE_DEV_IO -#else /* TEMPLATES are broken (must be a cfront-based compiler...) */ -#define ACE_DEV_CONNECTOR ACE_DEV_Connector, ACE_DEV_Addr -#define ACE_DEV_STREAM ACE_DEV_IO, ACE_DEV_Addr -#endif /* ACE_TEMPLATE_TYPEDEFS */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_DEV - * - * @brief Defines the member functions for the base class of the - * ACE_DEV abstraction. - */ -class ACE_Export ACE_DEV : public ACE_IO_SAP -{ -public: - /// Close down the DEVICE - int close (void); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - - /** - * Disable signal @a signum - * This is here to prevent Win32 from - * disabling SPIPE using socket calls - */ - int disable (int signum) const ; - -protected: - /// Ensure that this class is an abstract base class - ACE_DEV (void); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/DEV.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_DEV_H */ diff --git a/ACE/ace/DEV.inl b/ACE/ace/DEV.inl deleted file mode 100644 index e00f4fc705e..00000000000 --- a/ACE/ace/DEV.inl +++ /dev/null @@ -1,18 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE int -ACE_DEV::disable (int signum) const -{ -#if defined (ACE_WIN32) - ACE_UNUSED_ARG (signum) ; - return 0 ; -#else /* ACE_WIN32 */ - return ACE_IO_SAP::disable (signum) ; -#endif /* ACE_WIN32 */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/DEV_Addr.cpp b/ACE/ace/DEV_Addr.cpp deleted file mode 100644 index 39d1768051f..00000000000 --- a/ACE/ace/DEV_Addr.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// $Id$ - -#include "ace/DEV_Addr.h" -#if !defined (__ACE_INLINE__) -#include "ace/DEV_Addr.inl" -#endif /* __ACE_INLINE__ */ - -#include "ace/Log_Msg.h" -#include "ace/OS_NS_string.h" - -ACE_RCSID (ace, - DEV_Addr, - "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_DEV_Addr) - -// Transform the current address into string format. - -int -ACE_DEV_Addr::addr_to_string (ACE_TCHAR *s, size_t len) const -{ - ACE_TRACE ("ACE_DEV_Addr::addr_to_string"); - - ACE_OS::strsncpy (s, this->devname_, len); - return 0; -} - -// Return a pointer to the address. - -void * -ACE_DEV_Addr::get_addr (void) const -{ - ACE_TRACE ("ACE_DEV_Addr::get_addr"); - - return (void *) &this->devname_; -} - -void -ACE_DEV_Addr::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_DEV_Addr::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("devname_ = %s"), this->devname_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -// Do nothing constructor. - -ACE_DEV_Addr::ACE_DEV_Addr (void) - : ACE_Addr (AF_DEV, sizeof this->devname_) -{ - ACE_TRACE ("ACE_DEV_Addr::ACE_DEV_Addr"); - - (void) ACE_OS::memset ((void *) &this->devname_, - 0, sizeof this->devname_); -} - -int -ACE_DEV_Addr::set (const ACE_DEV_Addr &sa) -{ - this->base_set (sa.get_type (), sa.get_size ()); - - if (sa.get_type () == AF_ANY) - (void) ACE_OS::memset ((void *) &this->devname_, - 0, - sizeof this->devname_); - else - (void) ACE_OS::strsncpy (this->devname_, - sa.devname_, - ACE_DEV_Addr::DEVNAME_LENGTH); - return 0; -} - -// Copy constructor. - -ACE_DEV_Addr::ACE_DEV_Addr (const ACE_DEV_Addr &sa) - : ACE_Addr (AF_DEV, sizeof this->devname_) -{ - ACE_TRACE ("ACE_DEV_Addr::ACE_DEV_Addr"); - - this->set (sa); -} - -ACE_DEV_Addr::ACE_DEV_Addr (const ACE_TCHAR *devname) - : ACE_Addr (AF_DEV, sizeof this->devname_) -{ - ACE_TRACE ("ACE_DEV_Addr::ACE_DEV_Addr"); - - this->set (devname); -} - -ACE_DEV_Addr & -ACE_DEV_Addr::operator= (const ACE_DEV_Addr &sa) -{ - ACE_TRACE ("ACE_DEV_Addr::operator="); - - if (this != &sa) - this->set (sa); - - return *this; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/DEV_Addr.h b/ACE/ace/DEV_Addr.h deleted file mode 100644 index 0646260c8f9..00000000000 --- a/ACE/ace/DEV_Addr.h +++ /dev/null @@ -1,90 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file DEV_Addr.h - * - * $Id$ - * - * @author Gerhard Lenzer and Douglas C. Schmidt - */ -//========================================================================== - -#ifndef ACE_DEV_ADDR_H -#define ACE_DEV_ADDR_H - -#include /**/ "ace/pre.h" - -#include "ace/Addr.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/os_include/os_dirent.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_DEV_Addr - * - * @brief Defines device address family address format. - */ -class ACE_Export ACE_DEV_Addr : public ACE_Addr -{ -public: - // = Initialization methods. - /// Default constructor. - ACE_DEV_Addr (void); - - /// Copy constructor. - ACE_DEV_Addr (const ACE_DEV_Addr &sa); - - /// Acts like a copy constructor. - int set (const ACE_DEV_Addr &sa); - - /// Create a ACE_DEV_Addr from a device name. - explicit ACE_DEV_Addr (const ACE_TCHAR *devname); - - /// Create a ACE_Addr from a ACE_DEV pathname. - void set (const ACE_TCHAR *devname); - - /// Assignment operator. - ACE_DEV_Addr &operator= (const ACE_DEV_Addr &); - - /// Return a pointer to the address. - virtual void *get_addr (void) const; - - /// Transform the current address into string format. - virtual int addr_to_string (ACE_TCHAR *addr, size_t) const; - - /// Compare two addresses for equality. - bool operator == (const ACE_DEV_Addr &SAP) const; - - /// Compare two addresses for inequality. - bool operator != (const ACE_DEV_Addr &SAP) const; - - /// Return the path name used for the rendezvous point. - const ACE_TCHAR *get_path_name (void) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - enum { DEVNAME_LENGTH = MAXPATHLEN + 1 }; - /// Name of the device. - ACE_TCHAR devname_[DEVNAME_LENGTH]; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/DEV_Addr.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" - -#endif /* ACE_DEV_ADDR_H */ diff --git a/ACE/ace/DEV_Addr.inl b/ACE/ace/DEV_Addr.inl deleted file mode 100644 index 820b961d1d0..00000000000 --- a/ACE/ace/DEV_Addr.inl +++ /dev/null @@ -1,51 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/OS_NS_string.h" -#include "ace/Global_Macros.h" -#include "ace/os_include/sys/os_socket.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE void -ACE_DEV_Addr::set (const ACE_TCHAR *devname) -{ - ACE_TRACE ("ACE_DEV_Addr::set"); - - this->ACE_Addr::base_set - (AF_DEV, static_cast (ACE_OS::strlen (devname))); - ACE_OS::strsncpy (this->devname_, devname, ACE_DEV_Addr::DEVNAME_LENGTH); -} - -// Compare two addresses for equality. - -ACE_INLINE bool -ACE_DEV_Addr::operator == (const ACE_DEV_Addr &sap) const -{ - ACE_TRACE ("ACE_DEV_Addr::operator =="); - - return ACE_OS::strcmp (this->devname_, sap.devname_) == 0; -} - -// Compare two addresses for inequality. - -ACE_INLINE bool -ACE_DEV_Addr::operator != (const ACE_DEV_Addr &sap) const -{ - ACE_TRACE ("ACE_DEV_Addr::operator !="); - - return !((*this) == sap); // This is lazy, of course... ;-). -} - -// Return the path name used for the rendezvous point. - -ACE_INLINE const ACE_TCHAR * -ACE_DEV_Addr::get_path_name (void) const -{ - ACE_TRACE ("ACE_DEV_Addr::get_path_name"); - - return this->devname_; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/DEV_Connector.cpp b/ACE/ace/DEV_Connector.cpp deleted file mode 100644 index a1fef807057..00000000000 --- a/ACE/ace/DEV_Connector.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// $Id$ - -#include "ace/DEV_Connector.h" - -#include "ace/Handle_Ops.h" - -#if !defined (__ACE_INLINE__) -#include "ace/DEV_Connector.inl" -#endif /* __ACE_INLINE__ */ - - -ACE_RCSID (ace, - DEV_Connector, - "$Id$") - - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_DEV_Connector) - -void -ACE_DEV_Connector::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_DEV_Connector::dump"); -#endif /* ACE_HAS_DUMP */ -} - -ACE_DEV_Connector::ACE_DEV_Connector (void) -{ - ACE_TRACE ("ACE_DEV_Connector::ACE_DEV_Connector"); -} - -int -ACE_DEV_Connector::connect (ACE_DEV_IO &new_io, - const ACE_DEV_Addr &remote_sap, - ACE_Time_Value *timeout, - const ACE_Addr &, - int, - int flags, - int perms) -{ - ACE_TRACE ("ACE_DEV_Connector::connect"); - - ACE_HANDLE handle = ACE::handle_timed_open (timeout, - remote_sap.get_path_name (), - flags, perms); - new_io.set_handle (handle); - new_io.addr_ = remote_sap; // class copy. - return handle == ACE_INVALID_HANDLE ? -1 : 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/DEV_Connector.h b/ACE/ace/DEV_Connector.h deleted file mode 100644 index 9e001c412f4..00000000000 --- a/ACE/ace/DEV_Connector.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file DEV_Connector.h - * - * $Id$ - * - * @author Gerhard Lenzer and Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_DEV_CONNECTOR_H -#define ACE_DEV_CONNECTOR_H -#include /**/ "ace/pre.h" - -#include "ace/DEV_IO.h" -#include "ace/Log_Msg.h" -#include "ace/os_include/os_fcntl.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_DEV_Connector - * - * @brief Defines an active connection factory for the ACE_DEV wrappers. - */ -class ACE_Export ACE_DEV_Connector -{ -public: - /// Default constructor. - ACE_DEV_Connector (void); - - /** - * Actively connect and produce a @a new_io if things go well. - * The @a remote_sap is the address that we are trying to connect - * with. The @a timeout is the amount of time to wait to connect. - * If it's 0 then we block indefinitely. If *timeout == {0, 0} then - * the connection is done using non-blocking mode. In this case, if - * the connection can't be made immediately the value of -1 is - * returned with @c errno == EWOULDBLOCK. If *timeout > {0, 0} then - * this is the maximum amount of time to wait before timing out. If the - * time expires before the connection is made @c errno == ETIME. The - * @a local_sap is the value of local address to bind to. If it's - * the default value of ACE_Addr::sap_any then the user is letting - * the OS do the binding. If @a reuse_addr == 1 then the - * is reused, even if it hasn't been cleanedup yet. - * The @a flags and @a perms arguments are passed down to the - * method. - */ - ACE_DEV_Connector (ACE_DEV_IO &new_io, - const ACE_DEV_Addr &remote_sap, - ACE_Time_Value *timeout = 0, - const ACE_Addr &local_sap = ACE_Addr::sap_any, - int reuse_addr = 0, - int flags = O_RDWR, - int perms = 0); - - /** - * Actively connect and produce a @a new_io if things go well. - * The @a remote_sap is the address that we are trying to connect - * with. The @a timeout is the amount of time to wait to connect. - * If it's 0 then we block indefinitely. If *timeout == {0, 0} then - * the connection is done using non-blocking mode. In this case, if - * the connection can't be made immediately the value of -1 is - * returned with @c errno == EWOULDBLOCK. If *timeout > {0, 0} then - * this is the maximum amount of time to wait before timing out. If the - * time expires before the connection is made @c errno == ETIME. The - * @a local_sap is the value of local address to bind to. If it's - * the default value of ACE_Addr::sap_any then the user is letting - * the OS do the binding. If @a reuse_addr == 1 then the - * is reused, even if it hasn't been cleanedup yet. - * The @a flags and @a perms arguments are passed down to the - * method. - */ - int connect (ACE_DEV_IO &new_io, - const ACE_DEV_Addr &remote_sap, - ACE_Time_Value *timeout = 0, - const ACE_Addr &local_sap = ACE_Addr::sap_any, - int reuse_addr = 0, - int flags = O_RDWR, - int perms = 0); - - /// Resets any event associations on this handle - int reset_new_handle (ACE_HANDLE handle); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - - // = Meta-type info - typedef ACE_DEV_Addr PEER_ADDR; - typedef ACE_DEV_IO PEER_STREAM; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/DEV_Connector.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_DEV_CONNECTOR_H */ diff --git a/ACE/ace/DEV_Connector.inl b/ACE/ace/DEV_Connector.inl deleted file mode 100644 index 314952699de..00000000000 --- a/ACE/ace/DEV_Connector.inl +++ /dev/null @@ -1,34 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Creates a Local ACE_DEV. - -ACE_INLINE -ACE_DEV_Connector::ACE_DEV_Connector (ACE_DEV_IO &new_io, - const ACE_DEV_Addr &remote_sap, - ACE_Time_Value *timeout, - const ACE_Addr &local_sap, - int reuse_addr, - int flags, - int perms) -{ - ACE_TRACE ("ACE_DEV_Connector::ACE_DEV_Connector"); - if (this->connect (new_io, remote_sap, timeout, local_sap, - reuse_addr, flags, perms) == ACE_IO_SAP::INVALID_HANDLE - && timeout != 0 && !(errno == EWOULDBLOCK || errno == ETIME)) - ACE_ERROR ((LM_ERROR, ACE_TEXT ("address %s, %p\n"), - remote_sap.get_path_name (), ACE_TEXT ("ACE_DEV_IO"))); -} - -ACE_INLINE int -ACE_DEV_Connector::reset_new_handle (ACE_HANDLE handle) -{ - ACE_UNUSED_ARG (handle); - // Nothing to do here since the handle is not a socket - return 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/DEV_IO.cpp b/ACE/ace/DEV_IO.cpp deleted file mode 100644 index f5367d1d5cd..00000000000 --- a/ACE/ace/DEV_IO.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// $Id$ - -#include "ace/DEV_IO.h" -#include "ace/Log_Msg.h" - -#if !defined (__ACE_INLINE__) -#include "ace/DEV_IO.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, DEV_IO, "$Id$") - - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_DEV_IO) - -// Return the local endpoint address. - -int -ACE_DEV_IO::get_local_addr (ACE_DEV_Addr &addr) const -{ - ACE_TRACE ("ACE_DEV_IO::get_local_addr"); - - addr = this->addr_; - return 0; -} - -// Return the address of the remotely connected peer (if there is -// one). - -int -ACE_DEV_IO::get_remote_addr (ACE_DEV_Addr &addr) const -{ - ACE_TRACE ("ACE_DEV_IO::get_remote_addr"); - addr = this->addr_; - return 0; -} - -void -ACE_DEV_IO::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_DEV_IO::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - this->addr_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -// Simple-minded do nothing constructor. - -ACE_DEV_IO::ACE_DEV_IO (void) -{ - ACE_TRACE ("ACE_DEV_IO::ACE_DEV_IO"); -} - -// Send N char *ptrs and int lengths. Note that the char *'s precede -// the ints (basically, an varargs version of writev). The count N is -// the *total* number of trailing arguments, *not* a couple of the -// number of tuple pairs! - -ssize_t -ACE_DEV_IO::send (size_t n, ...) const -{ - ACE_TRACE ("ACE_DEV_IO::send"); - va_list argp; - int total_tuples = static_cast (n / 2); - iovec *iovp; -#if defined (ACE_HAS_ALLOCA) - iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); -#else - ACE_NEW_RETURN (iovp, - iovec[total_tuples], - -1); -#endif /* !defined (ACE_HAS_ALLOCA) */ - - va_start (argp, n); - - for (int i = 0; i < total_tuples; i++) - { - iovp[i].iov_base = va_arg (argp, char *); - iovp[i].iov_len = va_arg (argp, int); - } - - ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples); -#if !defined (ACE_HAS_ALLOCA) - delete [] iovp; -#endif /* !defined (ACE_HAS_ALLOCA) */ - va_end (argp); - return result; -} - -// This is basically an interface to ACE_OS::readv, that doesn't use the -// struct iovec explicitly. The ... can be passed as an arbitrary -// number of (char *ptr, int len) tuples. However, the count N is the -// *total* number of trailing arguments, *not* a couple of the number -// of tuple pairs! - -ssize_t -ACE_DEV_IO::recv (size_t n, ...) const -{ - ACE_TRACE ("ACE_DEV_IO::recv"); - va_list argp; - int total_tuples = static_cast (n / 2); - iovec *iovp; -#if defined (ACE_HAS_ALLOCA) - iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); -#else - ACE_NEW_RETURN (iovp, - iovec[total_tuples], - -1); -#endif /* !defined (ACE_HAS_ALLOCA) */ - - va_start (argp, n); - - for (int i = 0; i < total_tuples; i++) - { - iovp[i].iov_base = va_arg (argp, char *); - iovp[i].iov_len = va_arg (argp, int); - } - - ssize_t result = ACE_OS::readv (this->get_handle (), iovp, total_tuples); -#if !defined (ACE_HAS_ALLOCA) - delete [] iovp; -#endif /* !defined (ACE_HAS_ALLOCA) */ - va_end (argp); - return result; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/DEV_IO.h b/ACE/ace/DEV_IO.h deleted file mode 100644 index d3b1aadaa2f..00000000000 --- a/ACE/ace/DEV_IO.h +++ /dev/null @@ -1,185 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file DEV_IO.h - * - * $Id$ - * - * @author Gerhard Lenzer - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_DEV_IO_H -#define ACE_DEV_IO_H -#include /**/ "ace/pre.h" - -#include "ace/DEV.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_STREAM_PIPES) -# include "ace/OS_NS_stropts.h" -#endif /* ACE_HAS_STREAM_PIPES */ - -#include "ace/os_include/os_stdio.h" -#include "ace/os_include/sys/os_uio.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -class ACE_Time_Value; - -/** - * @class ACE_DEV_IO - * - * @brief Read/Write operations on Devices. - */ -class ACE_Export ACE_DEV_IO : public ACE_DEV -{ -public: - friend class ACE_DEV_Connector; - - /// Default constructor. - ACE_DEV_IO (void); - - // = Various send operations. - /// send upto @a n bytes in @a buf. - ssize_t send (const void *buf, size_t n) const; - - /// Recv upto @a n bytes in @a buf. - ssize_t recv (void *buf, size_t n) const; - - /// Send n bytes, keep trying until n are sent. - ssize_t send_n (const void *buf, - size_t n) const; - - /** - * @name I/O operations - * - * Notes on common parameters: - * - * @a buf is the buffer to write from or receive into. - * - * @a len is the number of bytes to transfer. - * - * The @a timeout parameter in the following methods indicates how - * long to blocking trying to transfer data. If @a timeout == 0, - * then the call behaves as a normal send/recv call, i.e., for - * blocking sockets, the call will block until action is possible; - * for non-blocking sockets, EWOULDBLOCK will be returned if no - * action is immediately possible. - * - * If @a timeout != 0, the call will wait until the relative time - * specified in *@a timeout elapses. - * - * The "_n()" I/O methods keep looping until all the data has been - * transferred. These methods also work for sockets in non-blocking - * mode i.e., they keep looping on EWOULDBLOCK. @a timeout is used - * to make sure we keep making progress, i.e., the same timeout - * value is used for every I/O operation in the loop and the timeout - * is not counted down. - * - * The return values for the "*_n()" methods match the return values - * from the non "_n()" methods and are specified as follows: - * - * - On complete transfer, the number of bytes transferred is returned. - * - On timeout, -1 is returned, errno == ETIME. - * - On error, -1 is returned, errno is set to appropriate error. - * - On EOF, 0 is returned, errno is irrelevant. - * - * On partial transfers, i.e., if any data is transferred before - * timeout/error/EOF, @a bytes_transferred will contain the number of - * bytes transferred. - */ - ssize_t recv_n (void *buf, - size_t n, - const ACE_Time_Value *timeout = 0, - size_t *bytes_transferred = 0) const; - -#if defined (ACE_HAS_STREAM_PIPES) - /// Recv bytes via STREAM pipes using "band" mode. - ssize_t recv (ACE_Str_Buf *cntl, - ACE_Str_Buf *data, - int *band, - int *flags) const; - - /// Send bytes via STREAM pipes using "band" mode. - ssize_t send (const ACE_Str_Buf *cntl, - const ACE_Str_Buf *data, - int band, - int flags) const; - - /// Recv @a cntl and @a data via STREAM pipes. - ssize_t recv (ACE_Str_Buf *cntl, - ACE_Str_Buf *data, - int *flags) const; - - /// Send @a cntl and @a data via STREAM pipes. - ssize_t send (const ACE_Str_Buf *cntl, - const ACE_Str_Buf *data, - int flags = 0) const; -#endif /* ACE_HAS_STREAM_PIPES */ - - /// Send iovecs via <::writev>. - ssize_t send (const iovec iov[], size_t n) const; - - /// Recv iovecs via <::readv>. - ssize_t recv (iovec iov[], size_t n) const; - - /** - * Send N char *ptrs and int lengths. Note that the char *'s - * precede the ints (basically, an varargs version of writev). The - * count N is the *total* number of trailing arguments, *not* a - * couple of the number of tuple pairs! - */ - ssize_t send (size_t n, ...) const; - - /** - * This is an interface to ::readv, that doesn't use the struct - * iovec explicitly. The ... can be passed as an arbitrary number - * of (char *ptr, int len) tuples. However, the count N is the - * *total* number of trailing arguments, *not* a couple of the - * number of tuple pairs! - */ - ssize_t recv (size_t n, ...) const; - - /// Send @a n bytes via Win32 WriteFile using overlapped I/O. - ssize_t send (const void *buf, size_t n, ACE_OVERLAPPED *overlapped) const; - - /// Recv @a n bytes via Win32 ReadFile using overlapped I/O. - ssize_t recv (void *buf, size_t n, ACE_OVERLAPPED *overlapped) const; - - /// Dump the state of an object. - void dump (void) const; - - // = The following two methods are no-ops to keep the - // ACE_Connector happy. - /// Return the local endpoint address. - int get_local_addr (ACE_DEV_Addr &) const; - - /// Return the address of the remotely connected peer (if there is - /// one). - int get_remote_addr (ACE_DEV_Addr &) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - - // = Meta-type info - typedef ACE_DEV_Addr PEER_ADDR; - -private: - /// Address of device we are connected to. - ACE_DEV_Addr addr_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/DEV_IO.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_DEV_IO_H */ diff --git a/ACE/ace/DEV_IO.inl b/ACE/ace/DEV_IO.inl deleted file mode 100644 index cb9392e2bf3..00000000000 --- a/ACE/ace/DEV_IO.inl +++ /dev/null @@ -1,126 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/OS_NS_sys_uio.h" -#include "ace/OS_NS_unistd.h" -#include "ace/OS_Memory.h" - -#include "ace/ACE.h" - -// Send exactly N bytes from BUF to this device. Keeping trying until -// this many bytes are sent. - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE ssize_t -ACE_DEV_IO::send_n (const void *buf, size_t n) const -{ - ACE_TRACE ("ACE_DEV_IO::send_n"); - return ACE::write_n (this->get_handle (), buf, n); -} - -// Receive exactly N bytes from this file into BUF. Keep trying until -// this many bytes are received. - -ACE_INLINE ssize_t -ACE_DEV_IO::recv_n (void *buf, - size_t n, - const ACE_Time_Value *timeout, - size_t *bytes_transferred) const -{ - ACE_TRACE ("ACE_DEV_IO::recv_n"); -#if defined (ACE_WIN32) - ACE_UNUSED_ARG (timeout); - - return ACE::read_n (this->get_handle (), - buf, - n, - bytes_transferred); -#else - return ACE::recv_n (this->get_handle (), - buf, - n, - timeout, - bytes_transferred); -#endif /*ACE_WIN32*/ -} - -ACE_INLINE ssize_t -ACE_DEV_IO::send (const void *buf, size_t n) const -{ - ACE_TRACE ("ACE_DEV_IO::send"); - return ACE_OS::write (this->get_handle (), (const char *) buf, n); -} - -ACE_INLINE ssize_t -ACE_DEV_IO::recv (void *buf, size_t n) const -{ - ACE_TRACE ("ACE_DEV_IO::recv"); - return ACE_OS::read (this->get_handle (), (char *) buf, n); -} - -ACE_INLINE ssize_t -ACE_DEV_IO::send (const iovec iov[], size_t n) const -{ - ACE_TRACE ("ACE_DEV_IO::send"); - return ACE_OS::writev (this->get_handle (), iov, static_cast (n)); -} - -ACE_INLINE ssize_t -ACE_DEV_IO::recv (iovec iov[], size_t n) const -{ - ACE_TRACE ("ACE_DEV_IO::recv"); - return ACE_OS::readv (this->get_handle (), iov, static_cast (n)); -} - -ACE_INLINE ssize_t -ACE_DEV_IO::send (const void *buf, size_t n, - ACE_OVERLAPPED *overlapped) const -{ - ACE_TRACE ("ACE_DEV_IO::send"); - return ACE_OS::write (this->get_handle (), - (const char *) buf, n, - overlapped); -} - -ACE_INLINE ssize_t -ACE_DEV_IO::recv (void *buf, size_t n, - ACE_OVERLAPPED *overlapped) const -{ - ACE_TRACE ("ACE_DEV_IO::recv"); - return ACE_OS::read (this->get_handle (), (char *) buf, n, - overlapped); -} - -#if defined (ACE_HAS_STREAM_PIPES) -ACE_INLINE ssize_t -ACE_DEV_IO::recv (ACE_Str_Buf *cntl, ACE_Str_Buf *data, int *band, int *flags) const -{ - ACE_TRACE ("ACE_DEV_IO::recv"); - return ACE_OS::getpmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, band, flags); -} - -ACE_INLINE ssize_t -ACE_DEV_IO::send (const ACE_Str_Buf *cntl, const ACE_Str_Buf *data, int band, int flags) const -{ - ACE_TRACE ("ACE_DEV_IO::send"); - return ACE_OS::putpmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, band, flags); -} - -ACE_INLINE ssize_t -ACE_DEV_IO::recv (ACE_Str_Buf *cntl, ACE_Str_Buf *data, int *flags) const -{ - ACE_TRACE ("ACE_DEV_IO::recv"); - return ACE_OS::getmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, flags); -} - -ACE_INLINE ssize_t -ACE_DEV_IO::send (const ACE_Str_Buf *cntl, const ACE_Str_Buf *data, int flags) const -{ - ACE_TRACE ("ACE_DEV_IO::send"); - return ACE_OS::putmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, flags); -} -#endif /* ACE_HAS_STREAM_PIPES */ - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/DLL.cpp b/ACE/ace/DLL.cpp deleted file mode 100644 index cdee3c6bd24..00000000000 --- a/ACE/ace/DLL.cpp +++ /dev/null @@ -1,267 +0,0 @@ -// $Id$ - -#include "ace/DLL.h" - -#include "ace/Log_Msg.h" -#include "ace/ACE.h" -#include "ace/DLL_Manager.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_dlfcn.h" -#include "ace/OS_NS_Thread.h" - -#include - -ACE_RCSID(ace, DLL, "$Id$") - - ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Default constructor. Also, by default, the object will be closed -// before it is destroyed. - -ACE_DLL::ACE_DLL (bool close_handle_on_destruction) - : open_mode_ (0), - dll_name_ (0), - close_handle_on_destruction_ (close_handle_on_destruction), - dll_handle_ (0), - error_ (0) -{ - ACE_TRACE ("ACE_DLL::ACE_DLL (int)"); -} - -ACE_DLL::ACE_DLL (const ACE_DLL &rhs) - : open_mode_ (0), - dll_name_ (0), - close_handle_on_destruction_ (false), - dll_handle_ (0), - error_ (0) -{ - ACE_TRACE ("ACE_DLL::ACE_DLL (const ACE_DLL &)"); - - if (rhs.dll_name_ - // This will automatically up the refcount. - && this->open (rhs.dll_name_, - rhs.open_mode_, - rhs.close_handle_on_destruction_) != 0 - && ACE::debug ()) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE_DLL::copy_ctor: error: %s\n"), - this->error ())); -} - -// Assignment operator - -ACE_DLL & -ACE_DLL::operator= (const ACE_DLL &rhs) -{ - ACE_TRACE ("ACE_DLL::operator= (const ACE_DLL &)"); - - ACE_DLL tmp (rhs); - - std::swap (this->open_mode_, tmp.open_mode_); - std::swap (this->dll_name_, tmp.dll_name_); - std::swap (this->close_handle_on_destruction_, - tmp.close_handle_on_destruction_); - std::swap (this->dll_handle_, tmp.dll_handle_); - std::swap (this->error_, tmp.error_); - - return *this; -} - - -// If the library name and the opening mode are specified than on -// object creation the library is implicitly opened. - -ACE_DLL::ACE_DLL (const ACE_TCHAR *dll_name, - int open_mode, - bool close_handle_on_destruction) - : open_mode_ (open_mode), - dll_name_ (0), - close_handle_on_destruction_ (close_handle_on_destruction), - dll_handle_ (0), - error_ (0) -{ - ACE_TRACE ("ACE_DLL::ACE_DLL"); - - if (this->open (dll_name, this->open_mode_, close_handle_on_destruction) != 0 - && ACE::debug ()) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE_DLL::open: error calling open: %s\n"), - this->error ())); -} - -// The library is closed before the class gets destroyed depending on -// the close_handle_on_destruction value specified which is stored in -// close_handle_on_destruction_. - -ACE_DLL::~ACE_DLL (void) -{ - ACE_TRACE ("ACE_DLL::~ACE_DLL"); - - this->close (); - - // Normally delete()d in ACE_DLL::close(). However, that may not - // occur if full ACE_DLL initialization is interrupted due to errors - // (e.g. attempting to open a DSO/DLL that does not exist). Make - // sure this->dll_name_ is deallocated. - delete [] this->dll_name_; -} - -// This method opens the library based on the mode specified using the -// ACE_SHLIB_HANDLE which is obtained on making the ACE_OS::dlopen call. -// The default mode is: -// RTLD_LAZY Only references to data symbols are relocate when the -// object is first loaded. -// The other modes include: -// RTLD_NOW All necessary relocations are performed when the -// object is first loaded. -// RTLD_GLOBAL The object symbols are made available for the -// relocation processing of any other object. - -int -ACE_DLL::open (const ACE_TCHAR *dll_filename, - int open_mode, - bool close_handle_on_destruction) -{ - ACE_TRACE ("ACE_DLL::open"); - - return open_i (dll_filename, open_mode, close_handle_on_destruction); -} - -int -ACE_DLL::open_i (const ACE_TCHAR *dll_filename, - int open_mode, - bool close_handle_on_destruction, - ACE_SHLIB_HANDLE handle) -{ - ACE_TRACE ("ACE_DLL::open_i"); - - this->error_ = 0; - - if (!dll_filename) - { - if (ACE::debug ()) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE_DLL::open_i: dll_name is %s\n"), - this->dll_name_ == 0 ? ACE_TEXT ("(null)") - : this->dll_name_)); - return -1; - } - - if (this->dll_handle_) - { - // If we have a good handle and its the same name, just return. - if (ACE_OS::strcmp (this->dll_name_, dll_filename) == 0) - return 0; - else - this->close (); - } - - if (!this->dll_name_) - this->dll_name_ = ACE::strnew (dll_filename); - - this->open_mode_ = open_mode; - this->close_handle_on_destruction_ = close_handle_on_destruction; - - this->dll_handle_ = ACE_DLL_Manager::instance()->open_dll (this->dll_name_, - this->open_mode_, - handle); - - if (!this->dll_handle_) - this->error_ = 1; - - return this->error_ ? -1 : 0; -} - -// The symbol refernce of the name specified is obtained. - -void * -ACE_DLL::symbol (const ACE_TCHAR *sym_name, int ignore_errors) -{ - ACE_TRACE ("ACE_DLL::symbol"); - - this->error_ = 0; - - void *sym = 0; - if (this->dll_handle_) - sym = this->dll_handle_->symbol (sym_name, ignore_errors); - - if (!sym) - this->error_ = 1; - - return sym; -} - -// The library is closed using the ACE_SHLIB_HANDLE object, i.e., the -// shared object is now disassociated form the current process. - -int -ACE_DLL::close (void) -{ - ACE_TRACE ("ACE_DLL::close"); - - int retval = 0; - - if (this->dll_handle_ - && this->close_handle_on_destruction_ - && this->dll_name_ - && (retval = ACE_DLL_Manager::instance ()->close_dll (this->dll_name_)) != 0) - this->error_ = 1; - - // Even if close_dll() failed, go ahead and cleanup. - this->dll_handle_ = 0; - delete [] this->dll_name_; - this->dll_name_ = 0; - this->close_handle_on_destruction_ = false; - - return retval; -} - -// This method is used return the last error of a library operation. - -ACE_TCHAR * -ACE_DLL::error (void) const -{ - ACE_TRACE ("ACE_DLL::error"); - if (this->error_) - { - return ACE_OS::dlerror (); - } - - return 0; -} - -// Return the handle to the user either temporarily or forever, thus -// orphaning it. If 0 means the user wants the handle forever and if 1 -// means the user temporarily wants to take the handle. - -ACE_SHLIB_HANDLE -ACE_DLL::get_handle (int become_owner) const -{ - ACE_TRACE ("ACE_DLL::get_handle"); - - ACE_SHLIB_HANDLE handle = ACE_SHLIB_INVALID_HANDLE; - - if (this->dll_handle_) - handle = this->dll_handle_->get_handle (become_owner); - - return handle; -} - -// Set the handle for the DLL. By default, the object will be closed -// before it is destroyed. - -int -ACE_DLL::set_handle (ACE_SHLIB_HANDLE handle, - bool close_handle_on_destruction) -{ - ACE_TRACE ("ACE_DLL::set_handle"); - - // Create a unique name. Note that this name is only quaranteed - // to be unique for the life of this object. - ACE_TCHAR temp[ACE_UNIQUE_NAME_LEN]; - ACE_OS::unique_name (this, temp, ACE_UNIQUE_NAME_LEN); - - return this->open_i (temp, 1, close_handle_on_destruction, handle); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/DLL.h b/ACE/ace/DLL.h deleted file mode 100644 index 64cb646576a..00000000000 --- a/ACE/ace/DLL.h +++ /dev/null @@ -1,196 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file DLL.h - * - * $Id$ - * - * @author Kirthika Parameswaran - */ -//============================================================================= - -#ifndef ACE_DLL_H -#define ACE_DLL_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Global_Macros.h" -#include "ace/os_include/os_dlfcn.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -class ACE_DLL_Handle; - -/** - * @class ACE_DLL - * - * @brief Provides an abstract interface for handling various DLL - * operations. - * - * This class is a wrapper over the various methods for utilizing - * a dynamically linked library (DLL), which is called a shared - * library on some platforms. Operations @c open(), @c close(), and - * @c symbol() have been implemented to help opening/closing and - * extracting symbol information from a DLL, respectively. - */ -class ACE_Export ACE_DLL -{ -public: - // = Initialization and termination methods. - - /** - * Default constructor. By default, the close() operation on the - * object will be invoked before it is destroyed. - * @param close_handle_on_destruction Indicates whether or not the - * close() method will be called to close an open DLL when this - * object is destroyed. By default, close() will be called. - * Set this parameter to 0 for situations where the DLL's lifetime - * is controlled in a scope other than that of this ACE_DLL object. - * For example, termination by ACE_DLL_Manager via ACE::fini(). - */ - explicit ACE_DLL (bool close_handle_on_destruction = true); - - /// Allow assignment - ACE_DLL& operator= (const ACE_DLL &rhs); - - - /** - * This constructor performs the actions of open() during construction. - * @param dll_name The name or path of the DLL to load. - * @param open_mode Flags to alter the actions taken when loading the DLL. - * The possible values are: - * @li @c RTLD_LAZY (this the default): loads identifier symbols but - * not the symbols for functions, which are loaded dynamically - * on-demand. - * @li @c RTLD_NOW: performs all necessary relocations when - * @a dll_name is first loaded - * @li RTLD_GLOBAL: makes symbols available for relocation - * processing of any other DLLs. - * @param close_handle_on_destruction Indicates whether or not the - * close() method will be called to close an open DLL when this - * object is destroyed. By default, close() will be called. - * Set this parameter to 0 for situations where the DLL's lifetime - * is controlled in a scope other than that of this ACE_DLL object. - * For example, termination by ACE_DLL_Manager via ACE::fini(). - */ - explicit ACE_DLL (const ACE_TCHAR *dll_name, - int open_mode = ACE_DEFAULT_SHLIB_MODE, - bool close_handle_on_destruction = true); - - /// Copy constructor. - ACE_DLL (const ACE_DLL &); - - /** - * This method opens and dynamically links a specified DLL. - * @param dll_name The filename or path of the DLL to load. - * If a filename is given to @c open(), the @c ACE::ldfind() is used - * to locate DLLs via the following algorithms: (1) DLL filename - * expansion: @c ACE::ldfind() determines the name of the DLL by - * adding the appropriate prefix and suffix, e.g., it adds the @c lib - * prefix and @c .so suffix for Solaris and the @c .dll suffix for - * Windows and (2) DLL search path: @c ACE::ldfind() will also search - * for the designated DLL using the platform's DLL search path - * environment variable, e.g., it searches for DLLs using @c - * LD_LIBRARY_PATH on many UNIX systems and @c PATH on Windows. - * @param open_mode Flags to alter the actions taken when loading the DLL. - * The possible values are: - * @li @c RTLD_LAZY (this the default): loads identifier symbols but - * not the symbols for functions, which are loaded dynamically - * on-demand. - * @li @c RTLD_NOW: performs all necessary relocations when - * @a dll_name is first loaded - * @li RTLD_GLOBAL: makes symbols available for relocation - * processing of any other DLLs. - * @param close_handle_on_destruction Indicates whether or not the - * close() method will be called to close an open DLL when this - * object is destroyed. By default, close() will be called. - * Set this parameter to 0 for situations where the DLL's lifetime - * is controlled in a scope other than that of this ACE_DLL object. - * For example, termination by ACE_DLL_Manager via ACE::fini(). - * @retval -1 On failure - * @retval 0 On success. - */ - int open (const ACE_TCHAR *dll_name, - int open_mode = ACE_DEFAULT_SHLIB_MODE, - bool close_handle_on_destruction = true); - - /// Call to close the DLL object. - int close (void); - - /** - * Called when the DLL object is destroyed -- invokes close() if the - * @a close_handle_on_destruction flag was set to non-zero in the - * constructor or open() method. - */ - ~ACE_DLL (void); - - /** - * Look up a named symbol in the DLL. DLL must be successfully opened - * before calling symbol(). - * @param symbol_name The symbol name to look up. - * @param ignore_errors If set to 1, allows you to probe a dll without - * generating error messages in the log. Handy for determining - * the capabilities of a library. - * @return Returns the value of @a symbol_name if it is a valid symbol - * in the DLL. Otherwise, returns 0. - */ - void *symbol (const ACE_TCHAR *symbol_name, int ignore_errors = 0); - - /// Returns a pointer to a string explaining that an error occured. You - /// will need to consult the error log for the actual error string - /// returned by the OS. - ACE_TCHAR *error (void) const; - - /** - * Return the handle to the caller. If @a become_owner is non-0 then - * caller assumes ownership of the handle and the ACE_DLL object - * won't call close() when it goes out of scope, even if - * is set. - */ - ACE_SHLIB_HANDLE get_handle (int become_owner = 0) const; - - /// Set the handle for the DLL object. By default, the close() - //operation on / the object will be invoked before it is destroyed. - int set_handle (ACE_SHLIB_HANDLE handle, - bool close_handle_on_destruction = true); - -private: - - int open_i (const ACE_TCHAR *dll_name, - int open_mode = ACE_DEFAULT_SHLIB_MODE, - bool close_handle_on_destruction = true, - ACE_SHLIB_HANDLE handle = 0); - - - //private: -public: - - /// Open mode. - int open_mode_; - - /// Keep track of the name of the loaded dll, so it can be used - /// to remove framework components, singletons that live in the dll, - /// prior to unloading the dll in the close() method. - ACE_TCHAR *dll_name_; - - /// This flag keeps track of whether we should close the handle - /// automatically when the object is destroyed. - bool close_handle_on_destruction_; - - ACE_DLL_Handle *dll_handle_; - - /// Flag to record if the last operation had an error. - bool error_; - -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#include /**/ "ace/post.h" -#endif /* ACE_DLL_H */ diff --git a/ACE/ace/DLL_Manager.cpp b/ACE/ace/DLL_Manager.cpp deleted file mode 100644 index 83c07cd125d..00000000000 --- a/ACE/ace/DLL_Manager.cpp +++ /dev/null @@ -1,787 +0,0 @@ -// $Id$ - -#include "ace/DLL_Manager.h" - -#include "ace/Log_Msg.h" -#include "ace/ACE.h" -#include "ace/Framework_Component.h" - -#include "ace/Lib_Find.h" -#include "ace/Object_Manager.h" -#include "ace/SString.h" -#include "ace/Recursive_Thread_Mutex.h" -#include "ace/Guard_T.h" -#include "ace/OS_NS_dlfcn.h" -#include "ace/OS_NS_string.h" - -ACE_RCSID (ace, - DLL_Manager, - "DLL_Manager.cpp,v 4.23 2003/11/05 23:30:46 shuston Exp") - -/******************************************************************/ - - ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -sig_atomic_t ACE_DLL_Handle::open_called_ = 0; - -ACE_DLL_Handle::ACE_DLL_Handle (void) - : refcount_ (0), - dll_name_ (0), - handle_ (ACE_SHLIB_INVALID_HANDLE) -{ - ACE_TRACE ("ACE_DLL_Handle::ACE_DLL_Handle"); -} - -ACE_DLL_Handle::~ACE_DLL_Handle (void) -{ - ACE_TRACE ("ACE_DLL_Handle::~ACE_DLL_Handle"); - this->close (1); - delete[] this->dll_name_; -} - -const ACE_TCHAR * -ACE_DLL_Handle::dll_name (void) const -{ - ACE_TRACE ("ACE_DLL_Handle::dll_name"); - return this->dll_name_; -} - -int -ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, - int open_mode, - ACE_SHLIB_HANDLE handle) -{ - ACE_TRACE ("ACE_DLL_Handle::open"); - ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); - - if (this->dll_name_) - { - // Once dll_name_ has been set, it can't be changed.. - if (ACE_OS::strcmp (this->dll_name_, dll_name) != 0) - { - if (ACE::debug ()) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("(%P|%t) DLL_Handle::open: error, ") - ACE_TEXT ("tried to reopen %s with name %s\n"), - this->dll_name_, - dll_name)); - - return -1; - } - } - else - this->dll_name_ = ACE::strnew (dll_name); - - if (!this->open_called_) - this->open_called_ = 1; - - // If it hasn't been loaded yet, go ahead and do that now. - if (this->handle_ == ACE_SHLIB_INVALID_HANDLE) - { - if (handle) - this->handle_ = handle; - else - { - /* - ** Get the set of names to try loading. We need to do this to - ** properly support the ability for a user to specify a simple, - ** unadorned name (for example, "ACE") that will work across - ** platforms. We apply platform specifics to get a name that will - ** work (e.g. libACE, ACEd.dll, ACE.dll, etc.) We rely on the - ** underlying dlopen() implementation to "Do The Right Thing" in - ** terms of using relative paths, LD_LIBRARY_PATH, system security - ** rules, etc. except when ACE_MUST_HELP_DLOPEN_SEARCH_PATH is set. - ** If it is set, then ACE::ldfind() scans the configured path - ** looking for a match on the name and prefix/suffix applications. - ** NOTE: having ACE scan for a file and then pass a fully-qualified - ** pathname to dlopen() is a potential security hole; therefore, - ** do not use ACE_MUST_HELP_DLOPEN_SEARCH_PATH unless necessary - ** and only after considering the risks. - */ - ACE_Array dll_names; - dll_names.max_size (10); // Decent guess to avoid realloc later - -#if defined (ACE_MUST_HELP_DLOPEN_SEARCH_PATH) - // Find out where the library is - ACE_TCHAR dll_pathname[MAXPATHLEN + 1]; - - // Transform the pathname into the appropriate dynamic link library - // by searching the ACE_LD_SEARCH_PATH. - ACE::ldfind (dll_name, - dll_pathname, - (sizeof dll_pathname / sizeof (ACE_TCHAR))); - ACE_TString dll_str (dll_pathname); - dll_names.size (1); - dll_names.set (dll_str, 0); -#else - this->get_dll_names (dll_name, dll_names); -#endif - - ACE_Array_Iterator name_iter (dll_names); - ACE_TString *name = 0; - while (name_iter.next (name)) - { - // The ACE_SHLIB_HANDLE object is obtained. - this->handle_ = ACE_OS::dlopen (name->c_str (), - open_mode); - - if (ACE::debug ()) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ") - ACE_TEXT ("(\"%s\", 0x%x) -> %s: %s\n"), - name->c_str (), - open_mode, - ((this->handle_ != ACE_SHLIB_INVALID_HANDLE) - ? ACE_TEXT ("succeeded") - : ACE_TEXT ("failed")), - this->error()->c_str())); - } - - if (this->handle_ != ACE_SHLIB_INVALID_HANDLE) // Good one? - break; - - // If errno is ENOENT we just skip over this one, - // anything else - like an undefined symbol, for - // instance must be flagged here or the next error will - // mask it. - // @TODO: If we've found our DLL _and_ it's - // broken, should we continue at all? - if ((errno != 0) && (errno != ENOENT) && ACE::debug ()) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ") - ACE_TEXT ("(\'%s\') failed, errno=") - ACE_TEXT ("%d: %s\n"), - name->c_str (), - errno, - this->error ()->c_str ())); - -#if defined (AIX) - // AIX often puts the shared library file (most often named - // shr.o) inside an archive library. If this is an archive - // library name, then try appending [shr.o] and retry. - if (ACE_TString::npos != name->strstr (ACE_TEXT (".a"))) - { - ACE_TCHAR aix_pathname[MAXPATHLEN + 1]; - ACE_OS::strncpy (aix_pathname, - name->c_str (), - name->length ()); - aix_pathname[name->length ()] = '\0'; - ACE_OS::strcat (aix_pathname, ACE_TEXT ("(shr.o)")); - open_mode |= RTLD_MEMBER; - - if (ACE::debug ()) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ") - ACE_TEXT ("(\"%s\", 0x%x) -> %s: %s\n"), - aix_pathname, - open_mode, - ACE_TEXT ((this->handle_ != ACE_SHLIB_INVALID_HANDLE) - ? "succeeded" - : "failed"), - this->error()->c_str())); - } - - this->handle_ = ACE_OS::dlopen (aix_pathname, open_mode); - if (this->handle_ != ACE_SHLIB_INVALID_HANDLE) - break; - - // If errno is ENOENT we just skip over this one, anything - // else - like an undefined symbol, for instance - // must be flagged here or the next error will mask it. - // - // @TODO: If we've found our DLL _and_ it's broken, - // should we continue at all? - if (ACE::debug () && (errno != 0) && (errno != ENOENT)) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ") - ACE_TEXT ("(\'%s\') failed, errno=") - ACE_TEXT ("%d: %s\n"), - name->c_str (), - errno, - this->error ()->c_str ())); - - } -#endif /* AIX */ - - name_iter.advance (); - } - - if (this->handle_ == ACE_SHLIB_INVALID_HANDLE) - { - if (ACE::debug ()) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE (%P|%t) DLL_Handle::open (\"%s\"): ") - ACE_TEXT ("Invalid handle error: %s\n"), - this->dll_name_, - this->error ()->c_str ())); - - return -1; - } - } - } - - ++this->refcount_; - - if (ACE::debug ()) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("ACE (%P|%t) DLL_Handle::open - %s (%d), refcount=%d\n"), - this->dll_name_, - this->handle_, - this->refcount_)); - return 0; -} - - -int -ACE_DLL_Handle::close (int unload) -{ - ACE_TRACE ("ACE_DLL_Handle::close"); - - int retval = 0; - ACE_SHLIB_HANDLE h = ACE_SHLIB_INVALID_HANDLE; - - // Only hold the lock until it comes time to dlclose() the DLL. Closing - // the DLL can cause further shutdowns as DLLs and their dependents are - // unloaded. - { - ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); - - // Since we don't actually unload the dll as soon as the refcount - // reaches zero, we need to make sure we don't decrement it below - // zero. - if (this->refcount_ > 0) - --this->refcount_; - else - this->refcount_ = 0; - - if (ACE::debug ()) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("ACE (%P|%t) DLL_Handle::close - ") - ACE_TEXT ("%s (handle=%d, refcount=%d)\n"), - this->dll_name_, - this->handle_, - this->refcount_)); - - if (this->refcount_ == 0 && - this->handle_ != ACE_SHLIB_INVALID_HANDLE && - unload == 1) - { - if (ACE::debug ()) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("ACE (%P|%t) DLL_Handle::close: ") - ACE_TEXT ("Unloading %s (handle=%d)\n"), - this->dll_name_, - this->handle_)); - - // First remove any associated Framework Components. - ACE_Framework_Repository *frPtr= ACE_Framework_Repository::instance (); - if (frPtr) - { - frPtr->remove_dll_components (this->dll_name_); - } - - h = this->handle_; - this->handle_ = ACE_SHLIB_INVALID_HANDLE; - } - } // Release lock_ here - - if (h != ACE_SHLIB_INVALID_HANDLE) - { - retval = ACE_OS::dlclose (h); - - if (retval != 0 && ACE::debug ()) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE (%P|%t) DLL_Handle::close - ") - ACE_TEXT ("Failed with: \"%s\".\n"), - this->error ()->c_str ())); - } - - return retval; -} - -sig_atomic_t -ACE_DLL_Handle::refcount (void) const -{ - return this->refcount_; -} - -void * -ACE_DLL_Handle::symbol (const ACE_TCHAR *sym_name, int ignore_errors) -{ - ACE_TRACE ("ACE_DLL_Handle::symbol"); - ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); - - ACE_Auto_Array_Ptr auto_name (ACE::ldname (sym_name)); - // handle_ can be invalid especially when ACE_DLL_Handle resigned ownership - // BTW. Handle lifecycle management is a little crazy in ACE - if (this->handle_ != ACE_SHLIB_INVALID_HANDLE) - { -#if defined (ACE_OPENVMS) - void *sym = ACE::ldsymbol (this->handle_, auto_name.get ()); -#else - void *sym = ACE_OS::dlsym (this->handle_, auto_name.get ()); -#endif - - // Linux says that the symbol could be null and that it isn't an - // error. So you should check the error message also, but since - // null symbols won't do us much good anyway, let's still report - // an error. - if (!sym && ignore_errors != 1) - { - if (ACE::debug ()) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE (%P|%t) DLL_Handle::symbol (\"%s\") ") - ACE_TEXT (" failed with \"%s\".\n"), - auto_name.get (), - this->error ()->c_str ())); - - return 0; - } - return sym; - } - return 0; -} - -ACE_SHLIB_HANDLE -ACE_DLL_Handle::get_handle (int become_owner) -{ - ACE_TRACE ("ACE_DLL_Handle::get_handle"); - ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); - - if (this->refcount_ == 0 && become_owner != 0) - { - if (ACE::debug ()) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE (%P|%t) DLL_Handle::get_handle: ") - ACE_TEXT ("cannot become owner, refcount == 0.\n"))); - - return ACE_SHLIB_INVALID_HANDLE; - } - - ACE_SHLIB_HANDLE handle = this->handle_; - - if (become_owner != 0) - { - if (--this->refcount_ == 0) - this->handle_ = ACE_SHLIB_INVALID_HANDLE; - } - - if (ACE::debug ()) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("ACE (%P|%t) ACE_DLL_Handle::get_handle: ") - ACE_TEXT ("post call: handle %s, refcount %d\n"), - this->handle_ == ACE_SHLIB_INVALID_HANDLE ? - ACE_TEXT ("invalid") : ACE_TEXT ("valid"), - this->refcount_)); - - return handle; -} - -// This method is used return the last error of a library operation. - -auto_ptr -ACE_DLL_Handle::error (void) -{ - ACE_TRACE ("ACE_DLL_Handle::error"); - const ACE_TCHAR *error = ACE_OS::dlerror (); - auto_ptr str - (new ACE_TString (error ? error : ACE_TEXT ("no error"))); - return str; -} - -void -ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name, - ACE_Array &try_names) -{ - // Build the array of DLL names to try on this platform by applying the - // proper prefixes and/or suffixes to the specified dll_name. - ACE_TString base (dll_name); - ACE_TString base_dir, base_file, base_suffix; - - // 1. Separate the dll_name into the dir part and the file part. We - // only decorate the file part to determine the names to try loading. - ACE_TString::size_type pos = base.rfind (ACE_DIRECTORY_SEPARATOR_CHAR); - if (pos != ACE_TString::npos) - { - base_dir = base.substr (0, pos + 1); - base_file = base.substr (pos + 1); - } - else - base_file = base; - - // 2. Locate the file suffix, if there is one. Move the '.' and the - // suffix to base_suffix. - if ((pos = base_file.rfind (ACE_TEXT ('.'))) != ACE_TString::npos) - { - base_suffix = base_file.substr (pos); - base_file = base_file.substr (0, pos); - } - - // 3. Build the combinations to try for this platform. - // Try these combinations: - // - name with decorator and platform's suffix appended (if not supplied) - // - name with platform's suffix appended (if not supplied) - // - name with platform's dll prefix (if it has one) and suffix - // - name with platform's dll prefix, decorator, and suffix. - // - name as originally given - // We first try to find the file using the decorator so that when a - // filename with and without decorator is used, we get the file with - // the same decorator as the ACE dll has and then as last resort - // the one without. For example with msvc, the debug build has a "d" - // decorator, but the release build has none and we really want to get - // the debug version of the library in a debug application instead - // of the release one. - // So we need room for 5 entries in try_names. - try_names.size (0); - if ((try_names.max_size () - try_names.size ()) < 5) - try_names.max_size (try_names.max_size () + 5); -#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK) - ACE_TString decorator (ACE_LD_DECORATOR_STR); -#endif - ACE_TString suffix (ACE_DLL_SUFFIX); - ACE_TString prefix (ACE_DLL_PREFIX); - - for (size_t i = 0; i < 5 && try_names.size () < try_names.max_size (); ++i) - { - ACE_TString try_this; - size_t j = try_names.size (); - switch (i) - { - case 0: // Name + decorator + suffix - case 1: // Name + suffix - case 2: // Prefix + name + decorator + suffix - case 3: // Prefix + name + suffix - if ( - base_suffix.length () > 0 -#if !(defined(ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)) - || (i == 1 || i == 3) // No decorator desired; skip -#endif - ) - break; - try_this = base_dir; - if (i > 1) - try_this += prefix; - try_this += base_file; - if (base_suffix.length () > 0) - try_this += base_suffix; - else - { -#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK) - try_this += decorator; -#endif - try_this += suffix; - } - break; - case 4: - try_this = dll_name; - break; - } - - if (try_this.length ()) - { - try_names.size (j + 1); - try_names.set (try_this, j); - } - } - return; -} - -/******************************************************************/ - -// Pointer to the Singleton instance. -ACE_DLL_Manager *ACE_DLL_Manager::instance_ = 0; - - -ACE_DLL_Manager * -ACE_DLL_Manager::instance (int size) -{ - ACE_TRACE ("ACE_DLL_Manager::instance"); - - if (ACE_DLL_Manager::instance_ == 0) - { - // Perform Double-Checked Locking Optimization. - ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, - *ACE_Static_Object_Lock::instance (), 0)); - if (ACE_DLL_Manager::instance_ == 0) - { - ACE_NEW_RETURN (ACE_DLL_Manager::instance_, - ACE_DLL_Manager (size), - 0); - } - } - - return ACE_DLL_Manager::instance_; -} - -void -ACE_DLL_Manager::close_singleton (void) -{ - ACE_TRACE ("ACE_DLL_Manager::close_singleton"); - - ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, - *ACE_Static_Object_Lock::instance ())); - - delete ACE_DLL_Manager::instance_; - ACE_DLL_Manager::instance_ = 0; -} - -ACE_DLL_Manager::ACE_DLL_Manager (int size) - : handle_vector_ (0), - current_size_ (0), - total_size_ (0), - unload_policy_ (ACE_DLL_UNLOAD_POLICY_PER_DLL) -{ - ACE_TRACE ("ACE_DLL_Manager::ACE_DLL_Manager"); - - if (this->open (size) != 0 && ACE::debug ()) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE_DLL_Manager ctor failed to allocate ") - ACE_TEXT ("handle_vector_.\n"))); -} - -ACE_DLL_Manager::~ACE_DLL_Manager (void) -{ - ACE_TRACE ("ACE_DLL_Manager::~ACE_DLL_Manager"); - - if (this->close () != 0 && ACE::debug ()) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE_DLL_Manager dtor failed to close ") - ACE_TEXT ("properly.\n"))); -} - -ACE_DLL_Handle * -ACE_DLL_Manager::open_dll (const ACE_TCHAR *dll_name, - int open_mode, - ACE_SHLIB_HANDLE handle) -{ - ACE_TRACE ("ACE_DLL_Manager::open_dll"); - - ACE_DLL_Handle *temp_handle = 0; - ACE_DLL_Handle *dll_handle = 0; - { - ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); - dll_handle = this->find_dll (dll_name); - if (!dll_handle) - { - if (this->current_size_ < this->total_size_) - { - ACE_NEW_RETURN (temp_handle, - ACE_DLL_Handle, - 0); - - dll_handle = temp_handle; - } - } - } - - if (dll_handle) - { - if (dll_handle->open (dll_name, open_mode, handle) != 0) - { - // Error while opening dll. Free temp handle - if (ACE::debug ()) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE_DLL_Manager::open_dll: Could not ") - ACE_TEXT ("open dll %s.\n"), - dll_name)); - - delete temp_handle; - return 0; - } - - // Add the handle to the vector only if the dll is successfully - // opened. - if (temp_handle != 0) - { - ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); - this->handle_vector_[this->current_size_] = dll_handle; - ++this->current_size_; - } - } - - return dll_handle; -} - -int -ACE_DLL_Manager::close_dll (const ACE_TCHAR *dll_name) -{ - ACE_TRACE ("ACE_DLL_Manager::close_dll"); - ACE_DLL_Handle *handle = 0; - - { - ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); - handle = this->find_dll (dll_name); - } - - if (handle) - { - return this->unload_dll (handle, 0); - } - - return -1; -} - -u_long -ACE_DLL_Manager::unload_policy (void) const -{ - ACE_TRACE ("ACE_DLL_Manager::unload_policy"); - return this->unload_policy_; -} - -void -ACE_DLL_Manager::unload_policy (u_long unload_policy) -{ - ACE_TRACE ("ACE_DLL_Manager::unload_policy"); - ACE_MT (ACE_GUARD (ACE_Thread_Mutex, ace_mon, this->lock_)); - - u_long old_policy = this->unload_policy_; - this->unload_policy_ = unload_policy; - - // If going from LAZY to EAGER or from PER_DLL to PER_PROCESS|EAGER, - // call close(1) on all the ACE_DLL_Handle objects with refcount == 0 - // which will force those that are still loaded to be unloaded. - if (this->handle_vector_) - if (( ACE_BIT_ENABLED (old_policy, ACE_DLL_UNLOAD_POLICY_LAZY) && - ACE_BIT_DISABLED (this->unload_policy_, ACE_DLL_UNLOAD_POLICY_LAZY) ) || - ( ACE_BIT_DISABLED (this->unload_policy_, ACE_DLL_UNLOAD_POLICY_LAZY) && - ACE_BIT_ENABLED (old_policy, ACE_DLL_UNLOAD_POLICY_PER_DLL) && - ACE_BIT_DISABLED (this->unload_policy_, ACE_DLL_UNLOAD_POLICY_PER_DLL) )) - { - for (int i = this->current_size_ - 1; i >= 0; i--) - { - if (this->handle_vector_[i] && - this->handle_vector_[i]->refcount () == 0) - this->handle_vector_[i]->close (1); - } - } -} - -int -ACE_DLL_Manager::open (int size) -{ - ACE_TRACE ("ACE_DLL_Manager::open"); - - ACE_DLL_Handle **temp = 0; - - ACE_NEW_RETURN (temp, - ACE_DLL_Handle *[size], - -1); - - this->handle_vector_ = temp; - this->total_size_ = size; - return 0; -} - -int -ACE_DLL_Manager::close (void) -{ - ACE_TRACE ("ACE_DLL_Manager::close"); - - int force_close = 1; - - if (this->handle_vector_ != 0) - { - // Delete components in reverse order. - for (int i = this->current_size_ - 1; i >= 0; i--) - { - if (this->handle_vector_[i]) - { - ACE_DLL_Handle *s = - const_cast (this->handle_vector_[i]); - this->handle_vector_[i] = 0; - this->unload_dll (s, force_close); - delete s; - } - } - - delete [] this->handle_vector_; - this->handle_vector_ = 0; - this->current_size_ = 0; - } - return 0; -} - -ACE_DLL_Handle * -ACE_DLL_Manager::find_dll (const ACE_TCHAR *dll_name) const -{ - ACE_TRACE ("ACE_DLL_Manager::find_dll"); - - for (int i = 0; i < this->current_size_; i++) - if (this->handle_vector_[i] && - ACE_OS::strcmp (this->handle_vector_[i]->dll_name (), dll_name) == 0) - { - return this->handle_vector_[i]; - } - - return 0; -} - -int -ACE_DLL_Manager::unload_dll (ACE_DLL_Handle *dll_handle, int force_unload) -{ - ACE_TRACE ("ACE_DLL_Manager::unload_dll"); - - if (dll_handle) - { - int unload = force_unload; - if (unload == 0) - { - // apply strategy - if (ACE_BIT_DISABLED (this->unload_policy_, - ACE_DLL_UNLOAD_POLICY_PER_DLL)) - { - unload = ACE_BIT_DISABLED (this->unload_policy_, - ACE_DLL_UNLOAD_POLICY_LAZY); - } - else - { - // Declare the type of the symbol: - typedef int (*dll_unload_policy)(void); - - void * const unload_policy_ptr = - dll_handle->symbol (ACE_TEXT ("_get_dll_unload_policy"), 1); -#if defined (ACE_OPENVMS) && (!defined (__INITIAL_POINTER_SIZE) || (__INITIAL_POINTER_SIZE < 64)) - int const temp_p = - reinterpret_cast (unload_policy_ptr); -#else - intptr_t const temp_p = - reinterpret_cast (unload_policy_ptr); -#endif - - dll_unload_policy const the_policy = - reinterpret_cast (temp_p); - - if (the_policy != 0) - unload = ACE_BIT_DISABLED (the_policy (), - ACE_DLL_UNLOAD_POLICY_LAZY); - else - unload = ACE_BIT_DISABLED (this->unload_policy_, - ACE_DLL_UNLOAD_POLICY_LAZY); - } - } - - if (dll_handle->close (unload) != 0) - { - if (ACE::debug ()) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE_DLL_Manager::unload error.\n"))); - - return -1; - } - } - else - { - if (ACE::debug ()) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE_DLL_Manager::unload_dll called with ") - ACE_TEXT ("null pointer.\n"))); - - return -1; - } - - return 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/DLL_Manager.h b/ACE/ace/DLL_Manager.h deleted file mode 100644 index a59636696ba..00000000000 --- a/ACE/ace/DLL_Manager.h +++ /dev/null @@ -1,269 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file DLL_Manager.h - * - * $Id$ - * - * @author Don Hinton - */ -//============================================================================= - -#ifndef ACE_DLL_MANAGER_H -#define ACE_DLL_MANAGER_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Auto_Ptr.h" -#include "ace/Containers_T.h" -#include "ace/SStringfwd.h" -#include "ace/os_include/os_dlfcn.h" - -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) -# include "ace/Thread_Mutex.h" -#endif /* ACE_MT_SAFE */ - -#define ACE_DEFAULT_DLL_MANAGER_SIZE 1024 - - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_DLL_Handle - * - * @brief Provides an abstract interface for handling various DLL - * operations. - * - * This class is an wrapper over the various methods for utilizing a - * dynamically linked library (DLL), which is called a shared library - * on some platforms. It is refcounted and managed by - * ACE_DLL_Manager, so there will only be a single instance of this - * class for each dll loaded, no matter how many instances of ACE_DLL - * an application has open. Operations , , and - * have been implemented to help opening/closing and extracting symbol - * information from a DLL, respectively. - * - * Most of this class came from the original ACE_DLL class. ACE_DLL - * is now just an interface that passed all it's calls either directly - * or via ACE_DLL_Manager to this class for execution. - * - */ -class ACE_Export ACE_DLL_Handle -{ -public: - - /// Default construtor. - ACE_DLL_Handle (void); - - /// Destructor. - ~ACE_DLL_Handle (void); - - /// Returns the name of the shared library (without prefixes or suffixes). - const ACE_TCHAR *dll_name () const; - - /** - * This method opens and dynamically links @a dll_name. The default - * mode is , which loads identifier symbols but not the - * symbols for functions, which are loaded dynamically on-demand. - * Other supported modes include: , which performs all - * necessary relocations when @a dll_name is first loaded and - * , which makes symbols available for relocation - * processing of any other DLLs. Returns -1 on failure and 0 on - * success. - */ - int open (const ACE_TCHAR *dll_name, - int open_mode, - ACE_SHLIB_HANDLE handle); - - /// Call to close the DLL object. If unload = 0, it only decrements - /// the refcount, but if unload = 1, then it will actually unload - /// the library when the refcount == 0; - int close (int unload = 0); - - /// Return the current refcount. - sig_atomic_t refcount (void) const; - - /// If @a symbol_name is in the symbol table of the DLL a pointer to - /// the @a symbol_name is returned. Otherwise, returns 0. Set the - /// ignore_errors flag to supress logging errors if symbol_name isn't - /// found. This is nice if you just want to probe a dll to see what's - /// available, since missing functions in that case aren't really errors. - void *symbol (const ACE_TCHAR *symbol_name, int ignore_errors = 0); - - /** - * Return the handle to the caller. If @a become_owner is non-0 then - * caller assumes ownership of the handle so we decrement the retcount. - */ - ACE_SHLIB_HANDLE get_handle (int become_owner = 0); - -private: - - /// Returns a pointer to a string explaining why or - /// failed. This is used internal to print out the error to the log, - /// but since this object is shared, we can't store or return the error - /// to the caller. - auto_ptr error (void); - - // Builds array of DLL names to try to dlopen, based on platform - // and configured DLL prefixes/suffixes. - // Returns the array of names to try in try_names. - void get_dll_names (const ACE_TCHAR *dll_name, - ACE_Array &try_names); - - // Disallow copying and assignment since we don't handle them. - ACE_DLL_Handle (const ACE_DLL_Handle &); - void operator= (const ACE_DLL_Handle &); - -private: - - // Keep track of how many ACE_DLL objects have a reference to this - // dll. - sig_atomic_t refcount_; - - /// Name of the shared library. - ACE_TCHAR *dll_name_; - - /// Handle to the actual library loaded by the OS. - ACE_SHLIB_HANDLE handle_; - - /// Keeps track of whether or not open() has ever been called. This - /// helps get around problem on Linux, and perhaps other OS's, that - /// seg-fault if dlerror() is called before the ld library has been - /// initialized by a call to dlopen(). - static sig_atomic_t open_called_; - -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) - /// Synchronization variable for the MT_SAFE Repository - ACE_Thread_Mutex lock_; -#endif /* ACE_MT_SAFE */ -}; - -class ACE_Framework_Repository; - -/** - * @class ACE_DLL_Manager - * - * @brief This class is a singleton and serves as a factory and - * repository for instances of ACE_DLL_Handle. - * - * This class is a singleton whose lifetime is managed by the - * ACE_Framework_Repository. Although it is normally meant to be - * used directly only by ACE_DLL, applications can call the unload_policy() - * methods in order get/set the the dll unload policy. Unload policies include - * per_process/per-dll and eager/lazy. Dlls can export set their own policy - * by using the ACE_DLL_UNLOAD_POLICY macro found in config-all.h. If a dll - * choses to set an unload policy, it will be used when the per-dll policy - * (the default) is in effect. If the per-dll policy is in effect and a dll - * has not chosen to set a policy, the current per-process policy will be - * used. - * - * The following policy macros are provided in config-all.h: - * - * ACE_DLL_UNLOAD_POLICY_PER_PROCESS - Per-process policy that unloads dlls - * eagerly. - * - * ACE_DLL_UNLOAD_POLICY_PER_DLL - Apply policy on a per-dll basis. If the - * dll doesn't use one of the macros below, the current per-process policy - * will be used. - * - * ACE_DLL_UNLOAD_POLICY_LAZY - Don't unload dll when refcount reaches - * zero, i.e., wait for either an explicit unload request or program exit. - * - * ACE_DLL_UNLOAD_POLICY_DEFAULT - Default policy allows dlls to control - * their own destinies, but will unload those that don't make a choice eagerly. - * - */ -class ACE_Export ACE_DLL_Manager -{ -public: - friend class ACE_Framework_Repository; - friend class ACE_Object_Manager; - - enum - { - DEFAULT_SIZE = ACE_DEFAULT_DLL_MANAGER_SIZE - }; - - /// Return a unique instance - static ACE_DLL_Manager *instance (int size = ACE_DLL_Manager::DEFAULT_SIZE); - - /// Factory for ACE_DLL_Handle objects. If one already exits, - /// its refcount is incremented. - ACE_DLL_Handle *open_dll (const ACE_TCHAR *dll_name, - int openmode, - ACE_SHLIB_HANDLE handle); - - /// Close the underlying dll. Decrements the refcount. - int close_dll (const ACE_TCHAR *dll_name); - - /// Returns the current per-process UNLOAD_POLICY. - u_long unload_policy (void) const; - - /// Set the per-process UNLOAD_POLICY. If the policy is changed from - /// LAZY to EAGER, then it will also unload any dlls with zero - /// refcounts. - void unload_policy (u_long unload_policy); - -protected: - - /// Default constructor. - ACE_DLL_Manager (int size = ACE_DLL_Manager::DEFAULT_SIZE); - - /// Destructor. - ~ACE_DLL_Manager (void); - - // Allocate handle_vector_. - int open (int size); - - // Close all open dlls and deallocate memory. - int close (void); - - // Find dll in handle_vector_. - ACE_DLL_Handle *find_dll (const ACE_TCHAR *dll_name) const; - - // Applies strategy for unloading dll. - int unload_dll (ACE_DLL_Handle *dll_handle, int force_unload = 0); - -private: - - /// Close the singleton instance. - static void close_singleton (void); - - // Disallow copying and assignment since we don't handle these. - ACE_DLL_Manager (const ACE_DLL_Manager &); - void operator= (const ACE_DLL_Manager &); - -private: - - /// Vector containing all loaded handle objects. - ACE_DLL_Handle **handle_vector_; - - /// Current number of handles. - int current_size_; - - /// Maximum number of handles. - int total_size_; - - /// Unload strategy. - u_long unload_policy_; - - /// Pointer to a process-wide ACE_DLL_Manager. - static ACE_DLL_Manager *instance_; - -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) - /// Synchronization variable for the MT_SAFE Repository - ACE_Thread_Mutex lock_; -#endif /* ACE_MT_SAFE */ - -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#include /**/ "ace/post.h" -#endif /* ACE_DLL_MANAGER_H */ diff --git a/ACE/ace/Date_Time.cpp b/ACE/ace/Date_Time.cpp deleted file mode 100644 index 85abf562c47..00000000000 --- a/ACE/ace/Date_Time.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// Date_Time.cpp -// $Id$ - -#include "ace/Date_Time.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Date_Time.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, Date_Time, "$Id$") diff --git a/ACE/ace/Date_Time.h b/ACE/ace/Date_Time.h deleted file mode 100644 index 9204e23a1b8..00000000000 --- a/ACE/ace/Date_Time.h +++ /dev/null @@ -1,125 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file Date_Time.h - * - * $Id$ - * - * @author Tim Harrison (harrison@cs.wustl.edu) (and he's darn proud of this ;-)) - * - */ -//========================================================================== - -#ifndef ACE_DATE_TIME_H -#define ACE_DATE_TIME_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -class ACE_Time_Value; - -/** - * @class ACE_Date_Time - * - * @brief System independent representation of date and time. - */ -class ACE_Export ACE_Date_Time -{ -public: - /// Constructor initializes current time/date info. - ACE_Date_Time (void); - - /// Constructor initializes with the given ACE_Time_Value - explicit ACE_Date_Time (const ACE_Time_Value& timevalue); - - /// Constructor with init values, no check for validy - /// Set/get portions of ACE_Date_Time, no check for validity. - ACE_Date_Time (long day, - long month = 0, - long year = 0, - long hour = 0, - long minute = 0, - long second = 0, - long microsec = 0, - long wday = 0); - - /// Update to the current time/date. - void update (void); - - /// Update to the given ACE_Time_Value - void update (const ACE_Time_Value& timevalue); - - /// Get day. - long day (void) const; - - /// Set day. - void day (long day); - - /// Get month. - long month (void) const; - - /// Set month. - void month (long month); - - /// Get year. - long year (void) const; - - /// Set year. - void year (long year); - - /// Get hour. - long hour (void) const; - - /// Set hour. - void hour (long hour); - - /// Get minute. - long minute (void) const; - - /// Set minute. - void minute (long minute); - - /// Get second. - long second (void) const; - - /// Set second. - void second (long second); - - /// Get microsec. - long microsec (void) const; - - /// Set microsec. - void microsec (long microsec); - - /// Get weekday. - long weekday (void) const; - - /// Set weekday. - void weekday (long wday); - -private: - long day_; - long month_; - long year_; - long hour_; - long minute_; - long second_; - long microsec_; - long wday_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Date_Time.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_DATE_TIME_H */ diff --git a/ACE/ace/Date_Time.inl b/ACE/ace/Date_Time.inl deleted file mode 100644 index dfb0d239bc3..00000000000 --- a/ACE/ace/Date_Time.inl +++ /dev/null @@ -1,219 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/Global_Macros.h" -#include "ace/Time_Value.h" -#include "ace/OS_NS_sys_time.h" -#include "ace/OS_NS_time.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE void -ACE_Date_Time::update (const ACE_Time_Value& timevalue) -{ -#if defined (ACE_HAS_WINCE) - // CE doesn't do localtime(). - FILETIME file_time = timevalue; - FILETIME local_file_time; - SYSTEMTIME sys_time; - ::FileTimeToLocalFileTime (&file_time, &local_file_time); - ::FileTimeToSystemTime (&local_file_time, &sys_time); - this->day_ = sys_time.wDay; - this->month_ = sys_time.wMonth; - this->year_ = sys_time.wYear; - this->hour_ = sys_time.wHour; - this->minute_ = sys_time.wMinute; - this->second_ = sys_time.wSecond; - this->microsec_ = sys_time.wMilliseconds * 1000; - this->wday_ = sys_time.wDayOfWeek; -#else - time_t time = timevalue.sec (); - struct tm tm_time; - ACE_OS::localtime_r (&time, &tm_time); - this->day_ = tm_time.tm_mday; - this->month_ = tm_time.tm_mon + 1; // localtime's months are 0-11 - this->year_ = tm_time.tm_year + 1900; // localtime reports years since 1900 - this->hour_ = tm_time.tm_hour; - this->minute_ = tm_time.tm_min; - this->second_ = tm_time.tm_sec; - this->microsec_ = timevalue.usec (); - this->wday_ = tm_time.tm_wday; -#endif /* ACE_HAS_WINCE */ -} - -ACE_INLINE void -ACE_Date_Time::update (void) -{ - ACE_TRACE ("ACE_Date_Time::update"); - - update(ACE_OS::gettimeofday ()); -} - -ACE_INLINE -ACE_Date_Time::ACE_Date_Time (void) -{ - ACE_TRACE ("ACE_Date_Time::ACE_Date_Time"); - this->update (); -} - -ACE_INLINE -ACE_Date_Time::ACE_Date_Time (const ACE_Time_Value& timevalue) -{ - ACE_TRACE ("ACE_Date_Time::ACE_Date_Time: timevalue"); - this->update (timevalue); -} - -// Constructor with init values, no check for validy -ACE_INLINE -ACE_Date_Time::ACE_Date_Time (long day, - long month, - long year, - long hour, - long minute, - long second, - long microsec, - long wday) - : day_ (day), - month_ (month), - year_ (year), - hour_ (hour), - minute_ (minute), - second_ (second), - microsec_ (microsec), - wday_ (wday) -{ - ACE_TRACE ("ACE_Date_Time::ACE_Date_Time"); -} - -// set/get portions of ACE_Date_Time, no check for validy - -// get day -ACE_INLINE long -ACE_Date_Time::day (void) const -{ - ACE_TRACE ("ACE_Date_Time::day"); - return day_; -} - -// set day -ACE_INLINE void -ACE_Date_Time::day (long day) -{ - ACE_TRACE ("ACE_Date_Time::day"); - day_ = day; -} - -// get month -ACE_INLINE long -ACE_Date_Time::month (void) const -{ - ACE_TRACE ("ACE_Date_Time::month"); - return month_; -} - -// set month -ACE_INLINE void -ACE_Date_Time::month (long month) -{ - ACE_TRACE ("ACE_Date_Time::month"); - month_ = month; -} - -// get year -ACE_INLINE long -ACE_Date_Time::year (void) const -{ - ACE_TRACE ("ACE_Date_Time::year"); - return year_; -} - -// set year -ACE_INLINE void -ACE_Date_Time::year (long year) -{ - ACE_TRACE ("ACE_Date_Time::year"); - year_ = year; -} - -// get hour -ACE_INLINE long -ACE_Date_Time::hour (void) const -{ - ACE_TRACE ("ACE_Date_Time::hour"); - return hour_; -} - -// set hour -ACE_INLINE void -ACE_Date_Time::hour (long hour) -{ - ACE_TRACE ("ACE_Date_Time::hour"); - hour_ = hour; -} - -// get minute -ACE_INLINE long -ACE_Date_Time::minute (void) const -{ - ACE_TRACE ("ACE_Date_Time::minute"); - return minute_; -} - -// set minute -ACE_INLINE void -ACE_Date_Time::minute (long minute) -{ - ACE_TRACE ("ACE_Date_Time::minute"); - minute_ = minute; -} - -// get second -ACE_INLINE long -ACE_Date_Time::second (void) const -{ - ACE_TRACE ("ACE_Date_Time::second"); - return second_; -} - -// set second -ACE_INLINE void -ACE_Date_Time::second (long second) -{ - ACE_TRACE ("ACE_Date_Time::second"); - second_ = second; -} - -// get microsec -ACE_INLINE long -ACE_Date_Time::microsec (void) const -{ - ACE_TRACE ("ACE_Date_Time::microsec"); - return microsec_; -} - -// set microsec -ACE_INLINE void -ACE_Date_Time::microsec (long microsec) -{ - ACE_TRACE ("ACE_Date_Time::microsec"); - microsec_ = microsec; -} - -// get wday -ACE_INLINE long -ACE_Date_Time::weekday (void) const -{ - ACE_TRACE ("ACE_Date_Time::weekday"); - return wday_; -} - -// set wday -ACE_INLINE void -ACE_Date_Time::weekday (long wday) -{ - ACE_TRACE ("ACE_Date_Time::weekday"); - wday_ = wday; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Default_Constants.h b/ACE/ace/Default_Constants.h deleted file mode 100644 index ce435121681..00000000000 --- a/ACE/ace/Default_Constants.h +++ /dev/null @@ -1,573 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Default_Constants.h - * - * $Id$ - * - * @author Douglas C. Schmidt - * @author Jesper S. M|ller - * @author and a cast of thousands... - * - * This one is split from the famous OS.h - */ -//============================================================================= - -#ifndef ACE_DEFAULT_CONSTANTS_H -#define ACE_DEFAULT_CONSTANTS_H -#include /**/ "ace/pre.h" - -// Included just keep compilers that see #pragma dierctive first -// happy. -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -// Define the default constants for ACE. Many of these are used for -// the ACE tests and applications. You can change these values by -// defining the macros in your config.h file. -# if !defined (ACE_DEFAULT_CLOSE_ALL_HANDLES) -# define ACE_DEFAULT_CLOSE_ALL_HANDLES true -# endif /* ACE_DEFAULT_CLOSE_ALL_HANDLES */ - -// The maximum length for a fully qualified Internet name. -# if !defined(ACE_MAX_FULLY_QUALIFIED_NAME_LEN) -# define ACE_MAX_FULLY_QUALIFIED_NAME_LEN 256 -# endif /* ACE_MAX_FULLY_QUALIFIED_NAME_LEN */ - -#if !defined (ACE_DEFAULT_PAGEFILE_POOL_BASE) -#define ACE_DEFAULT_PAGEFILE_POOL_BASE (void *) 0 -#endif /* ACE_DEFAULT_PAGEFILE_POOL_BASE */ - -#if !defined (ACE_DEFAULT_PAGEFILE_POOL_SIZE) -#define ACE_DEFAULT_PAGEFILE_POOL_SIZE (size_t) 0x01000000 -#endif /* ACE_DEFAULT_PAGEFILE_POOL_SIZE */ - -#if !defined (ACE_DEFAULT_PAGEFILE_POOL_CHUNK) -#define ACE_DEFAULT_PAGEFILE_POOL_CHUNK (size_t) 0x00010000 -#endif /* ACE_DEFAULT_PAGEFILE_POOL_CHUNK */ - -#if !defined (ACE_DEFAULT_PAGEFILE_POOL_NAME) -#define ACE_DEFAULT_PAGEFILE_POOL_NAME ACE_TEXT ("Default_ACE_Pagefile_Memory_Pool") -#endif /* ACE_DEFAULT_PAGEFILE_POOL_NAME */ - -#if !defined (ACE_DEFAULT_MESSAGE_BLOCK_PRIORITY) -#define ACE_DEFAULT_MESSAGE_BLOCK_PRIORITY 0 -#endif /* ACE_DEFAULT_MESSAGE_BLOCK_PRIORITY */ - -#if !defined (ACE_DEFAULT_SERVICE_REPOSITORY_SIZE) -#define ACE_DEFAULT_SERVICE_REPOSITORY_SIZE 1024 -#endif /* ACE_DEFAULT_SERVICE_REPOSITORY_SIZE */ - -#if !defined (ACE_REACTOR_NOTIFICATION_ARRAY_SIZE) -#define ACE_REACTOR_NOTIFICATION_ARRAY_SIZE 1024 -#endif /* ACE_REACTOR_NOTIFICATION_ARRAY_SIZE */ - -# if !defined (ACE_DEFAULT_TIMEOUT) -# define ACE_DEFAULT_TIMEOUT 5 -# endif /* ACE_DEFAULT_TIMEOUT */ - -# if !defined (ACE_DEFAULT_BACKLOG) -# define ACE_DEFAULT_BACKLOG 5 -# endif /* ACE_DEFAULT_BACKLOG */ - -# if !defined (ACE_DEFAULT_ASYNCH_BACKLOG) -# define ACE_DEFAULT_ASYNCH_BACKLOG 5 -# endif /* ACE_DEFAULT_ASYNCH_BACKLOG */ - -# if !defined (ACE_DEFAULT_THREADS) -# define ACE_DEFAULT_THREADS 1 -# endif /* ACE_DEFAULT_THREADS */ - -// The following 3 defines are used in the IP multicast and broadcast tests. -# if !defined (ACE_DEFAULT_BROADCAST_PORT) -# define ACE_DEFAULT_BROADCAST_PORT 20000 -# endif /* ACE_DEFAULT_BROADCAST_PORT */ - -# if !defined (ACE_DEFAULT_MULTICAST_PORT) -# define ACE_DEFAULT_MULTICAST_PORT 20001 -# endif /* ACE_DEFAULT_MULTICAST_PORT */ - -# if !defined (ACE_DEFAULT_MULTICAST_ADDR) -// This address MUST be within the range for host group addresses: -// 224.0.0.0 to 239.255.255.255. -# define ACE_DEFAULT_MULTICAST_ADDR "224.9.9.2" -# endif /* ACE_DEFAULT_MULTICAST_ADDR */ - -# if defined (ACE_HAS_IPV6) -# if !defined (ACE_DEFAULT_MULTICASTV6_ADDR) -// This address should be within the range for site-local addresses: -// ff05::0/16 . -# define ACE_DEFAULT_MULTICASTV6_ADDR "ff05:0::ff01:1" -# endif /* ACE_DEFAULT_MULTICASTV6_ADDR */ -# endif - -// Default port number for HTTP. -# if !defined (ACE_DEFAULT_HTTP_SERVER_PORT) -# define ACE_DEFAULT_HTTP_SERVER_PORT 80 -# endif /* ACE_DEFAULT_HTTP_SERVER_PORT */ - -// Used in many IPC_SAP tests -# if !defined (ACE_DEFAULT_SERVER_PORT) -# define ACE_DEFAULT_SERVER_PORT 20002 -# endif /* ACE_DEFAULT_SERVER_PORT */ - -# if !defined (ACE_DEFAULT_HTTP_PORT) -# define ACE_DEFAULT_HTTP_PORT 80 -# endif /* ACE_DEFAULT_HTTP_PORT */ - -# if !defined (ACE_DEFAULT_MAX_SOCKET_BUFSIZ) -# define ACE_DEFAULT_MAX_SOCKET_BUFSIZ 65536 -# endif /* ACE_DEFAULT_MAX_SOCKET_BUFSIZ */ - -# if !defined (ACE_DEFAULT_SERVER_PORT_STR) -# define ACE_DEFAULT_SERVER_PORT_STR ACE_TEXT("20002") -# endif /* ACE_DEFAULT_SERVER_PORT_STR */ - -// Used for the Service_Directory test -# if !defined (ACE_DEFAULT_SERVICE_PORT) -# define ACE_DEFAULT_SERVICE_PORT 20003 -# endif /* ACE_DEFAULT_SERVICE_PORT */ - -// Used for the ACE_Thread_Spawn test -# if !defined (ACE_DEFAULT_THR_PORT ) -# define ACE_DEFAULT_THR_PORT 20004 -# endif /* ACE_DEFAULT_THR_PORT */ - -// Used for tests -# if !defined (ACE_DEFAULT_LOCAL_PORT) -# define ACE_DEFAULT_LOCAL_PORT 20005 -# endif /* ACE_DEFAULT_LOCAL_PORT */ - -// Used for Connector tests -# if !defined (ACE_DEFAULT_LOCAL_PORT_STR) -# define ACE_DEFAULT_LOCAL_PORT_STR "20005" -# endif /* ACE_DEFAULT_LOCAL_PORT_STR */ - -// Used for the name server. -# if !defined (ACE_DEFAULT_NAME_SERVER_PORT) -# define ACE_DEFAULT_NAME_SERVER_PORT 20006 -# endif /* ACE_DEFAULT_NAME_SERVER_PORT */ - -# if !defined (ACE_DEFAULT_NAME_SERVER_PORT_STR) -# define ACE_DEFAULT_NAME_SERVER_PORT_STR "20006" -# endif /* ACE_DEFAULT_NAME_SERVER_PORT_STR */ - -// Used for the token server. -# if !defined (ACE_DEFAULT_TOKEN_SERVER_PORT) -# define ACE_DEFAULT_TOKEN_SERVER_PORT 20007 -# endif /* ACE_DEFAULT_TOKEN_SERVER_PORT */ - -# if !defined (ACE_DEFAULT_TOKEN_SERVER_PORT_STR) -# define ACE_DEFAULT_TOKEN_SERVER_PORT_STR "20007" -# endif /* ACE_DEFAULT_TOKEN_SERVER_PORT_STR */ - -// Used for the logging server. -# if !defined (ACE_DEFAULT_LOGGING_SERVER_PORT) -# define ACE_DEFAULT_LOGGING_SERVER_PORT 20008 -# endif /* ACE_DEFAULT_LOGGING_SERVER_PORT */ - -# if !defined (ACE_DEFAULT_LOGGING_SERVER_PORT_STR) -# define ACE_DEFAULT_LOGGING_SERVER_PORT_STR "20008" -# endif /* ACE_DEFAULT_LOGGING_SERVER_PORT_STR */ - -// Used for the logging server. -# if !defined (ACE_DEFAULT_THR_LOGGING_SERVER_PORT) -# define ACE_DEFAULT_THR_LOGGING_SERVER_PORT 20008 -# endif /* ACE_DEFAULT_THR_LOGGING_SERVER_PORT */ - -# if !defined (ACE_DEFAULT_THR_LOGGING_SERVER_PORT_STR) -# define ACE_DEFAULT_THR_LOGGING_SERVER_PORT_STR "20008" -# endif /* ACE_DEFAULT_THR_LOGGING_SERVER_PORT_STR */ - -// Used for the time server. -# if !defined (ACE_DEFAULT_TIME_SERVER_PORT) -# define ACE_DEFAULT_TIME_SERVER_PORT 20009 -# endif /* ACE_DEFAULT_TIME_SERVER_PORT */ - -# if !defined (ACE_DEFAULT_TIME_SERVER_PORT_STR) -# define ACE_DEFAULT_TIME_SERVER_PORT_STR "20009" -# endif /* ACE_DEFAULT_TIME_SERVER_PORT_STR */ - -# if !defined (ACE_DEFAULT_TIME_SERVER_STR) -# define ACE_DEFAULT_TIME_SERVER_STR "ACE_TS_TIME" -# endif /* ACE_DEFAULT_TIME_SERVER_STR */ - -// Used by the FIFO tests and the Client_Logging_Handler netsvc. -# if !defined (ACE_DEFAULT_RENDEZVOUS) -# if defined (ACE_HAS_STREAM_PIPES) -# define ACE_DEFAULT_RENDEZVOUS ACE_TEXT("/tmp/fifo.ace") -# else -# define ACE_DEFAULT_RENDEZVOUS ACE_TEXT("localhost:20010") -# endif /* ACE_HAS_STREAM_PIPES */ -# endif /* ACE_DEFAULT_RENDEZVOUS */ - -// Used for the UNIX syslog logging interface to ACE_Log_Msg. -# ifndef ACE_DEFAULT_SYSLOG_FACILITY -# define ACE_DEFAULT_SYSLOG_FACILITY LOG_USER -# endif /* ACE_DEFAULT_SYSLOG_FACILITY */ - -# if !defined (ACE_DEFAULT_LOGGER_KEY) - -# if defined (ACE_HAS_STREAM_PIPES) -# define ACE_DEFAULT_LOGGER_KEY ACE_TEXT ("/tmp/server_daemon") -# else -# define ACE_DEFAULT_LOGGER_KEY ACE_TEXT ("localhost:20012") -# endif /* ACE_HAS_STREAM_PIPES */ -# endif /* ACE_DEFAULT_LOGGER_KEY */ - -// The way to specify the local host for loopback IP. This is usually -// "localhost" but it may need changing on some platforms. -# if !defined (ACE_LOCALHOST) -# define ACE_LOCALHOST ACE_TEXT ("localhost") -# endif - -// This specification for an IPv6 localhost should work on all platforms -// supporting IPv6 -# if defined (ACE_HAS_IPV6) -# if !defined (ACE_IPV6_LOCALHOST) -# define ACE_IPV6_LOCALHOST ACE_TEXT ("::1") -# endif /* ACE_IPV6_LOCALHOST*/ -#endif /* ACE_HAS_IPV6 */ - -// This specification for an IPv6 ANY address should work on all platforms -// supporting IPv6 -# if defined (ACE_HAS_IPV6) -# if !defined (ACE_IPV6_ANY) -# define ACE_IPV6_ANY ACE_TEXT ("::") -# endif /* ACE_IPV6_ANY*/ -#endif /* ACE_HAS_IPV6 */ - -# if !defined (ACE_DEFAULT_SERVER_HOST) -# if defined (ACE_HAS_IPV6) -# define ACE_DEFAULT_SERVER_HOST ACE_IPV6_LOCALHOST -# else /*ACE_HAS_IPV6*/ -# define ACE_DEFAULT_SERVER_HOST ACE_LOCALHOST -# endif /*ACE_HAS_IPV6*/ -# endif /* ACE_DEFAULT_SERVER_HOST */ - -// Default shared memory key -# if !defined (ACE_DEFAULT_SHM_KEY) -# define ACE_DEFAULT_SHM_KEY 1234 -# endif /* ACE_DEFAULT_SHM_KEY */ - -// Default address for shared memory mapped files and SYSV shared memory -// (defaults to 64 M). -# if !defined (ACE_DEFAULT_BASE_ADDR) -# define ACE_DEFAULT_BASE_ADDR ((char *) (64 * 1024 * 1024)) -# endif /* ACE_DEFAULT_BASE_ADDR */ - -// Default segment size used by SYSV shared memory (128 K) -# if !defined (ACE_DEFAULT_SEGMENT_SIZE) -# define ACE_DEFAULT_SEGMENT_SIZE 1024 * 128 -# endif /* ACE_DEFAULT_SEGMENT_SIZE */ - -// Maximum number of SYSV shared memory segments -// (does anyone know how to figure out the right values?!) -# if !defined (ACE_DEFAULT_MAX_SEGMENTS) -# define ACE_DEFAULT_MAX_SEGMENTS 6 -# endif /* ACE_DEFAULT_MAX_SEGMENTS */ - -// Name of the map that's stored in shared memory. -# if !defined (ACE_NAME_SERVER_MAP) -# define ACE_NAME_SERVER_MAP "Name Server Map" -# endif /* ACE_NAME_SERVER_MAP */ - -// Default file permissions. -# if !defined (ACE_DEFAULT_FILE_PERMS) -# if defined (ACE_VXWORKS) -# define ACE_DEFAULT_FILE_PERMS (S_IRUSR | S_IWUSR| S_IRGRP| S_IROTH) -# else -# define ACE_DEFAULT_FILE_PERMS 0644 -# endif /* ACE_VXWORKS */ -# endif /* ACE_DEFAULT_FILE_PERMS */ - -// Default directory permissions. -# if !defined (ACE_DEFAULT_DIR_PERMS) -# define ACE_DEFAULT_DIR_PERMS 0755 -# endif /* ACE_DEFAULT_DIR_PERMS */ - -# if !defined (ACE_DEFAULT_TIMEPROBE_TABLE_SIZE) -# define ACE_DEFAULT_TIMEPROBE_TABLE_SIZE 8 * 1024 -# endif /* ACE_DEFAULT_TIMEPROBE_TABLE_SIZE */ - -// Default size of the ACE Map_Manager. -# if !defined (ACE_DEFAULT_MAP_SIZE) -# define ACE_DEFAULT_MAP_SIZE 1024 -# endif /* ACE_DEFAULT_MAP_SIZE */ - -// Defaults for ACE Timer Wheel -# if !defined (ACE_DEFAULT_TIMER_WHEEL_SIZE) -# define ACE_DEFAULT_TIMER_WHEEL_SIZE 1024 -# endif /* ACE_DEFAULT_TIMER_WHEEL_SIZE */ - -# if !defined (ACE_DEFAULT_TIMER_WHEEL_RESOLUTION) -# define ACE_DEFAULT_TIMER_WHEEL_RESOLUTION 100 -# endif /* ACE_DEFAULT_TIMER_WHEEL_RESOLUTION */ - -// Default size for ACE Timer Hash table -# if !defined (ACE_DEFAULT_TIMER_HASH_TABLE_SIZE) -# define ACE_DEFAULT_TIMER_HASH_TABLE_SIZE 1024 -# endif /* ACE_DEFAULT_TIMER_HASH_TABLE_SIZE */ - -// Defaults for the ACE Free List -# if !defined (ACE_DEFAULT_FREE_LIST_PREALLOC) -# define ACE_DEFAULT_FREE_LIST_PREALLOC 0 -# endif /* ACE_DEFAULT_FREE_LIST_PREALLOC */ - -# if !defined (ACE_DEFAULT_FREE_LIST_LWM) -# define ACE_DEFAULT_FREE_LIST_LWM 0 -# endif /* ACE_DEFAULT_FREE_LIST_LWM */ - -# if !defined (ACE_DEFAULT_FREE_LIST_HWM) -# define ACE_DEFAULT_FREE_LIST_HWM 25000 -# endif /* ACE_DEFAULT_FREE_LIST_HWM */ - -# if !defined (ACE_DEFAULT_FREE_LIST_INC) -# define ACE_DEFAULT_FREE_LIST_INC 100 -# endif /* ACE_DEFAULT_FREE_LIST_INC */ - -# if !defined (ACE_UNIQUE_NAME_LEN) -# define ACE_UNIQUE_NAME_LEN 100 -# endif /* ACE_UNIQUE_NAME_LEN */ - -# if !defined (ACE_MAX_DGRAM_SIZE) - // This is just a guess. 8k is the normal limit on - // most machines because that's what NFS expects. -# define ACE_MAX_DGRAM_SIZE 8192 -# endif /* ACE_MAX_DGRAM_SIZE */ - -# if !defined (ACE_DEFAULT_ARGV_BUFSIZ) -# define ACE_DEFAULT_ARGV_BUFSIZ 1024 * 4 -# endif /* ACE_DEFAULT_ARGV_BUFSIZ */ - -// A free list which create more elements when there aren't enough -// elements. -# define ACE_FREE_LIST_WITH_POOL 1 - -// A simple free list which doen't allocate/deallocate elements. -# define ACE_PURE_FREE_LIST 2 - -# if defined (ACE_WIN32) - -// This is necessary to work around bugs with Win32 non-blocking -// connects... -# if !defined (ACE_NON_BLOCKING_BUG_DELAY) -# define ACE_NON_BLOCKING_BUG_DELAY 35000 -# endif /* ACE_NON_BLOCKING_BUG_DELAY */ -# endif /*ACE_WIN32*/ - -// Max size of an ACE Log Record data buffer. This can be reset in -// the config.h file if you'd like to increase or decrease the size. -# if !defined (ACE_MAXLOGMSGLEN) -# define ACE_MAXLOGMSGLEN 4 * 1024 -# endif /* ACE_MAXLOGMSGLEN */ - -// Max size of an ACE Token. -# define ACE_MAXTOKENNAMELEN 40 - -// Max size of an ACE Token client ID. -# define ACE_MAXCLIENTIDLEN MAXHOSTNAMELEN + 20 - -/// Max udp packet size -#if !defined (ACE_MAX_UDP_PACKET_SIZE) -#define ACE_MAX_UDP_PACKET_SIZE 65536 -#endif - -/** - * @name Default values to control CDR classes memory allocation strategies - */ -//@{ - -/// Control the initial size of all CDR buffers, application -/// developers may want to optimize this value to fit their request -/// size -#if !defined (ACE_DEFAULT_CDR_BUFSIZE) -# define ACE_DEFAULT_CDR_BUFSIZE 512 -#endif /* ACE_DEFAULT_CDR_BUFSIZE */ - -#if (ACE_DEFAULT_CDR_BUFSIZE == 0) -# error: ACE_DEFAULT_CDR_BUFSIZE should be bigger then 0 -#endif - -/// Stop exponential growth of CDR buffers to avoid overallocation -#if !defined (ACE_DEFAULT_CDR_EXP_GROWTH_MAX) -# define ACE_DEFAULT_CDR_EXP_GROWTH_MAX 65536 -#endif /* ACE_DEFAULT_CDR_EXP_GROWTH_MAX */ - -/// Control CDR buffer growth after maximum exponential growth is -/// reached -#if !defined (ACE_DEFAULT_CDR_LINEAR_GROWTH_CHUNK) -# define ACE_DEFAULT_CDR_LINEAR_GROWTH_CHUNK 65536 -#endif /* ACE_DEFAULT_CDR_LINEAR_GROWTH_CHUNK */ -//@} - -/// Control the zero-copy optimizations for octet sequences -/** - * Large octet sequences can be sent without any copies by chaining - * them in the list of message blocks that represent a single CDR - * stream. However, if the octet sequence is too small the zero copy - * optimizations actually hurt performance. Octet sequences smaller - * than this value will be copied. - */ -#if !defined (ACE_DEFAULT_CDR_MEMCPY_TRADEOFF) -#define ACE_DEFAULT_CDR_MEMCPY_TRADEOFF 256 -#endif /* ACE_DEFAULT_CDR_MEMCPY_TRADEOFF */ - -#if defined (ACE_WIN32) - // Define the pathname separator characters for Win32 (ugh). -# define ACE_DIRECTORY_SEPARATOR_STR_A "\\" -# define ACE_DIRECTORY_SEPARATOR_CHAR_A '\\' -#else - // Define the pathname separator characters for UNIX. -# define ACE_DIRECTORY_SEPARATOR_STR_A "/" -# define ACE_DIRECTORY_SEPARATOR_CHAR_A '/' -#endif /* ACE_WIN32 */ - -// Define the Wide character and normal versions of some of the string macros -#if defined (ACE_HAS_WCHAR) -# define ACE_DIRECTORY_SEPARATOR_STR_W ACE_TEXT_WIDE(ACE_DIRECTORY_SEPARATOR_STR_A) -# define ACE_DIRECTORY_SEPARATOR_CHAR_W ACE_TEXT_WIDE(ACE_DIRECTORY_SEPARATOR_CHAR_A) -#endif /* ACE_HAS_WCHAR */ - -#define ACE_DIRECTORY_SEPARATOR_STR ACE_TEXT (ACE_DIRECTORY_SEPARATOR_STR_A) -#define ACE_DIRECTORY_SEPARATOR_CHAR ACE_TEXT (ACE_DIRECTORY_SEPARATOR_CHAR_A) - -#if !defined (ACE_DEFAULT_THREAD_PRIORITY) -# define ACE_DEFAULT_THREAD_PRIORITY (-0x7fffffffL - 1L) -#endif /* ACE_DEFAULT_THREAD_PRIORITY */ - -#if !defined (ACE_DEFAULT_THREAD_STACKSIZE) -# define ACE_DEFAULT_THREAD_STACKSIZE 0 -#endif /* ACE_DEFAULT_THREAD_STACKSIZE */ - -#if !defined (ACE_MAX_DEFAULT_PORT) -# define ACE_MAX_DEFAULT_PORT 65535 -#endif /* ACE_MAX_DEFAULT_PORT */ - -// Default number of ACE_Event_Handlers supported by -// ACE_Timer_Heap. -# if !defined (ACE_DEFAULT_TIMERS) -# define ACE_DEFAULT_TIMERS _POSIX_TIMER_MAX -# endif /* ACE_DEFAULT_TIMERS */ - -#if defined (ACE_WIN32) -# define ACE_PLATFORM_A "Win32" -# define ACE_PLATFORM_EXE_SUFFIX_A ".exe" -#elif defined (ACE_VXWORKS) -# define ACE_PLATFORM_A "VxWorks" -# if defined (__RTP__) -# define ACE_PLATFORM_EXE_SUFFIX_A ".vxe" -# else -# define ACE_PLATFORM_EXE_SUFFIX_A ".out" -# endif -#else /* !ACE_WIN32 && !ACE_VXWORKS */ -# define ACE_PLATFORM_A "UNIX" -# define ACE_PLATFORM_EXE_SUFFIX_A "" -#endif /* ACE_WIN32 */ - -// Define the Wide character and normal versions of some of the string macros -#if defined (ACE_HAS_WCHAR) -# define ACE_PLATFORM_W ACE_TEXT_WIDE(ACE_PLATFORM_A) -# define ACE_PLATFORM_EXE_SUFFIX_W ACE_TEXT_WIDE(ACE_PLATFORM_EXE_SUFFIX_A) -#endif /* ACE_HAS_WCHAR */ - -#define ACE_PLATFORM ACE_TEXT (ACE_PLATFORM_A) -#define ACE_PLATFORM_EXE_SUFFIX ACE_TEXT (ACE_PLATFORM_EXE_SUFFIX_A) - -#if defined (ACE_WIN32) -# define ACE_LD_SEARCH_PATH ACE_TEXT ("PATH") -# define ACE_LD_SEARCH_PATH_SEPARATOR_STR ACE_TEXT (";") -# define ACE_DLL_SUFFIX ACE_TEXT (".dll") -# if defined (__MINGW32__) -# define ACE_DLL_PREFIX ACE_TEXT ("lib") -# else /* __MINGW32__ */ -# define ACE_DLL_PREFIX ACE_TEXT ("") -# endif /* __MINGW32__ */ -#else /* !ACE_WIN32 */ -# if !defined (ACE_LD_SEARCH_PATH) -# define ACE_LD_SEARCH_PATH ACE_TEXT ("LD_LIBRARY_PATH") -# endif /* ACE_LD_SEARCH_PATH */ -# if !defined (ACE_LD_SEARCH_PATH_SEPARATOR_STR) -# define ACE_LD_SEARCH_PATH_SEPARATOR_STR ACE_TEXT (":") -# endif /* ACE_LD_SEARCH_PATH_SEPARATOR_STR */ -#endif /* ACE_WIN32 */ - -#if !defined (ACE_DLL_SUFFIX) -# define ACE_DLL_SUFFIX ACE_TEXT (".so") -#endif /* ACE_DLL_SUFFIX */ - -#if !defined (ACE_DLL_PREFIX) -# define ACE_DLL_PREFIX ACE_TEXT ("lib") -#endif /* ACE_DLL_PREFIX */ - -#if defined (ACE_WIN32) -// Used for dynamic linking -# if !defined (ACE_DEFAULT_SVC_CONF) -# if (ACE_USES_CLASSIC_SVC_CONF == 1) -# define ACE_DEFAULT_SVC_CONF ACE_TEXT (".\\svc.conf") -# else -# define ACE_DEFAULT_SVC_CONF ACE_TEXT (".\\svc.conf.xml") -# endif /* ACE_USES_CLASSIC_SVC_CONF ==1 */ -# endif /* ACE_DEFAULT_SVC_CONF */ -#endif /* ACE_WIN32 */ - - // Used for dynamic linking. -#if !defined (ACE_DEFAULT_SVC_CONF) -# if (ACE_USES_CLASSIC_SVC_CONF == 1) -# define ACE_DEFAULT_SVC_CONF ACE_TEXT ("./svc.conf") -# else -# define ACE_DEFAULT_SVC_CONF ACE_TEXT ("./svc.conf.xml") -# endif /* ACE_USES_CLASSIC_SVC_CONF ==1 */ -#endif /* ACE_DEFAULT_SVC_CONF */ - -#if !defined (ACE_LOGGER_KEY) -# define ACE_LOGGER_KEY ACE_TEXT ("/tmp/server_daemon") -#endif /* ACE_LOGGER_KEY */ - -// Theses defines are used by the ACE Name Server. -#if !defined (ACE_DEFAULT_LOCALNAME_A) -# define ACE_DEFAULT_LOCALNAME_A "localnames" -#endif /* ACE_DEFAULT_LOCALNAME_A */ -#if !defined (ACE_DEFAULT_GLOBALNAME_A) -# define ACE_DEFAULT_GLOBALNAME_A "globalnames" -#endif /* ACE_DEFAULT_GLOBALNAME_A */ - -// ACE_DEFAULT_NAMESPACE_DIR is for legacy mode apps. A better -// way of doing this is something like ACE_Lib_Find::get_temp_dir, since -// this directory may not exist -#if defined (ACE_LEGACY_MODE) -# if defined (ACE_WIN32) -# define ACE_DEFAULT_NAMESPACE_DIR_A "C:\\temp" -# else /* ACE_WIN32 */ -# define ACE_DEFAULT_NAMESPACE_DIR_A "/tmp" -# endif /* ACE_WIN32 */ -# if defined (ACE_HAS_WCHAR) -# define ACE_DEFAULT_NAMESPACE_DIR_W ACE_TEXT_WIDE(ACE_DEFAULT_NAMESPACE_DIR_A) -# endif /* ACE_HAS_WCHAR */ -# define ACE_DEFAULT_NAMESPACE_DIR ACE_TEXT(ACE_DEFAULT_NAMESPACE_DIR_A) -#endif /* ACE_LEGACY_MODE */ - -#if defined (ACE_HAS_WCHAR) -# define ACE_DEFAULT_LOCALNAME_W ACE_TEXT_WIDE(ACE_DEFAULT_LOCALNAME_A) -# define ACE_DEFAULT_GLOBALNAME_W ACE_TEXT_WIDE(ACE_DEFAULT_GLOBALNAME_A) -#endif /* ACE_HAS_WCHAR */ - -#define ACE_DEFAULT_LOCALNAME ACE_TEXT (ACE_DEFAULT_LOCALNAME_A) -#define ACE_DEFAULT_GLOBALNAME ACE_TEXT (ACE_DEFAULT_GLOBALNAME_A) - -# if defined (ACE_WIN32) - // The "null" device on Win32. -# define ACE_DEV_NULL "nul" -# define ACE_SYSCALL_FAILED 0xFFFFFFFF -# else /* !ACE_WIN32 */ - // The "null" device on UNIX. -# define ACE_DEV_NULL "/dev/null" -# define ACE_SYSCALL_FAILED -1 -# endif /* ACE_WIN32 */ - -#include /**/ "ace/post.h" -#endif /*ACE_DEFAULT_CONSTANTS_H*/ diff --git a/ACE/ace/Dev_Poll_Reactor.cpp b/ACE/ace/Dev_Poll_Reactor.cpp deleted file mode 100644 index cfa87d00650..00000000000 --- a/ACE/ace/Dev_Poll_Reactor.cpp +++ /dev/null @@ -1,2513 +0,0 @@ -// $Id$ - -#include "ace/OS_NS_errno.h" -#include "ace/Dev_Poll_Reactor.h" -#include "ace/Signal.h" -#include "ace/Sig_Handler.h" - -ACE_RCSID (ace, - Dev_Poll_Reactor, - "$Id$") - -#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL) - -# include "ace/OS_NS_unistd.h" -# include "ace/OS_NS_fcntl.h" -# include "ace/OS_NS_stropts.h" - -# if defined (ACE_HAS_EVENT_POLL) && defined (linux) -# include /**/ -# elif defined (ACE_HAS_DEV_POLL) -# if defined (linux) -# include /**/ -# elif defined (HPUX_VERS) && HPUX_VERS < 1123 -# include /**/ -# else -# include /**/ -# endif /* linux */ -# endif /* ACE_HAS_DEV_POLL */ - -#if !defined (__ACE_INLINE__) -# include "ace/Dev_Poll_Reactor.inl" -#endif /* __ACE_INLINE__ */ - - -#include "ace/Handle_Set.h" -#include "ace/Reactor.h" -#include "ace/Timer_Heap.h" -#include "ace/Timer_Queue.h" -#include "ace/ACE.h" -#include "ace/Reverse_Lock_T.h" -#include "ace/Recursive_Thread_Mutex.h" -#include "ace/Null_Mutex.h" -#include "ace/os_include/os_poll.h" -#include "ace/OS_NS_sys_mman.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_Dev_Poll_Reactor_Notify::ACE_Dev_Poll_Reactor_Notify (void) - : dp_reactor_ (0) - , notification_pipe_ () - , max_notify_iterations_ (-1) -#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) - , notification_queue_ () -#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */ -{ -} - -int -ACE_Dev_Poll_Reactor_Notify::open (ACE_Reactor_Impl *r, - ACE_Timer_Queue * /* timer_queue */, - int disable_notify_pipe) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::open"); - - if (disable_notify_pipe == 0) - { - this->dp_reactor_ = dynamic_cast (r); - - if (this->dp_reactor_ == 0) - { - errno = EINVAL; - return -1; - } - - if (this->notification_pipe_.open () == -1) - return -1; - -#if defined (F_SETFD) - // close-on-exec - ACE_OS::fcntl (this->notification_pipe_.read_handle (), F_SETFD, 1); - ACE_OS::fcntl (this->notification_pipe_.write_handle (), F_SETFD, 1); -#endif /* F_SETFD */ - -#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) - if (notification_queue_.open () == -1) - { - return -1; - } - - if (ACE::set_flags (this->notification_pipe_.write_handle (), - ACE_NONBLOCK) == -1) - return -1; -#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */ - - // Set the read handle into non-blocking mode since we need to - // perform a "speculative" read when determining if there are - // notifications to dispatch. - if (ACE::set_flags (this->notification_pipe_.read_handle (), - ACE_NONBLOCK) == -1) - return -1; - } - - return 0; -} - -int -ACE_Dev_Poll_Reactor_Notify::close (void) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::close"); - -#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) - notification_queue_.reset (); -#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */ - - return this->notification_pipe_.close (); -} - -int -ACE_Dev_Poll_Reactor_Notify::notify (ACE_Event_Handler *eh, - ACE_Reactor_Mask mask, - ACE_Time_Value *timeout) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::notify"); - - // Just consider this method a "no-op" if there's no - // ACE_Dev_Poll_Reactor configured. - if (this->dp_reactor_ == 0) - return 0; - - ACE_Notification_Buffer buffer (eh, mask); - -#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) - ACE_UNUSED_ARG (timeout); - ACE_Dev_Poll_Handler_Guard eh_guard (eh); - - int notification_required = - notification_queue_.push_new_notification (buffer); - - if (notification_required == -1) - return -1; // Also decrement eh's reference count - - // The notification has been queued, so it will be delivered at some - // point (and may have been already); release the refcnt guard. - eh_guard.release (); - - if (notification_required == 0) - return 0; - - // Now pop the pipe to force the callback for dispatching when ready. If - // the send fails due to a full pipe, don't fail - assume the already-sent - // pipe bytes will cause the entire notification queue to be processed. - ssize_t n = ACE::send (this->notification_pipe_.write_handle (), - (char *) &buffer, - 1, // Only need one byte to pop the pipe - &ACE_Time_Value::zero); - if (n == -1 && (errno != ETIME && errno != EAGAIN)) - return -1; - - return 0; -#else - - ACE_Dev_Poll_Handler_Guard eh_guard (eh); - - ssize_t n = ACE::send (this->notification_pipe_.write_handle (), - (char *) &buffer, - sizeof buffer, - timeout); - if (n == -1) - return -1; - - eh_guard.release (); - - return 0; -#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */ -} - -int -ACE_Dev_Poll_Reactor_Notify::dispatch_notifications ( - int & /* number_of_active_handles */, - ACE_Handle_Set & /* rd_mask */) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::dispatch_notifications"); - - // This method is unimplemented in the ACE_Dev_Poll_Reactor. - // Instead, the notification handler is invoked as part of the IO - // event set. Doing so alters the some documented semantics that - // state that the notifications are handled before IO events. - // Enforcing such semantics does not appear to be beneficial, and - // also serves to slow down event dispatching particularly with this - // ACE_Dev_Poll_Reactor. - - ACE_NOTSUP_RETURN (-1); -} - -int -ACE_Dev_Poll_Reactor_Notify::read_notify_pipe (ACE_HANDLE handle, - ACE_Notification_Buffer &buffer) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::read_notify_pipe"); - - // This is a (non-blocking) "speculative" read, i.e., we attempt to - // read even if no event was polled on the read handle. A - // speculative read is necessary since notifications must be - // dispatched before IO events. We can avoid the speculative read - // by "walking" the array of pollfd structures returned from - // `/dev/poll' or `/dev/epoll' but that is potentially much more - // expensive than simply checking for an EWOULDBLOCK. - size_t to_read; - char *read_p; - bool have_one = false; - -#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) - // For the queued case, we'll try to read one byte (since that's what - // the notify () tried to put in) but we don't need it - notifications can - // be queued even if the pipe fills, so there may be more notifications - // queued than there are bytes in the pipe. - char b; - read_p = &b; - to_read = 1; - - // Before reading the byte, pop a message from the queue and queue a - // new message unless the queue is now empty. The protocol is to - // keep a byte in the pipe as long as the queue is not empty. - bool more_messages_queued = false; - ACE_Notification_Buffer next; - - int result = notification_queue_.pop_next_notification (buffer, - more_messages_queued, - next); - - if (result == 0) - { - // remove the notification byte from the pipe, avoiding notification loop - ACE::recv (handle, read_p, to_read); - return 0; - } - - if (result == -1) - return -1; - - if (more_messages_queued) - (void) ACE::send (this->notification_pipe_.write_handle (), - (char *)&next, - 1 /* one byte is enough */, - &ACE_Time_Value::zero); -#else - to_read = sizeof buffer; - read_p = (char *)&buffer; -#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */ - - ssize_t n = ACE::recv (handle, read_p, to_read); - - if (n > 0) - { - // Check to see if we've got a short read. - if (static_cast (n) != to_read) - { - size_t remainder = to_read - n; - - // If so, try to recover by reading the remainder. If this - // doesn't work we're in big trouble since the input stream - // won't be aligned correctly. I'm not sure quite what to - // do at this point. It's probably best just to return -1. - if (ACE::recv (handle, &read_p[n], remainder) <= 0) - return -1; - } - - return 1; - } - - // Return -1 if things have gone seriously wrong. - if (n <= 0 && (errno != EWOULDBLOCK && errno != EAGAIN)) - return -1; - - return have_one ? 1 : 0; -} - - -int -ACE_Dev_Poll_Reactor_Notify::handle_input (ACE_HANDLE handle) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::handle_input"); - - // @@ We may end up dispatching this event handler twice: once when - // performing the speculative read on the notification pipe - // handle, and once more when dispatching the IO events. - - // Precondition: this->select_reactor_.token_.current_owner () == - // ACE_Thread::self (); - - int number_dispatched = 0; - int result = 0; - ACE_Notification_Buffer buffer; - - while ((result = this->read_notify_pipe (handle, buffer)) > 0) - { - // Dispatch the buffer - // NOTE: We count only if we made any dispatches ie. upcalls. - if (this->dispatch_notify (buffer) > 0) - ++number_dispatched; - - // Bail out if we've reached the . Note that - // by default is -1, so we'll loop until all - // the available notifications have been dispatched. - if (number_dispatched == this->max_notify_iterations_) - break; - } - - if (result == -1) - { - // Reassign number_dispatched to -1 if things have gone - // seriously wrong. - number_dispatched = -1; - } - - // Enqueue ourselves into the list of waiting threads. When we - // reacquire the token we'll be off and running again with ownership - // of the token. The postcondition of this call is that - // == . - //this->select_reactor_->renew (); - - return number_dispatched; -} - -ACE_HANDLE -ACE_Dev_Poll_Reactor_Notify::notify_handle (void) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::notify_handle"); - - return this->notification_pipe_.read_handle (); -} - -int -ACE_Dev_Poll_Reactor_Notify::is_dispatchable (ACE_Notification_Buffer &) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::is_dispatchable"); - - ACE_NOTSUP_RETURN (-1); -} - -int -ACE_Dev_Poll_Reactor_Notify::dispatch_notify (ACE_Notification_Buffer &buffer) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::dispatch_notify"); - - // If eh == 0 then another thread is unblocking the - // ACE_Dev_Poll_Reactor to update the ACE_Dev_Poll_Reactor's - // internal structures. Otherwise, we need to dispatch the - // appropriate handle_* method on the ACE_Event_Handler - // pointer we've been passed. - if (buffer.eh_ != 0) - { - int result = 0; - - // Guard the handler's refcount. Recall that when the notify - // was queued, the refcount was incremented, so it need not be - // now. The guard insures that it is decremented properly. - ACE_Dev_Poll_Handler_Guard eh_guard (buffer.eh_, false); - - switch (buffer.mask_) - { - case ACE_Event_Handler::READ_MASK: - case ACE_Event_Handler::ACCEPT_MASK: - result = buffer.eh_->handle_input (ACE_INVALID_HANDLE); - break; - case ACE_Event_Handler::WRITE_MASK: - result = buffer.eh_->handle_output (ACE_INVALID_HANDLE); - break; - case ACE_Event_Handler::EXCEPT_MASK: - result = buffer.eh_->handle_exception (ACE_INVALID_HANDLE); - break; - default: - // Should we bail out if we get an invalid mask? - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("dispatch_notify invalid mask = %d\n"), - buffer.mask_)); - } - if (result == -1) - buffer.eh_->handle_close (ACE_INVALID_HANDLE, buffer.mask_); - } - - return 1; -} - -void -ACE_Dev_Poll_Reactor_Notify::max_notify_iterations (int iterations) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::max_notify_iterations"); - - // Must always be > 0 or < 0 to optimize the loop exit condition. - if (iterations == 0) - iterations = 1; - - this->max_notify_iterations_ = iterations; -} - -int -ACE_Dev_Poll_Reactor_Notify::max_notify_iterations (void) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::max_notify_iterations"); - - return this->max_notify_iterations_; -} - -int -ACE_Dev_Poll_Reactor_Notify::purge_pending_notifications ( - ACE_Event_Handler *eh, - ACE_Reactor_Mask mask) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::purge_pending_notifications"); - -#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) - - return notification_queue_.purge_pending_notifications (eh, mask); - -#else /* defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) */ - ACE_UNUSED_ARG (eh); - ACE_UNUSED_ARG (mask); - ACE_NOTSUP_RETURN (-1); -#endif /* defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) */ -} - -void -ACE_Dev_Poll_Reactor_Notify::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("dp_reactor_ = %@"), - this->dp_reactor_)); - this->notification_pipe_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -// ----------------------------------------------------------------- - -ACE_Dev_Poll_Reactor_Handler_Repository:: -ACE_Dev_Poll_Reactor_Handler_Repository (void) - : max_size_ (0), - handlers_ (0) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::ACE_Dev_Poll_Reactor_Handler_Repository"); -} - -int -ACE_Dev_Poll_Reactor_Handler_Repository::invalid_handle ( - ACE_HANDLE handle) const -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::invalid_handle"); - - if (handle < 0 || handle >= this->max_size_) - { - errno = EINVAL; - return 1; - } - else - return 0; -} - -int -ACE_Dev_Poll_Reactor_Handler_Repository::handle_in_range ( - ACE_HANDLE handle) const -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::handle_in_range"); - - if (handle >= 0 && handle < this->max_size_) - return 1; - else - { - errno = EINVAL; - return 0; - } -} - -int -ACE_Dev_Poll_Reactor_Handler_Repository::open (size_t size) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::open"); - - this->max_size_ = size; - - // Try to allocate the memory. - ACE_NEW_RETURN (this->handlers_, - ACE_Dev_Poll_Event_Tuple[size], - -1); - - // Try to increase the number of handles if is greater than - // the current limit. - return ACE::set_handle_limit (size); -} - -int -ACE_Dev_Poll_Reactor_Handler_Repository::unbind_all (void) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::unbind_all"); - - // Unbind all of the event handlers. - for (int handle = 0; - handle < this->max_size_; - ++handle) - this->unbind (handle); - - return 0; -} - -int -ACE_Dev_Poll_Reactor_Handler_Repository::close (void) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::close"); - - if (this->handlers_ != 0) - { - this->unbind_all (); - - delete [] this->handlers_; - this->handlers_ = 0; - } - - return 0; -} - -ACE_Event_Handler * -ACE_Dev_Poll_Reactor_Handler_Repository::find (ACE_HANDLE handle, - size_t *index_p) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::find"); - - ACE_Event_Handler *eh = 0; - - // Only bother to search for the if it's in range. - if (this->handle_in_range (handle)) - { - eh = this->handlers_[handle].event_handler; - if (eh != 0) - { - if (index_p != 0) - *index_p = handle; - } - else - errno = ENOENT; - } - - return eh; -} - -int -ACE_Dev_Poll_Reactor_Handler_Repository::bind ( - ACE_HANDLE handle, - ACE_Event_Handler *event_handler, - ACE_Reactor_Mask mask) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::bind"); - - if (event_handler == 0) - return -1; - - if (handle == ACE_INVALID_HANDLE) - handle = event_handler->get_handle (); - - if (this->invalid_handle (handle)) - return -1; - - this->handlers_[handle].event_handler = event_handler; - this->handlers_[handle].mask = mask; - event_handler->add_reference (); - - return 0; -} - -int -ACE_Dev_Poll_Reactor_Handler_Repository::unbind (ACE_HANDLE handle, - bool decr_refcnt) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::unbind"); - - if (this->find (handle) == 0) - return -1; - - if (decr_refcnt) - this->handlers_[handle].event_handler->remove_reference (); - this->handlers_[handle].event_handler = 0; - this->handlers_[handle].mask = ACE_Event_Handler::NULL_MASK; - this->handlers_[handle].suspended = 0; - - return 0; -} - -// ----------------------------------------------------------------- - -ACE_Dev_Poll_Reactor::ACE_Dev_Poll_Reactor (ACE_Sig_Handler *sh, - ACE_Timer_Queue *tq, - int disable_notify_pipe, - ACE_Reactor_Notify *notify, - int mask_signals, - int s_queue) - : initialized_ (false) - , poll_fd_ (ACE_INVALID_HANDLE) - , size_ (0) - // , ready_set_ () -#if defined (ACE_HAS_EVENT_POLL) - , events_ (0) - , start_pevents_ (0) - , end_pevents_ (0) -#else - , dp_fds_ (0) - , start_pfds_ (0) - , end_pfds_ (0) -#endif /* ACE_HAS_EVENT_POLL */ - , deactivated_ (0) - , token_ (*this, s_queue) - , lock_adapter_ (token_) - , timer_queue_ (0) - , delete_timer_queue_ (false) - , signal_handler_ (0) - , delete_signal_handler_ (false) - , notify_handler_ (0) - , delete_notify_handler_ (false) - , mask_signals_ (mask_signals) - , restart_ (0) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::ACE_Dev_Poll_Reactor"); - - if (this->open (ACE::max_handles (), - 0, - sh, - tq, - disable_notify_pipe, - notify) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Dev_Poll_Reactor::open ") - ACE_TEXT ("failed inside ") - ACE_TEXT ("ACE_Dev_Poll_Reactor::CTOR"))); -} - -ACE_Dev_Poll_Reactor::ACE_Dev_Poll_Reactor (size_t size, - int rs, - ACE_Sig_Handler *sh, - ACE_Timer_Queue *tq, - int disable_notify_pipe, - ACE_Reactor_Notify *notify, - int mask_signals, - int s_queue) - : initialized_ (false) - , poll_fd_ (ACE_INVALID_HANDLE) - , size_ (0) - // , ready_set_ () -#if defined (ACE_HAS_EVENT_POLL) - , events_ (0) - , start_pevents_ (0) - , end_pevents_ (0) -#else - , dp_fds_ (0) - , start_pfds_ (0) - , end_pfds_ (0) -#endif /* ACE_HAS_EVENT_POLL */ - , deactivated_ (0) - , token_ (*this, s_queue) - , lock_adapter_ (token_) - , timer_queue_ (0) - , delete_timer_queue_ (false) - , signal_handler_ (0) - , delete_signal_handler_ (false) - , notify_handler_ (0) - , delete_notify_handler_ (false) - , mask_signals_ (mask_signals) - , restart_ (0) -{ - if (this->open (size, - rs, - sh, - tq, - disable_notify_pipe, - notify) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Dev_Poll_Reactor::open ") - ACE_TEXT ("failed inside ACE_Dev_Poll_Reactor::CTOR"))); -} - -ACE_Dev_Poll_Reactor::~ACE_Dev_Poll_Reactor (void) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::~ACE_Dev_Poll_Reactor"); - - (void) this->close (); -} - -int -ACE_Dev_Poll_Reactor::open (size_t size, - int restart, - ACE_Sig_Handler *sh, - ACE_Timer_Queue *tq, - int disable_notify_pipe, - ACE_Reactor_Notify *notify) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::open"); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - // Can't initialize ourselves more than once. - if (this->initialized_) - return -1; - - this->restart_ = restart; - this->signal_handler_ = sh; - this->timer_queue_ = tq; - this->notify_handler_ = notify; - - int result = 0; - - // Allows the signal handler to be overridden. - if (this->signal_handler_ == 0) - { - ACE_NEW_RETURN (this->signal_handler_, - ACE_Sig_Handler, - -1); - - if (this->signal_handler_ == 0) - result = -1; - else - this->delete_signal_handler_ = true; - } - - // Allows the timer queue to be overridden. - if (result != -1 && this->timer_queue_ == 0) - { - ACE_NEW_RETURN (this->timer_queue_, - ACE_Timer_Heap, - -1); - - if (this->timer_queue_ == 0) - result = -1; - else - this->delete_timer_queue_ = true; - } - - // Allows the Notify_Handler to be overridden. - if (result != -1 && this->notify_handler_ == 0) - { - ACE_NEW_RETURN (this->notify_handler_, - ACE_Dev_Poll_Reactor_Notify, - -1); - - if (this->notify_handler_ == 0) - result = -1; - else - this->delete_notify_handler_ = true; - } - -#if defined (ACE_HAS_EVENT_POLL) - - // Allocating event table: - ACE_NEW_RETURN (this->events_, epoll_event[size], -1); - - // Initializing epoll: - this->poll_fd_ = ::epoll_create (size); - if (this->poll_fd_ == -1) - result = -1; - -#else - - // Allocate the array before opening the device to avoid a potential - // resource leak if allocation fails. - ACE_NEW_RETURN (this->dp_fds_, - pollfd[size], - -1); - - // Open the `/dev/poll' character device. - this->poll_fd_ = ACE_OS::open ("/dev/poll", O_RDWR); - if (this->poll_fd_ == ACE_INVALID_HANDLE) - result = -1; - -#endif /* ACE_HAS_EVENT_POLL */ - - if (result != -1 && this->handler_rep_.open (size) == -1) - result = -1; - - // Registration of the notification handler must be done after the - // /dev/poll device has been fully initialized. - else if (this->notify_handler_->open (this, - 0, - disable_notify_pipe) == -1 - || (disable_notify_pipe == 0 - && this->register_handler_i ( - this->notify_handler_->notify_handle (), - this->notify_handler_, - ACE_Event_Handler::READ_MASK) == -1)) - result = -1; - - this->size_ = size; - - if (result != -1) - // We're all set to go. - this->initialized_ = true; - else - // This will close down all the allocated resources properly. - (void) this->close (); - - return result; -} - -int -ACE_Dev_Poll_Reactor::current_info (ACE_HANDLE, size_t & /* size */) -{ - ACE_NOTSUP_RETURN (-1); -} - - -int -ACE_Dev_Poll_Reactor::set_sig_handler (ACE_Sig_Handler *signal_handler) -{ - if (this->delete_signal_handler_) - delete this->signal_handler_; - - this->signal_handler_ = signal_handler; - this->delete_signal_handler_ = false; - - return 0; -} - -int -ACE_Dev_Poll_Reactor::timer_queue (ACE_Timer_Queue *tq) -{ - if (this->delete_timer_queue_) - delete this->timer_queue_; - - this->timer_queue_ = tq; - this->delete_timer_queue_ = false; - - return 0; - -} - -ACE_Timer_Queue * -ACE_Dev_Poll_Reactor::timer_queue (void) const -{ - return this->timer_queue_; -} - -int -ACE_Dev_Poll_Reactor::close (void) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::close"); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - int result = 0; - - if (this->poll_fd_ != ACE_INVALID_HANDLE) - { - result = ACE_OS::close (this->poll_fd_); - } - -#if defined (ACE_HAS_EVENT_POLL) - - delete [] this->events_; - this->events_ = 0; - -#else - - delete [] this->dp_fds_; - this->dp_fds_ = 0; - -#endif /* ACE_HAS_EVENT_POLL */ - - if (this->delete_signal_handler_) - { - delete this->signal_handler_; - this->signal_handler_ = 0; - this->delete_signal_handler_ = false; - } - - (void) this->handler_rep_.close (); - - if (this->delete_timer_queue_) - { - delete this->timer_queue_; - this->timer_queue_ = 0; - this->delete_timer_queue_ = false; - } - - if (this->notify_handler_ != 0) - this->notify_handler_->close (); - - if (this->delete_notify_handler_) - { - delete this->notify_handler_; - this->notify_handler_ = 0; - this->delete_notify_handler_ = false; - } - - this->poll_fd_ = ACE_INVALID_HANDLE; - -#if defined (ACE_HAS_EVENT_POLL) - this->start_pevents_ = 0; - this->end_pevents_ = 0; -#else - this->start_pfds_ = 0; - this->end_pfds_ = 0; -#endif /* ACE_HAS_EVENT_POLL */ - - this->initialized_ = false; - - return result; -} - -int -ACE_Dev_Poll_Reactor::work_pending (const ACE_Time_Value & max_wait_time) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::work_pending"); - - // Stash the current time - // - // The destructor of this object will automatically compute how much - // time elapsed since this method was called. - ACE_Time_Value mwt (max_wait_time); - ACE_MT (ACE_Countdown_Time countdown (&mwt)); - - Token_Guard guard (this->token_); - int const result = guard.acquire_quietly (&mwt); - - // If the guard is NOT the owner just return the retval - if (!guard.is_owner ()) - return result; - - // Update the countdown to reflect time waiting for the mutex. - ACE_MT (countdown.update ()); - - return this->work_pending_i (&mwt); -} - -int -ACE_Dev_Poll_Reactor::work_pending_i (ACE_Time_Value * max_wait_time) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::work_pending_i"); - - if (this->deactivated_) - return 0; - -#if defined (ACE_HAS_EVENT_POLL) - if (this->start_pevents_ != this->end_pevents_) -#else - if (this->start_pfds_ != this->end_pfds_) -#endif /* ACE_HAS_EVENT_POLL */ - return 1; // We still have work_pending (). Do not poll for - // additional events. - - ACE_Time_Value timer_buf (0); - ACE_Time_Value *this_timeout = - this->timer_queue_->calculate_timeout (max_wait_time, &timer_buf); - - // Check if we have timers to fire. - int const timers_pending = - ((this_timeout != 0 && max_wait_time == 0) - || (this_timeout != 0 && max_wait_time != 0 - && *this_timeout != *max_wait_time) ? 1 : 0); - - long const timeout = - (this_timeout == 0 - ? -1 /* Infinity */ - : static_cast (this_timeout->msec ())); - -#if defined (ACE_HAS_EVENT_POLL) - - // Wait for events. - int const nfds = ::epoll_wait (this->poll_fd_, - this->events_, - this->size_, - static_cast (timeout)); - - if (nfds > 0) - { - this->start_pevents_ = this->events_; - this->end_pevents_ = this->start_pevents_ + nfds; - } - -#else - - struct dvpoll dvp; - - dvp.dp_fds = this->dp_fds_; - dvp.dp_nfds = this->size_; - dvp.dp_timeout = timeout; // Milliseconds - - // Poll for events - int const nfds = ACE_OS::ioctl (this->poll_fd_, DP_POLL, &dvp); - - // Retrieve the results from the pollfd array. - this->start_pfds_ = dvp.dp_fds; - - // If nfds == 0 then end_pfds_ == start_pfds_ meaning that there is - // no work pending. If nfds > 0 then there is work pending. - // Otherwise an error occurred. - if (nfds > -1) - this->end_pfds_ = this->start_pfds_ + nfds; -#endif /* ACE_HAS_EVENT_POLL */ - - // If timers are pending, override any timeout from the poll. - return (nfds == 0 && timers_pending != 0 ? 1 : nfds); -} - - -int -ACE_Dev_Poll_Reactor::handle_events (ACE_Time_Value *max_wait_time) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::handle_events"); - - // Stash the current time - // - // The destructor of this object will automatically compute how much - // time elapsed since this method was called. - ACE_MT (ACE_Countdown_Time countdown (max_wait_time)); - - Token_Guard guard (this->token_); - int const result = guard.acquire_quietly (max_wait_time); - - // If the guard is NOT the owner just return the retval - if (!guard.is_owner ()) - return result; - - if (this->deactivated_) - return -1; - - // Update the countdown to reflect time waiting for the mutex. - ACE_MT (countdown.update ()); - - return this->handle_events_i (max_wait_time, guard); -} - -int -ACE_Dev_Poll_Reactor::handle_events_i (ACE_Time_Value *max_wait_time, - Token_Guard &guard) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::handle_events_i"); - - int result = 0; - // int active_handle_count = 0; - - // Poll for events - // - // If the underlying ioctl () call was interrupted via the interrupt - // signal (i.e. returned -1 with errno == EINTR) then the loop will - // be restarted if so desired. - do - { - result = this->work_pending_i (max_wait_time); - if (result == -1) - ACE_ERROR ((LM_ERROR, "%t: %p\n", "work_pending_i")); - } - while (result == -1 && this->restart_ != 0 && errno == EINTR); - - if (result == 0 || (result == -1 && errno == ETIME)) - return 0; - else if (result == -1) - { - if (errno != EINTR) - return -1; - - // Bail out -- we got here since the poll was interrupted. - // If it was due to a signal registered through our ACE_Sig_Handler, - // then it was dispatched, so we count it in the number of events - // handled rather than cause an error return. - if (ACE_Sig_Handler::sig_pending () != 0) - { - ACE_Sig_Handler::sig_pending (0); - return 1; - } - return -1; - } - - // Dispatch an event. - return this->dispatch (guard); -} - -// Dispatch an event. On entry, the token is held by the caller. If an -// event is found to dispatch, the token is released before dispatching it. -int -ACE_Dev_Poll_Reactor::dispatch (Token_Guard &guard) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::dispatch"); - - // Perform the Template Method for dispatching the first located event. - // We dispatch only one to effectively dispatch events concurrently. - // As soon as an event is located, the token is released, allowing the - // next waiter to begin getting an event while we dispatch one here. - int result = 0; - - // Handle timers early since they may have higher latency - // constraints than I/O handlers. Ideally, the order of - // dispatching should be a strategy... - if ((result = this->dispatch_timer_handler (guard)) != 0) - return result; - - // Check to see if there are no more I/O handles left to - // dispatch AFTER we've handled the timers. - - // Finally, dispatch the I/O handlers. - result = this->dispatch_io_event (guard); - - return result; -} - -int -ACE_Dev_Poll_Reactor::dispatch_timer_handler (Token_Guard &guard) -{ - if (this->timer_queue_->is_empty ()) - return 0; // Empty timer queue so cannot have any expired timers. - - // Get the current time - ACE_Time_Value cur_time (this->timer_queue_->gettimeofday () + - this->timer_queue_->timer_skew ()); - - // Look for a node in the timer queue whose timer <= the present - // time. - ACE_Timer_Node_Dispatch_Info info; - if (this->timer_queue_->dispatch_info (cur_time, info)) - { - const void *upcall_act = 0; - - // Preinvoke (handles refcount if needed, etc.) - this->timer_queue_->preinvoke (info, cur_time, upcall_act); - - // Release the token before expiration upcall. - guard.release_token (); - - // call the functor - this->timer_queue_->upcall (info, cur_time); - - // Postinvoke (undo refcount if needed, etc.) - this->timer_queue_->postinvoke (info, cur_time, upcall_act); - - // We have dispatched a timer - return 1; - } - - return 0; -} - -#if 0 -int -ACE_Dev_Poll_Reactor::dispatch_notification_handlers ( - ACE_Select_Reactor_Handle_Set &dispatch_set, - int &number_of_active_handles, - int &number_of_handlers_dispatched) -{ - // Check to see if the ACE_HANDLE associated with the - // Dev_Poll_Reactor's notify hook is enabled. If so, it means that - // one or more other threads are trying to update the - // ACE_Dev_Poll_Reactor's internal tables or the notify pipe is - // enabled. We'll handle all these threads and notifications, and - // then break out to continue the event loop. - - const int n = - this->notify_handler_->dispatch_notifications (number_of_active_handles, - dispatch_set.rd_mask_); - - if (n == -1) - return -1; - else - number_of_handlers_dispatched += n; - - return /* this->state_changed_ ? -1 : */ 0; -} -#endif /* 0 */ - -int -ACE_Dev_Poll_Reactor::dispatch_io_event (Token_Guard &guard) -{ - - // Define bits to check for while dispatching. -#if defined (ACE_HAS_EVENT_POLL) - const __uint32_t out_event = EPOLLOUT; - const __uint32_t exc_event = EPOLLPRI; - const __uint32_t in_event = EPOLLIN; - const __uint32_t err_event = EPOLLHUP | EPOLLERR; -#else - const short out_event = POLLOUT; - const short exc_event = POLLPRI; - const short in_event = POLLIN; - const short err_event = 0; // No known bits for this -#endif /* ACE_HAS_EVENT_POLL */ - - // Since the underlying event demultiplexing mechansim (`/dev/poll' - // or '/dev/epoll') is stateful, and since only one result buffer is - // used, all pending events (i.e. those retrieved from a previous - // poll) must be dispatched before any additional event can be - // polled. As such, the Dev_Poll_Reactor keeps track of the - // progress of events that have been dispatched. - - // Dispatch the events. - // - // Select the first available handle with event (s) pending. Check for - // event type in defined order of dispatch: output, exception, input. - // When an event is located, clear its bit in the dispatch set. If there - // are no more events for the handle, also increment the pfds pointer - // to move to the next handle ready. - // - // Notice that pfds only contains file descriptors that have - // received events. -#if defined (ACE_HAS_EVENT_POLL) - struct epoll_event *& pfds = this->start_pevents_; - if (pfds < this->end_pevents_) -#else - struct pollfd *& pfds = this->start_pfds_; - if (pfds < this->end_pfds_) -#endif /* ACE_HAS_EVENT_POLL */ - { -#if defined (ACE_HAS_EVENT_POLL) - const ACE_HANDLE handle = pfds->data.fd; - __uint32_t &revents = pfds->events; -#else - const ACE_HANDLE handle = pfds->fd; - short &revents = pfds->revents; -#endif /* ACE_HAS_EVENT_POLL */ - - // Figure out what to do first in order to make it easier to manage - // the bit twiddling and possible pfds increment before releasing - // the token for dispatch. - // Note that if there's an error (such as the handle was closed - // without being removed from the event set) the EPOLLHUP and/or - // EPOLLERR bits will be set in revents. - bool disp_out = false; - bool disp_exc = false; - bool disp_in = false; - if (ACE_BIT_ENABLED (revents, out_event)) - { - disp_out = true; - ACE_CLR_BITS (revents, out_event); - } - else if (ACE_BIT_ENABLED (revents, exc_event)) - { - disp_exc = true; - ACE_CLR_BITS (revents, exc_event); - } - else if (ACE_BIT_ENABLED (revents, in_event)) - { - disp_in = true; - ACE_CLR_BITS (revents, in_event); - } - else if (ACE_BIT_ENABLED (revents, err_event)) - { - this->remove_handler_i (handle, ACE_Event_Handler::ALL_EVENTS_MASK); - ++pfds; - return 1; - } - else - { - ACE_ERROR ((LM_ERROR, ACE_TEXT (" (%t) dispatch_io h %d unknown events 0x%x\n"), handle, revents)); - // ACE_ASSERT (0); - } - - // Increment the pointer to the next element before we - // release the token. Otherwise event handlers end up being - // dispatched multiple times for the same poll. - if (revents == 0) - ++pfds; - - /* When using sys_epoll, we can attach arbitrary user - data to the descriptor, so it can be delivered when - activity is detected. Perhaps we should store event - handler together with descriptor, instead of looking - it up in a repository ? Could it boost performance ? - */ - ACE_Event_Handler *eh = this->handler_rep_.find (handle); - - if (eh) - { - // Modify the reference count in an exception-safe way. - // Note that eh could be the notify handler. It's not strictly - // necessary to manage its refcount, but since we don't enable - // the counting policy, it won't do much. Management of the - // notified handlers themselves is done in the notify handler. - ACE_Dev_Poll_Handler_Guard eh_guard (eh); - - // Release the reactor token before upcall. - guard.release_token (); - - // Dispatch the detected event - if (disp_out) - { - const int status = - this->upcall (eh, &ACE_Event_Handler::handle_output, handle); - - if (status < 0) - // Note that the token is reacquired in remove_handler (). - this->remove_handler (handle, ACE_Event_Handler::WRITE_MASK); - return 1; - } - - if (disp_exc) - { - const int status = - this->upcall (eh, &ACE_Event_Handler::handle_exception, handle); - - if (status < 0) - // Note that the token is reacquired in remove_handler (). - this->remove_handler (handle, ACE_Event_Handler::EXCEPT_MASK); - return 1; - } - - if (disp_in) - { - const int status = - this->upcall (eh, &ACE_Event_Handler::handle_input, handle); - - if (status < 0) - // Note that the token is reacquired in remove_handler (). - this->remove_handler (handle, ACE_Event_Handler::READ_MASK); - return 1; - } - } // The reactor token is reacquired upon leaving this scope. - } - - return 0; -} - -int -ACE_Dev_Poll_Reactor::alertable_handle_events (ACE_Time_Value *max_wait_time) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::alertable_handle_events"); - - return this->handle_events (max_wait_time); -} - -int -ACE_Dev_Poll_Reactor::handle_events (ACE_Time_Value &max_wait_time) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::handle_events"); - - return this->handle_events (&max_wait_time); -} - -int -ACE_Dev_Poll_Reactor::alertable_handle_events (ACE_Time_Value &max_wait_time) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::alertable_handle_events"); - - return this->handle_events (max_wait_time); -} - -int -ACE_Dev_Poll_Reactor::deactivated (void) -{ - return this->deactivated_; -} - -void -ACE_Dev_Poll_Reactor::deactivate (int do_stop) -{ - this->deactivated_ = do_stop; - this->wakeup_all_threads (); -} - -int -ACE_Dev_Poll_Reactor::register_handler (ACE_Event_Handler *handler, - ACE_Reactor_Mask mask) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler"); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - return this->register_handler_i (handler->get_handle (), - handler, - mask); -} - -int -ACE_Dev_Poll_Reactor::register_handler (ACE_HANDLE handle, - ACE_Event_Handler *event_handler, - ACE_Reactor_Mask mask) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler"); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - return this->register_handler_i (handle, - event_handler, - mask); -} - -int -ACE_Dev_Poll_Reactor::register_handler_i (ACE_HANDLE handle, - ACE_Event_Handler *event_handler, - ACE_Reactor_Mask mask) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler_i"); - - if (handle == ACE_INVALID_HANDLE - || mask == ACE_Event_Handler::NULL_MASK) - { - errno = EINVAL; - return -1; - } - - if (this->handler_rep_.find (handle) == 0) - { - // Handler not present in the repository. Bind it. - if (this->handler_rep_.bind (handle, event_handler, mask) != 0) - return -1; - -#if defined (ACE_HAS_EVENT_POLL) - - struct epoll_event epev; - ACE_OS::memset (&epev, 0, sizeof (epev)); - static const int op = EPOLL_CTL_ADD; - - epev.events = this->reactor_mask_to_poll_event (mask); - epev.data.fd = handle; - - if (::epoll_ctl (this->poll_fd_, op, handle, &epev) == -1) - { - ACE_ERROR ((LM_ERROR, "%p\n", "epoll_ctl")); - (void) this->handler_rep_.unbind (handle); - return -1; - } - -#endif /* ACE_HAS_EVENT_POLL */ - } - else - { - // Handler is already present in the repository, so register it - // again, possibly for different event. Add new mask to the - // current one. - if (this->mask_ops_i (handle, mask, ACE_Reactor::ADD_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "mask_ops_i"), -1); - } - -#ifndef ACE_HAS_EVENT_POLL - - struct pollfd pfd; - - pfd.fd = handle; - pfd.events = this->reactor_mask_to_poll_event (mask); - pfd.revents = 0; - - // Add file descriptor to the "interest set." - if (ACE_OS::write (this->poll_fd_, &pfd, sizeof (pfd)) != sizeof (pfd)) - { - (void) this->handler_rep_.unbind (handle); - return -1; - } -#endif /*ACE_HAS_EVENT_POLL*/ - - // Note the fact that we've changed the state of the wait_set_, - // which is used by the dispatching loop to determine whether it can - // keep going or if it needs to reconsult select (). - // this->state_changed_ = 1; - - return 0; -} - -int -ACE_Dev_Poll_Reactor::register_handler ( - ACE_HANDLE /* event_handle */, - ACE_HANDLE /* io_handle */, - ACE_Event_Handler * /* event_handler */, - ACE_Reactor_Mask /* mask */) -{ - ACE_NOTSUP_RETURN (-1); -} - -int -ACE_Dev_Poll_Reactor::register_handler (const ACE_Handle_Set &handle_set, - ACE_Event_Handler *event_handler, - ACE_Reactor_Mask mask) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler"); - - ACE_Handle_Set_Iterator handle_iter (handle_set); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - // @@ It might be more efficient to construct a pollfd array and - // pass it to the write () call in register_handler_i () only once, - // instead of calling write () (a system call) once for each file - // descriptor. - - for (ACE_HANDLE h = handle_iter (); - h != ACE_INVALID_HANDLE; - h = handle_iter ()) - if (this->register_handler_i (h, event_handler, mask) == -1) - return -1; - - return 0; -} - -int -ACE_Dev_Poll_Reactor::register_handler (int signum, - ACE_Event_Handler *new_sh, - ACE_Sig_Action *new_disp, - ACE_Event_Handler **old_sh, - ACE_Sig_Action *old_disp) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler"); - - return this->signal_handler_->register_handler (signum, - new_sh, - new_disp, - old_sh, - old_disp); -} - -int -ACE_Dev_Poll_Reactor::register_handler (const ACE_Sig_Set &sigset, - ACE_Event_Handler *new_sh, - ACE_Sig_Action *new_disp) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler"); - - int result = 0; - -#if (ACE_NSIG > 0) - - for (int s = 1; s < ACE_NSIG; ++s) - if ((sigset.is_member (s) == 1) - && this->signal_handler_->register_handler (s, - new_sh, - new_disp) == -1) - result = -1; - -#else /* ACE_NSIG <= 0 */ - - ACE_UNUSED_ARG (sigset); - ACE_UNUSED_ARG (new_sh); - ACE_UNUSED_ARG (new_disp); - -#endif /* ACE_NSIG <= 0 */ - - return result; -} - -int -ACE_Dev_Poll_Reactor::remove_handler (ACE_Event_Handler *handler, - ACE_Reactor_Mask mask) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler"); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - return this->remove_handler_i (handler->get_handle (), mask); -} - -int -ACE_Dev_Poll_Reactor::remove_handler (ACE_HANDLE handle, - ACE_Reactor_Mask mask) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler"); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - return this->remove_handler_i (handle, mask); -} - -int -ACE_Dev_Poll_Reactor::remove_handler_i (ACE_HANDLE handle, - ACE_Reactor_Mask mask) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler_i"); - - ACE_Event_Handler *eh = this->handler_rep_.find (handle); - - if (eh == 0 || - this->mask_ops_i (handle, mask, ACE_Reactor::CLR_MASK) == -1) - return -1; - - // Check for ref counting now - handle_close () may delete eh. - bool const requires_reference_counting = - eh->reference_counting_policy ().value () == - ACE_Event_Handler::Reference_Counting_Policy::ENABLED; - - if (ACE_BIT_DISABLED (mask, ACE_Event_Handler::DONT_CALL)) - (void) eh->handle_close (handle, mask); - - // If there are no longer any outstanding events on the given handle - // then remove it from the handler repository. - if (this->handler_rep_.mask (handle) == ACE_Event_Handler::NULL_MASK) - this->handler_rep_.unbind (handle, requires_reference_counting); - - // Note the fact that we've changed the state of the wait_set, - // i.e. the "interest set," which is used by the dispatching loop to - // determine whether it can keep going or if it needs to reconsult - // /dev/poll or /dev/epoll. - // this->state_changed_ = 1; - - return 0; -} - -int -ACE_Dev_Poll_Reactor::remove_handler (const ACE_Handle_Set &handle_set, - ACE_Reactor_Mask mask) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler"); - - ACE_Handle_Set_Iterator handle_iter (handle_set); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - // @@ It might be more efficient to construct a pollfd array and - // pass it to the write () call in register_handler_i () only once, - // instead of calling write () (a system call) once for each file - // descriptor. - - for (ACE_HANDLE h = handle_iter (); - h != ACE_INVALID_HANDLE; - h = handle_iter ()) - if (this->remove_handler_i (h, mask) == -1) - return -1; - - return 0; -} - -int -ACE_Dev_Poll_Reactor::remove_handler (int signum, - ACE_Sig_Action *new_disp, - ACE_Sig_Action *old_disp, - int sigkey) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler"); - - return this->signal_handler_->remove_handler (signum, - new_disp, - old_disp, - sigkey); -} - -int -ACE_Dev_Poll_Reactor::remove_handler (const ACE_Sig_Set &sigset) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler"); - - int result = 0; - -#if (ACE_NSIG > 0) - - for (int s = 1; s < ACE_NSIG; ++s) - if ((sigset.is_member (s) == 1) - && this->signal_handler_->remove_handler (s) == -1) - result = -1; - -#else /* ACE_NSIG <= 0 */ - - ACE_UNUSED_ARG (sigset); - -#endif /* ACE_NSIG <= 0 */ - - return result; -} - -int -ACE_Dev_Poll_Reactor::suspend_handler (ACE_Event_Handler *event_handler) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handler"); - - if (event_handler == 0) - { - errno = EINVAL; - return -1; - } - - ACE_HANDLE handle = event_handler->get_handle (); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - return this->suspend_handler_i (handle); -} - -int -ACE_Dev_Poll_Reactor::suspend_handler (ACE_HANDLE handle) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handler"); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - return this->suspend_handler_i (handle); -} - -int -ACE_Dev_Poll_Reactor::suspend_handler (const ACE_Handle_Set &handles) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handler"); - - ACE_Handle_Set_Iterator handle_iter (handles); - ACE_HANDLE h; - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - while ((h = handle_iter ()) != ACE_INVALID_HANDLE) - if (this->suspend_handler_i (h) == -1) - return -1; - - return 0; -} - -int -ACE_Dev_Poll_Reactor::suspend_handlers (void) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handlers"); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - size_t const len = this->handler_rep_.size (); - - for (size_t i = 0; i < len; ++i) - if (this->handler_rep_.suspended (i) == 0 - && this->suspend_handler_i (i) != 0) - return -1; - - return 0; -} - -int -ACE_Dev_Poll_Reactor::suspend_handler_i (ACE_HANDLE handle) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handler_i"); - - if (this->handler_rep_.find (handle) == 0) - return -1; - - if (this->handler_rep_.suspended (handle)) - return 0; // Already suspended. @@ Should this be an error? - - // Remove the handle from the "interest set." - // - // Note that the associated event handler is still in the handler - // repository, but no events will be polled on the given handle thus - // no event will be dispatched to the event handler. - -#if defined (ACE_HAS_EVENT_POLL) - - struct epoll_event epev; - ACE_OS::memset (&epev, 0, sizeof (epev)); - static const int op = EPOLL_CTL_DEL; - - epev.events = 0; - epev.data.fd = handle; - - if (::epoll_ctl (this->poll_fd_, op, handle, &epev) == -1) - return -1; - -#else - - struct pollfd pfd[1]; - - pfd[0].fd = handle; - pfd[0].events = POLLREMOVE; - pfd[0].revents = 0; - - if (ACE_OS::write (this->poll_fd_, pfd, sizeof (pfd)) != sizeof (pfd)) - return -1; - -#endif /* ACE_HAS_EVENT_POLL */ - - this->handler_rep_.suspend (handle); - - return 0; -} - -int -ACE_Dev_Poll_Reactor::resume_handler (ACE_Event_Handler *event_handler) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handler"); - - if (event_handler == 0) - { - errno = EINVAL; - return -1; - } - - ACE_HANDLE handle = event_handler->get_handle (); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - return this->resume_handler_i (handle); -} - -int -ACE_Dev_Poll_Reactor::resume_handler (ACE_HANDLE handle) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handler"); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - return this->resume_handler_i (handle); -} - -int -ACE_Dev_Poll_Reactor::resume_handler (const ACE_Handle_Set &handles) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handler"); - - ACE_Handle_Set_Iterator handle_iter (handles); - ACE_HANDLE h; - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - while ((h = handle_iter ()) != ACE_INVALID_HANDLE) - if (this->resume_handler_i (h) == -1) - return -1; - - return 0; -} - -int -ACE_Dev_Poll_Reactor::resume_handlers (void) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handlers"); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - size_t const len = this->handler_rep_.size (); - - for (size_t i = 0; i < len; ++i) - if (this->handler_rep_.suspended (i) - && this->resume_handler_i (i) != 0) - return -1; - - return 0; -} - -int -ACE_Dev_Poll_Reactor::resume_handler_i (ACE_HANDLE handle) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handler_i"); - - if (this->handler_rep_.find (handle) == 0 - && this->handler_rep_.suspended (handle) == 0) - return -1; - - ACE_Reactor_Mask mask = this->handler_rep_.mask (handle); - - if (mask == ACE_Event_Handler::NULL_MASK) - return -1; - - // Place the handle back in to the "interest set." - // - // Events for the given handle will once again be polled. - -#if defined (ACE_HAS_EVENT_POLL) - - struct epoll_event epev; - ACE_OS::memset (&epev, 0, sizeof (epev)); - static const int op = EPOLL_CTL_ADD; - - epev.events = this->reactor_mask_to_poll_event (mask); - epev.data.fd = handle; - - if (::epoll_ctl (this->poll_fd_, op, handle, &epev) == -1) - return -1; - -#else - - struct pollfd pfd[1]; - - pfd[0].fd = handle; - pfd[0].events = this->reactor_mask_to_poll_event (mask); - pfd[0].revents = 0; - - if (ACE_OS::write (this->poll_fd_, pfd, sizeof (pfd)) != sizeof (pfd)) - return -1; - -#endif /* ACE_HAS_EVENT_POLL */ - - this->handler_rep_.resume (handle); - - return 0; -} - -int -ACE_Dev_Poll_Reactor::resumable_handler (void) -{ - // @@ Is this correct? - - return 0; -} - -int -ACE_Dev_Poll_Reactor::uses_event_associations (void) -{ - // Since the Dev_Poll_Reactor does not do any event associations, - // this method always return zero. - return 0; -} - -long -ACE_Dev_Poll_Reactor::schedule_timer (ACE_Event_Handler *event_handler, - const void *arg, - const ACE_Time_Value &delay, - const ACE_Time_Value &interval) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::schedule_timer"); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - if (0 != this->timer_queue_) - return this->timer_queue_->schedule - (event_handler, - arg, - this->timer_queue_->gettimeofday () + delay, - interval); - - errno = ESHUTDOWN; - return -1; -} - -int -ACE_Dev_Poll_Reactor::reset_timer_interval (long timer_id, - const ACE_Time_Value &interval) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::reset_timer_interval"); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - if (0 != this->timer_queue_) - return this->timer_queue_->reset_interval (timer_id, interval); - - errno = ESHUTDOWN; - return -1; -} - -int -ACE_Dev_Poll_Reactor::cancel_timer (ACE_Event_Handler *event_handler, - int dont_call_handle_close) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::cancel_timer"); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - return (this->timer_queue_ == 0 - ? 0 - : this->timer_queue_->cancel (event_handler, - dont_call_handle_close)); -} - -int -ACE_Dev_Poll_Reactor::cancel_timer (long timer_id, - const void **arg, - int dont_call_handle_close) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::cancel_timer"); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - return (this->timer_queue_ == 0 - ? 0 - : this->timer_queue_->cancel (timer_id, - arg, - dont_call_handle_close)); -} - -int -ACE_Dev_Poll_Reactor::schedule_wakeup (ACE_Event_Handler *eh, - ACE_Reactor_Mask mask) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::schedule_wakeup"); - - return this->mask_ops (eh->get_handle (), mask, ACE_Reactor::ADD_MASK); -} - -int -ACE_Dev_Poll_Reactor::schedule_wakeup (ACE_HANDLE handle, - ACE_Reactor_Mask mask) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::schedule_wakeup"); - - return this->mask_ops (handle, mask, ACE_Reactor::ADD_MASK); -} - -int -ACE_Dev_Poll_Reactor::cancel_wakeup (ACE_Event_Handler *eh, - ACE_Reactor_Mask mask) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::cancel_wakeup"); - - return this->mask_ops (eh->get_handle (), mask, ACE_Reactor::CLR_MASK); -} - -int -ACE_Dev_Poll_Reactor::cancel_wakeup (ACE_HANDLE handle, - ACE_Reactor_Mask mask) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::cancel_wakeup"); - - return this->mask_ops (handle, mask, ACE_Reactor::CLR_MASK); -} - -int -ACE_Dev_Poll_Reactor::notify (ACE_Event_Handler *eh, - ACE_Reactor_Mask mask, - ACE_Time_Value *timeout) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::notify"); - - ssize_t n = 0; - - // Pass over both the Event_Handler *and* the mask to allow the - // caller to dictate which Event_Handler method the receiver - // invokes. Note that this call can timeout. - - n = this->notify_handler_->notify (eh, mask, timeout); - - return n == -1 ? -1 : 0; -} - -void -ACE_Dev_Poll_Reactor::max_notify_iterations (int iterations) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::max_notify_iterations"); - - ACE_MT (ACE_GUARD (ACE_Dev_Poll_Reactor_Token, mon, this->token_)); - - this->notify_handler_->max_notify_iterations (iterations); -} - -int -ACE_Dev_Poll_Reactor::max_notify_iterations (void) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::max_notify_iterations"); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - return this->notify_handler_->max_notify_iterations (); -} - -int -ACE_Dev_Poll_Reactor::purge_pending_notifications (ACE_Event_Handler * eh, - ACE_Reactor_Mask mask) -{ - if (this->notify_handler_ == 0) - return 0; - - return this->notify_handler_->purge_pending_notifications (eh, mask); -} - -ACE_Event_Handler * -ACE_Dev_Poll_Reactor::find_handler (ACE_HANDLE handle) -{ - ACE_MT (ACE_READ_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, 0)); - - ACE_Event_Handler *event_handler = this->handler_rep_.find (handle); - if (event_handler) - event_handler->add_reference (); - return event_handler; -} - -int -ACE_Dev_Poll_Reactor::handler (ACE_HANDLE handle, - ACE_Reactor_Mask mask, - ACE_Event_Handler **event_handler) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::handler"); - - ACE_MT (ACE_READ_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - ACE_Event_Handler *h = this->handler_rep_.find (handle); - - if (h != 0 - && ACE_BIT_CMP_MASK (this->handler_rep_.mask (handle), - mask, // Compare all bits in the mask - mask)) - { - if (event_handler != 0) - *event_handler = h; - - return 0; - } - - return -1; -} - -int -ACE_Dev_Poll_Reactor::handler (int signum, - ACE_Event_Handler **eh) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::handler"); - - ACE_Event_Handler *handler = this->signal_handler_->handler (signum); - - if (handler == 0) - return -1; - else if (eh != 0) - *eh = handler; - - return 0; -} - -bool -ACE_Dev_Poll_Reactor::initialized (void) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::initialized"); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, false)); - - return this->initialized_; -} - -size_t -ACE_Dev_Poll_Reactor::size (void) const -{ - return this->size_; -} - -ACE_Lock & -ACE_Dev_Poll_Reactor::lock (void) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::lock"); - - return this->lock_adapter_; -} - -void -ACE_Dev_Poll_Reactor::wakeup_all_threads (void) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::wakeup_all_threads"); - - // Send a notification, but don't block if there's no one to receive - // it. - this->notify (0, - ACE_Event_Handler::NULL_MASK, - (ACE_Time_Value *) &ACE_Time_Value::zero); -} - -int -ACE_Dev_Poll_Reactor::owner (ACE_thread_t /* new_owner */, - ACE_thread_t * /* old_owner */) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::owner"); - - // There is no need to set the owner of the event loop. Multiple - // threads may invoke the event loop simulataneously. - - return 0; -} - -int -ACE_Dev_Poll_Reactor::owner (ACE_thread_t * /* owner */) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::owner"); - - // There is no need to set the owner of the event loop. Multiple - // threads may invoke the event loop simulataneously. - - return 0; -} - -int -ACE_Dev_Poll_Reactor::restart (void) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::restart"); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - return this->restart_; -} - -int -ACE_Dev_Poll_Reactor::restart (int r) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::restart"); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - int current_value = this->restart_; - this->restart_ = r; - return current_value; -} - -void -ACE_Dev_Poll_Reactor::requeue_position (int) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::requeue_position"); -} - -int -ACE_Dev_Poll_Reactor::requeue_position (void) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::requeue_position"); - - ACE_NOTSUP_RETURN (-1); -} - -int -ACE_Dev_Poll_Reactor::mask_ops (ACE_Event_Handler *event_handler, - ACE_Reactor_Mask mask, - int ops) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::mask_ops"); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - return this->mask_ops_i (event_handler->get_handle (), mask, ops); -} - -int -ACE_Dev_Poll_Reactor::mask_ops (ACE_HANDLE handle, - ACE_Reactor_Mask mask, - int ops) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::mask_ops"); - - ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); - - return this->mask_ops_i (handle, mask, ops); -} - -int -ACE_Dev_Poll_Reactor::mask_ops_i (ACE_HANDLE handle, - ACE_Reactor_Mask mask, - int ops) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::mask_ops_i"); - - if (this->handler_rep_.handle_in_range (handle) == 0) - return -1; - - // Block out all signals until method returns. - ACE_Sig_Guard sb; - - ACE_Reactor_Mask const old_mask = this->handler_rep_.mask (handle); - ACE_Reactor_Mask new_mask = old_mask; - - // Perform GET, CLR, SET, and ADD operations on the interest/wait - // set and the suspend set (if necessary). - // - // GET = 1, Retrieve current value - // SET = 2, Set value of bits to new mask (changes the entire mask) - // ADD = 3, Bitwise "or" the value into the mask (only changes - // enabled bits) - // CLR = 4 Bitwise "and" the negation of the value out of the mask - // (only changes enabled bits) - // - // Returns the original mask. - - switch (ops) - { - case ACE_Reactor::GET_MASK: - // The work for this operation is done in all cases at the - // begining of the function. - return old_mask; - - case ACE_Reactor::CLR_MASK: - ACE_CLR_BITS (new_mask, mask); - break; - - case ACE_Reactor::SET_MASK: - new_mask = mask; - break; - - case ACE_Reactor::ADD_MASK: - ACE_SET_BITS (new_mask, mask); - break; - - default: - return -1; - } - - /// Reset the mask for the given handle. - this->handler_rep_.mask (handle, new_mask); - - if (this->handler_rep_.suspended (handle) == 0) - { - // Only attempt to alter events for the handle from the - // "interest set" if it hasn't been suspended. - - short const events = this->reactor_mask_to_poll_event (new_mask); - -#if defined (sun) - // Apparently events cannot be updated on-the-fly on Solaris so - // remove the existing events, and then add the new ones. - struct pollfd pfd[2]; - - pfd[0].fd = handle; - pfd[0].events = POLLREMOVE; - pfd[0].revents = 0; - pfd[1].fd = (events == POLLREMOVE ? ACE_INVALID_HANDLE : handle); - pfd[1].events = events; - pfd[1].revents = 0; - - // Change the events associated with the given file descriptor. - if (ACE_OS::write (this->poll_fd_, - pfd, - sizeof (pfd)) != sizeof (pfd)) - return -1; -#elif defined (ACE_HAS_EVENT_POLL) - - struct epoll_event epev; - ACE_OS::memset (&epev, 0, sizeof (epev)); - int op; - - // ACE_Event_Handler::NULL_MASK ??? - if (new_mask == 0) - { - op = EPOLL_CTL_DEL; - epev.events = 0; - } - else - { - op = EPOLL_CTL_MOD; - epev.events = events; - } - - epev.data.fd = handle; - - if (::epoll_ctl (this->poll_fd_, op, handle, &epev) == -1) - { - // If a handle is closed, epoll removes it from the poll set - // automatically - we may not know about it yet. If that's the - // case, a mod operation will fail with ENOENT. Retry it as - // an add. - if (op == EPOLL_CTL_MOD && errno == ENOENT && - ::epoll_ctl (this->poll_fd_, EPOLL_CTL_ADD, handle, &epev) == -1) - return -1; - } - -#else - pollfd pfd[1]; - - pfd[0].fd = handle; - pfd[0].events = events; - pfd[0].revents = 0; - - // Change the events associated with the given file descriptor. - if (ACE_OS::write (this->poll_fd_, - pfd, - sizeof (pfd)) != sizeof (pfd)) - return -1; -#endif /*ACE_HAS_EVENT_POLL */ - } - - return old_mask; -} - -int -ACE_Dev_Poll_Reactor::ready_ops (ACE_Event_Handler * /* event_handler */, - ACE_Reactor_Mask /* mask */, - int /* ops */) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::ready_ops"); - - // Since the Dev_Poll_Reactor uses the poll result buffer, the - // ready_set cannot be directly manipulated outside of the event - // loop. - ACE_NOTSUP_RETURN (-1); -} - -int -ACE_Dev_Poll_Reactor::ready_ops (ACE_HANDLE /* handle */, - ACE_Reactor_Mask /* mask */, - int /* ops */) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::ready_ops"); - - // Since the Dev_Poll_Reactor uses the poll result buffer, the - // ready_set cannot be directly manipulated outside of the event - // loop. - ACE_NOTSUP_RETURN (-1); -} - -void -ACE_Dev_Poll_Reactor::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Dev_Poll_Reactor::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("restart_ = %d\n"), this->restart_)); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("initialized_ = %d"), - this->initialized_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("poll_fd_ = %d"), this->poll_fd_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("size_ = %u"), this->size_)); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("deactivated_ = %d"), - this->deactivated_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -short -ACE_Dev_Poll_Reactor::reactor_mask_to_poll_event (ACE_Reactor_Mask mask) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::reactor_mask_to_poll_event"); - - if (mask == ACE_Event_Handler::NULL_MASK) - // No event. Remove from interest set. -#if defined (ACE_HAS_EVENT_POLL) - return EPOLL_CTL_DEL; -#else - return POLLREMOVE; -#endif /* ACE_HAS_EVENT_POLL */ - - short events = 0; - - // READ, ACCEPT, and CONNECT flag will place the handle in the - // read set. - if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK) - || ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK) - || ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)) - { -#if defined (ACE_HAS_EVENT_POLL) - ACE_SET_BITS (events, EPOLLIN); -#else - ACE_SET_BITS (events, POLLIN); -#endif /*ACE_HAS_EVENT_POLL*/ - } - - // WRITE and CONNECT flag will place the handle in the write set. - if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK) - || ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)) - { -#if defined (ACE_HAS_EVENT_POLL) - ACE_SET_BITS (events, EPOLLOUT); -#else - ACE_SET_BITS (events, POLLOUT); -#endif /*ACE_HAS_EVENT_POLL*/ - } - - // EXCEPT flag will place the handle in the except set. - if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK)) - { -#if defined (ACE_HAS_EVENT_POLL) - ACE_SET_BITS (events, EPOLLPRI); -#else - ACE_SET_BITS (events, POLLPRI); -#endif /*ACE_HAS_EVENT_POLL*/ - } - - return events; -} - -namespace { - void polite_sleep_hook (void *) { } -} - -int -ACE_Dev_Poll_Reactor::Token_Guard::acquire_quietly (ACE_Time_Value *max_wait) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::Token_Guard::acquire_quietly"); - - // Acquire the token but don't ping any waiters; just queue up politely. - int result = 0; - if (max_wait) - { - ACE_Time_Value tv = ACE_OS::gettimeofday (); - tv += *max_wait; - - ACE_MT (result = this->token_.acquire_read (&polite_sleep_hook, - 0, - &tv)); - } - else - { - ACE_MT (result = this->token_.acquire_read (&polite_sleep_hook)); - } - - // Check for timeouts and errors. - if (result == -1) - { - if (errno == ETIME) - return 0; - else - { - ACE_ERROR ((LM_ERROR, "%t: %p\n", "token acquire_read")); - return -1; - } - } - - // We got the token and so let us mark ourselves as owner - this->owner_ = 1; - - return result; -} - -int -ACE_Dev_Poll_Reactor::Token_Guard::acquire (ACE_Time_Value *max_wait) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor::Token_Guard::acquire"); - - // Try to grab the token. If someone if already there, don't wake - // them up, just queue up in the thread pool. - int result = 0; - if (max_wait) - { - ACE_Time_Value tv = ACE_OS::gettimeofday (); - tv += *max_wait; - - ACE_MT (result = this->token_.acquire (0, 0, &tv)); - } - else - { - ACE_MT (result = this->token_.acquire ()); - } - - // Check for timeouts and errors. - if (result == -1) - { - if (errno == ETIME) - return 0; - else - return -1; - } - - // We got the token and so let us mark ourseleves as owner - this->owner_ = 1; - - return result; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_EVENT_POLL || ACE_HAS_DEV_POLL */ diff --git a/ACE/ace/Dev_Poll_Reactor.h b/ACE/ace/Dev_Poll_Reactor.h deleted file mode 100644 index b6af574ae3e..00000000000 --- a/ACE/ace/Dev_Poll_Reactor.h +++ /dev/null @@ -1,1252 +0,0 @@ -// -*- C++ -*- - -// ========================================================================= -/** - * @file Dev_Poll_Reactor.h - * - * $Id$ - * - * @c /dev/poll (or Linux @c sys_epoll) based Reactor implementation. - * - * @author Ossama Othman - */ -// ========================================================================= - - -#ifndef ACE_DEV_POLL_REACTOR_H -#define ACE_DEV_POLL_REACTOR_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_EVENT_POLL) && defined (ACE_HAS_DEV_POLL) -# error ACE_HAS_EVENT_POLL and ACE_HAS_DEV_POLL are mutually exclusive. -#endif /* ACE_HAS_EVENT_POLL && defined ACE_HAS_DEV_POLL */ - -#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL) - -#include "ace/Pipe.h" -#include "ace/Lock_Adapter_T.h" -#include "ace/Reactor_Impl.h" -#include "ace/Reactor_Token_T.h" -#include "ace/Token.h" - -#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) -# include "ace/Notification_Queue.h" -#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */ - -#if defined (ACE_HAS_DEV_POLL) -struct pollfd; -#elif defined (ACE_HAS_EVENT_POLL) -struct epoll_event; -#endif - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Forward declarations -class ACE_Sig_Handler; -class ACE_Dev_Poll_Reactor; - -/** - * @class ACE_Dev_Poll_Event_Tuple - * - * @brief Class that associates specific event mask with a given event - * handler. - * - * This class merely provides a means to associate an event mask - * with an event handler. Such an association is needed since it is - * not possible to retrieve the event mask from the "interest set" - * stored in the `/dev/poll' or `/dev/epoll' driver. Without this - * external association, it would not be possible keep track of the - * event mask for a given event handler when suspending it or resuming - * it. - * - * @note An ACE_Handle_Set is not used since the number of handles may - * exceed its capacity (ACE_DEFAULT_SELECT_REACTOR_SIZE). - */ -class ACE_Dev_Poll_Event_Tuple -{ -public: - - /// Constructor. - ACE_Dev_Poll_Event_Tuple (void); - -public: - - /// The event handler. - ACE_Event_Handler *event_handler; - - /// The event mask for the above event handler. - ACE_Reactor_Mask mask; - - /// Flag that states whether or not the event handler is suspended. - char suspended; -}; - -// --------------------------------------------------------------------- - -#if 0 -/** - * @class ACE_Dev_Poll_Ready_Set - * - * @brief Class that contains the list of "ready" file descriptors. - * - * This class points to an array of pollfd structures corresponding to - * "ready" file descriptors, such as those corresponding to event - * handlers that request an additional callback after being initially - * dispatched (i.e. return a value greater than zero). - * @par - * The idea is to store the "ready" set in an existing area of memory - * that already contains pollfd instances. Doing so is safe since the - * "ready" set is dispatched before polling for additional events, - * thus avoiding being potentially overwritten during the event poll. - * @par - * When the "ready" set is dispatched, all that needs to be done is to - * iterate over the contents of the array. There is no need to "walk" - * the array in search of ready file descriptors since the array by - * design only contains ready file descriptors. As such, this - * implementation of a ready set is much more efficient in the - * presence of a large number of file descriptors in terms of both - * time and space than the one used in the Select_Reactor, for - * example. - */ -class ACE_Dev_Poll_Ready_Set -{ -public: - - /// Constructor. - ACE_Dev_Poll_Ready_Set (void); - -public: - - /// The array containing the pollfd structures corresponding to the - /// "ready" file descriptors. - struct pollfd *pfds; - - /// The number of "ready" file descriptors in the above array. - int nfds; - -}; -#endif /* 0 */ - -// --------------------------------------------------------------------- - -/** - * @class ACE_Dev_Poll_Reactor_Notify - * - * @brief Event handler used for unblocking the ACE_Dev_Poll_Reactor - * from its event loop. - * - * This event handler is used internally by the ACE_Dev_Poll_Reactor - * as a means to allow a thread other then the one running the event - * loop to unblock the event loop. - */ -class ACE_Dev_Poll_Reactor_Notify : public ACE_Reactor_Notify -{ -public: - - /// Constructor - ACE_Dev_Poll_Reactor_Notify (void); - - /** - * @name Initialization and Termination Methods - * - * Methods called when initializing and terminating this event - * handler. - */ - virtual int open (ACE_Reactor_Impl *, - ACE_Timer_Queue *timer_queue = 0, - int disable_notify = 0); - virtual int close (void); - - /** - * Called by a thread when it wants to unblock the Reactor_Impl. - * This wakes up the Reactor_Impl if currently blocked. Pass over - * both the Event_Handler and the mask to allow the caller to - * dictate which Event_Handler method the Reactor_Impl will - * invoke. The ACE_Time_Value indicates how long to block - * trying to notify the Reactor_Impl. If timeout == 0, the - * caller will block until action is possible, else will wait until - * the relative time specified in *timeout elapses). - */ - virtual int notify (ACE_Event_Handler *eh = 0, - ACE_Reactor_Mask mask = ACE_Event_Handler::EXCEPT_MASK, - ACE_Time_Value *timeout = 0); - - /// Unimplemented method required by pure virtual method in abstract - /// base class. - /** - * This method's interface is not very compatibile with this - * Reactor's design. It's not clear why this method is pure virtual - * either. - */ - virtual int dispatch_notifications (int &number_of_active_handles, - ACE_Handle_Set &rd_mask); - - /// Returns the ACE_HANDLE of the notify pipe on which the reactor - /// is listening for notifications so that other threads can unblock - /// the Reactor_Impl. - virtual ACE_HANDLE notify_handle (void); - - /// Verify whether the buffer has dispatchable info or not. - virtual int is_dispatchable (ACE_Notification_Buffer &buffer); - - /// Handle one notify call represented in @a buffer. This could be - /// because of a thread trying to unblock the Reactor_Impl. - virtual int dispatch_notify (ACE_Notification_Buffer &buffer); - - /// Read one notify call on the handle into @a buffer. - /// This could be because of a thread trying to unblock the Reactor_Impl. - virtual int read_notify_pipe (ACE_HANDLE handle, - ACE_Notification_Buffer &buffer); - - /// Called back by the ACE_Dev_Poll_Reactor when a thread wants to - /// unblock us. - virtual int handle_input (ACE_HANDLE handle); - - /** - * Set the maximum number of times that the handle_input method - * will iterate and dispatch the ACE_Event_Handlers that are - * passed in via the notify queue before breaking out of the event - * loop. By default, this is set to -1, which means "iterate until - * the queue is empty." Setting this to a value like "1 or 2" will - * increase "fairness" (and thus prevent starvation) at the expense - * of slightly higher dispatching overhead. - */ - virtual void max_notify_iterations (int); - - /** - * Get the maximum number of times that the handle_input method - * will iterate and dispatch the ACE_Event_Handlers that are - * passed in via the notify queue before breaking out of its event - * loop. - */ - virtual int max_notify_iterations (void); - - /** - * Purge any notifications pending in this reactor for the specified - * ACE_Event_Handler object. Returns the number of notifications - * purged. Returns -1 on error. - */ - virtual int purge_pending_notifications ( - ACE_Event_Handler * = 0, - ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK); - - /// Dump the state of an object. - virtual void dump (void) const; - -protected: - - /** - * Keep a back pointer to the ACE_Dev_Poll_Reactor. If this value - * if NULL then the ACE_Dev_Poll_Reactor has been initialized with - * disable_notify_pipe. - */ - ACE_Dev_Poll_Reactor *dp_reactor_; - - /** - * Contains the ACE_HANDLE the ACE_Dev_Poll_Reactor is listening - * on, as well as the ACE_HANDLE that threads wanting the attention - * of the ACE_Dev_Poll_Reactor will write to. - */ - ACE_Pipe notification_pipe_; - - /** - * Keeps track of the maximum number of times that the - * ACE_Dev_Poll_Reactor_Notify::handle_input method will iterate and - * dispatch the ACE_Event_Handlers that are passed in via the - * notify pipe before breaking out of its recv loop. By default, - * this is set to -1, which means "iterate until the pipe is empty." - */ - int max_notify_iterations_; - -#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) - /** - * @brief A user-space queue to store the notifications. - * - * The notification pipe has OS-specific size restrictions. That - * is, no more than a certain number of bytes may be stored in the - * pipe without blocking. This limit may be too small for certain - * applications. In this case, ACE can be configured to store all - * the events in user-space. The pipe is still needed to wake up - * the reactor thread, but only one event is sent through the pipe - * at a time. - */ - ACE_Notification_Queue notification_queue_; -#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */ - -}; - -// --------------------------------------------------------------------- - -/** - * @class ACE_Dev_Poll_Reactor_Handler_Repository - * - * @internal - - * @brief Used to map ACE_HANDLEs onto the appropriate - * ACE_Event_Handler *. - * - * - * This class is simply a container that maps a handle to its - * corresponding event handler. It is not meant for use outside of - * the Dev_Poll_Reactor. - */ -class ACE_Dev_Poll_Reactor_Handler_Repository -{ -public: - - /// Constructor. - ACE_Dev_Poll_Reactor_Handler_Repository (void); - - /// Initialize a repository of the appropriate @a size. - int open (size_t size); - - /// Close down the repository. - int close (void); - - /** - * @name Repository Manipulation Operations - * - * Methods used to search and modify the handler repository. - */ - //@{ - - /** - * Return the @c ACE_Event_Handler associated with @c ACE_HANDLE. If - * @a index_p is non-zero, then return the index location of the - * handle, if found. - */ - ACE_Event_Handler *find (ACE_HANDLE handle, size_t *index_p = 0); - - /// Set the event mask for event handler associated with the given - /// handle. - void mask (ACE_HANDLE handle, ACE_Reactor_Mask mask); - - /// Retrieve the event mask for the event handler associated with - /// the given handle. - ACE_Reactor_Mask mask (ACE_HANDLE handle); - - /// Mark the event handler associated with the given handle as - /// "suspended." - void suspend (ACE_HANDLE handle); - - /// Mark the event handler associated with the given handle as - /// "resumed." - void resume (ACE_HANDLE handle); - - /// Is the event handler for the given handle suspended? - int suspended (ACE_HANDLE handle) const; - - /// Bind the ACE_Event_Handler to the @c ACE_HANDLE with the - /// appropriate ACE_Reactor_Mask settings. - int bind (ACE_HANDLE handle, - ACE_Event_Handler *handler, - ACE_Reactor_Mask mask); - - /// Remove the binding for @c ACE_HANDLE; optionally decrement the associated - /// handler's reference count. - int unbind (ACE_HANDLE handle, bool decr_refcnt = true); - - /// Remove all the (@c ACE_HANDLE, @c ACE_Event_Handler) tuples. - int unbind_all (void); - - /** - * @name Sanity Checking - * - * Methods used to prevent "out-of-range" errors when indexing the - * underlying handler array. - */ - //@{ - - // Check the @a handle to make sure it's a valid @c ACE_HANDLE that - // within the range of legal handles (i.e., greater than or equal to - // zero and less than @c max_size_). - int invalid_handle (ACE_HANDLE handle) const; - - // Check the handle to make sure it's a valid @c ACE_HANDLE that is - // within the range of currently registered handles (i.e., greater - // than or equal to zero and less than @c max_handlep1_). - int handle_in_range (ACE_HANDLE handle) const; - - //@} - - /// Returns the current table size. - size_t size (void) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - - /// Maximum number of handles. - int max_size_; - - /// The underlying array of event handlers. - /** - * The array of event handlers is directly indexed directly using - * an @c ACE_HANDLE value. This is Unix-specific. - */ - ACE_Dev_Poll_Event_Tuple *handlers_; - -}; - -// --------------------------------------------------------------------- - -/** - * @class ACE_Dev_Poll_Reactor - * - * @brief A `/dev/poll' or `/dev/epoll' based Reactor implemenatation. - * - * @attention The Linux epoll implementation works quite well and is - * fully supported; however, the /dev/poll implementation is @em experimental. - * - * The ACE_Dev_Poll_Reactor uses the `/dev/poll' or '/dev/epoll' - * character devices to demultiplex events on a given set of file - * descriptors. Unlike @c select(), `/dev/poll' and `/dev/epoll' have - * no hard-coded limit on the number of file descriptors that may be - * handled at any given time. As such, the ACE_Dev_Poll_Reactor can - * generally handle a much larger number of file descriptors than - * @c select() -based reactors. Furthermore, since `/dev/poll' and - * `/dev/epoll' both return a set of file descriptors that are active, - * there is no need to "walk" the set of file descriptors to determine - * which ones are active, such as what is done with the @c select() and - * @c poll() system calls. All returned file descriptors are active. - * This makes event dispatching very efficient. - * - * @note In general, this reactor may only be used to demultiplex - * events on sockets. Demultiplexing events on pipes, for - * example may not work. This is due to a limitation in the - * underlying `/dev/poll' device driver. - * - * @note It is only possible to achieve millisecond timeout - * resolutions with the @c ACE_Dev_Poll_Reactor. However, the - * timeout resolution for timers is independent of the reactors - * timeout resolution. As such, it may be possible to achieve - * sub-millisecond timeout resolutions for timers but that is - * entirely platform dependent. - */ - -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) -typedef ACE_Token ACE_DEV_POLL_TOKEN; -#else -typedef ACE_Noop_Token ACE_DEV_POLL_TOKEN; -#endif /* ACE_MT_SAFE && ACE_MT_SAFE != 0 */ -typedef ACE_Reactor_Token_T ACE_Dev_Poll_Reactor_Token; - -class ACE_Export ACE_Dev_Poll_Reactor : public ACE_Reactor_Impl -{ -public: - - /// Initialize @c ACE_Dev_Poll_Reactor with the default size. - /** - * The default size for the @c ACE_Dev_Poll_Reactor is the maximum - * number of open file descriptors for the process. - */ - ACE_Dev_Poll_Reactor (ACE_Sig_Handler * = 0, - ACE_Timer_Queue * = 0, - int disable_notify_pipe = 0, - ACE_Reactor_Notify *notify = 0, - int mask_signals = 1, - int s_queue = ACE_DEV_POLL_TOKEN::FIFO); - - /// Initialize ACE_Dev_Poll_Reactor with size @a size. - /** - * @note On Unix platforms, the @a size parameter should be as large - * as the maximum number of file descriptors allowed for a - * given process. This is necessary since a file descriptor - * is used to directly index the array of event handlers - * maintained by the Reactor's handler repository. Direct - * indexing is used for efficiency reasons. If the size - * parameter is less than the process maximum, the process - * maximum will be decreased in order to prevent potential - * access violations. - */ - ACE_Dev_Poll_Reactor (size_t size, - int restart = 0, - ACE_Sig_Handler * = 0, - ACE_Timer_Queue * = 0, - int disable_notify_pipe = 0, - ACE_Reactor_Notify *notify = 0, - int mask_signals = 1, - int s_queue = ACE_DEV_POLL_TOKEN::FIFO); - - /// Close down and release all resources. - virtual ~ACE_Dev_Poll_Reactor (void); - - /// Initialization. - virtual int open (size_t size, - int restart = 0, - ACE_Sig_Handler * = 0, - ACE_Timer_Queue * = 0, - int disable_notify_pipe = 0, - ACE_Reactor_Notify * = 0); - - /** - * @param handle allows the reactor to check if the caller is - * valid. - * - * @return 0 if the size of the current message has been put in - * size. -1 if not. - */ - virtual int current_info (ACE_HANDLE handle, size_t & /* size */); - - /// Use a user specified signal handler instead. - virtual int set_sig_handler (ACE_Sig_Handler *signal_handler); - - /// Set a user-specified timer queue. - virtual int timer_queue (ACE_Timer_Queue *tq); - - /// Get the timer queue - /// @return The current @c ACE_Timer_Queue. - virtual ACE_Timer_Queue *timer_queue (void) const; - - /// Close down and release all resources. - virtual int close (void); - - // = Event loop drivers. - /** - * Returns non-zero if there are I/O events "ready" for dispatching, - * but does not actually dispatch the event handlers. By default, - * don't block while checking this, i.e., "poll". - * - * @note It is only possible to achieve millisecond timeout - * resolutions with the @c ACE_Dev_Poll_Reactor. - */ - virtual int work_pending ( - const ACE_Time_Value &max_wait_time = ACE_Time_Value::zero); - - /** - * This event loop driver blocks for up to @a max_wait_time before - * returning. It will return earlier if events occur. Note that - * @a max_wait_time can be 0, in which case this method blocks - * indefinitely until events occur. - * @par - * @a max_wait_time is decremented to reflect how much time this - * call took. For instance, if a time value of 3 seconds is passed - * to @c handle_events() and an event occurs after 2 seconds, - * @a max_wait_time will equal 1 second. This can be used if an - * application wishes to handle events for some fixed amount of - * time. - * @par - * The only difference between @c alertable_handle_events() and - * handle_events() is that in the alertable case, the event loop - * will return when the system queues an I/O completion routine or - * an Asynchronous Procedure Call. - * - * @return The total number of @c ACE_Event_Handlers that were - * dispatched, 0 if the @a max_wait_time elapsed without - * dispatching any handlers, or -1 if an error occurs. - - * @note It is only possible to achieve millisecond timeout - * resolutions with the @c ACE_Dev_Poll_Reactor. - */ - virtual int handle_events (ACE_Time_Value *max_wait_time = 0); - virtual int alertable_handle_events (ACE_Time_Value *max_wait_time = 0); - - /** - * This method is just like the one above, except the - * @a max_wait_time value is a reference and can therefore never be - * @c NULL. - * - * @note It is only possible to achieve millisecond timeout - * resolutions with the @c ACE_Dev_Poll_Reactor. - */ - virtual int handle_events (ACE_Time_Value &max_wait_time); - virtual int alertable_handle_events (ACE_Time_Value &max_wait_time); - - // = Event handling control. - - /** - * @return The status of Reactor. If this function returns 0, the - * reactor is actively handling events. If it returns - * non-zero, @c handle_events() and - * @c handle_alertable_events() return -1 immediately. - */ - virtual int deactivated (void); - - /** - * Control whether the Reactor will handle any more incoming events - * or not. If @a do_stop == 1, the Reactor will be disabled. By - * default, a reactor is in active state and can be - * deactivated/reactived as desired. - */ - virtual void deactivate (int do_stop); - - // = Register and remove Handlers. - - /// Register @a event_handler with @a mask. The I/O handle will - /// always come from get_handle on the event_handler. - virtual int register_handler (ACE_Event_Handler *event_handler, - ACE_Reactor_Mask mask); - - /// Register @a event_handler with @a mask. The I/O handle is - /// provided through the @a io_handle parameter. - virtual int register_handler (ACE_HANDLE io_handle, - ACE_Event_Handler *event_handler, - ACE_Reactor_Mask mask); - - /** - * Register an @a event_handler that will be notified when - * @a event_handle is signaled. @a mask specifies the network - * events that the @a event_handler is interested in. - */ - virtual int register_handler (ACE_HANDLE event_handle, - ACE_HANDLE io_handle, - ACE_Event_Handler *event_handler, - ACE_Reactor_Mask mask); - - /// Register @a event_handler> with all the @a handles> in the @c - /// Handle_Set. - virtual int register_handler (const ACE_Handle_Set &handles, - ACE_Event_Handler *event_handler, - ACE_Reactor_Mask mask); - - /** - * Register @a new_sh to handle the signal @a signum using the - * @a new_disp. Returns the @a old_sh that was previously - * registered (if any), along with the @a old_disp of the signal - * handler. - */ - virtual int register_handler (int signum, - ACE_Event_Handler *new_sh, - ACE_Sig_Action *new_disp = 0, - ACE_Event_Handler **old_sh = 0, - ACE_Sig_Action *old_disp = 0); - - /// Registers to handle a set of signals using the - /// . - virtual int register_handler (const ACE_Sig_Set &sigset, - ACE_Event_Handler *new_sh, - ACE_Sig_Action *new_disp = 0); - - /// Removes @a event_handler. - /** - * @note The I/O handle will be obtained using @c get_handle() - * method of @a event_handler . If @a mask == - * @c ACE_Event_Handler::DONT_CALL then the @c handle_close() - * method of the @a event_handler is not invoked. - */ - virtual int remove_handler (ACE_Event_Handler *event_handler, - ACE_Reactor_Mask mask); - - /** - * Removes @a handle. If @a mask == ACE_Event_Handler::DONT_CALL - * then the method of the associated - * is not invoked. - */ - virtual int remove_handler (ACE_HANDLE handle, - ACE_Reactor_Mask mask); - - /** - * Removes all handles in . If @a mask == - * ACE_Event_Handler::DONT_CALL then the method of - * the associated s is not invoked. - */ - virtual int remove_handler (const ACE_Handle_Set &handle_set, - ACE_Reactor_Mask mask); - - /** - * Remove the ACE_Event_Handler currently associated with @a signum. - * Install the new disposition (if given) and return the previous - * disposition (if desired by the caller). Returns 0 on success and - * -1 if @a signum is invalid. - */ - virtual int remove_handler (int signum, - ACE_Sig_Action *new_disp, - ACE_Sig_Action *old_disp = 0, - int sigkey = -1); - - /// Calls for every signal in . - virtual int remove_handler (const ACE_Sig_Set &sigset); - - // = Suspend and resume Handlers. - - /// Suspend event_handler temporarily. Use - /// ACE_Event_Handler::get_handle() to get the handle. - virtual int suspend_handler (ACE_Event_Handler *event_handler); - - /// Suspend handle temporarily. - virtual int suspend_handler (ACE_HANDLE handle); - - /// Suspend all handles in handle set temporarily. - virtual int suspend_handler (const ACE_Handle_Set &handles); - - /// Suspend all handles temporarily. - virtual int suspend_handlers (void); - - /// Resume event_handler. Use ACE_Event_Handler::get_handle() to - /// get the handle. - virtual int resume_handler (ACE_Event_Handler *event_handler); - - /// Resume handle. - virtual int resume_handler (ACE_HANDLE handle); - - /// Resume all handles in handle set. - virtual int resume_handler (const ACE_Handle_Set &handles); - - /// Resume all handles. - virtual int resume_handlers (void); - - /// Does the reactor allow the application to resume the handle on - /// its own, i.e., can it pass on the control of handle resumption to - /// the application. - virtual int resumable_handler (void); - - /// Return 1 if we any event associations were made by the reactor - /// for the handles that it waits on, 0 otherwise. - virtual int uses_event_associations (void); - - // = Timer management. - - /** - * Schedule an ACE_Event_Handler that will expire after an amount - * of time. The return value of this method, a timer_id value, - * uniquely identifies the event_handler in the ACE_Reactor's - * internal list of timers. - * This timer_id value can be used to cancel the timer - * with the cancel_timer() call. - * - * @see cancel_timer() - * @see reset_timer_interval() - * - * @param event_handler event handler to schedule on reactor - * @param arg argument passed to the handle_timeout() method of - * event_handler. - * @param delay time interval after which the timer will expire. - * @param interval time interval for which the timer will be - * automatically rescheduled. - * @return -1 on failure, a timer_id value on success - */ - virtual long schedule_timer (ACE_Event_Handler *event_handler, - const void *arg, - const ACE_Time_Value &delay, - const ACE_Time_Value &interval = ACE_Time_Value::zero); - - /** - * Resets the interval of the timer represented by @a timer_id to - * @a interval, which is specified in relative time to the current - * . If @a interval is equal to - * ACE_Time_Value::zero, the timer will become a non-rescheduling - * timer. Returns 0 if successful, -1 if not. - */ - virtual int reset_timer_interval (long timer_id, - const ACE_Time_Value &interval); - - /// Cancel all Event_Handlers that match the address of - /// @a event_handler. Returns number of handlers cancelled. - virtual int cancel_timer (ACE_Event_Handler *event_handler, - int dont_call_handle_close = 1); - - /** - * Cancel the single event handler that matches the @a timer_id value - * (which was returned from the schedule method). If @a arg is - * non-NULL then it will be set to point to the ``magic cookie'' - * argument passed in when the event handler was registered. This - * makes it possible to free up the memory and avoid memory leaks. - * Returns 1 if cancellation succeeded and 0 if the @a timer_id - * wasn't found. - */ - virtual int cancel_timer (long timer_id, - const void **arg = 0, - int dont_call_handle_close = 1); - - // = High-level event handler scheduling operations - - /// Add @a masks_to_be_added to the @a event_handler's entry. - /// @a event_handler must already have been registered. - virtual int schedule_wakeup (ACE_Event_Handler *event_handler, - ACE_Reactor_Mask masks_to_be_added); - - /// Add @a masks_to_be_added to the @a handle's entry. - /// associated with @a handle must already have been registered. - virtual int schedule_wakeup (ACE_HANDLE handle, - ACE_Reactor_Mask masks_to_be_added); - - /// Clear @a masks_to_be_cleared from the @a event_handler's entry. - virtual int cancel_wakeup (ACE_Event_Handler *event_handler, - ACE_Reactor_Mask masks_to_be_cleared); - - /// Clear @a masks_to_be_cleared from the @a handle's entry. - virtual int cancel_wakeup (ACE_HANDLE handle, - ACE_Reactor_Mask masks_to_be_cleared); - - // = Notification methods. - - /** - * Notify @a event_handler of @a mask event. The ACE_Time_Value - * indicates how long to blocking trying to notify. If @a timeout == - * 0, the caller will block until action is possible, else will wait - * until the relative time specified in @a timeout elapses). - */ - virtual int notify (ACE_Event_Handler *event_handler = 0, - ACE_Reactor_Mask mask = ACE_Event_Handler::EXCEPT_MASK, - ACE_Time_Value * = 0); - - /** - * Set the maximum number of times that ACE_Reactor_Impl will - * iterate and dispatch the that are passed in - * via the notify queue before breaking out of its - * loop. By default, this is set to - * -1, which means "iterate until the queue is empty." Setting this - * to a value like "1 or 2" will increase "fairness" (and thus - * prevent starvation) at the expense of slightly higher dispatching - * overhead. - */ - virtual void max_notify_iterations (int); - - /** - * Get the maximum number of times that the ACE_Reactor_Impl will - * iterate and dispatch the that are passed in - * via the notify queue before breaking out of its - * loop. - */ - virtual int max_notify_iterations (void); - - /** - * Purge any notifications pending in this reactor for the specified - * ACE_Event_Handler object. Returns the number of notifications - * purged. Returns -1 on error. - */ - virtual int purge_pending_notifications (ACE_Event_Handler * = 0, - ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK); - - /** - * Return the Event_Handler associated with @a handle. Return 0 if - * @a handle is not registered. - */ - virtual ACE_Event_Handler *find_handler (ACE_HANDLE handle); - - /** - * Check to see if @a handle is associated with a valid Event_Handler - * bound to @a mask. Return the @a event_handler associated with this - * @c handler if @a event_handler != 0. - */ - virtual int handler (ACE_HANDLE handle, - ACE_Reactor_Mask mask, - ACE_Event_Handler **event_handler = 0); - - /** - * Check to see if @a signum is associated with a valid Event_Handler - * bound to a signal. Return the @a event_handler associated with - * this @c handler if @a event_handler != 0. - */ - virtual int handler (int signum, - ACE_Event_Handler ** = 0); - - /// Returns true if Reactor has been successfully initialized, else - /// false. - virtual bool initialized (void); - - /// Returns the current size of the Reactor's internal descriptor - /// table. - virtual size_t size (void) const; - - /// Returns a reference to the Reactor's internal lock. - virtual ACE_Lock &lock (void); - - /// Wake up all threads waiting in the event loop. - virtual void wakeup_all_threads (void); - - /// Transfers ownership of Reactor_Impl to the new_owner. - /** - * @note There is no need to set the owner of the event loop for the - * ACE_Dev_Poll_Reactor. Multiple threads may invoke the - * event loop simulataneously. As such, this method is a - * no-op. - */ - virtual int owner (ACE_thread_t new_owner, ACE_thread_t *old_owner = 0); - - /// Return the ID of the "owner" thread. - /** - * @note There is no need to set the owner of the event loop for the - * ACE_Dev_Poll_Reactor. Multiple threads may invoke the - * event loop simulataneously. As such, this method is a - * no-op. - */ - virtual int owner (ACE_thread_t *owner); - - /// Get the existing restart value. - virtual int restart (void); - - /// Set a new value for restart and return the original value. - /** - * @param r If zero, then the event loop will not be automatically - * restarted if the underlying poll is interrupted via the - * INTR (interrupt) signal. - * - * @return Returns the previous "restart" value. - */ - virtual int restart (int r); - - /// Set position of the owner thread. - /** - * @note This is currently a no-op. - */ - virtual void requeue_position (int); - - /// Get position of the owner thread. - /** - * @note This is currently a no-op. - */ - virtual int requeue_position (void); - - /** - * @name Low-level wait_set mask manipulation methods - * - * Low-level methods to manipulate the event/reactor mask associated - * with a handle and event handler when polling for events. - * @par - * The "interest set," i.e. the wait set, can be directly - * manipulated with these methods. - */ - //@{ - - /// GET/SET/ADD/CLR the dispatch mask "bit" bound with the - /// event_handler and mask. - /** - * @return Old mask on success, -1 on error. - */ - virtual int mask_ops (ACE_Event_Handler *event_handler, - ACE_Reactor_Mask mask, - int ops); - - /// GET/SET/ADD/CLR the dispatch MASK "bit" bound with the handle - /// and mask. - /** - * @return Old mask on success, -1 on error. - */ - virtual int mask_ops (ACE_HANDLE handle, - ACE_Reactor_Mask mask, - int ops); - - //@} - - /** - * @name Low-level ready_set mask manipulation methods - * - * These methods are unimplemented. - */ - //@{ - - /// GET/SET/ADD/CLR the ready "bit" bound with the event_handler - /// and mask. - virtual int ready_ops (ACE_Event_Handler *event_handler, - ACE_Reactor_Mask mask, - int ops); - - /// GET/SET/ADD/CLR the ready "bit" bound with the handle and mask. - virtual int ready_ops (ACE_HANDLE handle, - ACE_Reactor_Mask, - int ops); - - //@} - - /// Dump the state of an object. - virtual void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - - class Token_Guard; - - /// Non-locking version of wait_pending(). - /** - * Returns non-zero if there are I/O events "ready" for dispatching, - * but does not actually dispatch the event handlers. By default, - * don't block while checking this, i.e., "poll". - * - * @note It is only possible to achieve millisecond timeout - * resolutions with the ACE_Dev_Poll_Reactor. - */ - int work_pending_i (ACE_Time_Value *max_wait_time); - - /// Poll for events and return the number of event handlers that - /// were dispatched. - /** - * This is a helper method called by all handle_events() methods. - */ - int handle_events_i (ACE_Time_Value *max_wait_time, Token_Guard &guard); - - /// Perform the upcall with the given event handler method. - int upcall (ACE_Event_Handler *event_handler, - int (ACE_Event_Handler::*callback)(ACE_HANDLE), - ACE_HANDLE handle); - - /** - * Dispatch ACE_Event_Handlers for time events, I/O events, and - * signal events. Returns the total number of ACE_Event_Handlers - * that were dispatched or -1 if something goes wrong. - */ - int dispatch (Token_Guard &guard); - - /// Dispatch a single timer, if ready. - /// Returns: 0 if no timers ready (token still held), - /// 1 if a timer was expired (token released), - /// -1 on error (token still held). - int dispatch_timer_handler (Token_Guard &guard); - - /// Dispatch an IO event to the corresponding event handler. Returns - /// Returns: 0 if no events ready (token still held), - /// 1 if an event was expired (token released), - /// -1 on error (token still held). - int dispatch_io_event (Token_Guard &guard); - - /// Register the given event handler with the reactor. - int register_handler_i (ACE_HANDLE handle, - ACE_Event_Handler *eh, - ACE_Reactor_Mask mask); - - /// Remove the event handler associated with the given handle and - /// event mask from the "interest set." - int remove_handler_i (ACE_HANDLE handle, ACE_Reactor_Mask mask); - - /// Temporarily remove the given handle from the "interest set." - int suspend_handler_i (ACE_HANDLE handle); - - /// Place the given handle that was temporarily removed from the - /// "interest set," i.e that was suspended, back in to the interest - /// set. The given handle will once again be polled for events. - int resume_handler_i (ACE_HANDLE handle); - - /// GET/SET/ADD/CLR the dispatch MASK "bit" bound with the handle - /// and mask. This internal helper method acquires no lock. - /** - * @return Old mask on success, -1 on error. - */ - int mask_ops_i (ACE_HANDLE handle, - ACE_Reactor_Mask mask, - int ops); - - /// Convert a reactor mask to its corresponding poll() event mask. - short reactor_mask_to_poll_event (ACE_Reactor_Mask mask); - -protected: - - /// Has the reactor been initialized. - bool initialized_; - - /// The file descriptor associated with the open `/dev/poll' or - /// `/dev/epoll' device. - /** - * All interactions with the `/dev/poll' or `/dev/epoll' device are - * done through this file descriptor. - */ - ACE_HANDLE poll_fd_; - - /// The maximum number of file descriptors over which demultiplexing - /// will occur. - size_t size_; - - /// Track HANDLES we are interested in for various events that must - /// be dispatched *without* polling. - /// ACE_Dev_Poll_Ready_Set ready_set_; - -#if defined (ACE_HAS_EVENT_POLL) - /// Table of event structures to be filled by epoll_wait: - struct epoll_event *events_; - - /// Pointer to the next epoll_event array element that contains the next - /// event to be dispatched. - struct epoll_event *start_pevents_; - - /// The last element in the event array plus one. - /** - * The loop that dispatches IO events stops when this->start_pevents_ == - * this->end_pevents_. - */ - struct epoll_event *end_pevents_; - -#else - /// The pollfd array that `/dev/poll' will feed its results to. - struct pollfd *dp_fds_; - - - /// Pointer to the next pollfd array element that contains the next - /// event to be dispatched. - struct pollfd *start_pfds_; - - /// The last element in the pollfd array plus one. - /** - * The loop that dispatches IO events stops when this->start_pfds == - * this->end_pfds_. - */ - struct pollfd *end_pfds_; -#endif /* ACE_HAS_EVENT_POLL */ - - /// This flag is used to keep track of whether we are actively handling - /// events or not. - sig_atomic_t deactivated_; - - /// Lock used for synchronization of reactor state. - ACE_Dev_Poll_Reactor_Token token_; - - /// Adapter used to return internal lock to outside world. - ACE_Lock_Adapter lock_adapter_; - - /// The repository that contains all registered event handlers. - ACE_Dev_Poll_Reactor_Handler_Repository handler_rep_; - - /// Defined as a pointer to allow overriding by derived classes... - ACE_Timer_Queue *timer_queue_; - - /// Keeps track of whether we should delete the timer queue (if we - /// didn't create it, then we don't delete it). - bool delete_timer_queue_; - - /// Handle signals without requiring global/static variables. - ACE_Sig_Handler *signal_handler_; - - /// Keeps track of whether we should delete the signal handler (if we - /// didn't create it, then we don't delete it). - bool delete_signal_handler_; - - /// Callback object that unblocks the if it's - /// sleeping. - ACE_Reactor_Notify *notify_handler_; - - /// Keeps track of whether we need to delete the notify handler (if - /// we didn't create it, then we don't delete it). - bool delete_notify_handler_; - - /// Flag that determines if signals are masked during event - /// dispatching. - /** - * If 0 then the Reactor will not mask the signals during the event - * dispatching. This is useful for applications that do not - * register any signal handlers and want to reduce the overhead - * introduce by the kernel level locks required to change the mask. - */ - int mask_signals_; - - /// Restart the handle_events event loop method automatically when - /// polling function in use (ioctl() in this case) is interrupted - /// via an EINTR signal. - int restart_; - -protected: - - /** - * @class Token_Guard - * - * @brief A helper class that helps grabbing, releasing and waiting - * on tokens for a thread that needs access to the reactor's token. - */ - class ACE_Export Token_Guard - { - public: - - /// Constructor that will grab the token for us - Token_Guard (ACE_Dev_Poll_Reactor_Token &token); - - /// Destructor. This will release the token if it hasn't been - /// released till this point - ~Token_Guard (void); - - /// Release the token .. - void release_token (void); - - /// Returns whether the thread that created this object owns the - /// token or not. - int is_owner (void); - - /// A helper method that acquires the token 1) at a low priority, and - /// 2) wait quietly for the token, not waking another thread. This - /// is appropriate for cases where a thread wants to wait for and - /// dispatch an event, not causing an existing waiter to relinquish the - /// token, and also queueing up behind other threads waiting to modify - /// event records. - int acquire_quietly (ACE_Time_Value *max_wait = 0); - - /// A helper method that acquires the token at a high priority, and - /// does wake the current token holder. - int acquire (ACE_Time_Value *max_wait = 0); - - private: - - Token_Guard (void); - - private: - - /// The Reactor token. - ACE_Dev_Poll_Reactor_Token &token_; - - /// Flag that indicate whether the thread that created this object - /// owns the token or not. A value of 0 indicates that this class - /// hasn't got the token (and hence the thread) and a value of 1 - /// vice-versa. - int owner_; - - }; - -}; - - -/** - * @class ACE_Dev_Poll_Handler_Guard - * - * @brief Class used to make event handler reference count - * manipulation exception-safe. - * - * This class makes the reference count manipulation that occurs - * during an upcall exception-safe. Prior to dispatching the event - * handler, the reference count is increased. Once the upcall for the - * given event handler is complete, its reference count will be decreased. - */ -class ACE_Dev_Poll_Handler_Guard -{ -public: - - /// Constructor - /** - * The constructor checks to see if @a eh is a reference-counted handler and - * remember that for later. If @a eh is reference counted, its reference - * count is incremented unless @a do_incr is false. - * @a do_incr should be false if the reference count was incremented - * independently of this guard, for example, on a notify handler since - * the reference count is incremented when the notify is queued. - */ - ACE_Dev_Poll_Handler_Guard (ACE_Event_Handler *eh, bool do_incr = true); - - /// Destructor - /** - * The destructor decrements the reference count on the event - * handler corresponding to the given handle. - */ - ~ACE_Dev_Poll_Handler_Guard (void); - - /// Release the event handler from this guard; when the destructor is - /// called, the handler's reference count will not be decremented. - void release (void); - -private: - - /// The event handler being managed. - ACE_Event_Handler *eh_; - - /// true if eh_ is a reference-counted handler. - bool refcounted_; - -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -# include "ace/Dev_Poll_Reactor.inl" -#endif /* __ACE_INLINE__ */ - -#endif /* ACE_HAS_EVENT_POLL || ACE_HAS_DEV_POLL */ - -#include /**/ "ace/post.h" - -#endif /* ACE_DEV_POLL_REACTOR_H */ diff --git a/ACE/ace/Dev_Poll_Reactor.inl b/ACE/ace/Dev_Poll_Reactor.inl deleted file mode 100644 index b7034e07333..00000000000 --- a/ACE/ace/Dev_Poll_Reactor.inl +++ /dev/null @@ -1,228 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/Log_Msg.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_Dev_Poll_Event_Tuple::ACE_Dev_Poll_Event_Tuple (void) - : event_handler (0), - mask (ACE_Event_Handler::NULL_MASK), - suspended (0) -{ -} - -// --------------------------------------------------------------------- - -#if 0 -ACE_INLINE -ACE_Dev_Poll_Ready_Set::ACE_Dev_Poll_Ready_Set (void) - : pfds (0), - nfds (0) -{ -} -#endif /* 0 */ - -// --------------------------------------------------------------------- - -ACE_INLINE void -ACE_Dev_Poll_Reactor_Handler_Repository::mask (ACE_HANDLE handle, - ACE_Reactor_Mask mask) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::mask"); - - // Only bother to search for the handle if it's in range. - if (this->handle_in_range (handle)) - this->handlers_[handle].mask = mask; -} - -ACE_INLINE ACE_Reactor_Mask -ACE_Dev_Poll_Reactor_Handler_Repository::mask (ACE_HANDLE handle) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::mask"); - - ACE_Reactor_Mask mask = ACE_Event_Handler::NULL_MASK; - - // Only bother to search for the handle if it's in range. - if (this->handle_in_range (handle)) - mask = this->handlers_[handle].mask; - - if (mask == ACE_Event_Handler::NULL_MASK) - errno = ENOENT; - - return mask; -} - -ACE_INLINE void -ACE_Dev_Poll_Reactor_Handler_Repository::suspend (ACE_HANDLE handle) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::suspend"); - - // Only bother to search for the handle if it's in range. - if (this->handle_in_range (handle)) - this->handlers_[handle].suspended = 1; -} - -ACE_INLINE void -ACE_Dev_Poll_Reactor_Handler_Repository::resume (ACE_HANDLE handle) -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::resume"); - - // Only bother to search for the handle if it's in range. - if (this->handle_in_range (handle)) - this->handlers_[handle].suspended = 0; -} - -ACE_INLINE int -ACE_Dev_Poll_Reactor_Handler_Repository::suspended (ACE_HANDLE handle) const -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::suspended"); - - if (this->handle_in_range (handle)) - return this->handlers_[handle].suspended; - - return -1; -} - -ACE_INLINE size_t -ACE_Dev_Poll_Reactor_Handler_Repository::size (void) const -{ - ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::size"); - - return this->max_size_; -} - -// ----------------------------------------------------------------- - -ACE_INLINE -ACE_Dev_Poll_Handler_Guard::ACE_Dev_Poll_Handler_Guard - (ACE_Event_Handler *eh, - bool do_incr) - : eh_ (eh), - refcounted_ (false) -{ - if (eh == 0) - return; - - this->refcounted_ = - eh->reference_counting_policy ().value () == - ACE_Event_Handler::Reference_Counting_Policy::ENABLED; - - if (do_incr && this->refcounted_) - eh->add_reference (); - - /** - * The below comments were here when I replaced the old refcount - * scheme was replaced. They may still need addressing. -Steve Huston - */ - - /** - * @todo Suspend the handler so that other threads will not cause - * an event that is already in an upcall from being dispatched - * again. - * - * @note The naive approach would be to simply call - * suspend_handler_i() on the reactor. However, that would - * cause a system call (write()) to occur. Obviously this - * can potentially have an adverse affect on performance. - * Ideally, the handler would only be marked as "suspended" in - * the handler repository. If an event arrives for a - * suspended handler that event can be "queued" in a - * "handle readiness queue." "Queued" is quoted since a real - * queue need not be used since duplicate events can be - * coalesced, thus avoiding unbounded queue growth. Event - * coalescing is already done by Linux's event poll driver - * (/dev/epoll) so Solaris' poll driver (/dev/poll) is the - * main concern here. The largest the queue can be is the - * same size as the number of handlers stored in the handler - * repository. - */ -} - -ACE_INLINE -ACE_Dev_Poll_Handler_Guard::~ACE_Dev_Poll_Handler_Guard (void) -{ - if (this->refcounted_ && this->eh_ != 0) - this->eh_->remove_reference (); - - /** - * The below comments were here when I replaced the old refcount - * scheme was replaced. They may still need addressing. -Steve Huston - */ - /** - * @todo Resume the handler so that other threads will be allowed to - * dispatch the handler. - */ -} - -ACE_INLINE void -ACE_Dev_Poll_Handler_Guard::release (void) -{ - this->eh_ = 0; -} - -// --------------------------------------------------------------------- - -ACE_INLINE int -ACE_Dev_Poll_Reactor::upcall (ACE_Event_Handler *event_handler, - int (ACE_Event_Handler::*callback)(ACE_HANDLE), - ACE_HANDLE handle) -{ - // If the handler returns positive value (requesting a reactor - // callback) just call back as many times as the handler requests - // it. Other threads are off handling other things. - int status = 0; - - do - { - status = (event_handler->*callback) (handle); - } - while (status > 0); - - return status; -} - - -/************************************************************************/ -// Methods for ACE_Dev_Poll_Reactor::Token_Guard -/************************************************************************/ - -ACE_INLINE -ACE_Dev_Poll_Reactor::Token_Guard::Token_Guard (ACE_Dev_Poll_Reactor_Token &token) - - : token_ (token), - owner_ (0) -{ -} - -ACE_INLINE -ACE_Dev_Poll_Reactor::Token_Guard::~Token_Guard (void) -{ - if (this->owner_ == 1) - { - ACE_MT (this->token_.release ()); - this->owner_ = 0; - } -} - -ACE_INLINE void -ACE_Dev_Poll_Reactor::Token_Guard::release_token (void) -{ - if (this->owner_) - { - ACE_MT (this->token_.release ()); - - // We are not the owner anymore.. - this->owner_ = 0; - } -} - -ACE_INLINE int -ACE_Dev_Poll_Reactor::Token_Guard::is_owner (void) -{ - return this->owner_; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Dirent.cpp b/ACE/ace/Dirent.cpp deleted file mode 100644 index 50aab1ac5f3..00000000000 --- a/ACE/ace/Dirent.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// $Id$ - -#include "ace/Dirent.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Dirent.inl" -#endif /* __ACE_INLINE__ */ diff --git a/ACE/ace/Dirent.h b/ACE/ace/Dirent.h deleted file mode 100644 index 823b28d747c..00000000000 --- a/ACE/ace/Dirent.h +++ /dev/null @@ -1,122 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Dirent.h - * - * $Id$ - * - * Define a portable C++ interface to ACE_OS_Dirent directory-entry - * manipulation. - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_DIRENT_H -#define ACE_DIRENT_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/OS_NS_dirent.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Dirent - * - * @brief Define a portable C++ directory-entry iterator based on the POSIX API. - */ -class ACE_Export ACE_Dirent -{ -public: - // = Initialization and termination methods. - /// Default constructor. - ACE_Dirent (void); - - /// Constructor calls - explicit ACE_Dirent (const ACE_TCHAR *dirname); - - /// Opens the directory named by filename and associates a directory - /// stream with it. - int open (const ACE_TCHAR *filename); - - /// Destructor calls . - ~ACE_Dirent (void); - - /// Closes the directory stream and frees the structure. - void close (void); - - // = Iterator methods. - /** - * Returns a pointer to a structure representing the directory entry - * at the current position in the directory stream to which dirp - * refers, and positions the directory stream at the next entry, - * except on read-only filesystems. It returns a NULL pointer upon - * reaching the end of the directory stream, or upon detecting an - * invalid location in the directory. shall not return - * directory entries containing empty names. It is unspecified - * whether entries are returned for dot or dot-dot. The pointer - * returned by points to data that may be overwritten by - * another call to on the same directory stream. This - * data shall not be overwritten by another call to on a - * different directory stream. may buffer several - * directory entries per actual read operation; marks for - * update the st_atime field of the directory each time the - * directory is actually read. - */ - ACE_DIRENT *read (void); - - /** - * Has the equivalent functionality as except that an - * @a entry and @a result buffer must be supplied by the caller to - * store the result. - */ - int read (struct ACE_DIRENT *entry, - struct ACE_DIRENT **result); - - // = Manipulators. - /// Returns the current location associated with the directory - /// stream. - long tell (void); - - /** - * Sets the position of the next operation on the - * directory stream. The new position reverts to the position - * associated with the directory stream at the time the - * operation that provides loc was performed. Values returned by - * are good only for the lifetime of the pointer from - * which they are derived. If the directory is closed and then - * reopened, the value may be invalidated due to - * undetected directory compaction. It is safe to use a previous - * value immediately after a call to and before - * any calls to readdir. - */ - void seek (long loc); - - /** - * Resets the position of the directory stream to the beginning of - * the directory. It also causes the directory stream to refer to - * the current state of the corresponding directory, as a call to - * would. - */ - void rewind (void); - -private: - /// Pointer to the directory stream. - ACE_DIR *dirp_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Dirent.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_DIRENT_H */ diff --git a/ACE/ace/Dirent.inl b/ACE/ace/Dirent.inl deleted file mode 100644 index 5f6af5a3218..00000000000 --- a/ACE/ace/Dirent.inl +++ /dev/null @@ -1,99 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/Log_Msg.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE int -ACE_Dirent::open (const ACE_TCHAR *dirname) -{ - // If the directory stream is already open, close it to prevent - // possible resource leaks. - - if (this->dirp_ != 0) - { - ACE_OS::closedir (this->dirp_); - this->dirp_ = 0; - } - - this->dirp_ = ACE_OS::opendir (dirname); - - if (this->dirp_ == 0) - return -1; - else - return 0; -} - -ACE_INLINE -ACE_Dirent::ACE_Dirent (void) - : dirp_ (0) -{ -} - -ACE_INLINE -ACE_Dirent::ACE_Dirent (const ACE_TCHAR *dirname) - : dirp_ (0) -{ - if (this->open (dirname) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Dirent::ACE_Dirent"))); -} - -ACE_INLINE -ACE_Dirent::~ACE_Dirent (void) -{ - if (this->dirp_ != 0) - ACE_OS::closedir (this->dirp_); -} - -ACE_INLINE ACE_DIRENT * -ACE_Dirent::read (void) -{ - return this->dirp_ ? ACE_OS::readdir (this->dirp_) : 0; -} - -ACE_INLINE int -ACE_Dirent::read (struct ACE_DIRENT *entry, - struct ACE_DIRENT **result) -{ - return this->dirp_ - ? ACE_OS::readdir_r (this->dirp_, entry, result) - : 0; -} - -ACE_INLINE void -ACE_Dirent::close (void) -{ - if (this->dirp_ != 0) - { - ACE_OS::closedir (this->dirp_); - - // Prevent double closure - this->dirp_ = 0; - } -} - -ACE_INLINE void -ACE_Dirent::rewind (void) -{ - if (this->dirp_) - ACE_OS::rewinddir (this->dirp_); -} - -ACE_INLINE void -ACE_Dirent::seek (long loc) -{ - if (this->dirp_) - ACE_OS::seekdir (this->dirp_, loc); -} - -ACE_INLINE long -ACE_Dirent::tell (void) -{ - return this->dirp_ ? ACE_OS::telldir (this->dirp_) : 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Dirent_Selector.cpp b/ACE/ace/Dirent_Selector.cpp deleted file mode 100644 index 288fc6deacf..00000000000 --- a/ACE/ace/Dirent_Selector.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// $Id$ - -#include "ace/Dirent_Selector.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Dirent_Selector.inl" -#endif /* __ACE_INLINE__ */ - -#include "ace/OS_NS_dirent.h" -#include "ace/OS_NS_stdlib.h" - -ACE_RCSID (ace, - Dirent_Selector, - "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Construction/Destruction - -ACE_Dirent_Selector::ACE_Dirent_Selector (void) - : namelist_ (0), - n_ (0) -{ -} - -ACE_Dirent_Selector::~ACE_Dirent_Selector (void) -{ - // Free up any allocated resources. - this->close(); -} - -int -ACE_Dirent_Selector::open (const ACE_TCHAR *dir, - ACE_SCANDIR_SELECTOR sel, - ACE_SCANDIR_COMPARATOR cmp) -{ - n_ = ACE_OS::scandir (dir, &this->namelist_, sel, cmp); - return n_; -} - -int -ACE_Dirent_Selector::close (void) -{ - for (--n_; n_ >= 0; --n_) - { -#if defined (ACE_LACKS_STRUCT_DIR) - // Only the lacking-struct-dir emulation allocates this. Native - // scandir includes d_name in the dirent struct itself. - ACE_OS::free (this->namelist_[n_]->d_name); -#endif - ACE_OS::free (this->namelist_[n_]); - } - - ACE_OS::free (this->namelist_); - this->namelist_ = 0; - return 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Dirent_Selector.h b/ACE/ace/Dirent_Selector.h deleted file mode 100644 index 72b1b176c03..00000000000 --- a/ACE/ace/Dirent_Selector.h +++ /dev/null @@ -1,75 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Dirent_Selector.h - * - * $Id$ - * - * Define a portable C++ interface to the method. - * - * @author Rich Newman - */ -//============================================================================= - -#ifndef ACE_DIRENT_SELECTOR_H -#define ACE_DIRENT_SELECTOR_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/OS_NS_dirent.h" /* Need ACE_SCANDIR_SELECTOR, COMPARATOR */ -#include "ace/os_include/os_dirent.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Dirent_Selector - * - * @brief Define a portable C++ directory-entry iterator based on the - * POSIX scandir API. - */ -class ACE_Export ACE_Dirent_Selector -{ -public: - /// Constructor - ACE_Dirent_Selector (void); - - /// Destructor. - virtual ~ACE_Dirent_Selector (void); - - /// Return the length of the list of matching directory entries. - int length (void) const; - - /// Return the entry at @a index. - ACE_DIRENT *operator[] (const int index) const; - - /// Free up resources. - int close (void); - - /// Open the directory @a dir and populate the current list of names with - /// directory entries that match the @a selector and @a comparator. - int open (const ACE_TCHAR *dir, - ACE_SCANDIR_SELECTOR selector = 0, - ACE_SCANDIR_COMPARATOR comparator = 0); - -protected: - /// Ptr to the namelist array. - ACE_DIRENT **namelist_; - - /// Number of entries in the array. - int n_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Dirent_Selector.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_DIRENT_SELECTOR_H */ diff --git a/ACE/ace/Dirent_Selector.inl b/ACE/ace/Dirent_Selector.inl deleted file mode 100644 index 7c42f46b9be..00000000000 --- a/ACE/ace/Dirent_Selector.inl +++ /dev/null @@ -1,19 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE int -ACE_Dirent_Selector::length (void) const -{ - return n_; -} - -ACE_INLINE ACE_DIRENT * -ACE_Dirent_Selector::operator[] (const int n) const -{ - return this->namelist_[n]; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Dump.cpp b/ACE/ace/Dump.cpp deleted file mode 100644 index b601496f3b6..00000000000 --- a/ACE/ace/Dump.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// $Id$ - -#include "ace/Dump.h" -#include "ace/Guard_T.h" -#include "ace/Thread_Mutex.h" -#include "ace/Object_Manager.h" -#include "ace/Log_Msg.h" - -ACE_RCSID(ace, Dump, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Implementations (very simple for now...) - -ACE_Dumpable::~ACE_Dumpable (void) -{ - ACE_TRACE ("ACE_Dumpable::~ACE_Dumpable"); -} - -ACE_Dumpable::ACE_Dumpable (const void *this_ptr) - : this_ (this_ptr) -{ - ACE_TRACE ("ACE_Dumpable::ACE_Dumpable"); -} - -ACE_Dumpable_Ptr::ACE_Dumpable_Ptr (const ACE_Dumpable *dumper) - : dumper_ (dumper) -{ - ACE_TRACE ("ACE_Dumpable_Ptr::ACE_Dumpable_Ptr"); -} - -const ACE_Dumpable * -ACE_Dumpable_Ptr::operator->() const -{ - ACE_TRACE ("ACE_Dumpable_Ptr::operator->"); - return this->dumper_; -} - -void -ACE_Dumpable_Ptr::operator= (const ACE_Dumpable *dumper) const -{ - ACE_TRACE ("ACE_Dumpable_Ptr::operator="); - if (this->dumper_ != dumper) - { - delete const_cast (this->dumper_); - (const_cast (this))->dumper_ = dumper; - } -} - -ACE_ODB::ACE_ODB (void) - // Let the Tuple default constructor initialize object_table_ - : current_size_ (0) -{ - ACE_TRACE ("ACE_ODB::ACE_ODB"); -} - -ACE_ODB * -ACE_ODB::instance (void) -{ - ACE_TRACE ("ACE_ODB::instance"); - - if (ACE_ODB::instance_ == 0) - { - ACE_MT (ACE_Thread_Mutex *lock = - ACE_Managed_Object::get_preallocated_object - (ACE_Object_Manager::ACE_DUMP_LOCK); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, *lock, 0)); - - if (ACE_ODB::instance_ == 0) - ACE_NEW_RETURN (ACE_ODB::instance_, - ACE_ODB, - 0); - } - - return ACE_ODB::instance_; -} - -void -ACE_ODB::dump_objects (void) -{ - ACE_TRACE ("ACE_ODB::dump_objects"); - for (int i = 0; i < this->current_size_; i++) - { - if (this->object_table_[i].this_ != 0) - // Dump the state of the object. - this->object_table_[i].dumper_->dump (); - } -} - -// This method registers a new . It detects -// duplicates and simply overwrites them. - -void -ACE_ODB::register_object (const ACE_Dumpable *dumper) -{ - ACE_TRACE ("ACE_ODB::register_object"); - int i; - int slot = 0; - - for (i = 0; i < this->current_size_; i++) - { - if (this->object_table_[i].this_ == 0) - slot = i; - else if (this->object_table_[i].this_ == dumper->this_) - { - slot = i; - break; - } - } - - if (i == this->current_size_) - { - slot = this->current_size_++; - ACE_ASSERT (this->current_size_ < ACE_ODB::MAX_TABLE_SIZE); - } - this->object_table_[slot].this_ = dumper->this_; - this->object_table_[slot].dumper_ = dumper; -} - -void -ACE_ODB::remove_object (const void *this_ptr) -{ - ACE_TRACE ("ACE_ODB::remove_object"); - int i; - - for (i = 0; i < this->current_size_; i++) - { - if (this->object_table_[i].this_ == this_ptr) - break; - } - - if (i < this->current_size_) - { - this->object_table_[i].this_ = 0; - this->object_table_[i].dumper_ = 0; - } -} - -ACE_ODB *ACE_ODB::instance_ = 0; - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Dump.h b/ACE/ace/Dump.h deleted file mode 100644 index 97f0bac7966..00000000000 --- a/ACE/ace/Dump.h +++ /dev/null @@ -1,172 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file Dump.h - * - * $Id$ - * - * - * A prototype mechanism that allow all ACE objects to be registered - * with a central in-memory "database" that can dump the state of all - * live ACE objects (e.g., from within a debugger). - * - * The macros which allow easy registration and removal of objects to be - * dumped (ACE_REGISTER_OBJECT and ACE_REMOVE_OBJECT) are turned into - * no-ops by compiling with the ACE_NDEBUG macro defined. This allows - * usage to be removed in "release mode" builds without changing code. - * - * There are several interesting aspects to this design: - * - * 1. It uses the External Polymorphism pattern to avoid having to - * derive all ACE classes from a common base class that has virtual - * methods (this is crucial to avoid unnecessary overhead). In - * addition, there is no additional space added to ACE objects - * (this is crucial to maintain binary layout compatibility). - * - * 2. This mechanism can be conditionally compiled in order to - * completely disable this feature entirely. Moreover, by - * using macros there are relatively few changes to ACE code. - * - * 3. This mechanism copes with single-inheritance hierarchies of - * dumpable classes. In such cases we typically want only one - * dump, corresponding to the most derived instance. Thanks to - * Christian Millour (chris@etca.fr) for illustrating how to do - * this. Note, however, that this scheme doesn't generalize to - * work with multiple-inheritance or virtual base classes. - * - * Future work includes: - * - * 1. Using a dynamic object table rather than a static table - * - * 2. Adding support to allow particular classes of objects to - * be selectively dumped. - * - * - * @author Doug Schmidt - */ -//============================================================================= - - -#ifndef ACE_DUMP_H -#define ACE_DUMP_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Dumpable - * - * @brief Base class that defines a uniform interface for all object - * dumping. - */ -class ACE_Export ACE_Dumpable -{ -public: - friend class ACE_ODB; - friend class ACE_Dumpable_Ptr; - - /// Constructor. - ACE_Dumpable (const void *); - - /// This pure virtual method must be filled in by a subclass. - virtual void dump (void) const = 0; - -protected: - virtual ~ACE_Dumpable (void); - -private: - /// Pointer to the object that is being stored. - const void *this_; -}; - -/** - * @class ACE_Dumpable_Ptr - * - * @brief A smart pointer stored in the in-memory object database - * ACE_ODB. The pointee (if any) is deleted when reassigned. - */ -class ACE_Export ACE_Dumpable_Ptr -{ -public: - ACE_Dumpable_Ptr (const ACE_Dumpable *dumper = 0); - const ACE_Dumpable *operator->() const; - void operator= (const ACE_Dumpable *dumper) const; - -private: - /// "Real" pointer to the underlying abstract base class - /// pointer that does the real work. - const ACE_Dumpable *dumper_; -}; - -/** - * @class ACE_ODB - * - * @brief This is the object database (ODB) that keeps track of all - * live ACE objects. - */ -class ACE_Export ACE_ODB -{ -public: - /// @todo This is clearly inadequate and should be dynamic... - enum {MAX_TABLE_SIZE = 100000}; - - /// Iterates through the entire set of registered objects and - /// dumps their state. - void dump_objects (void); - - /// Add the tuple to the list of registered ACE objects. - void register_object (const ACE_Dumpable *dumper); - - /// Use to locate and remove the associated from the - /// list of registered ACE objects. - void remove_object (const void *this_); - - /// Interface to the Singleton instance of the object database. - static ACE_ODB *instance (void); - -private: - ACE_ODB (void); // Ensure we have a Singleton... - - struct Tuple - { - /// Pointer to the object that is registered. - const void *this_; - - /// Smart pointer to the ACE_Dumpable object associated with this_. - /// This uses an ACE_Dumpable_Ptr, instead of a bare pointer, to - /// cope with hierarchies of dumpable classes. In such cases we - /// typically want only one dump, corresponding to the most derived - /// instance. To achieve this, the handle registered for the - /// subobject corresponding to the base class is destroyed (hence - /// on destruction of the subobject its handle won't exist anymore - /// and we'll have to check for that). - const ACE_Dumpable_Ptr dumper_; - - Tuple (void) : dumper_(0) {} - }; - - /// Singleton instance of this class. - static ACE_ODB *instance_; - - /// The current implementation is very simple-minded and will be - /// changed to be dynamic. - Tuple object_table_[ACE_ODB::MAX_TABLE_SIZE]; - - /// Current size of . - int current_size_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -// Include the templates classes at this point. -#include "ace/Dump_T.h" - -#include /**/ "ace/post.h" -#endif /* ACE_DUMP_H */ diff --git a/ACE/ace/Dump_T.cpp b/ACE/ace/Dump_T.cpp deleted file mode 100644 index 3c789497eee..00000000000 --- a/ACE/ace/Dump_T.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Dump_T.cpp -// -// $Id$ - -#ifndef ACE_DUMP_T_CPP -#define ACE_DUMP_T_CPP - -#include "ace/Dump_T.h" -#include "ace/Global_Macros.h" -#include "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template -ACE_Dumpable_Adapter::~ACE_Dumpable_Adapter (void) -{ - ACE_TRACE ("ACE_Dumpable_Adapter::~ACE_Dumpable_Adapter"); -} - -template -ACE_Dumpable_Adapter::ACE_Dumpable_Adapter (const Concrete *t) - : ACE_Dumpable ((const void *) t), this_ (t) -{ - ACE_TRACE ("ACE_Dumpable_Adapter::ACE_Dumpable_Adapter"); -} - -template Concrete * -ACE_Dumpable_Adapter::operator->() const -{ - return (Concrete *) this->this_; -} - -template void -ACE_Dumpable_Adapter::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Dumpable_Adapter::dump"); - this->this_->dump (); -#endif /* ACE_HAS_DUMP */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_DUMP_T_CPP */ diff --git a/ACE/ace/Dump_T.h b/ACE/ace/Dump_T.h deleted file mode 100644 index 33249fb1fa9..00000000000 --- a/ACE/ace/Dump_T.h +++ /dev/null @@ -1,82 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Dump_T.h - * - * $Id$ - * - * @author Doug Schmidt - */ -//============================================================================= - - -#ifndef ACE_DUMP_T_H -#define ACE_DUMP_T_H -#include /**/ "ace/pre.h" - -#include "ace/Dump.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Dumpable_Adapter - * - * @brief This class inherits the interface of the abstract ACE_Dumpable - * class and is instantiated with the implementation of the - * concrete component class . - * - * This design is similar to the Adapter and Decorator patterns - * from the ``Gang of Four'' book. Note that - * need not inherit from a common class since ACE_Dumpable - * provides the uniform virtual interface! - */ -template -class ACE_Dumpable_Adapter : public ACE_Dumpable -{ -public: - // = Initialization and termination methods. - ACE_Dumpable_Adapter (const Concrete *t); - ~ACE_Dumpable_Adapter (void); - - /// Concrete dump method (simply delegates to the method of - /// ). - virtual void dump (void) const; - - /// Delegate to methods in the Concrete class. - Concrete *operator->() const; - -private: - /// Pointer to @c this of . - const Concrete *this_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -// Some useful macros for conditionally compiling this feature... -#if defined (ACE_NDEBUG) -#define ACE_REGISTER_OBJECT(CLASS) -#define ACE_REMOVE_OBJECT -#else -#define ACE_REGISTER_OBJECT(CLASS) \ - ACE_ODB::instance ()->register_object \ - (new ACE_Dumpable_Adapter (this)); -#define ACE_REMOVE_OBJECT \ - ACE_ODB::instance ()->remove_object \ - ((void *) this); -#endif /* ACE_NDEBUG */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Dump_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Dump_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" -#endif /* ACE_DUMP_T_H */ diff --git a/ACE/ace/Dynamic.cpp b/ACE/ace/Dynamic.cpp deleted file mode 100644 index adeae242579..00000000000 --- a/ACE/ace/Dynamic.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// $Id$ - -#include "ace/Dynamic.h" -#include "ace/Singleton.h" -#include "ace/TSS_T.h" -#include "ace/Synch_Traits.h" -#include "ace/Null_Mutex.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Dynamic.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, Dynamic, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_Dynamic::ACE_Dynamic (void) - : is_dynamic_ (false) -{ - ACE_TRACE ("ACE_Dynamic::ACE_Dynamic"); -} - -/* static */ ACE_Dynamic * -ACE_Dynamic::instance (void) -{ - return ACE_TSS_Singleton::instance (); -} - -#if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION) -template ACE_TSS_Singleton * - ACE_TSS_Singleton::singleton_; -#endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */ - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Dynamic.h b/ACE/ace/Dynamic.h deleted file mode 100644 index 4d52b67673f..00000000000 --- a/ACE/ace/Dynamic.h +++ /dev/null @@ -1,75 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file Dynamic.h - * - * $Id$ - * - * @author Doug Schmidt - * @author Irfan Pyarali. - */ -//========================================================================== - -#ifndef ACE_DYNAMIC_H -#define ACE_DYNAMIC_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Dynamic - * - * @brief Checks to see if an object was dynamically allocated. - * - * This class holds the pointer in a thread-safe manner between - * the call to operator new and the call to the constructor. - */ -class ACE_Export ACE_Dynamic -{ -public: - // = Initialization and termination method. - /// Constructor. - ACE_Dynamic (void); - - /// Destructor. - ~ACE_Dynamic (void); - - /** - * Sets a flag that indicates that the object was dynamically - * created. This method is usually called in operator new and then - * checked and reset in the constructor. - */ - void set (void); - - /// @c true if we were allocated dynamically, else @c false. - bool is_dynamic (void); - - /// Resets state flag. - void reset (void); - - static ACE_Dynamic *instance (void); - -private: - /** - * Flag that indicates that the object was dynamically created. This - * method is usually called in operator new and then checked and - * reset in the constructor. - */ - bool is_dynamic_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Dynamic.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_DYNAMIC_H */ diff --git a/ACE/ace/Dynamic.inl b/ACE/ace/Dynamic.inl deleted file mode 100644 index 3f506bc51f4..00000000000 --- a/ACE/ace/Dynamic.inl +++ /dev/null @@ -1,34 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_Dynamic::~ACE_Dynamic (void) -{ - // ACE_TRACE ("ACE_Dynamic::~ACE_Dynamic"); -} - -ACE_INLINE void -ACE_Dynamic::set (void) -{ - // ACE_TRACE ("ACE_Dynamic::set"); - this->is_dynamic_ = true; -} - -ACE_INLINE bool -ACE_Dynamic::is_dynamic (void) -{ - // ACE_TRACE ("ACE_Dynamic::is_dynamic"); - return this->is_dynamic_; -} - -ACE_INLINE void -ACE_Dynamic::reset (void) -{ - // ACE_TRACE ("ACE_Dynamic::reset"); - this->is_dynamic_ = false; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Dynamic_Message_Strategy.cpp b/ACE/ace/Dynamic_Message_Strategy.cpp deleted file mode 100644 index 060aef6f5b5..00000000000 --- a/ACE/ace/Dynamic_Message_Strategy.cpp +++ /dev/null @@ -1,205 +0,0 @@ -#include "ace/Dynamic_Message_Strategy.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Dynamic_Message_Strategy.inl" -#endif /* __ACE_INLINE__ */ - -#include "ace/Guard_T.h" -#include "ace/Log_Msg.h" -#include "ace/Malloc_Base.h" -#include "ace/OS_NS_string.h" - -ACE_RCSID (ace, - Dynamic_Message_Strategy, - "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// ctor - -ACE_Dynamic_Message_Strategy::ACE_Dynamic_Message_Strategy (unsigned long static_bit_field_mask, - unsigned long static_bit_field_shift, - unsigned long dynamic_priority_max, - unsigned long dynamic_priority_offset) - : static_bit_field_mask_ (static_bit_field_mask), - static_bit_field_shift_ (static_bit_field_shift), - dynamic_priority_max_ (dynamic_priority_max), - dynamic_priority_offset_ (dynamic_priority_offset), - max_late_ (0, dynamic_priority_offset - 1), - min_pending_ (0, dynamic_priority_offset), - pending_shift_ (0, dynamic_priority_max) -{ -} - -// dtor - -ACE_Dynamic_Message_Strategy::~ACE_Dynamic_Message_Strategy (void) -{ -} - -ACE_Dynamic_Message_Strategy::Priority_Status -ACE_Dynamic_Message_Strategy::priority_status (ACE_Message_Block & mb, - const ACE_Time_Value & tv) -{ - // default the message to have pending priority status - Priority_Status status = ACE_Dynamic_Message_Strategy::PENDING; - - // start with the passed absolute time as the message's priority, then - // call the polymorphic hook method to (at least partially) convert - // the absolute time and message attributes into the message's priority - ACE_Time_Value priority (tv); - convert_priority (priority, mb); - - // if the priority is negative, the message is pending - if (priority < ACE_Time_Value::zero) - { - // priority for pending messages must be shifted - // upward above the late priority range - priority += pending_shift_; - if (priority < min_pending_) - priority = min_pending_; - } - // otherwise, if the priority is greater than the maximum late - // priority value that can be represented, it is beyond late - else if (priority > max_late_) - { - // all messages that are beyond late are assigned lowest priority (zero) - mb.msg_priority (0); - return ACE_Dynamic_Message_Strategy::BEYOND_LATE; - } - // otherwise, the message is late, but its priority is correct - else - status = ACE_Dynamic_Message_Strategy::LATE; - - // use (fast) bitwise operators to isolate and replace - // the dynamic portion of the message's priority - mb.msg_priority((mb.msg_priority() & static_bit_field_mask_) | - ((priority.usec () + - ACE_ONE_SECOND_IN_USECS * (suseconds_t)(priority.sec())) << - static_bit_field_shift_)); - - // returns the priority status of the message - return status; -} - - -// Dump the state of the strategy. - -void -ACE_Dynamic_Message_Strategy::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Dynamic_Message_Strategy::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("static_bit_field_mask_ = %u\n") - ACE_TEXT ("static_bit_field_shift_ = %u\n") - ACE_TEXT ("dynamic_priority_max_ = %u\n") - ACE_TEXT ("dynamic_priority_offset_ = %u\n") - ACE_TEXT ("max_late_ = [%d sec, %d usec]\n") - ACE_TEXT ("min_pending_ = [%d sec, %d usec]\n") - ACE_TEXT ("pending_shift_ = [%d sec, %d usec]\n"), - this->static_bit_field_mask_, - this->static_bit_field_shift_, - this->dynamic_priority_max_, - this->dynamic_priority_offset_, - this->max_late_.sec (), - this->max_late_.usec (), - this->min_pending_.sec (), - this->min_pending_.usec (), - this->pending_shift_.sec (), - this->pending_shift_.usec ())); - - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_Deadline_Message_Strategy::ACE_Deadline_Message_Strategy (unsigned long static_bit_field_mask, - unsigned long static_bit_field_shift, - unsigned long dynamic_priority_max, - unsigned long dynamic_priority_offset) - : ACE_Dynamic_Message_Strategy (static_bit_field_mask, - static_bit_field_shift, - dynamic_priority_max, - dynamic_priority_offset) -{ -} - -ACE_Deadline_Message_Strategy::~ACE_Deadline_Message_Strategy (void) -{ -} - -void -ACE_Deadline_Message_Strategy::convert_priority (ACE_Time_Value & priority, - const ACE_Message_Block & mb) -{ - // Convert absolute time passed in tv to negative time - // to deadline of mb with respect to that absolute time. - priority -= mb.msg_deadline_time (); -} - // dynamic priority conversion function based on time to deadline - -void -ACE_Deadline_Message_Strategy::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Deadline_Message_Strategy::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Dynamic_Message_Strategy base class: \n"))); - this->ACE_Dynamic_Message_Strategy::dump (); - - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nderived class: ACE_Deadline_Message_Strategy\n"))); - - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_Laxity_Message_Strategy::ACE_Laxity_Message_Strategy (unsigned long static_bit_field_mask, - unsigned long static_bit_field_shift, - unsigned long dynamic_priority_max, - unsigned long dynamic_priority_offset) - : ACE_Dynamic_Message_Strategy (static_bit_field_mask, - static_bit_field_shift, - dynamic_priority_max, - dynamic_priority_offset) -{ -} - -ACE_Laxity_Message_Strategy::~ACE_Laxity_Message_Strategy (void) -{ -} - -void -ACE_Laxity_Message_Strategy::convert_priority (ACE_Time_Value & priority, - const ACE_Message_Block & mb) -{ - // Convert absolute time passed in tv to negative - // laxity of mb with respect to that absolute time. - priority += mb.msg_execution_time (); - priority -= mb.msg_deadline_time (); -} - // dynamic priority conversion function based on laxity - -void -ACE_Laxity_Message_Strategy::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Laxity_Message_Strategy::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Dynamic_Message_Strategy base class: \n"))); - this->ACE_Dynamic_Message_Strategy::dump (); - - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nderived class: ACE_Laxity_Message_Strategy\n"))); - - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - // Dump the state of the strategy. - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Dynamic_Message_Strategy.h b/ACE/ace/Dynamic_Message_Strategy.h deleted file mode 100644 index 66448a8247b..00000000000 --- a/ACE/ace/Dynamic_Message_Strategy.h +++ /dev/null @@ -1,217 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file Dynamic_Message_Strategy.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//========================================================================== - -#ifndef ACE_DYNAMIC_MESSAGE_STRATEGY_H -#define ACE_DYNAMIC_MESSAGE_STRATEGY_H - -#include /**/ "ace/pre.h" - -#include "ace/config-lite.h" -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Message_Block.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Dynamic_Message_Strategy - * - * @brief An abstract base class which provides dynamic priority - * evaluation methods for use by the ACE_Dynamic_Message_Queue - * class or any other class which needs to manage the priorities - * of a collection of ACE_Message_Blocks dynamically. - * - * Methods for deadline and laxity based priority evaluation are - * provided. These methods assume a specific partitioning of - * the message priority number into a higher order dynamic bit - * field and a lower order static priority bit field. The - * default partitioning assumes an unsigned dynamic message - * priority field of 22 bits and an unsigned static message - * priority field of 10 bits. This corresponds to the initial - * values of the static class members. To provide a different - * partitioning, assign a different set of values to the static - * class memebers before using the static member functions. - */ -class ACE_Export ACE_Dynamic_Message_Strategy -{ -public: - - // = Message priority status - - // Values are defined as bit flags so that status combinations may - // be specified easily. - - enum Priority_Status - { - /// Message can still make its deadline - PENDING = 0x01, - /// Message cannot make its deadline - LATE = 0x02, - /// Message is so late its priority is undefined - BEYOND_LATE = 0x04, - /// Mask to match any priority status - ANY_STATUS = 0x07 - }; - - /// Constructor. - ACE_Dynamic_Message_Strategy (unsigned long static_bit_field_mask, - unsigned long static_bit_field_shift, - unsigned long dynamic_priority_max, - unsigned long dynamic_priority_offset); - - /// Virtual destructor. - virtual ~ACE_Dynamic_Message_Strategy (void); - - /// Updates the message's priority and returns its priority status. - Priority_Status priority_status (ACE_Message_Block &mb, - const ACE_Time_Value &tv); - - /// Get static bit field mask. - unsigned long static_bit_field_mask (void) const; - - /// Set static bit field mask. - void static_bit_field_mask (unsigned long); - - /// Get left shift value to make room for static bit field. - unsigned long static_bit_field_shift (void) const; - - /// Set left shift value to make room for static bit field. - void static_bit_field_shift (unsigned long); - - /// Get maximum supported priority value. - unsigned long dynamic_priority_max (void) const; - - /// Set maximum supported priority value. - void dynamic_priority_max (unsigned long); - - /// Get offset to boundary between signed range and unsigned range. - unsigned long dynamic_priority_offset (void) const; - - /// Set offset to boundary between signed range and unsigned range. - void dynamic_priority_offset (unsigned long); - - /// Dump the state of the strategy. - virtual void dump (void) const; - -protected: - /// Hook method for dynamic priority conversion. - virtual void convert_priority (ACE_Time_Value &priority, - const ACE_Message_Block &mb) = 0; - - /// This is a bit mask with all ones in the static bit field. - unsigned long static_bit_field_mask_; - - /** - * This is a left shift value to make room for static bit field: - * this value should be the logarithm base 2 of - * (static_bit_field_mask_ + 1). - */ - unsigned long static_bit_field_shift_; - - /// Maximum supported priority value. - unsigned long dynamic_priority_max_; - - /// Offset to boundary between signed range and unsigned range. - unsigned long dynamic_priority_offset_; - - /// Maximum late time value that can be represented. - ACE_Time_Value max_late_; - - /// Minimum pending time value that can be represented. - ACE_Time_Value min_pending_; - - /// Time value by which to shift pending priority. - ACE_Time_Value pending_shift_; -}; - -/** - * @class ACE_Deadline_Message_Strategy - * - * @brief Deadline based message priority strategy. - * - * Assigns dynamic message priority according to time to deadline. The - * message priority is divided into high and low order bit fields. The - * high order bit field is used for dynamic message priority, which is - * updated whenever the convert_priority() method is called. The - * low order bit field is used for static message priority and is left - * unchanged. The partitioning of the priority value into high and low - * order bit fields is done according to the arguments passed to the - * strategy object's constructor. - */ -class ACE_Export ACE_Deadline_Message_Strategy : public ACE_Dynamic_Message_Strategy -{ -public: - /// Ctor, with all arguments defaulted. - ACE_Deadline_Message_Strategy (unsigned long static_bit_field_mask = 0x3FFUL, // 2^(10) - 1 - unsigned long static_bit_field_shift = 10, // 10 low order bits - unsigned long dynamic_priority_max = 0x3FFFFFUL, // 2^(22)-1 - unsigned long dynamic_priority_offset = 0x200000UL); // 2^(22-1) - - /// Virtual dtor. - virtual ~ACE_Deadline_Message_Strategy (void); - - /// Dynamic priority conversion function based on time to deadline. - virtual void convert_priority (ACE_Time_Value &priority, - const ACE_Message_Block &mb); - - /// Dump the state of the strategy. - virtual void dump (void) const; -}; - -/** - * @class ACE_Laxity_Message_Strategy - * - * @brief Laxity based message priority strategy. - * - * Assigns dynamic message priority according to laxity (time to - * deadline minus worst case execution time). The message priority is - * divided into high and low order bit fields. The high order - * bit field is used for dynamic message priority, which is - * updated whenever the convert_priority() method is called. The - * low order bit field is used for static message priority and is left - * unchanged. The partitioning of the priority value into high and low - * order bit fields is done according to the arguments passed to the - * strategy object's constructor. - */ -class ACE_Export ACE_Laxity_Message_Strategy : public ACE_Dynamic_Message_Strategy -{ -public: - /// Ctor, with all arguments defaulted. - ACE_Laxity_Message_Strategy (unsigned long static_bit_field_mask = 0x3FFUL, // 2^(10) - 1 - unsigned long static_bit_field_shift = 10, // 10 low order bits - unsigned long dynamic_priority_max = 0x3FFFFFUL, // 2^(22)-1 - unsigned long dynamic_priority_offset = 0x200000UL); // 2^(22-1) - - /// virtual dtor. - virtual ~ACE_Laxity_Message_Strategy (void); - - /// Dynamic priority conversion function based on laxity. - virtual void convert_priority (ACE_Time_Value &priority, - const ACE_Message_Block &mb); - - /// Dump the state of the strategy. - virtual void dump (void) const; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Dynamic_Message_Strategy.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" - -#endif /* ACE_DYNAMIC_MESSAGE_STRATEGY_H */ diff --git a/ACE/ace/Dynamic_Message_Strategy.inl b/ACE/ace/Dynamic_Message_Strategy.inl deleted file mode 100644 index b855acef597..00000000000 --- a/ACE/ace/Dynamic_Message_Strategy.inl +++ /dev/null @@ -1,75 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE unsigned long -ACE_Dynamic_Message_Strategy::static_bit_field_mask (void) const -{ - return static_bit_field_mask_; -} - // get static bit field mask - -ACE_INLINE void -ACE_Dynamic_Message_Strategy::static_bit_field_mask (unsigned long ul) -{ - static_bit_field_mask_ = ul; -} - // set static bit field mask - -ACE_INLINE unsigned long -ACE_Dynamic_Message_Strategy::static_bit_field_shift (void) const -{ - return static_bit_field_shift_; -} - // get left shift value to make room for static bit field - -ACE_INLINE void -ACE_Dynamic_Message_Strategy::static_bit_field_shift (unsigned long ul) -{ - static_bit_field_shift_ = ul; -} - // set left shift value to make room for static bit field - -ACE_INLINE unsigned long -ACE_Dynamic_Message_Strategy::dynamic_priority_max (void) const -{ - return dynamic_priority_max_; -} - // get maximum supported priority value - -ACE_INLINE void -ACE_Dynamic_Message_Strategy::dynamic_priority_max (unsigned long ul) -{ - // pending_shift_ depends on dynamic_priority_max_: for performance - // reasons, the value in pending_shift_ is (re)calculated only when - // dynamic_priority_max_ is initialized or changes, and is stored - // as a class member rather than being a derived value. - dynamic_priority_max_ = ul; - pending_shift_ = ACE_Time_Value (0, ul); -} - // set maximum supported priority value - -ACE_INLINE unsigned long -ACE_Dynamic_Message_Strategy::dynamic_priority_offset (void) const -{ - return dynamic_priority_offset_; -} - // get offset for boundary between signed range and unsigned range - -ACE_INLINE void -ACE_Dynamic_Message_Strategy::dynamic_priority_offset (unsigned long ul) -{ - // max_late_ and min_pending_ depend on dynamic_priority_offset_: - // for performance reasons, the values in max_late_ and min_pending_ - // are (re)calculated only when dynamic_priority_offset_ is - // initialized or changes, and are stored as a class member rather - // than being derived each time one of their values is needed. - dynamic_priority_offset_ = ul; - max_late_ = ACE_Time_Value (0, ul - 1); - min_pending_ = ACE_Time_Value (0, ul); -} - // set offset for boundary between signed range and unsigned range - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Dynamic_Service.cpp b/ACE/ace/Dynamic_Service.cpp deleted file mode 100644 index 53d762dc364..00000000000 --- a/ACE/ace/Dynamic_Service.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// $Id$ - -#ifndef ACE_DYNAMIC_SERVICE_CPP -#define ACE_DYNAMIC_SERVICE_CPP - -#include "ace/Dynamic_Service.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Service_Object.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Dynamic_Service.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - - -template TYPE * -ACE_Dynamic_Service::instance (const ACE_TCHAR *name) -{ - ACE_Service_Object * svc_obj = - static_cast - (ACE_Dynamic_Service_Base::instance (name,false)); - return dynamic_cast (svc_obj); -} - -template TYPE * -ACE_Dynamic_Service::instance (const ACE_TCHAR *name, - bool no_global) -{ - ACE_Service_Object * svc_obj = - static_cast - (ACE_Dynamic_Service_Base::instance (name, no_global)); - return dynamic_cast (svc_obj); -} - -template TYPE * -ACE_Dynamic_Service::instance (const ACE_Service_Gestalt* conf, - const ACE_TCHAR *name) -{ - ACE_Service_Object * svc_obj = - static_cast - (ACE_Dynamic_Service_Base::instance (conf, name, false)); - return dynamic_cast (svc_obj); -} - -template TYPE * -ACE_Dynamic_Service::instance (const ACE_Service_Gestalt* conf, - const ACE_TCHAR *name, - bool no_global) -{ - ACE_Service_Object * svc_obj = - static_cast - (ACE_Dynamic_Service_Base::instance (conf, name, no_global)); - return dynamic_cast (svc_obj); -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_DYNAMIC_SERVICE_CPP */ diff --git a/ACE/ace/Dynamic_Service.h b/ACE/ace/Dynamic_Service.h deleted file mode 100644 index ed7317ef562..00000000000 --- a/ACE/ace/Dynamic_Service.h +++ /dev/null @@ -1,89 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Dynamic_Service.h - * - * $Id$ - * - * @author Prashant Jain - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_DYNAMIC_SERVICE_H -#define ACE_DYNAMIC_SERVICE_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" -#include "ace/Global_Macros.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Dynamic_Service_Base.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -class ACE_Service_Object; - -/** - * @class ACE_Dynamic_Service - * - * @brief Provides a general interface to retrieve arbitrary objects - * from the ACE service repository. - * - * Uses "name" for lookup in the ACE service repository. Obtains - * the object and returns it as the appropriate type. - */ -template -class ACE_Dynamic_Service : public ACE_Dynamic_Service_Base -{ -public: - /// Return instance using @a name to search the Service_Repository. - static TYPE* instance (const ACE_TCHAR *name); - static TYPE* instance (const ACE_TCHAR *name, bool no_global); - - static TYPE* instance (const ACE_Service_Gestalt* repo, - const ACE_TCHAR *name); - static TYPE* instance (const ACE_Service_Gestalt* repo, - const ACE_TCHAR *name, bool no_global); - -#if defined (ACE_USES_WCHAR) - - /// Return instance using @a name to search the Service_Repository. - static TYPE* instance (const ACE_ANTI_TCHAR *name); - - static TYPE* instance (const ACE_ANTI_TCHAR *name, bool no_global); - - static TYPE* instance (const ACE_Service_Gestalt* repo, - const ACE_ANTI_TCHAR *name); - static TYPE* instance (const ACE_Service_Gestalt* repo, - const ACE_ANTI_TCHAR *name, bool no_global); -#endif // ACE_USES_WCHAR - -private: - ACE_UNIMPLEMENTED_FUNC (ACE_Dynamic_Service ()) - ACE_UNIMPLEMENTED_FUNC (ACE_Dynamic_Service (const ACE_Dynamic_Service&)) - ACE_UNIMPLEMENTED_FUNC (ACE_Dynamic_Service& operator= (const ACE_Dynamic_Service&)) -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Dynamic_Service.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -# include "ace/Dynamic_Service.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -# pragma implementation ("Dynamic_Service.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" - -#endif /* ACE_DYNAMIC_SERVICE_H */ diff --git a/ACE/ace/Dynamic_Service.inl b/ACE/ace/Dynamic_Service.inl deleted file mode 100644 index 48978c595ed..00000000000 --- a/ACE/ace/Dynamic_Service.inl +++ /dev/null @@ -1,40 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -#if defined (ACE_USES_WCHAR) - -template ACE_INLINE TYPE * -ACE_Dynamic_Service::instance (const ACE_ANTI_TCHAR *name) -{ - return instance (ACE_TEXT_CHAR_TO_TCHAR (name),false); -} - -template ACE_INLINE TYPE * -ACE_Dynamic_Service::instance (const ACE_ANTI_TCHAR *name, - bool no_global) -{ - return instance (ACE_TEXT_CHAR_TO_TCHAR (name),no_global); -} - -template ACE_INLINE TYPE * -ACE_Dynamic_Service::instance (const ACE_Service_Gestalt* repo, - const ACE_ANTI_TCHAR *name) -{ - return instance (repo, ACE_TEXT_CHAR_TO_TCHAR (name),false); -} - -template ACE_INLINE TYPE * -ACE_Dynamic_Service::instance (const ACE_Service_Gestalt* repo, - const ACE_ANTI_TCHAR *name, - bool no_global) -{ - return instance (repo, ACE_TEXT_CHAR_TO_TCHAR (name),no_global); -} - - -#endif // ACE_USES_WCHAR - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Dynamic_Service_Base.cpp b/ACE/ace/Dynamic_Service_Base.cpp deleted file mode 100644 index e93dde6e905..00000000000 --- a/ACE/ace/Dynamic_Service_Base.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include "ace/Dynamic_Service_Base.h" -#include "ace/ACE.h" -#include "ace/Service_Config.h" -#include "ace/Service_Repository.h" -#include "ace/Service_Types.h" -#include "ace/Log_Msg.h" - - -ACE_RCSID (ace, - Dynamic_Service_Base, - "$Id$") - - ACE_BEGIN_VERSIONED_NAMESPACE_DECL - - -void -ACE_Dynamic_Service_Base::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Dynamic_Service_Base::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -// Get the instance using for the current global -// service configuration repository. - -void * -ACE_Dynamic_Service_Base::instance (const ACE_TCHAR *name, bool no_global) -{ - ACE_TRACE ("ACE_Dynamic_Service_Base::instance"); - return instance (ACE_Service_Config::current (), name, no_global); -} - -// Find a service registration - -const ACE_Service_Type * -ACE_Dynamic_Service_Base::find_i (const ACE_Service_Gestalt* &repo, - const ACE_TCHAR *name, - bool no_global) -{ - ACE_TRACE ("ACE_Dynamic_Service_Base::find_i"); - const ACE_Service_Type *svc_rec = 0; - - ACE_Service_Gestalt* global = ACE_Service_Config::global (); - - for ( ; (repo->find (name, &svc_rec) == -1) && !no_global; repo = global) - { - // Check the static repo, too if different - if (repo == global) - break; - } - - return svc_rec; -} - - -// Get the instance using for specific configuration repository. -void * -ACE_Dynamic_Service_Base::instance (const ACE_Service_Gestalt* repo, - const ACE_TCHAR *name, - bool no_global) -{ - ACE_TRACE ("ACE_Dynamic_Service_Base::instance"); - - void *obj = 0; - const ACE_Service_Type_Impl *type = 0; - - const ACE_Service_Gestalt* repo_found = repo; - const ACE_Service_Type *svc_rec = find_i (repo_found, name, no_global); - if (svc_rec != 0) - { - type = svc_rec->type (); - if (type != 0) - obj = type->object (); - } - - if (ACE::debug ()) - { - ACE_Guard log_guard (*ACE_Log_Msg::instance ()); - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("ACE (%P|%t) DSB::instance, repo=%@, name=%s") - ACE_TEXT (" type=%@ => %@"), - repo->repo_, name, type, obj)); - - if (repo->repo_ != repo_found->repo_) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT (" [in repo=%@]\n"), - repo_found->repo_)); - else - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); - } - - return obj; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Dynamic_Service_Base.h b/ACE/ace/Dynamic_Service_Base.h deleted file mode 100644 index 7a039a1a6b2..00000000000 --- a/ACE/ace/Dynamic_Service_Base.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file Dynamic_Service_Base.h - * - * $Id$ - * - * @author Prashant Jain - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_DYNAMIC_SERVICE_BASE_H -#define ACE_DYNAMIC_SERVICE_BASE_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -class ACE_Service_Gestalt; -class ACE_Service_Type; - -/** - * @class ACE_Dynamic_Service_Base - * - * @brief Base class for all ACE_Dynamic_Service instantiations. - * - * Factors out common code shared by all ACE_Dynamic_Service - * instantiations, this avoid code bloat. - */ -class ACE_Export ACE_Dynamic_Service_Base -{ - -public: - /// Dump the current static of the object - void dump (void) const; - -protected: - /// Perform the default repo search, but optionally skip searching the global - /// repo. - static void* instance (const ACE_TCHAR *name, bool no_global = false); - - static void* instance (const ACE_Service_Gestalt* repo, - const ACE_TCHAR *name, - bool no_global = false); - - /// No need to create, or assign instances of this class - ACE_Dynamic_Service_Base (void); - ~ACE_Dynamic_Service_Base (void); - const ACE_Dynamic_Service_Base& operator= (const ACE_Dynamic_Service_Base&); - -private: - /// Implement the service search policy, i.e. "look for the service first - /// locally and then globally" - static const ACE_Service_Type *find_i (const ACE_Service_Gestalt* &repo, - const ACE_TCHAR *name, - bool no_global); - - /// The dependency declaration class needs access to the service search - /// policy, implemented by find_i() - friend class ACE_Dynamic_Service_Dependency; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#include /**/ "ace/post.h" -#endif /* ACE_DYNAMIC_SERVICE_BASE_H */ diff --git a/ACE/ace/Dynamic_Service_Dependency.cpp b/ACE/ace/Dynamic_Service_Dependency.cpp deleted file mode 100644 index f2a9b45d61c..00000000000 --- a/ACE/ace/Dynamic_Service_Dependency.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "ace/ACE.h" -#include "ace/DLL_Manager.h" -#include "ace/Dynamic_Service_Dependency.h" -#include "ace/Service_Config.h" -#include "ace/Log_Msg.h" - -ACE_RCSID (ace, - Dynamic_Service_Dependency, - "$Id$") - - - ACE_BEGIN_VERSIONED_NAMESPACE_DECL - - -ACE_Dynamic_Service_Dependency::ACE_Dynamic_Service_Dependency (const ACE_TCHAR *principal) -{ - this->init (ACE_Service_Config::current (), principal); -} - -ACE_Dynamic_Service_Dependency::ACE_Dynamic_Service_Dependency (const ACE_Service_Gestalt *cfg, - const ACE_TCHAR *principal) -{ - this->init (cfg, principal); -} - - -ACE_Dynamic_Service_Dependency::~ACE_Dynamic_Service_Dependency (void) -{ - if (ACE::debug ()) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) DSD, this=%@ - destroying\n"), - this)); -} - -void -ACE_Dynamic_Service_Dependency::init (const ACE_Service_Gestalt *cfg, - const ACE_TCHAR *principal) -{ - const ACE_Service_Type* st = - ACE_Dynamic_Service_Base::find_i (cfg, principal,false); - if (ACE::debug ()) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) DSD, this=%@ - creating dependency on "), this)); - st->dump (); - } - this->tracker_ = st->dll (); -} - - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Dynamic_Service_Dependency.h b/ACE/ace/Dynamic_Service_Dependency.h deleted file mode 100644 index 3eb4e0df7c7..00000000000 --- a/ACE/ace/Dynamic_Service_Dependency.h +++ /dev/null @@ -1,70 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Dynamic_Service_Dependency.h - * - * $Id$ - * - * @author Iliyan Jeliazkov - */ -//============================================================================= - -#ifndef ACE_DYNAMIC_SERVICE_DEPENDENCY_H -#define ACE_DYNAMIC_SERVICE_DEPENDENCY_H - -#include /**/ "ace/pre.h" - - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Dynamic_Service_Base.h" -#include "ace/Service_Object.h" -#include "ace/DLL.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Dynamic_Service_Dependency - * - * @brief Provides a way to declare dependency on specific service, - * thus helping to avoid order of initialization issues with instances - * of an objects whose implementation code resides in dynamically loaded - * services. - * - * It is disastrous to have dynamically loadable services create and give away - * ownership of objects and then ending up being unloaded before all those - * instances have been deleted. Normally the code for such objects classes - * resides within the TEXT segment of the DLL, which implements the service. - * If a service gets removed, its DLL may be unmapped from memory and then - * any attempt to invoke a method on the said objects will cause SEGV. - * - * Such instances must contain a member of ACE_Dynamic_Service_Dependency - * initialized with the service they depend on. - * ACE_Dynamic_Service_Dependency's constructor and destructor are - * "magical" - they work by maintaining the underlying dynamic service's - * DLL reference count. - */ -class ACE_Export ACE_Dynamic_Service_Dependency -{ -public: - ACE_Dynamic_Service_Dependency (const ACE_Service_Gestalt *cfg, - const ACE_TCHAR *principal); - ACE_Dynamic_Service_Dependency (const ACE_TCHAR *principal); - ~ACE_Dynamic_Service_Dependency (void); - -private: - void init (const ACE_Service_Gestalt *cfg, const ACE_TCHAR *principal); - -private: - ACE_DLL tracker_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - - -#include /**/ "ace/post.h" - -#endif /* ACE_DYNAMIC_SERVICE_DEPENDENCY_H */ diff --git a/ACE/ace/Encoding_Converter.cpp b/ACE/ace/Encoding_Converter.cpp deleted file mode 100644 index 60e561ea534..00000000000 --- a/ACE/ace/Encoding_Converter.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// $Id$ -#include "ace/Encoding_Converter.h" - -#if defined (ACE_USES_WCHAR) -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_Encoding_Converter::~ACE_Encoding_Converter (void) -{ -} - -ACE_END_VERSIONED_NAMESPACE_DECL -#endif /* ACE_USES_WCHAR */ diff --git a/ACE/ace/Encoding_Converter.h b/ACE/ace/Encoding_Converter.h deleted file mode 100644 index 7d5bd39b512..00000000000 --- a/ACE/ace/Encoding_Converter.h +++ /dev/null @@ -1,70 +0,0 @@ -// -*- C++ -*- - -//========================================================================= -/** - * @file Encoding_Converter.h - * - * $Id$ - * - * This class is the base class for all encoding converters that convert - * to and from UTF-8. - * - * @author Chad Elliott - */ -//========================================================================= - -#ifndef ACE_ENCODING_CONVERTER_H -#define ACE_ENCODING_CONVERTER_H - -#include /**/ "ace/pre.h" - -#include "ace/Basic_Types.h" - -#if defined (ACE_USES_WCHAR) -#include /**/ "ace/ACE_export.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** The base class for all ACE UTF Encoding Converters. - * This class provides a generic interface that is used to implement - * various UTF encoding conversion classes. - */ -class ACE_Export ACE_Encoding_Converter -{ -public: - /// This enum describes the various states that can be returned - /// from the to_utf8() and from_utf8() methods which depends on - /// both the source buffer and the size of the target buffer. - enum Result {CONVERSION_OK, - SOURCE_EXHAUSTED, - TARGET_EXHAUSTED, - SOURCE_ILLEGAL - }; - - /// This destructor is here (and virtual) because we have virtual - /// functions. - virtual ~ACE_Encoding_Converter (void); - - /// Convert the source (which can be in any encoding) to UTF-8 and - /// store it in the provided target buffer. - virtual Result to_utf8 (const void* source, - size_t source_size, - ACE_Byte* target, - size_t target_size, - bool strict = true) = 0; - - /// Convert the UTF-8 source into an alternate encoding and store it - /// in the provided target buffer. - virtual Result from_utf8 (const ACE_Byte* source, - size_t source_size, - void* target, - size_t target_size, - bool strict = true) = 0; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL -#endif /* ACE_USES_WCHAR */ - -#include /**/ "ace/post.h" - -#endif /* ACE_ENCODING_CONVERTER_H */ diff --git a/ACE/ace/Encoding_Converter_Factory.cpp b/ACE/ace/Encoding_Converter_Factory.cpp deleted file mode 100644 index 8cf1ed22c3f..00000000000 --- a/ACE/ace/Encoding_Converter_Factory.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// $Id$ -#include "ace/Encoding_Converter_Factory.h" - -#if defined (ACE_USES_WCHAR) -#include "ace/UTF32_Encoding_Converter.h" -#include "ace/UTF16_Encoding_Converter.h" -#include "ace/UTF8_Encoding_Converter.h" -#include "ace/OS_Memory.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_Encoding_Converter* -ACE_Encoding_Converter_Factory::create ( - const ACE_Byte* source, - size_t source_size, - ACE_Encoding_Converter_Factory::Encoding_Hint hint) -{ -#if defined (ACE_BIG_ENDIAN) - bool const convert_for_bigendian = true; -#else - bool const convert_for_bigendian = false; -#endif /* ACE_BIG_ENDIAN */ - ACE_Encoding_Converter* converter = 0; - - switch (hint) - { - case ACE_UTF_32BE: - ACE_NEW_RETURN (converter, - ACE_UTF32_Encoding_Converter (!convert_for_bigendian), - 0); - break; - case ACE_UTF_32LE: - ACE_NEW_RETURN (converter, - ACE_UTF32_Encoding_Converter (convert_for_bigendian), - 0); - break; - case ACE_UTF_16BE: - ACE_NEW_RETURN (converter, - ACE_UTF16_Encoding_Converter (!convert_for_bigendian), - 0); - break; - case ACE_UTF_16LE: - ACE_NEW_RETURN (converter, - ACE_UTF16_Encoding_Converter (convert_for_bigendian), - 0); - break; - case ACE_UTF_8: - ACE_NEW_RETURN (converter, - ACE_UTF8_Encoding_Converter, - 0); - break; - default: - // First check for ASCII since much of ASCII text will appear to - // convert from UTF-16 to UTF-8. - converter = ACE_UTF8_Encoding_Converter::encoded (source, source_size); - if (converter != 0) - return converter; - - // Check for UTF-32 - converter = ACE_UTF32_Encoding_Converter::encoded (source, source_size); - if (converter != 0) - return converter; - - // Check for UTF-16 - converter = ACE_UTF16_Encoding_Converter::encoded (source, source_size); - if (converter != 0) - return converter; - } - - return converter; -} - -ACE_END_VERSIONED_NAMESPACE_DECL -#endif /* ACE_USES_WCHAR */ diff --git a/ACE/ace/Encoding_Converter_Factory.h b/ACE/ace/Encoding_Converter_Factory.h deleted file mode 100644 index 11ec541ebae..00000000000 --- a/ACE/ace/Encoding_Converter_Factory.h +++ /dev/null @@ -1,54 +0,0 @@ -// -*- C++ -*- - -//========================================================================= -/** - * @file Encoding_Converter_Factory.h - * - * $Id$ - * - * This class can be used to create encoding converters of various types. - * - * @author Chad Elliott - */ -//========================================================================= - -#ifndef ACE_ENCODING_CONVERTER_FACTORY_H -#define ACE_ENCODING_CONVERTER_FACTORY_H - -#include /**/ "ace/pre.h" - -#include "ace/Basic_Types.h" - -#if defined (ACE_USES_WCHAR) -#include /**/ "ace/ACE_export.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -class ACE_Encoding_Converter; - -/** Create an encoding converter based on the source or hint. - * This class allows users to avoid knowing any concrete converter types. - */ -class ACE_Export ACE_Encoding_Converter_Factory -{ -public: - /// This enum is used to tell what type of converter to create. - enum Encoding_Hint { ACE_UTF_32BE, ACE_UTF_32LE, - ACE_UTF_16BE, ACE_UTF_16LE, - ACE_UTF_8, ACE_NONE - }; - - /// Create an encoding converter based on the source. If a hint is - /// given, it just creates the specified type of converter without looking - /// at the source. - static ACE_Encoding_Converter* create (const ACE_Byte* source, - size_t source_size, - Encoding_Hint hint = ACE_NONE); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL -#endif /* ACE_USES_WCHAR */ - -#include /**/ "ace/post.h" - -#endif /* ACE_ENCODING_CONVERTER_FACTORY_H */ diff --git a/ACE/ace/Env_Value_T.cpp b/ACE/ace/Env_Value_T.cpp deleted file mode 100644 index 788bf125fc5..00000000000 --- a/ACE/ace/Env_Value_T.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// $Id$ - -#ifndef ACE_ENV_VALUE_T_CPP -#define ACE_ENV_VALUE_T_CPP - -#include "ace/Env_Value_T.h" - -#if ! defined (__ACE_INLINE__) -#include "ace/Env_Value_T.inl" -#endif /* __ACE_INLINE__ */ - -#endif /* ACE_ENV_VALUE_T_CPP */ diff --git a/ACE/ace/Env_Value_T.h b/ACE/ace/Env_Value_T.h deleted file mode 100644 index 01f4fcc5e8d..00000000000 --- a/ACE/ace/Env_Value_T.h +++ /dev/null @@ -1,166 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Env_Value_T.h - * - * $Id$ - * - * Template to encapsulate getting a value from an environment variable - * and using a supplied default value if not in the environment. - * - * - * @author Chris Cleeland (derived from work by Carlos O'Ryan) - */ -//============================================================================= - -#ifndef ACE_ENV_VALUE_T_H -#define ACE_ENV_VALUE_T_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" -#include "ace/Global_Macros.h" -#include "ace/OS_NS_stdlib.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Env_Value - * - * @brief Environment Variable Value - * - * Reads a variable from the user environment, providing a default - * value. - */ -template -class ACE_Env_Value -{ -public: - /** - * Default constructor which isn't bound to a specific environment - * variable name or a default value. Before being useful it must - * 'd. - */ - ACE_Env_Value (void); - - /// Constructor that calls . - ACE_Env_Value (const ACE_TCHAR *varname, - const T &vardefault); - - /// Destroy the value. - ~ACE_Env_Value (void); - - /// Returns the value as type T. - operator T (void); - - /// The constructor, read @a varname from the environment, using - /// @a defval as its value if it is not defined. - void open (const ACE_TCHAR *varname, const T &defval); - - /// Returns the name of the variable being tracked. - const ACE_TCHAR *varname (void) const; - -private: - /// Disallow copying and assignment. - ACE_UNIMPLEMENTED_FUNC (ACE_Env_Value(const ACE_Env_Value &)) - ACE_UNIMPLEMENTED_FUNC (ACE_Env_Value operator=(const ACE_Env_Value &)) - - void fetch_value (void); - - const ACE_TCHAR *varname_; - T value_; -}; - -/// Function to convert a string @a s into type @c T. -template void ACE_Convert (const ACE_TCHAR *s, T &t); - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Env_Value_T.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Env_Value_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template <> inline void -ACE_Convert (const ACE_TCHAR *s, ACE_TCHAR *&v) -{ - v = (ACE_TCHAR *) s; -} - -template <> inline void -ACE_Convert (const ACE_TCHAR *s, const ACE_TCHAR *&v) -{ - v = (const ACE_TCHAR *) s; -} - -template <> inline void -ACE_Convert (const ACE_TCHAR *s, short &si) -{ - si = static_cast (ACE_OS::strtol (s, 0, 10)); -} - -template <> inline void -ACE_Convert (const ACE_TCHAR *s, u_short &us) -{ - us = static_cast (ACE_OS::strtol (s, 0, 10)); -} - -template <> inline void -ACE_Convert (const ACE_TCHAR *s, u_int &i) -{ - i = static_cast (ACE_OS::strtol (s, 0, 10)); -} - -template <> inline void -ACE_Convert (const ACE_TCHAR *s, long &l) -{ - l = ACE_OS::strtol (s, 0, 10); -} - -template <> inline void -ACE_Convert (const ACE_TCHAR *s, int &i) -{ - i = static_cast (ACE_OS::strtol (s, 0, 10)); -} - -template <> inline void -ACE_Convert (const ACE_TCHAR *s, u_long &ul) -{ - ul = ACE_OS::strtoul (s, 0, 10); -} - -template <> inline void -ACE_Convert (const ACE_TCHAR *s, double &d) -{ - d = ACE_OS::strtod (s, 0); -} - -// Default calls a CTOR on type T of the form 'T::T(const char*)', but -// users can feel free to create their own specialized conversion -// functions if necessary, as shown above. Note that for 'char*' the -// default is used because a simple cast will be performed and no -// conversion will be necessary. -template inline void -ACE_Convert (const ACE_TCHAR *s, T &t) -{ - t = T (s); -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Env_Value_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" -#endif /* ACE_ENV_VALUE_T_H */ diff --git a/ACE/ace/Env_Value_T.inl b/ACE/ace/Env_Value_T.inl deleted file mode 100644 index 63fe8df1f29..00000000000 --- a/ACE/ace/Env_Value_T.inl +++ /dev/null @@ -1,60 +0,0 @@ -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template ACE_INLINE -ACE_Env_Value::operator T (void) -{ - return value_; -} - -template ACE_INLINE -ACE_Env_Value::ACE_Env_Value (void) - : varname_ (0) -{ -} - -template ACE_INLINE -ACE_Env_Value::ACE_Env_Value (const ACE_TCHAR *varname, - const T &defval) - : varname_ (varname), - value_(defval) -{ - this->fetch_value (); -} - -template ACE_INLINE void -ACE_Env_Value::open (const ACE_TCHAR *varname, - const T &defval) -{ - this->varname_ = varname; - this->value_ = defval; - this->fetch_value (); -} - -template ACE_INLINE void -ACE_Env_Value::fetch_value (void) -{ -#if defined (ACE_WIN32) - const ACE_TCHAR *env = ACE_OS::getenv (this->varname_); - if (env != 0) - ACE_Convert (env, value_); -#else - char *nenv = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (this->varname_)); - if (nenv != 0) - ACE_Convert (ACE_TEXT_CHAR_TO_TCHAR (nenv), this->value_); -#endif -} - -template ACE_INLINE const ACE_TCHAR* -ACE_Env_Value::varname (void) const -{ - return this->varname_; -} - -template ACE_INLINE -ACE_Env_Value::~ACE_Env_Value (void) -{ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Event.cpp b/ACE/ace/Event.cpp deleted file mode 100644 index e185ec37117..00000000000 --- a/ACE/ace/Event.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// $Id$ - -#include "ace/Event.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Event.inl" -#endif /* __ACE_INLINE__ */ - -#include "ace/Log_Msg.h" - -ACE_RCSID(ace, Event, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_Event::ACE_Event (int manual_reset, - int initial_state, - int type, - const ACE_TCHAR *name, - void *arg, - LPSECURITY_ATTRIBUTES sa) - : removed_ (false) -{ - if (ACE_OS::event_init (&this->handle_, - manual_reset, - initial_state, - type, - name, - arg, - sa) != 0) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Event::ACE_Event"))); -} - -ACE_Event::~ACE_Event (void) -{ - this->remove (); -} - -int -ACE_Event::remove (void) -{ - int result = 0; - if (!this->removed_) - { - this->removed_ = true; - result = ACE_OS::event_destroy (&this->handle_); - } - return result; -} - -int -ACE_Event::wait (void) -{ - return ACE_OS::event_wait (&this->handle_); -} - -int -ACE_Event::wait (const ACE_Time_Value *abstime, int use_absolute_time) -{ - return ACE_OS::event_timedwait (&this->handle_, - const_cast (abstime), - use_absolute_time); -} - -int -ACE_Event::signal (void) -{ - return ACE_OS::event_signal (&this->handle_); -} - -int -ACE_Event::pulse (void) -{ - return ACE_OS::event_pulse (&this->handle_); -} - -int -ACE_Event::reset (void) -{ - return ACE_OS::event_reset (&this->handle_); -} - -void -ACE_Event::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Event.h b/ACE/ace/Event.h deleted file mode 100644 index 177c0039df1..00000000000 --- a/ACE/ace/Event.h +++ /dev/null @@ -1,143 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file Event.h - * - * $Id$ - * - * Moved from Synch.h. - * - * @author Douglas C. Schmidt - */ -//========================================================================== - -#ifndef ACE_EVENT_H -#define ACE_EVENT_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/OS_NS_Thread.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Event - * - * @brief A wrapper around the Win32 event locking mechanism. - * - * Portable implementation of an Event mechanism, which is native to - * Win32, but must be emulated on UNIX. All platforms support - * process-scope locking support. However, only Win32 platforms - * support global naming and system-scope locking support. - */ -class ACE_Export ACE_Event -{ -public: - /// Constructor that creates event. - ACE_Event (int manual_reset = 0, - int initial_state = 0, - int type = USYNC_THREAD, - const ACE_TCHAR *name = 0, - void *arg = 0, - LPSECURITY_ATTRIBUTES sa = 0); - - /// Implicitly destroy the event variable. - ~ACE_Event (void); - - /** - * Explicitly destroy the event variable. Note that only one thread - * should call this method since it doesn't protect against race - * conditions. - */ - int remove (void); - - /// Underlying handle to event. - ACE_event_t handle (void) const; - - /** - * Set the underlying handle to event. Note that this method assumes - * ownership of the and will close it down in . If - * you want the to stay open when is called make - * sure to call on the before closing it. You are - * responsible for the closing the existing before - * overwriting it. - */ - void handle (ACE_event_t new_handle); - - /** - * if MANUAL reset - * sleep till the event becomes signaled - * event remains signaled after wait() completes. - * else AUTO reset - * sleep till the event becomes signaled - * event resets wait() completes. - */ - int wait (void); - - /// Same as wait() above, but this one can be timed - /// @a abstime is absolute time-of-day if if @a use_absolute_time - /// is non-0, else it is relative time. - int wait (const ACE_Time_Value *abstime, - int use_absolute_time = 1); - - /** - * if MANUAL reset - * wake up all waiting threads - * set to signaled state - * else AUTO reset - * if no thread is waiting, set to signaled state - * if thread(s) are waiting, wake up one waiting thread and - * reset event - */ - int signal (void); - - /** - * if MANUAL reset - * wakeup all waiting threads and - * reset event - * else AUTO reset - * wakeup one waiting thread (if present) and - * reset event - */ - int pulse (void); - - /// Set to nonsignaled state. - int reset (void); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks - ACE_ALLOC_HOOK_DECLARE; - -protected: - /// The underlying handle. - ACE_event_t handle_; - - /// Keeps track of whether has been called yet to avoid - /// multiple calls, e.g., explicitly and implicitly in the - /// destructor. This flag isn't protected by a lock, so make sure - /// that you don't have multiple threads simultaneously calling - /// on the same object, which is a bad idea anyway... - bool removed_; - -private: - // = Prevent copying. - ACE_Event (const ACE_Event& event); - const ACE_Event &operator= (const ACE_Event &rhs); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Event.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_EVENT_H */ diff --git a/ACE/ace/Event.inl b/ACE/ace/Event.inl deleted file mode 100644 index 188d7c202cf..00000000000 --- a/ACE/ace/Event.inl +++ /dev/null @@ -1,18 +0,0 @@ -// -*- C++ -*- -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE ACE_event_t -ACE_Event::handle (void) const -{ - return this->handle_; -} - -ACE_INLINE void -ACE_Event::handle (ACE_event_t new_handle) -{ - this->handle_ = new_handle; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Event_Handler.cpp b/ACE/ace/Event_Handler.cpp deleted file mode 100644 index d4542b61349..00000000000 --- a/ACE/ace/Event_Handler.cpp +++ /dev/null @@ -1,396 +0,0 @@ -// Event_Handler.cpp -// $Id$ - -#include "ace/Event_Handler.h" -#include "ace/OS_Errno.h" -#include "ace/Reactor.h" -#include "ace/Thread_Manager.h" -/* Need to see if ACE_HAS_BUILTIN_ATOMIC_OP defined */ -#include "ace/Atomic_Op.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Event_Handler.inl" -#endif /* __ACE_INLINE__ */ - -#include - -ACE_RCSID(ace, Event_Handler, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Implement conceptually abstract virtual functions in the base class -// so derived classes don't have to implement unused ones. - -ACE_Event_Handler::ACE_Event_Handler (ACE_Reactor *r, - int p) - : reference_count_ (1), - priority_ (p), - reactor_ (r), - reference_counting_policy_ (Reference_Counting_Policy::DISABLED) -{ - // ACE_TRACE ("ACE_Event_Handler::ACE_Event_Handler"); -} - -ACE_Event_Handler::~ACE_Event_Handler (void) -{ - // ACE_TRACE ("ACE_Event_Handler::~ACE_Event_Handler"); -} - -// Gets the file descriptor associated with this I/O device. - -ACE_HANDLE -ACE_Event_Handler::get_handle (void) const -{ - ACE_TRACE ("ACE_Event_Handler::get_handle"); - return ACE_INVALID_HANDLE; -} - -// Sets the file descriptor associated with this I/O device. - -void -ACE_Event_Handler::set_handle (ACE_HANDLE) -{ - ACE_TRACE ("ACE_Event_Handler::set_handle"); -} - -// Gets the priority of this handler. - -int -ACE_Event_Handler::priority (void) const -{ - ACE_TRACE ("ACE_Event_Handler::priority"); - return this->priority_; -} - -// Sets the priority - -void -ACE_Event_Handler::priority (int priority) -{ - ACE_TRACE ("ACE_Event_Handler::priority"); - this->priority_ = priority; -} - -// Called when the object is about to be removed from the Dispatcher -// tables. - -int -ACE_Event_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) -{ - ACE_TRACE ("ACE_Event_Handler::handle_close"); - return -1; -} - -// Called when input becomes available on fd. - -int -ACE_Event_Handler::handle_input (ACE_HANDLE) -{ - ACE_TRACE ("ACE_Event_Handler::handle_input"); - return -1; -} - -// Called when output is possible on fd. - -int -ACE_Event_Handler::handle_output (ACE_HANDLE) -{ - ACE_TRACE ("ACE_Event_Handler::handle_output"); - return -1; -} - -// Called when urgent data is available on fd. - -int -ACE_Event_Handler::handle_exception (ACE_HANDLE) -{ - ACE_TRACE ("ACE_Event_Handler::handle_exception"); - return -1; -} - -// Called when timer expires, TV stores the current time. - -int -ACE_Event_Handler::handle_timeout (const ACE_Time_Value &, const void *) -{ - ACE_TRACE ("ACE_Event_Handler::handle_timeout"); - return -1; -} - -// Called when a monitored Process exits - -int -ACE_Event_Handler::handle_exit (ACE_Process *) -{ - ACE_TRACE ("ACE_Event_Handler::handle_exit"); - return -1; -} - -// Called when a registered signal occurs. - -int -ACE_Event_Handler::handle_signal (int, siginfo_t *, ucontext_t *) -{ - ACE_TRACE ("ACE_Event_Handler::handle_signal"); - return -1; -} - -int -ACE_Event_Handler::resume_handler (void) -{ - ACE_TRACE ("ACE_Event_Handler::resume_handler"); - - // Return a default value and allow the reactor to take care of - // resuming the handler - return ACE_Event_Handler::ACE_REACTOR_RESUMES_HANDLER; -} - - -int -ACE_Event_Handler::handle_qos (ACE_HANDLE) -{ - ACE_TRACE ("ACE_Event_Handler::handle_qos"); - return -1; -} - -int -ACE_Event_Handler::handle_group_qos (ACE_HANDLE) -{ - ACE_TRACE ("ACE_Event_Handler::handle_group_qos"); - return -1; -} - -void -ACE_Event_Handler::reactor (ACE_Reactor *reactor) -{ - ACE_TRACE ("ACE_Event_Handler::reactor"); - this->reactor_ = reactor; -} - -ACE_Reactor * -ACE_Event_Handler::reactor (void) const -{ - ACE_TRACE ("ACE_Event_Handler::reactor"); - return this->reactor_; -} - -ACE_Reactor_Timer_Interface * -ACE_Event_Handler::reactor_timer_interface (void) const -{ - ACE_TRACE ("ACE_Event_Handler::reactor_timer_interface"); - return this->reactor_; -} - -ACE_Event_Handler::Reference_Count -ACE_Event_Handler::add_reference (void) -{ - bool const reference_counting_required = - this->reference_counting_policy ().value () == - ACE_Event_Handler::Reference_Counting_Policy::ENABLED; - - if (reference_counting_required) - return ++this->reference_count_; - else - return 1; -} - -ACE_Event_Handler::Reference_Count -ACE_Event_Handler::remove_reference (void) -{ - bool const reference_counting_required = - this->reference_counting_policy ().value () == - ACE_Event_Handler::Reference_Counting_Policy::ENABLED; - - if (reference_counting_required) - { - Reference_Count result = - --this->reference_count_; - - if (result == 0) - delete this; - - return result; - } - else - { - return 1; - } -} - -ACE_Event_Handler::Policy::~Policy (void) -{ -} - -ACE_Event_Handler::Reference_Counting_Policy::Reference_Counting_Policy (Reference_Counting_Policy::Value value) - : value_ (value) -{ -} - -ACE_Event_Handler::Reference_Counting_Policy::Value -ACE_Event_Handler::Reference_Counting_Policy::value (void) const -{ - return this->value_; -} - -void -ACE_Event_Handler::Reference_Counting_Policy::value (ACE_Event_Handler::Reference_Counting_Policy::Value value) -{ - this->value_ = value; -} - -ACE_Event_Handler::Reference_Counting_Policy & -ACE_Event_Handler::reference_counting_policy (void) -{ - return this->reference_counting_policy_; -} - -//#if !defined (ACE_HAS_WINCE) - -ACE_THR_FUNC_RETURN -ACE_Event_Handler::read_adapter (void *args) -{ - ACE_Event_Handler *this_ptr = static_cast (args); - ACE_Reactor *r = this_ptr->reactor (); - - while (this_ptr->handle_input (ACE_STDIN) != -1) - continue; - - this_ptr->handle_close (ACE_STDIN, ACE_Event_Handler::READ_MASK); - // It's possible for handle_close() to "delete this" so we need to - // cache the reactor pointer and use it here. - r->notify (); - - return 0; -} - -int -ACE_Event_Handler::register_stdin_handler (ACE_Event_Handler *eh, - ACE_Reactor *reactor, - ACE_Thread_Manager *thr_mgr, - int flags) -{ -#if defined (ACE_WIN32) - ACE_UNUSED_ARG (reactor); - - eh->reactor (reactor); - return thr_mgr->spawn (&read_adapter, static_cast (eh), flags); -#else - // Keep compilers happy. - ACE_UNUSED_ARG (flags); - ACE_UNUSED_ARG (thr_mgr); - return reactor->register_handler (ACE_STDIN, - eh, - ACE_Event_Handler::READ_MASK); -#endif /* ACE_WIN32 */ -} - -int -ACE_Event_Handler::remove_stdin_handler (ACE_Reactor *reactor, - ACE_Thread_Manager * /* thr_mgr */) -{ -#if defined (ACE_WIN32) - ACE_UNUSED_ARG (reactor); - - // What should we do here? - ACE_NOTSUP_RETURN (-1); -#else - return reactor->remove_handler (ACE_STDIN, - ACE_Event_Handler::READ_MASK); -#endif /* ACE_WIN32 */ -} - -//#endif /* ACE_HAS_WINCE */ - -// --------------------------------------------------------------------- - -ACE_Event_Handler_var::ACE_Event_Handler_var (void) - : ptr_ (0) -{ -} - -ACE_Event_Handler_var::ACE_Event_Handler_var (ACE_Event_Handler *p) - : ptr_ (p) -{ -} - -ACE_Event_Handler_var::ACE_Event_Handler_var (const ACE_Event_Handler_var &b) - : ptr_ (b.ptr_) -{ - if (this->ptr_ != 0) - { - this->ptr_->add_reference (); - } -} - -ACE_Event_Handler_var::~ACE_Event_Handler_var (void) -{ - if (this->ptr_ != 0) - { - ACE_Errno_Guard eguard (errno); - this->ptr_->remove_reference (); - } -} - -ACE_Event_Handler_var & -ACE_Event_Handler_var::operator= (ACE_Event_Handler *p) -{ - if (this->ptr_ != p) - { - ACE_Event_Handler_var tmp (p); - std::swap (this->ptr_, tmp.ptr_); - } - - return *this; -} - -ACE_Event_Handler_var & -ACE_Event_Handler_var::operator= (const ACE_Event_Handler_var &b) -{ - ACE_Event_Handler_var tmp (b); - std::swap (this->ptr_, tmp.ptr_); - - return *this; -} - -ACE_Event_Handler * -ACE_Event_Handler_var::operator->() const -{ - return this->ptr_; -} - -ACE_Event_Handler * -ACE_Event_Handler_var::handler (void) const -{ - return this->ptr_; -} - -ACE_Event_Handler * -ACE_Event_Handler_var::release (void) -{ - ACE_Event_Handler * const old = this->ptr_; - this->ptr_ = 0; - return old; -} - -void -ACE_Event_Handler_var::reset (ACE_Event_Handler *p) -{ - *this = p; -} - -// --------------------------------------------------------------------- - -ACE_Notification_Buffer::ACE_Notification_Buffer (void) -{ - ACE_TRACE ("ACE_Notification_Buffer::ACE_Notification_Buffer"); -} - -ACE_Notification_Buffer::ACE_Notification_Buffer (ACE_Event_Handler *eh, - ACE_Reactor_Mask mask) - : eh_ (eh), - mask_ (mask) -{ - ACE_TRACE ("ACE_Notification_Buffer::ACE_Notification_Buffer"); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Event_Handler.h b/ACE/ace/Event_Handler.h deleted file mode 100644 index 3ccaf1d1aa0..00000000000 --- a/ACE/ace/Event_Handler.h +++ /dev/null @@ -1,388 +0,0 @@ -/* -*- C++ -*- */ - -//========================================================================== -/** - * @file Event_Handler.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//========================================================================== - -#ifndef ACE_EVENT_HANDLER_H -#define ACE_EVENT_HANDLER_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/os_include/os_signal.h" -#include "ace/Atomic_Op.h" -#include "ace/Synch_Traits.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Forward declaration. -class ACE_Message_Block; -class ACE_Reactor; -class ACE_Reactor_Timer_Interface; -class ACE_Thread_Manager; -class ACE_Process; - -typedef unsigned long ACE_Reactor_Mask; - -/** - * @class ACE_Event_Handler - * - * @brief Provides an abstract interface for handling various types of - * I/O, timer, and signal events. - * - * Subclasses read/write input/output on an I/O descriptor, - * handle an exception raised on an I/O descriptor, handle a - * timer's expiration, or handle a signal. - */ -class ACE_Export ACE_Event_Handler -{ -public: - enum - { - LO_PRIORITY = 0, - HI_PRIORITY = 10, - NULL_MASK = 0, -#if defined (ACE_USE_POLL) - READ_MASK = POLLIN, - WRITE_MASK = POLLOUT, - EXCEPT_MASK = POLLPRI, -#else /* USE SELECT */ - READ_MASK = (1 << 0), - WRITE_MASK = (1 << 1), - EXCEPT_MASK = (1 << 2), -#endif /* ACE_USE_POLL */ - ACCEPT_MASK = (1 << 3), - CONNECT_MASK = (1 << 4), - TIMER_MASK = (1 << 5), - QOS_MASK = (1 << 6), - GROUP_QOS_MASK = (1 << 7), - SIGNAL_MASK = (1 << 8), - ALL_EVENTS_MASK = READ_MASK | - WRITE_MASK | - EXCEPT_MASK | - ACCEPT_MASK | - CONNECT_MASK | - TIMER_MASK | - QOS_MASK | - GROUP_QOS_MASK | - SIGNAL_MASK, - RWE_MASK = READ_MASK | - WRITE_MASK | - EXCEPT_MASK, - DONT_CALL = (1 << 9) - }; - - /// Destructor is virtual to enable proper cleanup. - virtual ~ACE_Event_Handler (void); - - /// Get the I/O handle. - virtual ACE_HANDLE get_handle (void) const; - - /// Set the I/O handle. - virtual void set_handle (ACE_HANDLE); - - // = Get/set priority - - // Priorities run from MIN_PRIORITY (which is the "lowest priority") - // to MAX_PRIORITY (which is the "highest priority"). - /// Get the priority of the Event_Handler. - virtual int priority (void) const; - - /// Set the priority of the Event_Handler. - virtual void priority (int priority); - - /// Called when input events occur (e.g., connection or data). - virtual int handle_input (ACE_HANDLE fd = ACE_INVALID_HANDLE); - - /// Called when output events are possible (e.g., when flow control - /// abates or non-blocking connection completes). - virtual int handle_output (ACE_HANDLE fd = ACE_INVALID_HANDLE); - - /// Called when an exceptional events occur (e.g., SIGURG). - virtual int handle_exception (ACE_HANDLE fd = ACE_INVALID_HANDLE); - - /** - * Called when timer expires. @a current_time represents the current - * time that the was selected for timeout - * dispatching and @a act is the asynchronous completion token that - * was passed in when was invoked. - */ - virtual int handle_timeout (const ACE_Time_Value ¤t_time, - const void *act = 0); - - /// Called when a process exits. - virtual int handle_exit (ACE_Process *); - - /// Called when a method returns -1 or when the - /// method is called on an ACE_Reactor. The - /// @a close_mask indicates which event has triggered the - /// method callback on a particular @a handle. - virtual int handle_close (ACE_HANDLE handle, - ACE_Reactor_Mask close_mask); - - /// Called when object is signaled by OS (either via UNIX signals or - /// when a Win32 object becomes signaled). - virtual int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); - - enum - { - /// The handler is not resumed at all. Could lead to deadlock.. - ACE_EVENT_HANDLER_NOT_RESUMED = -1, - /// The reactor takes responsibility of resuming the handler and - /// is the default - ACE_REACTOR_RESUMES_HANDLER = 0, - /// The application takes responsibility of resuming the handler - ACE_APPLICATION_RESUMES_HANDLER - }; - /** - * Called to figure out whether the handler needs to resumed by the - * reactor or the application can take care of it. The default - * value of 0 would be returned which would allow the reactor to - * take care of resumption of the handler. The application can - * return a value more than zero and decide to resume the handler - * themseleves. - * - * @note This method is only useful for the ACE_TP_Reactor. Sad - * that we have to have this method in a class that is supposed to - * be used across different components in ACE. - */ - virtual int resume_handler (void); - - virtual int handle_qos (ACE_HANDLE = ACE_INVALID_HANDLE); - virtual int handle_group_qos (ACE_HANDLE = ACE_INVALID_HANDLE); - - // = Accessors to set/get the various event demultiplexors. - /// Set the event demultiplexors. - virtual void reactor (ACE_Reactor *reactor); - - /// Get the event demultiplexors. - virtual ACE_Reactor *reactor (void) const; - - /// Get only the reactor's timer related interface. - virtual ACE_Reactor_Timer_Interface *reactor_timer_interface (void) const; - - /** - * Used to read from non-socket ACE_HANDLEs in our own thread to - * work around Win32 limitations that don't allow us to 'able on - * Win32. - */ - static int register_stdin_handler (ACE_Event_Handler *eh, - ACE_Reactor *reactor, - ACE_Thread_Manager *thr_mgr, - int flags = THR_DETACHED); - - /// Performs the inverse of the method. - static int remove_stdin_handler (ACE_Reactor *reactor, - ACE_Thread_Manager *thr_mgr); - - /// Reference count type. - typedef long Reference_Count; - - /// Increment reference count on the handler. - /** - * This method is called when the handler is registered with the - * Reactor and when the Reactor makes an upcall on the handler. - * Reference count is 1 when the handler is created. - * - * @return Current reference count. - */ - virtual Reference_Count add_reference (void); - - /// Decrement reference count on the handler. - /** - * This method is called when the handler is removed from the - * Reactor and when an upcall made on the handler by the Reactor - * completes. Handler is deleted when the reference count reaches - * 0. - * - * @return Current reference count. - */ - virtual Reference_Count remove_reference (void); - - /** - * @class Policy - * - * @brief Base class for all handler policies. - */ - class ACE_Export Policy - { - - public: - - /// Virtual destructor. - virtual ~Policy (void); - }; - - /** - * @class Reference_Counting_Policy - * - * @brief This policy dictates the reference counting requirements - * for the handler. - * - * This policy allows applications to configure whether it wants the - * Reactor to call add_reference() and remove_reference() during - * registrations, removals, and upcalls. - * - * Default: DISABLED. - */ - class ACE_Export Reference_Counting_Policy : public Policy - { - /// This policy can only be created by the handler. - friend class ACE_Event_Handler; - - public: - - enum Value - { - /// Perform reference counting. - ENABLED, - /// Don't perform reference counting. - DISABLED - }; - - /// Current Reference_Counting_Policy. - Value value (void) const; - - /// Update Reference_Counting_Policy. - void value (Value value); - - private: - - /// Private constructor. - Reference_Counting_Policy (Value value); - - /// The value of the policy. - Value value_; - }; - - /// Current Reference_Counting_Policy. - Reference_Counting_Policy &reference_counting_policy (void); - -protected: - /// Force ACE_Event_Handler to be an abstract base class. - ACE_Event_Handler (ACE_Reactor * = 0, - int priority = ACE_Event_Handler::LO_PRIORITY); - - /// Typedef for implementation of reference counting. - typedef ACE_Atomic_Op Atomic_Reference_Count; - - /// Reference count. - Atomic_Reference_Count reference_count_; - -private: - - /// Priority of this Event_Handler. - int priority_; - - /// Pointer to the various event demultiplexors. - ACE_Reactor *reactor_; - - /// Reference counting requirements. - Reference_Counting_Policy reference_counting_policy_; -}; - -/** - * @class ACE_Event_Handler_var - * - * @brief Auto pointer like class for Event Handlers. - * - * Used to manage lifecycle of handlers. This class calls - * ACE_Event_Handler::remove_reference() in its destructor. - */ -class ACE_Export ACE_Event_Handler_var -{ - -public: - - /// Default constructor. - ACE_Event_Handler_var (void); - - /// Construct with a handler. - ACE_Event_Handler_var (ACE_Event_Handler *p); - - /// Copy constructor. - ACE_Event_Handler_var (const ACE_Event_Handler_var &b); - - /// Destructor. - ~ACE_Event_Handler_var (void); - - /// Assignment to a handler. - ACE_Event_Handler_var &operator= (ACE_Event_Handler *p); - - /// Assignment to a ACE_Event_Handler_var. - ACE_Event_Handler_var &operator= (const ACE_Event_Handler_var &b); - - /// Overloaded "->". - ACE_Event_Handler *operator-> () const; - - /// Access the handler. - ACE_Event_Handler *handler (void) const; - - /// Release the handler. - ACE_Event_Handler *release (void); - - /// Reset the handler. - void reset (ACE_Event_Handler *p = 0); - -private: - - /// Handler. - ACE_Event_Handler *ptr_; -}; - -/** - * @class ACE_Notification_Buffer - * - * @brief Simple wrapper for passing s and - * ACE_Reactor_Masks between threads. - */ -class ACE_Export ACE_Notification_Buffer -{ -public: - ACE_Notification_Buffer (void); - - ACE_Notification_Buffer (ACE_Event_Handler *eh, - ACE_Reactor_Mask mask); - - /// Default dtor. - ~ACE_Notification_Buffer (void); - - /// Pointer to the Event_Handler that will be dispatched - /// by the main event loop. - ACE_Event_Handler *eh_; - - /// Mask that indicates which method to call. - ACE_Reactor_Mask mask_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Event_Handler.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_EVENT_HANDLER_H */ diff --git a/ACE/ace/Event_Handler.inl b/ACE/ace/Event_Handler.inl deleted file mode 100644 index 75f2cd12aa5..00000000000 --- a/ACE/ace/Event_Handler.inl +++ /dev/null @@ -1,12 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_Notification_Buffer::~ACE_Notification_Buffer (void) -{ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Event_Handler_T.cpp b/ACE/ace/Event_Handler_T.cpp deleted file mode 100644 index 51a03f62310..00000000000 --- a/ACE/ace/Event_Handler_T.cpp +++ /dev/null @@ -1,125 +0,0 @@ -// Event_Handler_T.cpp -// -// $Id$ - -#ifndef ACE_EVENT_HANDLER_T_CPP -#define ACE_EVENT_HANDLER_T_CPP - -#include "ace/Event_Handler_T.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_TEMPLATE_TYPEDEFS) - -#if !defined (__ACE_INLINE__) -#include "ace/Event_Handler_T.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_Event_Handler_T) - -template void -ACE_Event_Handler_T::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Event_Handler_T::dump"); -#endif /* ACE_HAS_DUMP */ -} - -template -ACE_Event_Handler_T::~ACE_Event_Handler_T (void) -{ - ACE_TRACE ("ACE_Event_Handler_T::~ACE_Event_Handler_T"); - if (this->delete_handler_) - delete this->op_handler_; -} - -template -ACE_Event_Handler_T::ACE_Event_Handler_T (T *op_handler, int delete_handler, - GET_HANDLE get_handle, - IO_HANDLER input_h, - CL_HANDLER close_h, - SIG_HANDLER sig_h, - TO_HANDLER timeout_h, - IO_HANDLER output_h, - SET_HANDLE set_handle, - IO_HANDLER except_h) - : op_handler_ (op_handler), - input_handler_ (input_h), - output_handler_ (output_h), - except_handler_ (except_h), - to_handler_ (timeout_h), - cl_handler_ (close_h), - sig_handler_ (sig_h), - delete_handler_ (delete_handler), - set_handle_ (set_handle), - get_handle_ (get_handle) -{ - ACE_TRACE ("ACE_Event_Handler_T::ACE_Event_Handler_T"); -} - -template ACE_HANDLE -ACE_Event_Handler_T::get_handle (void) const -{ - ACE_TRACE ("ACE_Event_Handler_T::get_handle"); - return this->get_handle_ == 0 ? ACE_INVALID_HANDLE : (this->op_handler_->*get_handle_) (); -} - -template void -ACE_Event_Handler_T::set_handle (ACE_HANDLE h) -{ - ACE_TRACE ("ACE_Event_Handler_T::set_handle"); - if (this->set_handle_ != 0) - (this->op_handler_->*set_handle_) (h); -} - -template int -ACE_Event_Handler_T::handle_input (ACE_HANDLE fd) -{ - ACE_TRACE ("ACE_Event_Handler_T::handle_input"); - return this->input_handler_ == 0 ? 0 : (this->op_handler_->*input_handler_) (fd); -} - -template int -ACE_Event_Handler_T::handle_output (ACE_HANDLE fd) -{ - ACE_TRACE ("ACE_Event_Handler_T::handle_output"); - return this->output_handler_ == 0 ? 0 : (this->op_handler_->*output_handler_) (fd); -} - -template int -ACE_Event_Handler_T::handle_exception (ACE_HANDLE fd) -{ - ACE_TRACE ("ACE_Event_Handler_T::handle_exception"); - return this->except_handler_ == 0 ? 0 : (this->op_handler_->*except_handler_) (fd); -} - -template int -ACE_Event_Handler_T::handle_timeout (const ACE_Time_Value &tv, const void *arg) -{ - ACE_TRACE ("ACE_Event_Handler_T::handle_timeout"); - return this->to_handler_ == 0 ? 0 : (this->op_handler_->*to_handler_) (tv, arg); -} - -template int -ACE_Event_Handler_T::handle_close (ACE_HANDLE fd, ACE_Reactor_Mask close_mask) -{ - ACE_TRACE ("ACE_Event_Handler_T::handle_close"); - return this->cl_handler_ == 0 ? 0 : (this->op_handler_->*cl_handler_) (fd, close_mask); -} - -template int -ACE_Event_Handler_T::handle_signal (int signum, siginfo_t *s, ucontext_t *u) -{ - ACE_TRACE ("ACE_Event_Handler_T::handle_signal"); - return this->sig_handler_ == 0 ? 0 : (this->op_handler_->*sig_handler_) (signum, s, u); -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_TEMPLATE_TYPEDEFS */ - -#endif /* ACE_EVENT_HANDLER_T_CPP */ diff --git a/ACE/ace/Event_Handler_T.h b/ACE/ace/Event_Handler_T.h deleted file mode 100644 index 71c97bcf4a8..00000000000 --- a/ACE/ace/Event_Handler_T.h +++ /dev/null @@ -1,191 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file Event_Handler_T.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_EVENT_HANDLER_T_H -#define ACE_EVENT_HANDLER_T_H -#include /**/ "ace/pre.h" - -#include "ace/Event_Handler.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_TEMPLATE_TYPEDEFS) - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Event_Handler_T - * - * @brief Enable a class that doesn't inherit from the - * ACE_Event_Handler to be incorporated into the ACE_Reactor - * framework. Thanks to Greg Lavender (g.lavender@isode.com) - * for sharing this idea. - * - * It is sometimes the case that an application has a hierarchy - * of operation dispatcher classes that have their own - * inheritance hierarchy but also would like to integrate with - * the ACE_Reactor. Rather than adopt a "mixin" approach, it is - * often cleaner to define a template as a subclass of - * ACE_Event_Handler and paramterize it with an operation - * dispatcher type. - * When constructing an instantiation of the ACE_Event_Handler_T - * object, a set of pointers to member functions must be - * provided so that when one of the handle_* methods is called - * by the ACE_Reactor, the appropriate method is called on the - * underlying operations object. This is done since in some - * cases it is useful to map any event that happens to the same - * method on an object. - * The ACE_Event_Handler_T template is instantiated by an - * operations object and registered with the ACE_Reactor, and it - * then calls the appropriate op_handler. So, it's basically - * just another level of indirection in event dispatching. The - * coupling betweent the ultimate handler of the event and the - * ACE_Event_Handler class is relaxed a bit by have this - * intermediate object of type around. The - * client object can then dynamically change the bindings for - * the various handlers so that during the life of one of the - * operation objects, it can change how it wants events to be - * handled. It just instantiates a new instance of the template - * with different bindings and reregisters this new object with - * the ACE_Reactor. - */ -template -class ACE_Event_Handler_T : public ACE_Event_Handler -{ -public: - // = Typedefs to simplify pointer-to-member-function registration. - - // Get/set the underlying handle. - typedef ACE_HANDLE (T::*GET_HANDLE) (void) const; - typedef void (T::*SET_HANDLE) (ACE_HANDLE); - - /// Handle I/O events. - typedef int (T::*IO_HANDLER) (ACE_HANDLE); - - /// Handle timeout events. - typedef int (T::*TO_HANDLER) (const ACE_Time_Value &, const void *); - - /// Handle close events. - typedef int (T::*CL_HANDLER) (ACE_HANDLE, ACE_Reactor_Mask); - - /// = Initialization and termination methods. - typedef int (T::*SIG_HANDLER) (int, siginfo_t*, ucontext_t*); - - /// Initialize the op_handler. - ACE_Event_Handler_T (T *op_handler, - int delete_handler, - GET_HANDLE get_handle = 0, - IO_HANDLER input = 0, - CL_HANDLER close = 0, - SIG_HANDLER sig = 0, - TO_HANDLER timeout = 0, - IO_HANDLER output = 0, - SET_HANDLE set_handle = 0, - IO_HANDLER except = 0); - - /// Close down and delete the - ~ACE_Event_Handler_T (void); - - // = Override all the ACE_Event_Handler methods. - - // These methods all delegate down to the operations handler. - virtual ACE_HANDLE get_handle (void) const; - virtual void set_handle (ACE_HANDLE); - virtual int handle_input (ACE_HANDLE fd = ACE_INVALID_HANDLE); - virtual int handle_output (ACE_HANDLE fd = ACE_INVALID_HANDLE); - virtual int handle_exception (ACE_HANDLE fd = ACE_INVALID_HANDLE); - virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg = 0); - virtual int handle_close (ACE_HANDLE fd, ACE_Reactor_Mask close_mask); - virtual int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); - - // = Get/set the operations handler. - T *op_handler (void); - void op_handler (T *); - - // = Get/set the target pointer-to-method used for dispatching. - - GET_HANDLE handle_get (void); - void handle_get (GET_HANDLE); - - SET_HANDLE handle_set (void); - void handle_set (SET_HANDLE); - - IO_HANDLER input_handler (void); - void input_handler (IO_HANDLER); - - IO_HANDLER output_handler (void); - void output_handler (IO_HANDLER); - - IO_HANDLER except_handler (void); - void except_handler (IO_HANDLER); - - TO_HANDLER to_handler (void); - void to_handler (TO_HANDLER); - - CL_HANDLER cl_handler (void); - void cl_handler (CL_HANDLER); - - SIG_HANDLER sig_handler (void); - void sig_handler (SIG_HANDLER); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - /// Pointer to the object that handles all the delegated operations. - T *op_handler_; - - // = Handle input, output, and exception events. - IO_HANDLER input_handler_; - IO_HANDLER output_handler_; - IO_HANDLER except_handler_; - - /// Handle timeout events. - TO_HANDLER to_handler_; - - /// Handle close events. - CL_HANDLER cl_handler_; - - /// Handle signal events. - SIG_HANDLER sig_handler_; - - /// Keeps track of whether we need to delete the handler in the - /// destructor. - int delete_handler_; - - // = Get/set underlying handle. - SET_HANDLE set_handle_; - GET_HANDLE get_handle_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Event_Handler_T.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Event_Handler_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Event_Handler_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#endif /* ACE_HAS_TEMPLATE_TYPEDEFS */ -#include /**/ "ace/post.h" -#endif /* ACE_EVENT_HANDLER_H */ diff --git a/ACE/ace/Event_Handler_T.inl b/ACE/ace/Event_Handler_T.inl deleted file mode 100644 index c3facd7e25f..00000000000 --- a/ACE/ace/Event_Handler_T.inl +++ /dev/null @@ -1,135 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/Global_Macros.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template ACE_INLINE void -ACE_Event_Handler_T::op_handler (T *op) -{ - ACE_TRACE ("ACE_Event_Handler_T::op_handler"); - this->op_handler_ = op; -} - -template ACE_INLINE T * -ACE_Event_Handler_T::op_handler (void) -{ - ACE_TRACE ("ACE_Event_Handler_T::op_handler"); - return this->op_handler_; -} - -template ACE_INLINE typename ACE_Event_Handler_T::GET_HANDLE -ACE_Event_Handler_T::handle_get (void) -{ - ACE_TRACE ("ACE_Event_Handler_T::handle_get"); - return this->get_handle_; -} - -template ACE_INLINE void -ACE_Event_Handler_T::handle_get (typename ACE_Event_Handler_T::GET_HANDLE h) -{ - ACE_TRACE ("ACE_Event_Handler_T::handle_get"); - this->get_handle_ = h; -} - -template ACE_INLINE typename ACE_Event_Handler_T::SET_HANDLE -ACE_Event_Handler_T::handle_set (void) -{ - ACE_TRACE ("ACE_Event_Handler_T::handle_set"); - return this->set_handle_; -} - -template ACE_INLINE void -ACE_Event_Handler_T::handle_set (typename ACE_Event_Handler_T::SET_HANDLE h) -{ - ACE_TRACE ("ACE_Event_Handler_T::handle_set"); - this->set_handle_ = h; -} - -template ACE_INLINE typename ACE_Event_Handler_T::IO_HANDLER -ACE_Event_Handler_T::input_handler (void) -{ - ACE_TRACE ("ACE_Event_Handler_T::input_handler"); - return this->input_handler_; -} - -template ACE_INLINE void -ACE_Event_Handler_T::input_handler (typename ACE_Event_Handler_T::IO_HANDLER h) -{ - ACE_TRACE ("ACE_Event_Handler_T::input_handler"); - this->input_handler_ = h; -} - -template ACE_INLINE typename ACE_Event_Handler_T::IO_HANDLER -ACE_Event_Handler_T::output_handler (void) -{ - ACE_TRACE ("ACE_Event_Handler_T::output_handler"); - return this->output_handler_; -} - -template ACE_INLINE void -ACE_Event_Handler_T::output_handler (typename ACE_Event_Handler_T::IO_HANDLER h) -{ - ACE_TRACE ("ACE_Event_Handler_T::output_handler"); - this->output_handler_ = h; -} - -template ACE_INLINE typename ACE_Event_Handler_T::IO_HANDLER -ACE_Event_Handler_T::except_handler (void) -{ - ACE_TRACE ("ACE_Event_Handler_T::except_handler"); - return this->except_handler_; -} - -template ACE_INLINE void -ACE_Event_Handler_T::except_handler (typename ACE_Event_Handler_T::IO_HANDLER h) -{ - ACE_TRACE ("ACE_Event_Handler_T::except_handler"); - this->except_handler_ = h; -} - -template ACE_INLINE typename ACE_Event_Handler_T::TO_HANDLER -ACE_Event_Handler_T::to_handler (void) -{ - ACE_TRACE ("ACE_Event_Handler_T::to_handler"); - return this->to_handler_; -} - -template ACE_INLINE void -ACE_Event_Handler_T::to_handler (typename ACE_Event_Handler_T::TO_HANDLER h) -{ - ACE_TRACE ("ACE_Event_Handler_T::to_handler"); - this->to_handler_ = h; -} - -template ACE_INLINE typename ACE_Event_Handler_T::CL_HANDLER -ACE_Event_Handler_T::cl_handler (void) -{ - ACE_TRACE ("ACE_Event_Handler_T::cl_handler"); - return this->cl_handler_; -} - -template ACE_INLINE void -ACE_Event_Handler_T::cl_handler (typename ACE_Event_Handler_T::CL_HANDLER h) -{ - ACE_TRACE ("ACE_Event_Handler_T::cl_handler"); - this->cl_handler_ = h; -} - -template ACE_INLINE typename ACE_Event_Handler_T::SIG_HANDLER -ACE_Event_Handler_T::sig_handler (void) -{ - ACE_TRACE ("ACE_Event_Handler_T::sig_handler"); - return this->sig_handler_; -} - -template ACE_INLINE void -ACE_Event_Handler_T::sig_handler (typename ACE_Event_Handler_T::SIG_HANDLER h) -{ - ACE_TRACE ("ACE_Event_Handler_T::sig_handler"); - this->sig_handler_ = h; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Exception_Macros.h b/ACE/ace/Exception_Macros.h deleted file mode 100644 index 7efc532f93a..00000000000 --- a/ACE/ace/Exception_Macros.h +++ /dev/null @@ -1,55 +0,0 @@ -// -*- C++ -*- - -// ============================================================================ -/** - * @file Exception_Macros.h - * - * $Id$ - * - * Writing code that is portable between platforms with or without - * native C++ exceptions is hard. The following macros offer some - * help on this task. - * - * @author Nanbor Wang - * @author Aniruddha Gokhale - * @author Carlos O'Ryan - * @author Krishnakumar B , et al. - */ -// ============================================================================ - -// Macros for handling exceptions. - -#ifndef ACE_EXCEPTION_MACROS_H -#define ACE_EXCEPTION_MACROS_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -# if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -# endif /* ACE_LACKS_PRAGMA_ONCE */ - -// By default, if the compiler supports native exception handling, assume -// CORBA also support native exception handling. But it can be disabled by -// defining ACE_CORBA_HAS_EXCEPTIONS=0. If the compiler does not support -// exceptions handling, make sure native exception handling is disabled. -#if defined (ACE_HAS_EXCEPTIONS) -# if defined (ACE_CORBA_HAS_EXCEPTIONS) -# if (ACE_CORBA_HAS_EXCEPTIONS == 0) -# undef ACE_USES_NATIVE_EXCEPTIONS -# else /* ACE_CORBA_HAS_EXCEPTIONS != 0 */ -# define ACE_USES_NATIVE_EXCEPTIONS -# endif /* ACE_CORBA_HAS_EXCEPTIONS == 0 */ -# else -# define ACE_USES_NATIVE_EXCEPTIONS -# define ACE_CORBA_HAS_EXCEPTIONS -# endif /* ACE_CORBA_HAS_EXCEPTIONS */ -#else /* ! ACE_HAS_EXCEPTIONS */ -# undef ACE_CORBA_HAS_EXCEPTIONS -# undef ACE_USES_NATIVE_EXCEPTIONS -#endif /* ACE_HAS_EXCEPTIONS */ - -#include /**/ "ace/post.h" - -#endif /* ACE_EXCEPTION_MACROS_H */ diff --git a/ACE/ace/FIFO.cpp b/ACE/ace/FIFO.cpp deleted file mode 100644 index 22172e376f7..00000000000 --- a/ACE/ace/FIFO.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// $Id$ - -#include "ace/FIFO.h" - -#if !defined (__ACE_INLINE__) -#include "ace/FIFO.inl" -#endif /* __ACE_INLINE__ */ - -#include "ace/Log_Msg.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_errno.h" -#include "ace/OS_NS_sys_stat.h" -#include "ace/OS_NS_fcntl.h" - -ACE_RCSID(ace, FIFO, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_FIFO) - -void -ACE_FIFO::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_FIFO::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("rendezvous_ = %s"), this->rendezvous_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -int -ACE_FIFO::open (const ACE_TCHAR *r, int flags, mode_t perms, - LPSECURITY_ATTRIBUTES sa) -{ - ACE_TRACE ("ACE_FIFO::open"); - ACE_OS::strsncpy (this->rendezvous_, r, MAXPATHLEN); - - if ((flags & O_CREAT) != 0 - && ACE_OS::mkfifo (this->rendezvous_, perms) == -1 - && !(errno == EEXIST)) - return -1; - - this->set_handle (ACE_OS::open (this->rendezvous_, flags, 0, sa)); - return this->get_handle () == ACE_INVALID_HANDLE ? -1 : 0; -} - -ACE_FIFO::ACE_FIFO (const ACE_TCHAR *fifo_name, - int flags, - mode_t perms, - LPSECURITY_ATTRIBUTES sa) -{ - ACE_TRACE ("ACE_FIFO::ACE_FIFO"); - if (this->open (fifo_name, flags, perms, sa) == -1) - ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_FIFO"))); -} - -ACE_FIFO::ACE_FIFO (void) -{ -// ACE_TRACE ("ACE_FIFO::ACE_FIFO"); -} - -int -ACE_FIFO::close (void) -{ - ACE_TRACE ("ACE_FIFO::close"); - int result = 0; - - if (this->get_handle () != ACE_INVALID_HANDLE) - { - result = ACE_OS::close (this->get_handle ()); - this->set_handle (ACE_INVALID_HANDLE); - } - return result; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/FIFO.h b/ACE/ace/FIFO.h deleted file mode 100644 index 3866b0e4eb8..00000000000 --- a/ACE/ace/FIFO.h +++ /dev/null @@ -1,85 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file FIFO.h - * - * $Id$ - * - * @author Doug Schmidt - */ -//========================================================================== - - -#ifndef ACE_FIFO_H -#define ACE_FIFO_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/IPC_SAP.h" -#include "ace/os_include/os_limits.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_FIFO - * - * @brief Abstract base class for UNIX FIFOs - * - * UNIX FIFOs are also known Named Pipes, which are totally - * unrelated to Win32 Named Pipes. If you want to use a local - * IPC mechanism that will be portable to both UNIX and Win32, - * take a look at the classes. - */ -class ACE_Export ACE_FIFO : public ACE_IPC_SAP -{ -public: - /// Open up the named pipe on the in accordance with the - /// flags. - int open (const ACE_TCHAR *rendezvous, int flags, mode_t perms, - LPSECURITY_ATTRIBUTES sa = 0); - - /// Close down the ACE_FIFO without removing the rendezvous point. - int close (void); - - /// Close down the ACE_FIFO and remove the rendezvous point from the - /// file system. - int remove (void); - - /// Return the local address of this endpoint. - int get_local_addr (const ACE_TCHAR *&rendezvous) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - // = Make these protected to ensure that the class is "abstract." - /// Default constructor. - ACE_FIFO (void); - - /// Open up the named pipe on the in accordance with the - /// flags. - ACE_FIFO (const ACE_TCHAR *rendezvous, int flags, mode_t perms, - LPSECURITY_ATTRIBUTES sa = 0); - -private: - /// Rendezvous point in the file system. - ACE_TCHAR rendezvous_[MAXPATHLEN + 1]; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/FIFO.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_FIFO_H */ diff --git a/ACE/ace/FIFO.inl b/ACE/ace/FIFO.inl deleted file mode 100644 index 149ed11318b..00000000000 --- a/ACE/ace/FIFO.inl +++ /dev/null @@ -1,25 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/OS_NS_unistd.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE int -ACE_FIFO::get_local_addr (const ACE_TCHAR *&r) const -{ - ACE_TRACE ("ACE_FIFO::get_local_addr"); - r = this->rendezvous_; - return 0; -} - -ACE_INLINE int -ACE_FIFO::remove (void) -{ - ACE_TRACE ("ACE_FIFO::remove"); - int const result = this->close (); - return ACE_OS::unlink (this->rendezvous_) == -1 || result == -1 ? -1 : 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/FIFO_Recv.cpp b/ACE/ace/FIFO_Recv.cpp deleted file mode 100644 index ca1305cf71a..00000000000 --- a/ACE/ace/FIFO_Recv.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// $Id$ - -#include "ace/FIFO_Recv.h" -#include "ace/Log_Msg.h" -#include "ace/OS_NS_fcntl.h" - -#if !defined (__ACE_INLINE__) -#include "ace/FIFO_Recv.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, FIFO_Recv, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Recv) - -void -ACE_FIFO_Recv::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_FIFO_Recv::dump"); - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_FIFO::dump (); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("aux_handle_ = %d"), this->aux_handle_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -int -ACE_FIFO_Recv::close (void) -{ - ACE_TRACE ("ACE_FIFO_Recv::close"); - int result = ACE_FIFO::close (); - - if (this->aux_handle_ != ACE_INVALID_HANDLE) - return ACE_OS::close (this->aux_handle_); - else - return result; -} - -// Note that persistent means "open fifo for writing, as well as -// reading." This ensures that the fifo never gets EOF, even if there -// aren't any writers at the moment! - -int -ACE_FIFO_Recv::open (const ACE_TCHAR *fifo_name, - int flags, - mode_t perms, - int persistent, - LPSECURITY_ATTRIBUTES sa) -{ - ACE_TRACE ("ACE_FIFO_Recv::open"); - - if (ACE_FIFO::open (fifo_name, ACE_NONBLOCK | flags, perms, sa) == -1) - return -1; - else if (this->disable (ACE_NONBLOCK) == -1) - return -1; - else if (persistent - && (this->aux_handle_ = ACE_OS::open (fifo_name, O_WRONLY, 0, sa)) == ACE_INVALID_HANDLE) - return -1; - else - return this->get_handle () == ACE_INVALID_HANDLE ? -1 : 0; -} - -ACE_FIFO_Recv::ACE_FIFO_Recv (void) - : aux_handle_ (ACE_INVALID_HANDLE) -{ - ACE_TRACE ("ACE_FIFO_Recv::ACE_FIFO_Recv"); -} - -ACE_FIFO_Recv::ACE_FIFO_Recv (const ACE_TCHAR *fifo_name, - int flags, - mode_t perms, - int persistent, - LPSECURITY_ATTRIBUTES sa) - : aux_handle_ (ACE_INVALID_HANDLE) -{ - ACE_TRACE ("ACE_FIFO_Recv::ACE_FIFO_Recv"); - - if (this->ACE_FIFO_Recv::open (fifo_name, - flags, - perms, - persistent, - sa) == -1) - ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_FIFO_Recv"))); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/FIFO_Recv.h b/ACE/ace/FIFO_Recv.h deleted file mode 100644 index fa18cf291a5..00000000000 --- a/ACE/ace/FIFO_Recv.h +++ /dev/null @@ -1,85 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file FIFO_Recv.h - * - * $Id$ - * - * @author Doug Schmidt - */ -//========================================================================== - - -#ifndef ACE_FIFO_RECV_H -#define ACE_FIFO_RECV_H - -#include /**/ "ace/pre.h" - -#include "ace/FIFO.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/os_include/os_fcntl.h" -#include "ace/Default_Constants.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_FIFO_Recv - * - * @brief Receiver side of the bytestream C++ wrapper for UNIX - * FIFOs. - */ -class ACE_Export ACE_FIFO_Recv : public ACE_FIFO -{ -public: - // = Initialization methods. - /// Default constructor. - ACE_FIFO_Recv (void); - - /// Open up a bytestream named pipe for reading. - ACE_FIFO_Recv (const ACE_TCHAR *rendezvous, - int flags = O_CREAT | O_RDONLY, - mode_t perms = ACE_DEFAULT_FILE_PERMS, - int persistent = 1, - LPSECURITY_ATTRIBUTES sa = 0); - - /// Open up a bytestream named pipe for reading. - int open (const ACE_TCHAR *rendezvous, - int flags = O_CREAT | O_RDONLY, - mode_t perms = ACE_DEFAULT_FILE_PERMS, - int persistent = 1, - LPSECURITY_ATTRIBUTES sa = 0); - - /// Close down the named pipe. - int close (void); - - /// Recv @a buf of up to @a len bytes. - ssize_t recv (void *buf, size_t len); - - /// Recv @a buf of exactly @a len bytes (block until done). - ssize_t recv_n (void *buf, size_t len); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - /// Auxiliary handle that is used to implement persistent FIFOs. - ACE_HANDLE aux_handle_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/FIFO_Recv.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" - -#endif /* ACE_FIFO_RECV_H */ diff --git a/ACE/ace/FIFO_Recv.inl b/ACE/ace/FIFO_Recv.inl deleted file mode 100644 index b5cf96cb56d..00000000000 --- a/ACE/ace/FIFO_Recv.inl +++ /dev/null @@ -1,24 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/ACE.h" -#include "ace/OS_NS_unistd.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE ssize_t -ACE_FIFO_Recv::recv (void *buf, size_t len) -{ - ACE_TRACE ("ACE_FIFO_Recv::recv"); - return ACE_OS::read (this->get_handle (), (char *) buf, len); -} - -ACE_INLINE ssize_t -ACE_FIFO_Recv::recv_n (void *buf, size_t n) -{ - ACE_TRACE ("ACE_FIFO_Recv::recv_n"); - return ACE::recv_n (this->get_handle (), buf, n); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/FIFO_Recv_Msg.cpp b/ACE/ace/FIFO_Recv_Msg.cpp deleted file mode 100644 index 68d77af8a78..00000000000 --- a/ACE/ace/FIFO_Recv_Msg.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// $Id$ - -#include "ace/FIFO_Recv_Msg.h" - -#include "ace/Log_Msg.h" - -#if !defined (__ACE_INLINE__) -#include "ace/FIFO_Recv_Msg.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, FIFO_Recv_Msg, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Recv_Msg) - -void -ACE_FIFO_Recv_Msg::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_FIFO_Recv_Msg::dump"); - ACE_FIFO_Recv::dump (); -#endif /* ACE_HAS_DUMP */ -} - -// Note that persistent means "open FIFO for writing, as well as -// reading." This ensures that the FIFO never gets EOF, even if there -// aren't any writers at the moment! - -int -ACE_FIFO_Recv_Msg::open (const ACE_TCHAR *fifo_name, - int flags, - mode_t perms, - int persistent, - LPSECURITY_ATTRIBUTES sa) -{ - ACE_TRACE ("ACE_FIFO_Recv_Msg::open"); - - return ACE_FIFO_Recv::open (fifo_name, - flags, - perms, - persistent, - sa); -} - -ACE_FIFO_Recv_Msg::ACE_FIFO_Recv_Msg (void) -{ - ACE_TRACE ("ACE_FIFO_Recv_Msg::ACE_FIFO_Recv_Msg"); -} - -ACE_FIFO_Recv_Msg::ACE_FIFO_Recv_Msg (const ACE_TCHAR *fifo_name, - int flags, - mode_t perms, - int persistent, - LPSECURITY_ATTRIBUTES sa) -{ - ACE_TRACE ("ACE_FIFO_Recv_Msg::ACE_FIFO_Recv_Msg"); - - if (this->ACE_FIFO_Recv_Msg::open (fifo_name, - flags, - perms, - persistent, - sa) == -1) - ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_FIFO_Recv_Msg"))); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/FIFO_Recv_Msg.h b/ACE/ace/FIFO_Recv_Msg.h deleted file mode 100644 index b1c7afe3eb3..00000000000 --- a/ACE/ace/FIFO_Recv_Msg.h +++ /dev/null @@ -1,138 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file FIFO_Recv_Msg.h - * - * $Id$ - * - * @author Doug Schmidt - */ -//============================================================================= - - -#ifndef ACE_FIFO_RECV_MSG_H -#define ACE_FIFO_RECV_MSG_H -#include /**/ "ace/pre.h" - -#include "ace/FIFO_Recv.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Forward decls -class ACE_Str_Buf; - -/** - * @class ACE_FIFO_Recv_Msg - * - * @brief Receiver side for the record oriented C++ wrapper for UNIX FIFOs. - * - * This method works slightly differently on platforms with the - * @c ACE_HAS_STREAM_PIPES configuration setting than those without. - * With ACE_HAS_STREAM_PIPES, the @c getmsg() system function is used - * and it preserves message boundaries internally. Without - * @c ACE_HAS_STREAM_PIPES, the message boundaries are emulated by - * this class and ACE_FIFO_Send_Msg cooperating. The sending class - * first writes an integer number of bytes in the message, then the - * message. ACE_FIFO_Recv_Msg reads the count, then the data. - * The operational differences occur primarily when a message is larger - * than what a caller of this class requests. See recv() for details. - */ -class ACE_Export ACE_FIFO_Recv_Msg : public ACE_FIFO_Recv -{ -public: - // = Initialization methods. - /// Default constructor. - ACE_FIFO_Recv_Msg (void); - - /// Open up a record-oriented named pipe for reading. - ACE_FIFO_Recv_Msg (const ACE_TCHAR *rendezvous, - int flags = O_CREAT | O_RDONLY, - mode_t perms = ACE_DEFAULT_FILE_PERMS, - int persistent = 1, - LPSECURITY_ATTRIBUTES sa = 0); - - /// Open up a record-oriented named pipe for reading. - int open (const ACE_TCHAR *rendezvous, - int flags = O_CREAT | O_RDONLY, - mode_t perms = ACE_DEFAULT_FILE_PERMS, - int persistent = 1, - LPSECURITY_ATTRIBUTES sa = 0); - - /// Receive a message based on attributes in an ACE_Str_Buf. - /** - * @param msg Reference to an ACE_Str_Buf whose @c buf member points - * to the memory to receive the data and @c maxlen member - * contains the maximum number of bytes to receive. - * On return after successfully reading data, the - * @c len member contains the number of bytes received and - * placed in the buffer pointed to by @c msg.buf. - * - * @retval -1 Error; consult @c errno for specific error number. - * @return If the @c ACE_HAS_STREAM_PIPES configuration setting is - * defined, the return value is the number of bytes received - * in the message and will be the same as @c buf.len. - * The return value from the @c getmsg() system function - * is discarded. - * If @c ACE_HAS_STREAM_PIPES is not defined, the number - * of bytes in the message read from the FIFO is returned. - * If the message is larger than the maximum length - * requested in @c msg.maxlen, the return value reflects - * the entire message length, and the @c msg.len member - * reflects how many bytes were actually placed in the - * caller's buffer. Any part of the message longer than - * @c msg.maxlen is discarded. - */ - ssize_t recv (ACE_Str_Buf &msg); - - /// Receive a message based on buffer pointer and maximum size. - /** - * @param buf Pointer to the memory to receive the data. - * @param len The maximum number of bytes to receive. - * - * @retval -1 Error; consult @c errno for specific error number. - * @return The number of bytes received in the message. For messages - * that are larger than the requested maximum size, the - * behavior is different depending on the @c ACE_HAS_STREAM_PIPES - * configuration setting. With @c ACE_HAS_STREAM_PIPES, - * the return value will be the same as @arg len (this is - * also possible if the message is exactly the same length - * as @arg len, and the two cases are indistinguishable). - * Without @c ACE_HAS_STREAM_PIPES, the return value is - * the total length of the message, including bytes in - * excess of @arg len. The excess bytes are discarded. - */ - ssize_t recv (void *buf, size_t len); - -#if defined (ACE_HAS_STREAM_PIPES) - /// Recv and message via Stream pipes. - ssize_t recv (ACE_Str_Buf *data, - ACE_Str_Buf *cntl, - int *flags); - - /// Recv and message via Stream pipes in "band" mode. - ssize_t recv (int *band, - ACE_Str_Buf *data, - ACE_Str_Buf *cntl, - int *flags); -#endif /* ACE_HAS_STREAM_PIPES */ - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/FIFO_Recv_Msg.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_FIFO_RECV_MSG_H */ diff --git a/ACE/ace/FIFO_Recv_Msg.inl b/ACE/ace/FIFO_Recv_Msg.inl deleted file mode 100644 index bab21a7e20e..00000000000 --- a/ACE/ace/FIFO_Recv_Msg.inl +++ /dev/null @@ -1,111 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/Min_Max.h" -#include "ace/OS_NS_stropts.h" - -#if !defined (ACE_HAS_STREAM_PIPES) -#include "ace/OS_NS_unistd.h" -#endif - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE ssize_t -ACE_FIFO_Recv_Msg::recv (ACE_Str_Buf &recv_msg) -{ - ACE_TRACE ("ACE_FIFO_Recv_Msg::recv"); -#if defined (ACE_HAS_STREAM_PIPES) - int i = 0; - if (ACE_OS::getmsg (this->get_handle (), - (strbuf *) 0, - (strbuf *) &recv_msg, - &i) == -1) - return -1; - else - return recv_msg.len; -#else /* Do the ol' 2-read trick... */ - if (ACE_OS::read (this->get_handle (), - (char *) &recv_msg.len, - sizeof recv_msg.len) != sizeof recv_msg.len) - return -1; - else - { - size_t remaining = static_cast (recv_msg.len); - size_t requested = static_cast (recv_msg.maxlen); - ssize_t recv_len = ACE_OS::read (this->get_handle (), - (char *) recv_msg.buf, - ACE_MIN (remaining, requested)); - if (recv_len == -1) - return -1; - // Tell caller what's really in the buffer. - recv_msg.len = static_cast (recv_len); - - // If there are more bytes remaining in the message, read them and - // throw them away. Leaving them in the FIFO would make it difficult - // to find the start of the next message in the fifo. - // Since the ACE_HAS_STREAM_PIPES version of this method doesn't - // return getmsg()'s indication of "data remaining", don't worry about - // saving the indication here either to read the remainder later. - size_t total_msg_size = remaining; - remaining -= recv_len; - while (remaining > 0) - { - const size_t throw_away = 1024; - char dev_null[throw_away]; - recv_len = ACE_OS::read (this->get_handle (), - dev_null, - ACE_MIN (remaining, throw_away)); - if (recv_len == -1) - break; - remaining -= recv_len; - } - return total_msg_size; - } -#endif /* ACE_HAS_STREAM_PIPES */ -} - -ACE_INLINE ssize_t -ACE_FIFO_Recv_Msg::recv (void *buf, size_t max_len) -{ - ACE_TRACE ("ACE_FIFO_Recv_Msg::recv"); - ACE_Str_Buf recv_msg ((char *) buf, 0, static_cast (max_len)); - - return this->recv (recv_msg); -} - -#if defined (ACE_HAS_STREAM_PIPES) -ACE_INLINE ssize_t -ACE_FIFO_Recv_Msg::recv (ACE_Str_Buf *data, - ACE_Str_Buf *cntl, - int *flags) -{ - ACE_TRACE ("ACE_FIFO_Recv_Msg::recv"); - if (ACE_OS::getmsg (this->get_handle (), - (strbuf *) cntl, - (strbuf *) data, - flags) == -1) - return -1; - else - return (cntl == 0 ? 0 : cntl->len) + (data == 0 ? 0 : data->len); -} - -ACE_INLINE ssize_t -ACE_FIFO_Recv_Msg::recv (int *band, - ACE_Str_Buf *data, - ACE_Str_Buf *cntl, - int *flags) -{ - ACE_TRACE ("ACE_FIFO_Recv_Msg::recv"); - if (ACE_OS::getpmsg (this->get_handle (), - (strbuf *) cntl, - (strbuf *) data, - band, - flags) == -1) - return -1; - else - return (cntl == 0 ? 0 : cntl->len) + (data == 0 ? 0 : data->len); -} -#endif /* ACE_HAS_STREAM_PIPES */ - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/FIFO_Send.cpp b/ACE/ace/FIFO_Send.cpp deleted file mode 100644 index 47a3c90e814..00000000000 --- a/ACE/ace/FIFO_Send.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// $Id$ - -#include "ace/FIFO_Send.h" -#include "ace/Log_Msg.h" - -#if !defined (__ACE_INLINE__) -#include "ace/FIFO_Send.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, FIFO_Send, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Send) - -void -ACE_FIFO_Send::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_FIFO_Send::dump"); - ACE_FIFO::dump (); -#endif /* ACE_HAS_DUMP */ -} - -ACE_FIFO_Send::ACE_FIFO_Send (void) -{ -// ACE_TRACE ("ACE_FIFO_Send::ACE_FIFO_Send"); -} - -int -ACE_FIFO_Send::open (const ACE_TCHAR *rendezvous_name, - int flags, - mode_t perms, - LPSECURITY_ATTRIBUTES sa) -{ - ACE_TRACE ("ACE_FIFO_Send::open"); - return ACE_FIFO::open (rendezvous_name, - flags | O_WRONLY, - perms, - sa); -} - -ACE_FIFO_Send::ACE_FIFO_Send (const ACE_TCHAR *fifo_name, - int flags, - mode_t perms, - LPSECURITY_ATTRIBUTES sa) -{ - ACE_TRACE ("ACE_FIFO_Send::ACE_FIFO_Send"); - if (this->ACE_FIFO_Send::open (fifo_name, - flags, - perms, - sa) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_FIFO_Send::ACE_FIFO_Send"))); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/FIFO_Send.h b/ACE/ace/FIFO_Send.h deleted file mode 100644 index 51a14508114..00000000000 --- a/ACE/ace/FIFO_Send.h +++ /dev/null @@ -1,75 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file FIFO_Send.h - * - * $Id$ - * - * @author Doug Schmidt - */ -//========================================================================== - - -#ifndef ACE_FIFO_SEND_H -#define ACE_FIFO_SEND_H - -#include /**/ "ace/pre.h" - -#include "ace/FIFO.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/os_include/os_fcntl.h" -#include "ace/Default_Constants.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_FIFO_Send - * - * @brief Sender side for the bytestream C++ wrapper for UNIX FIFOs - */ -class ACE_Export ACE_FIFO_Send : public ACE_FIFO -{ -public: - // = Initialization methods. - /// Default constructor. - ACE_FIFO_Send (void); - - /// Open up a bytestream named pipe for writing. - ACE_FIFO_Send (const ACE_TCHAR *rendezvous, - int flags = O_WRONLY, - mode_t perms = ACE_DEFAULT_FILE_PERMS, - LPSECURITY_ATTRIBUTES sa = 0); - - /// Open up a bytestream named pipe for writing. - int open (const ACE_TCHAR *rendezvous, - int flags = O_WRONLY, - mode_t perms = ACE_DEFAULT_FILE_PERMS, - LPSECURITY_ATTRIBUTES sa = 0); - - /// Send @a buf of up to @a len bytes. - ssize_t send (const void *buf, size_t len); - - /// Send @a buf of exactly @a len bytes (block until done). - ssize_t send_n (const void *buf, size_t len); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/FIFO_Send.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" - -#endif /* ACE_FIFO_SEND_H */ diff --git a/ACE/ace/FIFO_Send.inl b/ACE/ace/FIFO_Send.inl deleted file mode 100644 index 12491058e2c..00000000000 --- a/ACE/ace/FIFO_Send.inl +++ /dev/null @@ -1,24 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/ACE.h" -#include "ace/OS_NS_unistd.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE ssize_t -ACE_FIFO_Send::send (const void *buf, size_t len) -{ - ACE_TRACE ("ACE_FIFO_Send::send"); - return ACE_OS::write (this->get_handle (), (const char *) buf, len); -} - -ACE_INLINE ssize_t -ACE_FIFO_Send::send_n (const void *buf, size_t n) -{ - ACE_TRACE ("ACE_FIFO_Send::send_n"); - return ACE::send_n (this->get_handle (), buf, n); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/FIFO_Send_Msg.cpp b/ACE/ace/FIFO_Send_Msg.cpp deleted file mode 100644 index c06b737a6bb..00000000000 --- a/ACE/ace/FIFO_Send_Msg.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// $Id$ - -#include "ace/FIFO_Send_Msg.h" - -#include "ace/Log_Msg.h" -#include "ace/OS_NS_sys_uio.h" - -#if !defined (__ACE_INLINE__) -#include "ace/FIFO_Send_Msg.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, FIFO_Send_Msg, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Send_Msg) - -void -ACE_FIFO_Send_Msg::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_FIFO_Send_Msg::dump"); - ACE_FIFO_Send::dump (); -#endif /* ACE_HAS_DUMP */ -} - -ssize_t -ACE_FIFO_Send_Msg::send (const ACE_Str_Buf &send_msg) -{ - // ACE_TRACE ("ACE_FIFO_Send_Msg::send"); -#if defined (ACE_HAS_STREAM_PIPES) - if (ACE_OS::putmsg (this->get_handle (), - (strbuf *) 0, - (strbuf *) &send_msg, - 0) == -1) - return -1; - else - return send_msg.len; -#else - iovec iov[2]; - - iov[0].iov_base = (char *) &send_msg.len; - iov[0].iov_len = sizeof send_msg.len; - - iov[1].iov_base = (char *) send_msg.buf; - iov[1].iov_len = static_cast (send_msg.len); - - ssize_t sent = ACE_OS::writev (this->get_handle (), iov, 2); - if (sent > 0) - sent -= iov[0].iov_len; // Don't count the length we added. - return sent; -#endif /* ACE_HAS_STREAM_PIPES */ -} - -ACE_FIFO_Send_Msg::ACE_FIFO_Send_Msg (void) -{ -// ACE_TRACE ("ACE_FIFO_Send_Msg::ACE_FIFO_Send_Msg"); -} - -int -ACE_FIFO_Send_Msg::open (const ACE_TCHAR *fifo_name, - int flags, - mode_t perms, - LPSECURITY_ATTRIBUTES sa) -{ - ACE_TRACE ("ACE_FIFO_Send_Msg::open"); - return ACE_FIFO_Send::open (fifo_name, flags | O_WRONLY, perms, sa); -} - -ACE_FIFO_Send_Msg::ACE_FIFO_Send_Msg (const ACE_TCHAR *fifo_name, - int flags, - mode_t perms, - LPSECURITY_ATTRIBUTES sa) -{ - ACE_TRACE ("ACE_FIFO_Send_Msg::ACE_FIFO_Send_Msg"); - if (this->ACE_FIFO_Send_Msg::open (fifo_name, flags, perms, sa) == -1) - ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_FIFO_Send_Msg"))); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/FIFO_Send_Msg.h b/ACE/ace/FIFO_Send_Msg.h deleted file mode 100644 index a2e0affce8a..00000000000 --- a/ACE/ace/FIFO_Send_Msg.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file FIFO_Send_Msg.h - * - * $Id$ - * - * @author Doug Schmidt - */ -//============================================================================= - - -#ifndef ACE_FIFO_SEND_MSG_H -#define ACE_FIFO_SEND_MSG_H -#include /**/ "ace/pre.h" - -#include "ace/FIFO_Send.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_STREAM_PIPES) -# include "ace/OS_NS_stropts.h" -#endif /* ACE_HAS_STREAM_PIPES */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Forward Decls -class ACE_Str_Buf; - -/** - * @class ACE_FIFO_Send_Msg - * - * @brief Sender side for the Record oriented C++ wrapper for UNIX - * FIFOs. - */ -class ACE_Export ACE_FIFO_Send_Msg : public ACE_FIFO_Send -{ -public: - // = Initialization methods. - /// Default constructor. - ACE_FIFO_Send_Msg (void); - - /// Open up a record-oriented named pipe for writing. - ACE_FIFO_Send_Msg (const ACE_TCHAR *rendezvous, - int flags = O_WRONLY, - mode_t perms = ACE_DEFAULT_FILE_PERMS, - LPSECURITY_ATTRIBUTES sa = 0); - - /// Open up a record-oriented named pipe for writing. - int open (const ACE_TCHAR *rendezvous, - int flags = O_WRONLY, - mode_t perms = ACE_DEFAULT_FILE_PERMS, - LPSECURITY_ATTRIBUTES sa = 0); - - /// Send @a buf of up to @a len bytes. - ssize_t send (const ACE_Str_Buf &msg); - - /// Send @a buf of exactly @a len bytes (block until done). - ssize_t send (const void *buf, size_t len); - -#if defined (ACE_HAS_STREAM_PIPES) - /// Send and message via Stream pipes. - ssize_t send (const ACE_Str_Buf *data, - const ACE_Str_Buf *cntl = 0, - int flags = 0); - - /// Send and message via Stream pipes in "band" mode. - ssize_t send (int band, - const ACE_Str_Buf *data, - const ACE_Str_Buf *cntl = 0, - int flags = MSG_BAND); -#endif /* ACE_HAS_STREAM_PIPES */ - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/FIFO_Send_Msg.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_FIFO_SEND_MSG_H */ diff --git a/ACE/ace/FIFO_Send_Msg.inl b/ACE/ace/FIFO_Send_Msg.inl deleted file mode 100644 index 74392656597..00000000000 --- a/ACE/ace/FIFO_Send_Msg.inl +++ /dev/null @@ -1,53 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/OS_NS_stropts.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE ssize_t -ACE_FIFO_Send_Msg::send (const void *buf, size_t len) -{ - ACE_TRACE ("ACE_FIFO_Send_Msg::send"); - ACE_Str_Buf send_msg ((char *) buf, static_cast (len)); - - return this->send (send_msg); -} - -#if defined (ACE_HAS_STREAM_PIPES) -ACE_INLINE ssize_t -ACE_FIFO_Send_Msg::send (const ACE_Str_Buf *data, - const ACE_Str_Buf *cntl, - int flags) -{ - ACE_TRACE ("ACE_FIFO_Send_Msg::send"); - if (ACE_OS::putmsg (this->get_handle (), - (strbuf *) cntl, - (strbuf *) data, - flags) == -1) - return-1; - else - return (cntl == 0 ? 0 : cntl->len) + (data == 0 ? 0 : data->len); -} - -ACE_INLINE ssize_t -ACE_FIFO_Send_Msg::send (int band, - const ACE_Str_Buf *data, - const ACE_Str_Buf *cntl, - int flags) -{ - ACE_TRACE ("ACE_FIFO_Send_Msg::send"); - - if (ACE_OS::putpmsg (this->get_handle (), - (strbuf *) cntl, - (strbuf *) data, - band, - flags) == -1) - return -1; - else - return (cntl == 0 ? 0 : cntl->len) + (data == 0 ? 0 : data->len); -} -#endif /* ACE_HAS_STREAM_PIPES */ - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/FILE.cpp b/ACE/ace/FILE.cpp deleted file mode 100644 index 8b3015524e3..00000000000 --- a/ACE/ace/FILE.cpp +++ /dev/null @@ -1,147 +0,0 @@ -// $Id$ - -/* Defines the member functions for the base class of the ACE_IO_SAP - ACE_FILE abstraction. */ - -#include "ace/FILE.h" - -#include "ace/OS_NS_unistd.h" -#include "ace/OS_NS_sys_stat.h" - -#if !defined (__ACE_INLINE__) -#include "ace/FILE.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, FILE, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_FILE) - -void -ACE_FILE::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_FILE::dump"); - ACE_IO_SAP::dump (); -#endif /* ACE_HAS_DUMP */ -} - -// This is the do-nothing constructor. - -ACE_FILE::ACE_FILE (void) -{ - ACE_TRACE ("ACE_FILE::ACE_FILE"); -} - -// Close the file - -int -ACE_FILE::close (void) -{ - ACE_TRACE ("ACE_FILE::close"); - int result = 0; - - if (this->get_handle () != ACE_INVALID_HANDLE) - { - result = ACE_OS::close (this->get_handle ()); - this->set_handle (ACE_INVALID_HANDLE); - } - return result; -} - -int -ACE_FILE::get_info (ACE_FILE_Info *finfo) -{ - ACE_TRACE ("ACE_FILE::get_info"); - ACE_stat filestatus; - - int const result = ACE_OS::fstat (this->get_handle (), &filestatus); - - if (result == 0) - { - finfo->mode_ = filestatus.st_mode; - finfo->nlink_ = filestatus.st_nlink; - finfo->size_ = filestatus.st_size; - } - - return result; -} - -int -ACE_FILE::get_info (ACE_FILE_Info &finfo) -{ - ACE_TRACE ("ACE_FILE::get_info"); - - return this->get_info (&finfo); -} - -int -ACE_FILE::truncate (ACE_OFF_T length) -{ - ACE_TRACE ("ACE_FILE::truncate"); - return ACE_OS::ftruncate (this->get_handle (), length); -} - -ACE_OFF_T -ACE_FILE::seek (ACE_OFF_T offset, int startpos) -{ - return ACE_OS::lseek (this->get_handle (), offset, startpos); -} - -ACE_OFF_T -ACE_FILE::tell (void) -{ - ACE_TRACE ("ACE_FILE::tell"); - return ACE_OS::lseek (this->get_handle (), 0, SEEK_CUR); -} - -// Return the local endpoint address. - -int -ACE_FILE::get_local_addr (ACE_Addr &addr) const -{ - ACE_TRACE ("ACE_FILE::get_local_addr"); - - // Perform the downcast since had better be an - // . - ACE_FILE_Addr *file_addr = - dynamic_cast (&addr); - - if (file_addr == 0) - return -1; - else - { - *file_addr = this->addr_; - return 0; - } -} - -// Return the same result as . - -int -ACE_FILE::get_remote_addr (ACE_Addr &addr) const -{ - ACE_TRACE ("ACE_FILE::get_remote_addr"); - - return this->get_local_addr (addr); -} - -int -ACE_FILE::remove (void) -{ - ACE_TRACE ("ACE_FILE::remove"); - - this->close (); - return ACE_OS::unlink (this->addr_.get_path_name ()); -} - -int -ACE_FILE::unlink (void) -{ - ACE_TRACE ("ACE_FILE::unlink"); - - return ACE_OS::unlink (this->addr_.get_path_name ()); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/FILE.h b/ACE/ace/FILE.h deleted file mode 100644 index bf8f4561d4f..00000000000 --- a/ACE/ace/FILE.h +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file FILE.h - * - * $Id$ - * - * @author Gerhard Lenzer - */ -//============================================================================= - -#ifndef ACE_FILE_H -#define ACE_FILE_H -#include /**/ "ace/pre.h" - -#include "ace/IO_SAP.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/FILE_Addr.h" - -// The following is necessary since many C++ compilers don't support -// typedef'd types inside of classes used as formal template -// arguments... ;-(. Luckily, using the C++ preprocessor I can hide -// most of this nastiness! - -#if defined (ACE_HAS_TEMPLATE_TYPEDEFS) -#define ACE_FILE_CONNECTOR ACE_FILE_Connector -#define ACE_FILE_STREAM ACE_FILE_IO -#else /* TEMPLATES are broken (must be a cfront-based compiler...) */ -#define ACE_FILE_CONNECTOR ACE_FILE_Connector, ACE_FILE_Addr -#define ACE_FILE_STREAM ACE_FILE_IO, ACE_FILE_Addr -#endif /* ACE_TEMPLATE_TYPEDEFS */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_FILE_Info - * - * @brief Abstracts basic OS FILE information. - */ -class ACE_Export ACE_FILE_Info -{ -public: - /// Mode of file - mode_t mode_; - - /// No of links - nlink_t nlink_; - - /// Size of file - ACE_OFF_T size_; -}; - -/** - * @class ACE_FILE - * - * @brief Defines the core methods of the ACE_FILE abstraction. - */ -class ACE_Export ACE_FILE : public ACE_IO_SAP -{ -public: - /// Close the ACE_FILE handle without removing the ACE_FILE from - /// the file system. - int close (void); - - /// Close and remove the ACE_FILE from the file system. - int remove (void); - - /// Remove the ACE_FILE from the file system without closing the - /// ACE_FILE handle. - int unlink (void); - - /// Get information on this ACE_FILE. - int get_info (ACE_FILE_Info *finfo); - - /// Get information on this ACE_FILE. - int get_info (ACE_FILE_Info &finfo); - - /// Set filesize to length byte. - int truncate (ACE_OFF_T length); - - /** - * Sets the file pointer as follows: - * o If is , the pointer is set to @a offset - * bytes. - * - * o If is , the pointer is set to its - * current location plus @a offset. - * - * o If is , the pointer is set to the size - * of the file plus offset. - */ - ACE_OFF_T seek (ACE_OFF_T offset, - int whence = SEEK_CUR); - - /// Return an offset for the file handle. - ACE_OFF_T tell (void); - - /** - * Disable signal @a signum - * This is here to prevent Win32 from - * disabling SPIPE using socket calls - */ - int disable (int signum) const ; - - /// Return the local endpoint address in the referenced ACE_Addr. - /// Returns 0 if successful, else -1. - int get_local_addr (ACE_Addr &) const; - - /// Return the same thing as get_local_addr(). - int get_remote_addr (ACE_Addr &) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - /// Ensure that this class is only created by the - /// ACE_FILE_Connector. - ACE_FILE (void); - - /// File we are "connected" with... - ACE_FILE_Addr addr_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/FILE.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_FILE_H */ diff --git a/ACE/ace/FILE.inl b/ACE/ace/FILE.inl deleted file mode 100644 index fdd65029d3a..00000000000 --- a/ACE/ace/FILE.inl +++ /dev/null @@ -1,18 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE int -ACE_FILE::disable (int signum) const -{ -#if defined (ACE_WIN32) - ACE_UNUSED_ARG (signum) ; - return 0 ; -#else /* ACE_WIN32 */ - return ACE_IO_SAP::disable (signum) ; -#endif /* ACE_WIN32 */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/FILE_Addr.cpp b/ACE/ace/FILE_Addr.cpp deleted file mode 100644 index 79d9db6e296..00000000000 --- a/ACE/ace/FILE_Addr.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// $Id$ - -#include "ace/FILE_Addr.h" -#include "ace/Lib_Find.h" -#include "ace/Log_Msg.h" -#include "ace/OS_NS_stdlib.h" -#include "ace/OS_NS_string.h" -#include "ace/os_include/sys/os_socket.h" - -#if !defined (__ACE_INLINE__) -#include "ace/FILE_Addr.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, FILE_Addr, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_FILE_Addr) - -ACE_FILE_Addr::ACE_FILE_Addr (void) - : ACE_Addr (AF_FILE, sizeof this->filename_ / sizeof (ACE_TCHAR)) -{ - this->filename_[0] = '\0'; -} - -int -ACE_FILE_Addr::set (const ACE_FILE_Addr &sa) -{ - if (sa.get_type () == AF_ANY) - { -#if defined (ACE_DEFAULT_TEMP_FILE) - // Create a temporary file. - ACE_OS::strcpy (this->filename_, - ACE_DEFAULT_TEMP_FILE); -#else /* ACE_DEFAULT_TEMP_FILE */ - if (ACE::get_temp_dir (this->filename_, MAXPATHLEN - 15) == -1) - // -15 for ace-file-XXXXXX - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("Temporary path too long, ") - ACE_TEXT ("defaulting to current directory\n"))); - this->filename_[0] = 0; - } - - // Add the filename to the end - ACE_OS::strcat (this->filename_, ACE_TEXT ("ace-fileXXXXXX")); - -#endif /* ACE_DEFAULT_TEMP_FILE */ - - if (ACE_OS::mktemp (this->filename_) == 0) - return -1; - this->base_set (AF_FILE, - static_cast (ACE_OS::strlen (this->filename_) + 1)); - } - else - { - (void)ACE_OS::strsncpy (this->filename_, sa.filename_, sa.get_size ()); - - this->base_set (sa.get_type (), sa.get_size ()); - } - return 0; -} - -// Copy constructor. - -ACE_FILE_Addr::ACE_FILE_Addr (const ACE_FILE_Addr &sa) - : ACE_Addr (AF_FILE, sizeof this->filename_) -{ - this->set (sa); -} - -int -ACE_FILE_Addr::set (const ACE_TCHAR *filename) -{ - this->ACE_Addr::base_set (AF_FILE, - static_cast (ACE_OS::strlen (filename) + 1)); - (void) ACE_OS::strsncpy (this->filename_, - filename, - sizeof this->filename_ / sizeof (ACE_TCHAR)); - return 0; -} - -ACE_FILE_Addr & -ACE_FILE_Addr::operator= (const ACE_FILE_Addr &sa) -{ - if (this != &sa) - this->set (sa); - return *this; -} - -// Create a ACE_Addr from a ACE_FILE pathname. - -ACE_FILE_Addr::ACE_FILE_Addr (const ACE_TCHAR *filename) -{ - this->set (filename); -} - -int -ACE_FILE_Addr::addr_to_string (ACE_TCHAR *s, size_t len) const -{ - ACE_OS::strsncpy (s, this->filename_, len); - return 0; -} - -// Return the address. - -void * -ACE_FILE_Addr::get_addr (void) const -{ - return (void *)&this->filename_; -} - -void -ACE_FILE_Addr::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_FILE_Addr::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("filename_ = %s"), this->filename_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/FILE_Addr.h b/ACE/ace/FILE_Addr.h deleted file mode 100644 index 2fa9e0f4ae4..00000000000 --- a/ACE/ace/FILE_Addr.h +++ /dev/null @@ -1,89 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file FILE_Addr.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_FILE_ADDR_H -#define ACE_FILE_ADDR_H -#include /**/ "ace/pre.h" - -#include "ace/Addr.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Flag_Manip.h" -#include "ace/os_include/os_dirent.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_FILE_Addr - * - * @brief Defines the FILE address family address format. - */ -class ACE_Export ACE_FILE_Addr : public ACE_Addr -{ -public: - // = Initialization methods. - /// Default constructor. - ACE_FILE_Addr (void); - - /// Copy constructor. - ACE_FILE_Addr (const ACE_FILE_Addr &sa); - - /// Acts like a copy constructor. If @a sa == ACE_Addr::sap_any then - /// create a temporary filename using ACE_OS::mktemp. - int set (const ACE_FILE_Addr &sa); - - /// Create a ACE_FILE_Addr from a pathname. - explicit ACE_FILE_Addr (const ACE_TCHAR *filename); - - /// Create a ACE_FILE_Addr from a pathname. - int set (const ACE_TCHAR *filename); - - /// Assignment operator. - ACE_FILE_Addr &operator= (const ACE_FILE_Addr &); - - /// Return a pointer to the address. - virtual void *get_addr (void) const; - - /// Transform the current address into string format. - virtual int addr_to_string (ACE_TCHAR *addr, size_t) const; - - /// Compare two addresses for equality. - bool operator == (const ACE_FILE_Addr &SAP) const; - - /// Compare two addresses for inequality. - bool operator != (const ACE_FILE_Addr &SAP) const; - - /// Return the path name used for the rendezvous point. - const ACE_TCHAR *get_path_name (void) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - /// Name of the file. - ACE_TCHAR filename_[MAXPATHLEN + 1]; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/FILE_Addr.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_FILE_ADDR_H */ diff --git a/ACE/ace/FILE_Addr.inl b/ACE/ace/FILE_Addr.inl deleted file mode 100644 index e03cd2ab156..00000000000 --- a/ACE/ace/FILE_Addr.inl +++ /dev/null @@ -1,34 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - - -#include "ace/SString.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Compare two addresses for equality. - -ACE_INLINE bool -ACE_FILE_Addr::operator == (const ACE_FILE_Addr &sap) const -{ - return ACE_OS::strcmp (this->filename_, sap.filename_) == 0; -} - -// Compare two addresses for inequality. - -ACE_INLINE bool -ACE_FILE_Addr::operator != (const ACE_FILE_Addr &sap) const -{ - return !((*this) == sap); // This is lazy, of course... ;-) -} - -// Return the path name used for the rendezvous point. - -ACE_INLINE const ACE_TCHAR * -ACE_FILE_Addr::get_path_name (void) const -{ - return this->filename_; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/FILE_Connector.cpp b/ACE/ace/FILE_Connector.cpp deleted file mode 100644 index c136b0b47eb..00000000000 --- a/ACE/ace/FILE_Connector.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// $Id$ - -#include "ace/FILE_Connector.h" -#include "ace/Handle_Ops.h" -#include "ace/OS_NS_stdlib.h" - -#if !defined (__ACE_INLINE__) -#include "ace/FILE_Connector.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, FILE_Connector, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_FILE_Connector) - -void -ACE_FILE_Connector::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_FILE_Connector::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_FILE_Connector::ACE_FILE_Connector (void) -{ - ACE_TRACE ("ACE_FILE_Connector::ACE_FILE_Connector"); -} - -int -ACE_FILE_Connector::connect (ACE_FILE_IO &new_io, - const ACE_FILE_Addr &remote_sap, - ACE_Time_Value *timeout, - const ACE_Addr &, - int, - int flags, - int perms) -{ - ACE_TRACE ("ACE_FILE_Connector::connect"); - ACE_ASSERT (new_io.get_handle () == ACE_INVALID_HANDLE); - - ACE_HANDLE handle = ACE_INVALID_HANDLE; - - // Check to see if caller has requested that we create the filename. - if (reinterpret_cast ( - const_cast (remote_sap)) == ACE_Addr::sap_any) - { - // Create a new temporary file. - // Use ACE_OS::mkstemp() if it is available since it avoids a - // race condition, and subsequently a security hole due to that - // race condition (specifically, a denial-of-service attack). - // - // However, using mkstemp() prevents us from doing a timed open - // since it opens the file for us. Better to avoid the race - // condition. - char filename[] = "ace-file-XXXXXX"; - - handle = ACE_OS::mkstemp (filename); // mkstemp() replaces "XXXXXX" - - if (handle == ACE_INVALID_HANDLE - || new_io.addr_.set (ACE_TEXT_CHAR_TO_TCHAR (filename)) != 0) - return -1; - - new_io.set_handle (handle); - - return 0; - } - else - new_io.addr_ = remote_sap; // class copy. - - handle = ACE::handle_timed_open (timeout, - new_io.addr_.get_path_name (), - flags, - perms); - - new_io.set_handle (handle); - return handle == ACE_INVALID_HANDLE ? -1 : 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/FILE_Connector.h b/ACE/ace/FILE_Connector.h deleted file mode 100644 index b02b01e7dbb..00000000000 --- a/ACE/ace/FILE_Connector.h +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file FILE_Connector.h - * - * $Id$ - * - * @author Doug Schmidt - */ -//============================================================================= - -#ifndef ACE_FILE_CONNECTOR_H -#define ACE_FILE_CONNECTOR_H -#include /**/ "ace/pre.h" - -#include "ace/FILE_IO.h" -#include "ace/Log_Msg.h" -#include "ace/os_include/os_fcntl.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_FILE_Connector - * - * @brief Defines an active connection factory for the ACE_FILE wrappers. - * - * Note that the O_APPEND flag is only partly supported on Win32. If - * you specify O_APPEND, then the file pointer will be positioned at - * the end of the file initially during open, but it is not - * re-positioned at the end prior to each write, as specified by - * POSIX. This is generally good enough for typical situations, but - * it is ``not quite right'' in its semantics. - */ -class ACE_Export ACE_FILE_Connector -{ -public: - // = Initialization methods. - /// Default constructor. - ACE_FILE_Connector (void); - - /** - * Actively ``connect'' and produce a @a new_io ACE_FILE_IO object - * if things go well. The @a remote_sap is the file that we are - * trying to create/open. If it's the default value of - * ACE_Addr::sap_any then the user is letting the OS create the - * filename (via ). The @a timeout is the amount of - * time to wait to create/open the file. If it's 0 then we block - * indefinitely. If *timeout == {0, 0} then the file is created - * using non-blocking mode. If *timeout > {0, 0} then this is the - * maximum amount of time to wait before timing out. The - * @a local_sap and @a reuse_addr parameters are ignored. The @a flags - * and @a perms arguments are passed down to the - * method. - */ - ACE_FILE_Connector (ACE_FILE_IO &new_io, - const ACE_FILE_Addr &remote_sap, - ACE_Time_Value *timeout = 0, - const ACE_Addr &local_sap = ACE_Addr::sap_any, - int reuse_addr = 0, - int flags = O_RDWR | O_CREAT, - int perms = ACE_DEFAULT_FILE_PERMS); - - /** - * Actively ``connect'' and produce a @a new_io object - * if things go well. The @a remote_sap is the file that we are - * trying to create/open. If it's the default value of - * ACE_Addr::sap_any then the user is letting the OS create the - * filename (via ). The @a timeout is the amount of - * time to wait to create/open the file. If it's 0 then we block - * indefinitely. If *timeout == {0, 0} then the file is created - * using non-blocking mode. In this case, if the create/open can't - * be done immediately the value of -1 is returned with . If *timeout > {0, 0} then this is the maximum amount of - * time to wait before timing out. If the time expires before the - * connection is made @c errno == ETIME. The @a local_sap and - * @a reuse_addr parameters are ignored. The @a flags and @a perms - * arguments are passed down to the method. - */ - int connect (ACE_FILE_IO &new_io, - const ACE_FILE_Addr &remote_sap, - ACE_Time_Value *timeout = 0, - const ACE_Addr &local_sap = ACE_Addr::sap_any, - int reuse_addr = 0, - int flags = O_RDWR | O_CREAT, - int perms = ACE_DEFAULT_FILE_PERMS); - - /// Resets any event associations on this handle - int reset_new_handle (ACE_HANDLE handle); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - - // = Meta-type "trait" information. - typedef ACE_FILE_Addr PEER_ADDR; - typedef ACE_FILE_IO PEER_STREAM; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/FILE_Connector.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_FILE_CONNECTOR_H */ diff --git a/ACE/ace/FILE_Connector.inl b/ACE/ace/FILE_Connector.inl deleted file mode 100644 index d598341ba8d..00000000000 --- a/ACE/ace/FILE_Connector.inl +++ /dev/null @@ -1,36 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -// Creates a Local ACE_FILE. - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_FILE_Connector::ACE_FILE_Connector (ACE_FILE_IO &new_io, - const ACE_FILE_Addr &remote_sap, - ACE_Time_Value *timeout, - const ACE_Addr &local_sap, - int reuse_addr, - int flags, - int perms) -{ - ACE_TRACE ("ACE_FILE_Connector::ACE_FILE_Connector"); - if (this->connect (new_io, remote_sap, timeout, local_sap, - reuse_addr, flags, perms) == ACE_IO_SAP::INVALID_HANDLE - && timeout != 0 && !(errno == EWOULDBLOCK || errno == ETIME)) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("address %s, %p\n"), - remote_sap.get_path_name (), - ACE_TEXT ("ACE_FILE_IO"))); -} - -ACE_INLINE int -ACE_FILE_Connector::reset_new_handle (ACE_HANDLE handle) -{ - ACE_UNUSED_ARG (handle); - // Nothing to do here since the handle is not a socket - return 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/FILE_IO.cpp b/ACE/ace/FILE_IO.cpp deleted file mode 100644 index bf0c41bf418..00000000000 --- a/ACE/ace/FILE_IO.cpp +++ /dev/null @@ -1,142 +0,0 @@ -// $Id$ - -#include "ace/FILE_IO.h" - -#include "ace/Log_Msg.h" -#include "ace/OS_NS_sys_stat.h" -#include "ace/OS_Memory.h" -#include "ace/Truncate.h" - -#if !defined (__ACE_INLINE__) -#include "ace/FILE_IO.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, FILE_IO, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_FILE_IO) - -void -ACE_FILE_IO::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_FILE_IO::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - this->addr_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -// Simple-minded do nothing constructor. - -ACE_FILE_IO::ACE_FILE_IO (void) -{ - ACE_TRACE ("ACE_FILE_IO::ACE_FILE_IO"); -} - -// Send N char *ptrs and int lengths. Note that the char *'s precede -// the ints (basically, an varargs version of writev). The count N is -// the *total* number of trailing arguments, *not* a couple of the -// number of tuple pairs! - -ssize_t -ACE_FILE_IO::send (size_t n, ...) const -{ - ACE_TRACE ("ACE_FILE_IO::send"); - va_list argp; - int total_tuples = ACE_Utils::truncate_cast (n / 2); - iovec *iovp = 0; -#if defined (ACE_HAS_ALLOCA) - iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); -#else - ACE_NEW_RETURN (iovp, - iovec[total_tuples], - -1); -#endif /* !defined (ACE_HAS_ALLOCA) */ - - va_start (argp, n); - - for (int i = 0; i < total_tuples; i++) - { - iovp[i].iov_base = va_arg (argp, char *); - iovp[i].iov_len = va_arg (argp, int); - } - - ssize_t result = ACE_OS::writev (this->get_handle (), - iovp, - total_tuples); -#if !defined (ACE_HAS_ALLOCA) - delete [] iovp; -#endif /* !defined (ACE_HAS_ALLOCA) */ - va_end (argp); - return result; -} - -// This is basically an interface to ACE_OS::readv, that doesn't use -// the struct iovec explicitly. The ... can be passed as an arbitrary -// number of (char *ptr, int len) tuples. However, the count N is the -// *total* number of trailing arguments, *not* a couple of the number -// of tuple pairs! - -ssize_t -ACE_FILE_IO::recv (size_t n, ...) const -{ - ACE_TRACE ("ACE_FILE_IO::recv"); - va_list argp; - int total_tuples = ACE_Utils::truncate_cast (n / 2); - iovec *iovp = 0; -#if defined (ACE_HAS_ALLOCA) - iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); -#else - ACE_NEW_RETURN (iovp, - iovec[total_tuples], - -1); -#endif /* !defined (ACE_HAS_ALLOCA) */ - - va_start (argp, n); - - for (int i = 0; i < total_tuples; i++) - { - iovp[i].iov_base = va_arg (argp, char *); - iovp[i].iov_len = va_arg (argp, int); - } - - ssize_t const result = ACE_OS::readv (this->get_handle (), - iovp, - total_tuples); -#if !defined (ACE_HAS_ALLOCA) - delete [] iovp; -#endif /* !defined (ACE_HAS_ALLOCA) */ - va_end (argp); - return result; -} - -// Allows a client to read from a file without having to provide a -// buffer to read. This method determines how much data is in the -// file, allocates a buffer of this size, reads in the data, and -// returns the number of bytes read. - -ssize_t -ACE_FILE_IO::recvv (iovec *io_vec) -{ - ACE_TRACE ("ACE_FILE_IO::recvv"); - - io_vec->iov_base = 0; - size_t const length = static_cast (ACE_OS::filesize (this->get_handle ())); - - if (length > 0) - { - ACE_NEW_RETURN (io_vec->iov_base, - char[length], - -1); - io_vec->iov_len = this->recv_n (io_vec->iov_base, - length); - return io_vec->iov_len; - } - else - return length; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/FILE_IO.h b/ACE/ace/FILE_IO.h deleted file mode 100644 index e975c0cc2c9..00000000000 --- a/ACE/ace/FILE_IO.h +++ /dev/null @@ -1,170 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file FILE_IO.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_FILE_IO_H -#define ACE_FILE_IO_H -#include /**/ "ace/pre.h" - -#include "ace/FILE.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/FILE_Addr.h" - -// Used in the FILE_IO.h file... -#include "ace/os_include/os_stdio.h" -#include "ace/os_include/sys/os_uio.h" - -#if defined (ACE_HAS_STREAM_PIPES) -# include "ace/OS_NS_stropts.h" -#endif /* ACE_HAS_STREAM_PIPES */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Forward decl. -class ACE_Message_Block; -class ACE_Time_Value; - -/** - * @class ACE_FILE_IO - * - * @brief Read/Write operations on Files - */ -class ACE_Export ACE_FILE_IO : public ACE_FILE -{ -public: - friend class ACE_FILE_Connector; - - // = Initialization method. - /// Default constructor. - ACE_FILE_IO (void); - - /// send upto @a n bytes in @a buf. - ssize_t send (const void *buf, size_t n) const; - - /// Recv upto @a n bytes in @a buf. - ssize_t recv (void *buf, size_t n) const; - - /// Send n bytes, keep trying until n are sent. - ssize_t send_n (const void *buf, size_t n) const; - - /// Send all the @a message_blocks chained through their and - /// pointers. This call uses the underlying OS gather-write - /// operation to reduce the domain-crossing penalty. - ssize_t send_n (const ACE_Message_Block *message_block, - const ACE_Time_Value *timeout = 0, - size_t *bytes_transferred = 0); - - /// Recv n bytes, keep trying until n are received. - ssize_t recv_n (void *buf, size_t n) const; - -#if defined (ACE_HAS_STREAM_PIPES) - /// Send bytes via STREAM pipes. - ssize_t send (const ACE_Str_Buf *cntl, - const ACE_Str_Buf *data, - int flags = 0) const; - - /// Recv bytes via STREAM pipes. - ssize_t recv (ACE_Str_Buf *cntl, - ACE_Str_Buf *data, - int *flags) const; - - /// Send bytes via STREAM pipes using "band" mode. - ssize_t send (const ACE_Str_Buf *cntl, - const ACE_Str_Buf *data, - int band, - int flags) const; - - /// Recv bytes via STREAM pipes using "band" mode. - ssize_t recv (ACE_Str_Buf *cntl, - ACE_Str_Buf *data, - int *band, - int *flags) const; - -#endif /* ACE_HAS_STREAM_PIPES */ - - /// Send iovecs via <::writev>. - ssize_t send (const iovec iov[], int n) const; - - /// Recv iovecs via <::readv>. - ssize_t recv (iovec iov[], int n) const; - - /** - * Send N char *ptrs and int lengths. Note that the char *'s - * precede the ints (basically, an varargs version of writev). The - * count N is the *total* number of trailing arguments, *not* a - * couple of the number of tuple pairs! - */ - ssize_t send (size_t n, ...) const; - - /** - * This is an interface to ::readv, that doesn't use the struct - * iovec explicitly. The ... can be passed as an arbitrary number - * of (char *ptr, int len) tuples. However, the count N is the - * *total* number of trailing arguments, *not* a couple of the - * number of tuple pairs! - */ - ssize_t recv (size_t n, ...) const; - - /// Send @a n bytes via Win32 WriteFile using overlapped I/O. - ssize_t send (const void *buf, - size_t n, - ACE_OVERLAPPED *overlapped) const; - - /// Recv @a n bytes via Win32 ReadFile using overlapped I/O. - ssize_t recv (void *buf, - size_t n, - ACE_OVERLAPPED *overlapped) const; - - /// Send an @c iovec of size @a n to the file. - ssize_t sendv (const iovec iov[], - int n) const; - - /** - * Allows a client to read from a file without having to provide a - * buffer to read. This method determines how much data is in the - * file, allocates a buffer of this size, reads in the data, and - * returns the number of bytes read. The caller is responsible for - * deleting the member in the field of using - * delete [] io_vec->iov_base. - */ - ssize_t recvv (iovec *io_vec); - - /// Send an of size @a n to the file. Will block until all - /// bytes are sent or an error occurs. - ssize_t sendv_n (const iovec iov[], - int n) const; - - /// Receive an of size @a n to the file. - ssize_t recvv_n (iovec iov[], - int n) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - - // = Meta-type info - typedef ACE_FILE_Addr PEER_ADDR; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/FILE_IO.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_FILE_IO_H */ diff --git a/ACE/ace/FILE_IO.inl b/ACE/ace/FILE_IO.inl deleted file mode 100644 index 7db33a0c717..00000000000 --- a/ACE/ace/FILE_IO.inl +++ /dev/null @@ -1,152 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/ACE.h" -#include "ace/OS_NS_sys_uio.h" -#include "ace/OS_NS_unistd.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE ssize_t -ACE_FILE_IO::sendv_n (const iovec iov[], int n) const -{ - ACE_TRACE ("ACE_FILE_IO::sendv_n"); - return ACE::writev_n (this->get_handle (), - iov, - n); -} - -ACE_INLINE ssize_t -ACE_FILE_IO::send_n (const ACE_Message_Block *message_block, - const ACE_Time_Value *timeout, - size_t *bytes_transferred) -{ - ACE_TRACE ("ACE_FILE_IO::send_n"); - ACE_UNUSED_ARG (timeout); - return ACE::write_n (this->get_handle (), - message_block, - bytes_transferred); -} - -// Recv an n byte message from the file. - -ACE_INLINE ssize_t -ACE_FILE_IO::recvv_n (iovec iov[], int n) const -{ - ACE_TRACE ("ACE_FILE_IO::recvv_n"); - // @@ Carlos, can you please update this to call the - // new ACE::recvv_n() method that you write? - return ACE_OS::readv (this->get_handle (), - iov, - n); -} - -// Send an of size to the file. - -ACE_INLINE ssize_t -ACE_FILE_IO::sendv (const iovec iov[], int n) const -{ - ACE_TRACE ("ACE_FILE_IO::sendv"); - return ACE_OS::writev (this->get_handle (), iov, n); -} - -// Send exactly N bytes from BUF to this file. Keeping trying until -// this many bytes are sent. - -ACE_INLINE ssize_t -ACE_FILE_IO::send_n (const void *buf, size_t n) const -{ - ACE_TRACE ("ACE_FILE_IO::send_n"); - return ACE::write_n (this->get_handle (), buf, n); -} - -// Receive exactly N bytes from this file into BUF. Keep trying until -// this many bytes are received. - -ACE_INLINE ssize_t -ACE_FILE_IO::recv_n (void *buf, size_t n) const -{ - ACE_TRACE ("ACE_FILE_IO::recv_n"); - return ACE::read_n (this->get_handle (), buf, n); -} - -ACE_INLINE ssize_t -ACE_FILE_IO::send (const void *buf, size_t n) const -{ - ACE_TRACE ("ACE_FILE_IO::send"); - return ACE_OS::write (this->get_handle (), buf, n); -} - -ACE_INLINE ssize_t -ACE_FILE_IO::recv (void *buf, size_t n) const -{ - ACE_TRACE ("ACE_FILE_IO::recv"); - return ACE_OS::read (this->get_handle (), buf, n); -} - -ACE_INLINE ssize_t -ACE_FILE_IO::send (const iovec iov[], int n) const -{ - ACE_TRACE ("ACE_FILE_IO::send"); - return ACE_OS::writev (this->get_handle (), iov, n); -} - -ACE_INLINE ssize_t -ACE_FILE_IO::recv (iovec iov[], int n) const -{ - ACE_TRACE ("ACE_FILE_IO::recv"); - return ACE_OS::readv (this->get_handle (), iov, n); -} - -#if defined (ACE_HAS_STREAM_PIPES) -ACE_INLINE ssize_t -ACE_FILE_IO::recv (ACE_Str_Buf *cntl, ACE_Str_Buf *data, int *band, int *flags) const -{ - ACE_TRACE ("ACE_FILE_IO::recv"); - return ACE_OS::getpmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, band, flags); -} - -ACE_INLINE ssize_t -ACE_FILE_IO::send (const ACE_Str_Buf *cntl, const ACE_Str_Buf *data, int band, int flags) const -{ - ACE_TRACE ("ACE_FILE_IO::send"); - return ACE_OS::putpmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, band, flags); -} - -ACE_INLINE ssize_t -ACE_FILE_IO::recv (ACE_Str_Buf *cntl, ACE_Str_Buf *data, int *flags) const -{ - ACE_TRACE ("ACE_FILE_IO::recv"); - return ACE_OS::getmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, flags); -} - -ACE_INLINE ssize_t -ACE_FILE_IO::send (const ACE_Str_Buf *cntl, const ACE_Str_Buf *data, int flags) const -{ - ACE_TRACE ("ACE_FILE_IO::send"); - return ACE_OS::putmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, flags); -} - -ACE_INLINE ssize_t -ACE_FILE_IO::send (const void *buf, size_t n, - ACE_OVERLAPPED *overlapped) const -{ - ACE_TRACE ("ACE_FILE_IO::send"); - return ACE_OS::write (this->get_handle (), - buf, n, - overlapped); -} - -ACE_INLINE ssize_t -ACE_FILE_IO::recv (void *buf, size_t n, - ACE_OVERLAPPED *overlapped) const -{ - ACE_TRACE ("ACE_FILE_IO::recv"); - return ACE_OS::read (this->get_handle (), buf, n, - overlapped); -} - -#endif /* ACE_HAS_STREAM_PIPES */ - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/File_Lock.cpp b/ACE/ace/File_Lock.cpp deleted file mode 100644 index 88935c3a5d7..00000000000 --- a/ACE/ace/File_Lock.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// $Id$ - -#include "ace/File_Lock.h" -#include "ace/Log_Msg.h" - -#if !defined (__ACE_INLINE__) -#include "ace/File_Lock.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, File_Lock, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_File_Lock) - -void -ACE_File_Lock::dump (void) const -{ -#if defined (ACE_HAS_DUMP) -// ACE_TRACE ("ACE_File_Lock::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - this->lock_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_File_Lock::ACE_File_Lock (ACE_HANDLE h, - int unlink_in_destructor) - : removed_ (0), - unlink_in_destructor_ (unlink_in_destructor) -{ -// ACE_TRACE ("ACE_File_Lock::ACE_File_Lock"); - if (ACE_OS::flock_init (&this->lock_) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_File_Lock::ACE_File_Lock"))); - this->set_handle (h); -} - -ACE_File_Lock::ACE_File_Lock (const ACE_TCHAR *name, - int flags, - mode_t perms, - int unlink_in_destructor) - : unlink_in_destructor_ (unlink_in_destructor) -{ -// ACE_TRACE ("ACE_File_Lock::ACE_File_Lock"); - - if (this->open (name, flags, perms) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p %s\n"), - ACE_TEXT ("ACE_File_Lock::ACE_File_Lock"), - name)); -} - -int -ACE_File_Lock::open (const ACE_TCHAR *name, - int flags, - mode_t perms) -{ -// ACE_TRACE ("ACE_File_Lock::open"); - this->removed_ = 0; - return ACE_OS::flock_init (&this->lock_, flags, name, perms); -} - -ACE_File_Lock::~ACE_File_Lock (void) -{ -// ACE_TRACE ("ACE_File_Lock::~ACE_File_Lock"); - this->remove (this->unlink_in_destructor_); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/File_Lock.h b/ACE/ace/File_Lock.h deleted file mode 100644 index eec103e1fe0..00000000000 --- a/ACE/ace/File_Lock.h +++ /dev/null @@ -1,170 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file File_Lock.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_FILE_LOCK_H -#define ACE_FILE_LOCK_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/OS_NS_stdio.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_File_Lock - * - * @brief A wrapper around the UNIX file locking mechanism. - * - * Allows us to "adapt" the UNIX file locking mechanisms to work - * with all of our Guard stuff... - */ -class ACE_Export ACE_File_Lock -{ -public: - /** - * Set the of the File_Lock to @a handle. Note that this - * constructor assumes ownership of the @a handle and will close it - * down in . If you want the @a handle to stay open when - * is called make sure to call on the @a handle. - * If you don't want the file unlinked in the destructor pass a - * zero value for . - */ - ACE_File_Lock (ACE_HANDLE handle = ACE_INVALID_HANDLE, - int unlink_in_destructor = 1); - - /// Open the @a filename with @a flags and @a mode and set the result - /// to . If you don't want the file unlinked in the - /// destructor pass a zero value for . - ACE_File_Lock (const ACE_TCHAR *filename, - int flags, - mode_t mode = 0, - int unlink_in_destructor = 1); - - /// Open the @a filename with @a flags and @a mode and set the result to - /// . - int open (const ACE_TCHAR *filename, - int flags, - mode_t mode = 0); - - /// Remove a File lock by releasing it and closing down the . - ~ACE_File_Lock (void); - - /// Remove a File lock by releasing it and closing down the - /// . If is non-0 then we unlink the file. - int remove (int unlink_file = 1); - - /** - * Note, for interface uniformity with other synchronization - * wrappers we include the method. This is implemented as - * a write-lock to be on the safe-side... - */ - int acquire (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1); - - /** - * Note, for interface uniformity with other synchronization - * wrappers we include the method. This is implemented - * as a write-lock to be on the safe-side... Returns -1 on failure. - * If we "failed" because someone else already had the lock, @c errno - * is set to @c EBUSY. - */ - int tryacquire (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1); - - /// Unlock a readers/writer lock. - int release (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1); - - /// Acquire a write lock, but block if any readers or a - /// writer hold the lock. - int acquire_write (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1); - - /** - * Conditionally acquire a write lock (i.e., won't block). Returns - * -1 on failure. If we "failed" because someone else already had - * the lock, @c errno is set to @c EBUSY. - */ - int tryacquire_write (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1); - - /** - * Conditionally upgrade to a write lock (i.e., won't block). Returns - * -1 on failure. If we "failed" because someone else already had - * the lock, @c errno is set to @c EBUSY. - */ - int tryacquire_write_upgrade (short whence = 0, - ACE_OFF_T start = 0, - ACE_OFF_T len = 1); - - /** - * Acquire a read lock, but block if a writer hold the lock. - * Returns -1 on failure. If we "failed" because someone else - * already had the lock, @c errno is set to @c EBUSY. - */ - int acquire_read (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1); - - /** - * Conditionally acquire a read lock (i.e., won't block). Returns - * -1 on failure. If we "failed" because someone else already had - * the lock, @c errno is set to @c EBUSY. - */ - int tryacquire_read (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1); - - /// Get underlying ACE_HANDLE for the file. - ACE_HANDLE get_handle (void) const; - - /** - * Set underlying ACE_HANDLE. Note that this method assumes - * ownership of the and will close it down in . If - * you want the to stay open when is called make - * sure to call on the before closing it. You are - * responsible for the closing the existing before - * overwriting it. - */ - void set_handle (ACE_HANDLE); - - /// Dump state of the object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - /// Locking structure for OS record locks. - ACE_OS::ace_flock_t lock_; - - /// Keeps track of whether has been called yet to avoid - /// multiple calls, e.g., explicitly and implicitly in the - /// destructor. This flag isn't protected by a lock, so make sure - /// that you don't have multiple threads simultaneously calling - /// on the same object, which is a bad idea anyway... - int removed_; - - /// Keeps track of whether to unlink the underlying file in the - /// destructor. - int unlink_in_destructor_; - -private: - // = Prevent assignment and initialization. - void operator= (const ACE_File_Lock &); - ACE_File_Lock (const ACE_File_Lock &); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/File_Lock.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_FILE_LOCK_H */ diff --git a/ACE/ace/File_Lock.inl b/ACE/ace/File_Lock.inl deleted file mode 100644 index bef9de9d063..00000000000 --- a/ACE/ace/File_Lock.inl +++ /dev/null @@ -1,96 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE int -ACE_File_Lock::acquire_read (short whence, ACE_OFF_T start, ACE_OFF_T len) -{ -// ACE_TRACE ("ACE_File_Lock::acquire_read"); - return ACE_OS::flock_rdlock (&this->lock_, whence, start, len); -} - -ACE_INLINE int -ACE_File_Lock::tryacquire_read (short whence, ACE_OFF_T start, ACE_OFF_T len) -{ -// ACE_TRACE ("ACE_File_Lock::tryacquire_read"); - return ACE_OS::flock_tryrdlock (&this->lock_, whence, start, len); -} - -ACE_INLINE int -ACE_File_Lock::tryacquire_write (short whence, ACE_OFF_T start, ACE_OFF_T len) -{ -// ACE_TRACE ("ACE_File_Lock::tryacquire_write"); - return ACE_OS::flock_trywrlock (&this->lock_, whence, start, len); -} - -ACE_INLINE int -ACE_File_Lock::tryacquire_write_upgrade (short whence, - ACE_OFF_T start, - ACE_OFF_T len) -{ -// ACE_TRACE ("ACE_File_Lock::tryacquire_write_upgrade"); - return ACE_OS::flock_trywrlock (&this->lock_, whence, start, len); -} - -ACE_INLINE int -ACE_File_Lock::tryacquire (short whence, ACE_OFF_T start, ACE_OFF_T len) -{ -// ACE_TRACE ("ACE_File_Lock::tryacquire"); - return this->tryacquire_write (whence, start, len); -} - -ACE_INLINE int -ACE_File_Lock::acquire_write (short whence, ACE_OFF_T start, ACE_OFF_T len) -{ -// ACE_TRACE ("ACE_File_Lock::acquire_write"); - return ACE_OS::flock_wrlock (&this->lock_, whence, start, len); -} - -ACE_INLINE int -ACE_File_Lock::acquire (short whence, ACE_OFF_T start, ACE_OFF_T len) -{ -// ACE_TRACE ("ACE_File_Lock::acquire"); - return this->acquire_write (whence, start, len); -} - -ACE_INLINE int -ACE_File_Lock::release (short whence, ACE_OFF_T start, ACE_OFF_T len) -{ -// ACE_TRACE ("ACE_File_Lock::release"); - return ACE_OS::flock_unlock (&this->lock_, whence, start, len); -} - -ACE_INLINE int -ACE_File_Lock::remove (int unlink_file) -{ -// ACE_TRACE ("ACE_File_Lock::remove"); - - int result = 0; - - if (this->removed_ == 0) - { - this->removed_ = 1; - result = ACE_OS::flock_destroy (&this->lock_, - unlink_file); - } - return result; -} - -ACE_INLINE ACE_HANDLE -ACE_File_Lock::get_handle (void) const -{ -// ACE_TRACE ("ACE_File_Lock::get_handle"); - return this->lock_.handle_; -} - -ACE_INLINE void -ACE_File_Lock::set_handle (ACE_HANDLE h) -{ -// ACE_TRACE ("ACE_File_Lock::set_handle"); - this->lock_.handle_ = h; - this->removed_ = 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Filecache.cpp b/ACE/ace/Filecache.cpp deleted file mode 100644 index 5122cb6fdc8..00000000000 --- a/ACE/ace/Filecache.cpp +++ /dev/null @@ -1,754 +0,0 @@ -// $Id$ - -#include "ace/Filecache.h" -#include "ace/Object_Manager.h" -#include "ace/Log_Msg.h" -#include "ace/ACE.h" -#include "ace/Guard_T.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_time.h" -#include "ace/OS_NS_unistd.h" -#include "ace/OS_NS_fcntl.h" -#include "ace/Truncate.h" - -ACE_RCSID (ace, - Filecache, - "$Id$") - -#if defined (ACE_WIN32) -// Specifies no sharing flags. -#define R_MASK ACE_DEFAULT_OPEN_PERMS -#define W_MASK 0 -#else -#define R_MASK S_IRUSR|S_IRGRP|S_IROTH -#define W_MASK S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR|S_IWGRP|S_IWOTH -#endif /* ACE_WIN32 */ - -#if defined (ACE_WIN32) -// See if you can get rid of some of these. -#define READ_FLAGS (FILE_FLAG_SEQUENTIAL_SCAN | \ - FILE_FLAG_OVERLAPPED | \ - O_RDONLY) -// static const int RCOPY_FLAGS = (FILE_FLAG_SEQUENTIAL_SCAN | -// O_RDONLY); -#define WRITE_FLAGS (FILE_FLAG_SEQUENTIAL_SCAN | \ - FILE_FLAG_OVERLAPPED | \ - O_RDWR | O_CREAT | O_TRUNC) -// static const int WCOPY_FLAGS = (FILE_FLAG_SEQUENTIAL_SCAN | -// O_RDWR | O_CREAT | O_TRUNC); -#else -#define READ_FLAGS O_RDONLY -// static const int RCOPY_FLAGS = O_RDONLY; -#define WRITE_FLAGS (O_RDWR | O_CREAT | O_TRUNC) -// static const int WCOPY_FLAGS = O_RDWR | O_CREAT | O_TRUNC; -#endif /* ACE_WIN32 */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// static data members -ACE_Filecache *ACE_Filecache::cvf_ = 0; - -void -ACE_Filecache_Handle::init (void) -{ - this->file_ = 0; - this->handle_ = ACE_INVALID_HANDLE; -} - -ACE_Filecache_Handle::ACE_Filecache_Handle (void) - : file_ (0), handle_ (0), mapit_ (0) -{ - this->init (); -} - -ACE_Filecache_Handle::ACE_Filecache_Handle (const ACE_TCHAR *filename, - ACE_Filecache_Flag mapit) - : file_ (0), handle_ (0), mapit_ (mapit) -{ - this->init (); - // Fetch the file from the Virtual_Filesystem let the - // Virtual_Filesystem do the work of cache coherency. - - // Filecache will also do the acquire, since it holds the lock at - // that time. - this->file_ = ACE_Filecache::instance ()->fetch (filename, mapit); -} - -ACE_Filecache_Handle::ACE_Filecache_Handle (const ACE_TCHAR *filename, - int size, - ACE_Filecache_Flag mapit) - : file_ (0), handle_ (0), mapit_ (mapit) -{ - this->init (); - - if (size == 0) - ACE_Filecache::instance ()->remove (filename); - else - { - // Since this is being opened for a write, simply create a new - // ACE_Filecache_Object now, and let the destructor add it into CVF - // later - - // Filecache will also do the acquire, since it holds the lock at - // that time. - this->file_ = ACE_Filecache::instance ()->create (filename, size); - } -} - -ACE_Filecache_Handle::~ACE_Filecache_Handle (void) -{ - if (this->handle_ != ACE_INVALID_HANDLE) - // this was dup ()'d - ACE_OS::close (this->handle_); - - ACE_Filecache::instance ()->finish (this->file_); -} - -void * -ACE_Filecache_Handle::address (void) const -{ - return this->file_ == 0 ? 0 : this->file_->address (); -} - -ACE_HANDLE -ACE_Filecache_Handle::handle (void) const -{ - if (this->handle_ == ACE_INVALID_HANDLE && this->file_ != 0) - { - ACE_Filecache_Handle *mutable_this = - const_cast (this); - mutable_this->handle_ = ACE_OS::dup (this->file_->handle ()); - } - return this->handle_; -} - -int -ACE_Filecache_Handle::error (void) const -{ - if (this->file_ == 0) - return -1; - else - return this->file_->error (); -} - -ACE_OFF_T -ACE_Filecache_Handle::size (void) const -{ - if (this->file_ == 0) - return -1; - else - return this->file_->size (); -} - -// ------------------ -// ACE_Filecache_Hash -// ------------------ - -#define ACE_Filecache_Hash \ - ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex> -#define ACE_Filecache_Hash_Entry \ - ACE_Hash_Map_Entry - -template <> -ACE_Filecache_Hash_Entry::ACE_Hash_Map_Entry ( - const ACE_TCHAR *const &ext_id, - ACE_Filecache_Object *const &int_id, - ACE_Filecache_Hash_Entry *next, - ACE_Filecache_Hash_Entry *prev) - : ext_id_ (ext_id - ? ACE_OS::strdup (ext_id) - : ACE_OS::strdup (ACE_TEXT (""))), - int_id_ (int_id), - next_ (next), - prev_ (prev) -{ -} - -template <> -ACE_Filecache_Hash_Entry::ACE_Hash_Map_Entry (ACE_Filecache_Hash_Entry *next, - ACE_Filecache_Hash_Entry *prev) - : ext_id_ (0), - next_ (next), - prev_ (prev) -{ -} - -template <> -ACE_Filecache_Hash_Entry::~ACE_Hash_Map_Entry (void) -{ - ACE_OS::free ((void *) ext_id_); -} - -// We need these template specializations since KEY is defined as a -// ACE_TCHAR*, which doesn't have a hash() or equal() method defined on it. - -template <> -unsigned long -ACE_Filecache_Hash::hash (const ACE_TCHAR *const &ext_id) -{ - return ACE::hash_pjw (ext_id); -} - -template <> -int -ACE_Filecache_Hash::equal (const ACE_TCHAR *const &id1, - const ACE_TCHAR *const &id2) -{ - return ACE_OS::strcmp (id1, id2) == 0; -} - -#undef ACE_Filecache_Hash -#undef ACE_Filecache_Hash_Entry - - -// ------------- -// ACE_Filecache -// ------------- - -ACE_Filecache * -ACE_Filecache::instance (void) -{ - // Double check locking pattern. - if (ACE_Filecache::cvf_ == 0) - { - ACE_SYNCH_RW_MUTEX &lock = - *ACE_Managed_Object::get_preallocated_object - (ACE_Object_Manager::ACE_FILECACHE_LOCK); - ACE_GUARD_RETURN (ACE_SYNCH_RW_MUTEX, ace_mon, lock, 0); - - // @@ James, please check each of the ACE_NEW_RETURN calls to - // make sure that it is safe to return if allocation fails. - if (ACE_Filecache::cvf_ == 0) - ACE_NEW_RETURN (ACE_Filecache::cvf_, - ACE_Filecache, - 0); - } - - return ACE_Filecache::cvf_; -} - -ACE_Filecache::ACE_Filecache (void) - : size_ (ACE_DEFAULT_VIRTUAL_FILESYSTEM_TABLE_SIZE), - hash_ (size_) -{ -} - -ACE_Filecache::~ACE_Filecache (void) -{ -} - -ACE_Filecache_Object * -ACE_Filecache::insert_i (const ACE_TCHAR *filename, - ACE_SYNCH_RW_MUTEX &filelock, - int mapit) -{ - ACE_Filecache_Object *handle = 0; - - if (this->hash_.find (filename, handle) == -1) - { - ACE_NEW_RETURN (handle, - ACE_Filecache_Object (filename, filelock, 0, mapit), - 0); - - // ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" (%t) CVF: creating %s\n"), filename)); - - if (this->hash_.bind (filename, handle) == -1) - { - delete handle; - handle = 0; - } - } - else - handle = 0; - - return handle; -} - -ACE_Filecache_Object * -ACE_Filecache::remove_i (const ACE_TCHAR *filename) -{ - ACE_Filecache_Object *handle = 0; - - // Disassociate file from the cache. - if (this->hash_.unbind (filename, handle) == 0) - { - handle->stale_ = 1; - - // Try a lock. If it succeeds, we can delete it now. - // Otherwise, it will clean itself up later. - if (handle->lock_.tryacquire_write () == 0) - { - delete handle; - handle = 0; - } - } - else - handle = 0; - - return handle; -} - -ACE_Filecache_Object * -ACE_Filecache::update_i (const ACE_TCHAR *filename, - ACE_SYNCH_RW_MUTEX &filelock, - int mapit) -{ - ACE_Filecache_Object *handle = 0; - - handle = this->remove_i (filename); - handle = this->insert_i (filename, filelock, mapit); - - return handle; -} - -int -ACE_Filecache::find (const ACE_TCHAR *filename) -{ - return this->hash_.find (filename); -} - - -ACE_Filecache_Object * -ACE_Filecache::remove (const ACE_TCHAR *filename) -{ - ACE_Filecache_Object *handle = 0; - - ACE_OFF_T loc = ACE::hash_pjw (filename) % this->size_; - ACE_SYNCH_RW_MUTEX &hashlock = this->hash_lock_[loc]; - // ACE_SYNCH_RW_MUTEX &filelock = this->file_lock_[loc]; - - if (this->hash_.find (filename, handle) != -1) - { - ACE_WRITE_GUARD_RETURN (ACE_SYNCH_RW_MUTEX, - ace_mon, - hashlock, - 0); - - return this->remove_i (filename); - } - - return 0; -} - - -ACE_Filecache_Object * -ACE_Filecache::fetch (const ACE_TCHAR *filename, int mapit) -{ - ACE_Filecache_Object *handle = 0; - - ACE_OFF_T loc = ACE::hash_pjw (filename) % this->size_; - ACE_SYNCH_RW_MUTEX &hashlock = this->hash_lock_[loc]; - ACE_SYNCH_RW_MUTEX &filelock = this->file_lock_[loc]; - - filelock.acquire_read (); - - if (this->hash_.find (filename, handle) == -1) - { - ACE_WRITE_GUARD_RETURN (ACE_SYNCH_RW_MUTEX, - ace_mon, - hashlock, - 0); - - // Second check in the method call - handle = this->insert_i (filename, filelock, mapit); - - if (handle == 0) - filelock.release (); - } - else - { - if (handle->update ()) - { - { - // Double check locking pattern - ACE_WRITE_GUARD_RETURN (ACE_SYNCH_RW_MUTEX, - ace_mon, - hashlock, - 0); - - // Second check in the method call - handle = this->update_i (filename, filelock, mapit); - - if (handle == 0) - filelock.release (); - } - } - // ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" (%t) CVF: found %s\n"), filename)); - } - - return handle; -} - -ACE_Filecache_Object * -ACE_Filecache::create (const ACE_TCHAR *filename, int size) -{ - ACE_Filecache_Object *handle = 0; - - ACE_OFF_T loc = ACE::hash_pjw (filename) % this->size_; - ACE_SYNCH_RW_MUTEX &filelock = this->file_lock_[loc]; - - ACE_NEW_RETURN (handle, - ACE_Filecache_Object (filename, size, filelock), - 0); - handle->acquire (); - - return handle; -} - -ACE_Filecache_Object * -ACE_Filecache::finish (ACE_Filecache_Object *&file) -{ - if (file == 0) - return file; - - ACE_OFF_T loc = ACE::hash_pjw (file->filename_) % this->size_; - ACE_SYNCH_RW_MUTEX &hashlock = this->hash_lock_[loc]; - - if (file != 0) - switch (file->action_) - { - case ACE_Filecache_Object::ACE_WRITING: - { - ACE_WRITE_GUARD_RETURN (ACE_SYNCH_RW_MUTEX, - ace_mon, - hashlock, - 0); - - file->release (); - - this->remove_i (file->filename_); -#if 0 - int result = this->hash_.bind (file->filename (), file); - - if (result == 0) - file->acquire (); -#else - // Last one using a stale file is resposible for deleting it. - if (file->stale_) - { - // Try a lock. If it succeds, we can delete it now. - // Otherwise, it will clean itself up later. - if (file->lock_.tryacquire_write () == 0) - { - delete file; - file = 0; - } - } -#endif - } - - break; - default: - file->release (); - - // Last one using a stale file is resposible for deleting it. - if (file->stale_) - { - // Try a lock. If it succeds, we can delete it now. - // Otherwise, it will clean itself up later. - if (file->lock_.tryacquire_write () == 0) - { - delete file; - file = 0; - } - } - - break; - } - - return file; -} - -void -ACE_Filecache_Object::init (void) -{ - this->filename_[0] = '\0'; - this->handle_ = ACE_INVALID_HANDLE; - this->error_ = ACE_SUCCESS; - this->tempname_ = 0; - this->size_ = 0; - - ACE_OS::memset (&(this->stat_), 0, sizeof (this->stat_)); -} - -ACE_Filecache_Object::ACE_Filecache_Object (void) - : tempname_ (0), - mmap_ (), - handle_ (0), - // stat_ (), - size_ (0), - action_ (0), - error_ (0), - stale_ (0), - // sa_ (), - junklock_ (), - lock_ (junklock_) -{ - this->init (); -} - -ACE_Filecache_Object::ACE_Filecache_Object (const ACE_TCHAR *filename, - ACE_SYNCH_RW_MUTEX &lock, - LPSECURITY_ATTRIBUTES sa, - int mapit) - : tempname_ (0), - mmap_ (), - handle_ (0), - // stat_ (), - size_ (0), - action_ (0), - error_ (0), - stale_ (0), - sa_ (sa), - junklock_ (), - lock_ (lock) -{ - this->init (); - - // ASSERT strlen(filename) < sizeof (this->filename_) - ACE_OS::strcpy (this->filename_, filename); - this->action_ = ACE_Filecache_Object::ACE_READING; - // place ourselves into the READING state - - // Can we access the file? - if (ACE_OS::access (this->filename_, R_OK) == -1) - { - this->error_i (ACE_Filecache_Object::ACE_ACCESS_FAILED); - return; - } - - // Can we stat the file? - if (ACE_OS::stat (this->filename_, &this->stat_) == -1) - { - this->error_i (ACE_Filecache_Object::ACE_STAT_FAILED); - return; - } - - this->size_ = ACE_Utils::truncate_cast (this->stat_.st_size); - this->tempname_ = this->filename_; - - // Can we open the file? - this->handle_ = ACE_OS::open (this->tempname_, - READ_FLAGS, R_MASK, this->sa_); - if (this->handle_ == ACE_INVALID_HANDLE) - { - this->error_i (ACE_Filecache_Object::ACE_OPEN_FAILED, - ACE_TEXT ("ACE_Filecache_Object::ctor: open")); - return; - } - - if (mapit) - { - // Can we map the file? - if (this->mmap_.map (this->handle_, static_cast (-1), - PROT_READ, ACE_MAP_PRIVATE, 0, 0, this->sa_) != 0) - { - this->error_i (ACE_Filecache_Object::ACE_MEMMAP_FAILED, - ACE_TEXT ("ACE_Filecache_Object::ctor: map")); - ACE_OS::close (this->handle_); - this->handle_ = ACE_INVALID_HANDLE; - return; - } - } - - // Ok, finished! - this->action_ = ACE_Filecache_Object::ACE_READING; -} - -ACE_Filecache_Object::ACE_Filecache_Object (const ACE_TCHAR *filename, - ACE_OFF_T size, - ACE_SYNCH_RW_MUTEX &lock, - LPSECURITY_ATTRIBUTES sa) - : stale_ (0), - sa_ (sa), - lock_ (lock) -{ - this->init (); - - this->size_ = size; - ACE_OS::strcpy (this->filename_, filename); - this->action_ = ACE_Filecache_Object::ACE_WRITING; - - // Can we access the file? - if (ACE_OS::access (this->filename_, R_OK|W_OK) == -1 - // Does it exist? - && ACE_OS::access (this->filename_, F_OK) != -1) - { - // File exists, but we cannot access it. - this->error_i (ACE_Filecache_Object::ACE_ACCESS_FAILED); - return; - } - - this->tempname_ = this->filename_; - - // Can we open the file? - this->handle_ = ACE_OS::open (this->tempname_, WRITE_FLAGS, W_MASK, this->sa_); - if (this->handle_ == ACE_INVALID_HANDLE) - { - this->error_i (ACE_Filecache_Object::ACE_OPEN_FAILED, - ACE_TEXT ("ACE_Filecache_Object::acquire: open")); - return; - } - - // Can we write? - if (ACE_OS::pwrite (this->handle_, "", 1, this->size_ - 1) != 1) - { - this->error_i (ACE_Filecache_Object::ACE_WRITE_FAILED, - ACE_TEXT ("ACE_Filecache_Object::acquire: write")); - ACE_OS::close (this->handle_); - return; - } - - // Can we map? - if (this->mmap_.map (this->handle_, this->size_, PROT_RDWR, MAP_SHARED, - 0, 0, this->sa_) != 0) - { - this->error_i (ACE_Filecache_Object::ACE_MEMMAP_FAILED, - ACE_TEXT ("ACE_Filecache_Object::acquire: map")); - ACE_OS::close (this->handle_); - } - - // Ok, done! -} - -ACE_Filecache_Object::~ACE_Filecache_Object (void) -{ - if (this->error_ == ACE_SUCCESS) - { - this->mmap_.unmap (); - ACE_OS::close (this->handle_); - this->handle_ = ACE_INVALID_HANDLE; - } - - this->lock_.release (); -} - -int -ACE_Filecache_Object::acquire (void) -{ - return this->lock_.tryacquire_read (); -} - -int -ACE_Filecache_Object::release (void) -{ - if (this->action_ == ACE_WRITING) - { - // We are safe since only one thread has a writable Filecache_Object - -#if 0 - ACE_HANDLE original = ACE_OS::open (this->filename_, WRITE_FLAGS, W_MASK, - this->sa_); - if (original == ACE_INVALID_HANDLE) - this->error_ = ACE_Filecache_Object::ACE_OPEN_FAILED; - else if (ACE_OS::write (original, this->mmap_.addr (), - this->size_) == -1) - { - this->error_ = ACE_Filecache_Object::ACE_WRITE_FAILED; - ACE_OS::close (original); - ACE_OS::unlink (this->filename_); - } - else if (ACE_OS::stat (this->filename_, &this->stat_) == -1) - this->error_ = ACE_Filecache_Object::ACE_STAT_FAILED; -#endif - - this->mmap_.unmap (); - ACE_OS::close (this->handle_); - this->handle_ = ACE_INVALID_HANDLE; - -#if 0 - // Leave the file in an acquirable state. - this->handle_ = ACE_OS::open (this->tempname_, READ_FLAGS, R_MASK); - if (this->handle_ == ACE_INVALID_HANDLE) - { - this->error_i (ACE_Filecache_Object::ACE_OPEN_FAILED, - "ACE_Filecache_Object::acquire: open"); - } - else if (this->mmap_.map (this->handle_, -1, - PROT_READ, - ACE_MAP_PRIVATE, - 0, - 0, - this->sa_) != 0) - { - this->error_i (ACE_Filecache_Object::ACE_MEMMAP_FAILED, - "ACE_Filecache_Object::acquire: map"); - ACE_OS::close (this->handle_); - this->handle_ = ACE_INVALID_HANDLE; - } - - this->action_ = ACE_Filecache_Object::ACE_READING; -#endif - } - - return this->lock_.release (); -} - -int -ACE_Filecache_Object::error (void) const -{ - // The existence of the object means a read lock is being held. - return this->error_; -} - -int -ACE_Filecache_Object::error_i (int error_value, const ACE_TCHAR *s) -{ - s = s; - ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p.\n"), s)); - this->error_ = error_value; - return error_value; -} - -const ACE_TCHAR * -ACE_Filecache_Object::filename (void) const -{ - // The existence of the object means a read lock is being held. - return this->filename_; -} - -ACE_OFF_T -ACE_Filecache_Object::size (void) const -{ - // The existence of the object means a read lock is being held. - return this->size_; -} - -ACE_HANDLE -ACE_Filecache_Object::handle (void) const -{ - // The existence of the object means a read lock is being held. - return this->handle_; -} - -void * -ACE_Filecache_Object::address (void) const -{ - // The existence of the object means a read lock is being held. - return this->mmap_.addr (); -} - -int -ACE_Filecache_Object::update (void) const -{ - // The existence of the object means a read lock is being held. - int result; - ACE_stat statbuf; - - if (ACE_OS::stat (this->filename_, &statbuf) == -1) - result = 1; - else - // non-portable code may follow -#if defined (ACE_HAS_WINCE) - // Yup, non-portable... there's probably a way to safely implement - // difftime() on WinCE, but for now, this will have to do. It flags - // every file as having changed since cached. - result = 1; -#else - result = ACE_OS::difftime (this->stat_.st_mtime, statbuf.st_mtime) < 0; -#endif /* ACE_HAS_WINCE */ - - return result; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Filecache.h b/ACE/ace/Filecache.h deleted file mode 100644 index df1835b9372..00000000000 --- a/ACE/ace/Filecache.h +++ /dev/null @@ -1,353 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Filecache.h - * - * $Id$ - * - * @author James Hu - */ -//============================================================================= - - -#ifndef ACE_FILECACHE_H -#define ACE_FILECACHE_H - -#include /**/ "ace/pre.h" - -#include "ace/Mem_Map.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Hash_Map_Manager_T.h" -#include "ace/Null_Mutex.h" -#include "ace/Synch_Traits.h" -#include "ace/RW_Thread_Mutex.h" -#include "ace/OS_NS_sys_stat.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -enum ACE_Filecache_Flag -{ - ACE_NOMAP = 0, - ACE_MAPIT = 1 -}; - -class ACE_Filecache_Object; - -/** - * @class ACE_Filecache_Handle - * - * @brief Abstraction over a real file. This is meant to be the entry - * point into the Cached Virtual Filesystem. - * - * This is a cached filesystem implementation based loosely on the - * implementation of JAWS_File. The interfaces will be nearly the - * same. The under-the-hood implementation should hopefully be a - * much faster thing. - * These will be given their own implementations later. For now, we - * borrow the implementation provided by JAWS. - * On creation, the cache is checked, and reference count is - * incremented. On destruction, reference count is decremented. If - * the reference count is 0, the file is removed from the cache. - * E.g. 1, - * { - * ACE_Filecache_Handle foo("foo.html"); - * this->peer ().send (foo.address (), foo.size ()); - * } - * E.g. 2, - * { - * ACE_Filecache_Handle foo("foo.html"); - * io->transmitfile (foo.handle (), this->peer ().handle ()); - * } - * E.g. 3, - * { - * ACE_Filecache_Handle foo("foo.html", content_length); - * this->peer ().recv (foo.address (), content_length); - * } - * TODO: - */ -class ACE_Export ACE_Filecache_Handle -{ - // (1) Get rid of the useless copying of files when reading. - // Although it does make sure the file you send isn't being changed, - // it doesn't make sure the file is in a sensible state before - // sending it. - // - // Alternative: if the file get's trashed while it is being shipped, - // let the client request the file again. The cache should have an - // updated copy by that point. - // - // (2) Use hashing for locating files. This means I need a hastable - // implementation with buckets. - // - // (3) Only lock when absolutely necessary. JAWS_Virtual_Filesystem was - // rather conservative, but for some reason it still ran into problems. - // Since this design should be simpler, problems should be easier to spot. - // -public: - - /// Query cache for file, and acquire it. Assumes the file is being - /// opened for reading. - ACE_Filecache_Handle (const ACE_TCHAR *filename, - ACE_Filecache_Flag mapit = ACE_MAPIT); - - /** - * Create new entry, and acquire it. Presence of SIZE assumes the - * file is being opened for writing. If SIZE is zero, assumes the - * file is to be removed from the cache. - */ - ACE_Filecache_Handle (const ACE_TCHAR *filename, - int size, - ACE_Filecache_Flag mapit = ACE_MAPIT); - - /// Closes any open handles, release acquired file. - ~ACE_Filecache_Handle (void); - - /// Base address of memory mapped file. - void *address (void) const; - - /// A handle (e.g., UNIX file descriptor, or NT file handle). - ACE_HANDLE handle (void) const; - - /// Any associated error in handle creation and acquisition. - int error (void) const; - - /// The size of the file. - ACE_OFF_T size (void) const; - -protected: - /// Default do nothing constructor. Prevent it from being called. - ACE_Filecache_Handle (void); - - /// Common initializations for constructors. - void init (void); - -public: - /// These come from ACE_Filecache_Object, which is an internal class. - enum - { - ACE_SUCCESS = 0, - ACE_ACCESS_FAILED, - ACE_OPEN_FAILED, - ACE_COPY_FAILED, - ACE_STAT_FAILED, - ACE_MEMMAP_FAILED, - ACE_WRITE_FAILED - }; - -private: - /// A reference to the low level instance. - ACE_Filecache_Object *file_; - - /// A 'd version of the one from . - ACE_HANDLE handle_; - - int mapit_; -}; - -typedef ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex> - ACE_Filecache_Hash; - -typedef ACE_Hash_Map_Entry ACE_Filecache_Hash_Entry; - -/** - * @class ACE_Filecache - * - * @brief A hash table holding the information about entry point into - * the Cached Virtual Filesystem. On insertion, the reference - * count is incremented. On destruction, reference count is - * decremented. - */ -class ACE_Export ACE_Filecache -{ -public: - /// Singleton pattern. - static ACE_Filecache *instance (void); - - ~ACE_Filecache (void); - - /// Returns 0 if the file associated with ``filename'' is in the cache, - /// or -1 if not. - int find (const ACE_TCHAR *filename); - - /// Return the file associated with ``filename'' if it is in the cache, - /// or create if not. - ACE_Filecache_Object *fetch (const ACE_TCHAR *filename, int mapit = 1); - - /// Remove the file associated with ``filename'' from the cache. - ACE_Filecache_Object *remove (const ACE_TCHAR *filename); - - /// Create a new Filecache_Object, returns it. - ACE_Filecache_Object *create (const ACE_TCHAR *filename, int size); - - /// Release an acquired Filecache_Object, returns it again or NULL if it - /// was deleted. - ACE_Filecache_Object *finish (ACE_Filecache_Object *&new_file); - -protected: - ACE_Filecache_Object *insert_i (const ACE_TCHAR *filename, - ACE_SYNCH_RW_MUTEX &filelock, - int mapit); - ACE_Filecache_Object *remove_i (const ACE_TCHAR *filename); - ACE_Filecache_Object *update_i (const ACE_TCHAR *filename, - ACE_SYNCH_RW_MUTEX &filelock, - int mapit); - -public: - - enum - { - /// For this stupid implementation, use an array. Someday, use a - /// balanced search tree, or real hash table. - ACE_DEFAULT_VIRTUAL_FILESYSTEM_TABLE_SIZE = 512, - - /// This determines the highwater mark in megabytes for the cache. - /// This will be ignored for now. - ACE_DEFAULT_VIRTUAL_FILESYSTEM_CACHE_SIZE = 20 - }; - -protected: - /// Prevent it from being called. - ACE_Filecache (void); - -private: - ACE_OFF_T size_; - - /// The hash table - ACE_Filecache_Hash hash_; - - /// The reference to the instance - static ACE_Filecache *cvf_; - - // = Synchronization variables. - ACE_SYNCH_RW_MUTEX hash_lock_[ACE_DEFAULT_VIRTUAL_FILESYSTEM_TABLE_SIZE]; - ACE_SYNCH_RW_MUTEX file_lock_[ACE_DEFAULT_VIRTUAL_FILESYSTEM_TABLE_SIZE]; -}; - -/** - * @class ACE_Filecache_Object - * - * @brief Abstraction over a real file. This is what the Virtual - * Filesystem contains. This class is not intended for general - * consumption. Please consult a physician before attempting to - * use this class. - */ -class ACE_Export ACE_Filecache_Object -{ -public: - friend class ACE_Filecache; - - /// Creates a file for reading. - ACE_Filecache_Object (const ACE_TCHAR *filename, - ACE_SYNCH_RW_MUTEX &lock, - LPSECURITY_ATTRIBUTES sa = 0, - int mapit = 1); - - /// Creates a file for writing. - ACE_Filecache_Object (const ACE_TCHAR *filename, - ACE_OFF_T size, - ACE_SYNCH_RW_MUTEX &lock, - LPSECURITY_ATTRIBUTES sa = 0); - - /// Only if reference count is zero should this be called. - ~ACE_Filecache_Object (void); - - /// Increment the reference_count_. - int acquire (void); - - /// Decrement the reference_count_. - int release (void); - - // = error_ accessors - int error (void) const; - int error (int error_value, - const ACE_TCHAR *s = ACE_TEXT ("ACE_Filecache_Object")); - - /// filename_ accessor - const ACE_TCHAR *filename (void) const; - - /// handle_ accessor. - ACE_HANDLE handle (void) const; - - /// Base memory address for memory mapped file. - void *address (void) const; - - /// size_ accessor. - ACE_OFF_T size (void) const; - - /// True if file on disk is newer than cached file. - int update (void) const; - -protected: - /// Prevent from being called. - ACE_Filecache_Object (void); - - /// Common initialization code, - void init (void); - -private: - /// Internal error logging method, no locking. - int error_i (int error_value, - const ACE_TCHAR *s = ACE_TEXT ("ACE_Filecache_Object")); - -public: - - enum Creation_States - { - ACE_READING = 1, - ACE_WRITING = 2 - }; - - enum Error_Conditions - { - ACE_SUCCESS = 0, - ACE_ACCESS_FAILED, - ACE_OPEN_FAILED, - ACE_COPY_FAILED, - ACE_STAT_FAILED, - ACE_MEMMAP_FAILED, - ACE_WRITE_FAILED - }; - -private: - /// The temporary file name and the real file name. The real file is - /// copied into the temporary file for safety reasons. - ACE_TCHAR *tempname_; - ACE_TCHAR filename_[MAXPATHLEN + 1]; - - /// Holds the memory mapped version of the temporary file. - ACE_Mem_Map mmap_; - - /// The descriptor to the temporary file. - ACE_HANDLE handle_; - - /// Used to compare against the real file to test if an update is needed. - ACE_stat stat_; - ACE_OFF_T size_; - - /// Status indicators. - int action_; - int error_; - - /// If set to 1, means the object is flagged for removal. - int stale_; - - /// Security attribute object. - LPSECURITY_ATTRIBUTES sa_; - - /// The default initializer - ACE_SYNCH_RW_MUTEX junklock_; - - /// Provides a bookkeeping mechanism for users of this object. - ACE_SYNCH_RW_MUTEX &lock_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#include /**/ "ace/post.h" - -#endif /* ACE_FILECACHE_H */ diff --git a/ACE/ace/FlReactor/ACE_FlReactor.pc.in b/ACE/ace/FlReactor/ACE_FlReactor.pc.in deleted file mode 100644 index c284481585d..00000000000 --- a/ACE/ace/FlReactor/ACE_FlReactor.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: ACE_FlReactor -Description: ACE FlReactor Library -Requires: ACE -Version: @VERSION@ -Libs: -L${libdir} -lACE_FlReactor -Cflags: -I${includedir} diff --git a/ACE/ace/FlReactor/ACE_FlReactor_export.h b/ACE/ace/FlReactor/ACE_FlReactor_export.h deleted file mode 100644 index f46b66cb3f7..00000000000 --- a/ACE/ace/FlReactor/ACE_FlReactor_export.h +++ /dev/null @@ -1,58 +0,0 @@ - -// -*- C++ -*- -// $Id$ -// Definition for Win32 Export directives. -// This file is generated automatically by generate_export_file.pl -s ACE_FlReactor -// ------------------------------ -#ifndef ACE_FLREACTOR_EXPORT_H -#define ACE_FLREACTOR_EXPORT_H - -#include /**/ "ace/config-all.h" - -#if defined (ACE_AS_STATIC_LIBS) && !defined (ACE_FLREACTOR_HAS_DLL) -# define ACE_FLREACTOR_HAS_DLL 0 -#endif /* ACE_AS_STATIC_LIBS && ACE_FLREACTOR_HAS_DLL */ - -#if !defined (ACE_FLREACTOR_HAS_DLL) -# define ACE_FLREACTOR_HAS_DLL 1 -#endif /* ! ACE_FLREACTOR_HAS_DLL */ - -#if defined (ACE_FLREACTOR_HAS_DLL) && (ACE_FLREACTOR_HAS_DLL == 1) -# if defined (ACE_FLREACTOR_BUILD_DLL) -# define ACE_FlReactor_Export ACE_Proper_Export_Flag -# define ACE_FLREACTOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) -# define ACE_FLREACTOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -# else /* ACE_FLREACTOR_BUILD_DLL */ -# define ACE_FlReactor_Export ACE_Proper_Import_Flag -# define ACE_FLREACTOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) -# define ACE_FLREACTOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -# endif /* ACE_FLREACTOR_BUILD_DLL */ -#else /* ACE_FLREACTOR_HAS_DLL == 1 */ -# define ACE_FlReactor_Export -# define ACE_FLREACTOR_SINGLETON_DECLARATION(T) -# define ACE_FLREACTOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -#endif /* ACE_FLREACTOR_HAS_DLL == 1 */ - -// Set ACE_FLREACTOR_NTRACE = 0 to turn on library specific tracing even if -// tracing is turned off for ACE. -#if !defined (ACE_FLREACTOR_NTRACE) -# if (ACE_NTRACE == 1) -# define ACE_FLREACTOR_NTRACE 1 -# else /* (ACE_NTRACE == 1) */ -# define ACE_FLREACTOR_NTRACE 0 -# endif /* (ACE_NTRACE == 1) */ -#endif /* !ACE_FLREACTOR_NTRACE */ - -#if (ACE_FLREACTOR_NTRACE == 1) -# define ACE_FLREACTOR_TRACE(X) -#else /* (ACE_FLREACTOR_NTRACE == 1) */ -# if !defined (ACE_HAS_TRACE) -# define ACE_HAS_TRACE -# endif /* ACE_HAS_TRACE */ -# define ACE_FLREACTOR_TRACE(X) ACE_TRACE_IMPL(X) -# include "ace/Trace.h" -#endif /* (ACE_FLREACTOR_NTRACE == 1) */ - -#endif /* ACE_FLREACTOR_EXPORT_H */ - -// End of auto generated file. diff --git a/ACE/ace/FlReactor/FlReactor.cpp b/ACE/ace/FlReactor/FlReactor.cpp deleted file mode 100644 index 611b9a14a19..00000000000 --- a/ACE/ace/FlReactor/FlReactor.cpp +++ /dev/null @@ -1,330 +0,0 @@ -// $Id$ - -#include "ace/FlReactor/FlReactor.h" - -ACE_RCSID(ace, FlReactor, "$Id$") - -#include /**/ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE (ACE_FlReactor) - -// Must be called with lock held -ACE_FlReactor::ACE_FlReactor (size_t size, - int restart, - ACE_Sig_Handler *h) - : ACE_Select_Reactor (size, restart, h) -{ - // When the ACE_Select_Reactor is constructed it creates the notify - // pipe and registers it with the register_handler_i() method. The - // FlReactor overloads this method BUT because the - // register_handler_i occurs when constructing the base class - // ACE_Select_Reactor, the ACE_Select_Reactor register_handler_i() - // is called not the FlReactor register_handler_i(). This means - // that the notify pipe is registered with the ACE_Select_Reactor - // event handling code not the FlReactor and so notfications don't - // work. To get around this we simply close and re-opened the - // notification handler in the constructor of the FlReactor. - -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) - this->notify_handler_->close (); - this->notify_handler_->open (this, 0); -#endif /* ACE_MT_SAFE */ -} - -ACE_FlReactor::~ACE_FlReactor (void) -{ -} - -// This is just the from ace/Reactor.cpp -// but we use the Fl functions to wait for an event, not , just use the Fl mechanism - // to wait for one or more events... - - // Wait for something to happen. - double t = 0; - if (max_wait_time != 0) - t = max_wait_time->sec () + max_wait_time->usec () / 1000000.0F; - - while (t > 0) { - t = Fl::wait (t); - } - - // Reset the width, in case it changed during the upcalls. - width = this->handler_rep_.max_handlep1 (); - - // Now actually read the result needed by the - // using - -int -ACE_FoxReactor::wait_for_multiple_events (ACE_Select_Reactor_Handle_Set &handle_set, - ACE_Time_Value *max_wait_time) -{ - ACE_TRACE( "ACE_FoxReactor::wait_for_multiple_events" ); - - int nfound = 0; - do - { - max_wait_time = this->timer_queue_->calculate_timeout (max_wait_time); - size_t width = this->handler_rep_.max_handlep1 (); - handle_set.rd_mask_ = this->wait_set_.rd_mask_; - handle_set.wr_mask_ = this->wait_set_.wr_mask_; - handle_set.ex_mask_ = this->wait_set_.ex_mask_; - - nfound = FoxWaitForMultipleEvents (width, - handle_set, - max_wait_time); - - } while( nfound == -1 && this->handle_error () > 0 ); - - if (nfound > 0) - { -#if !defined (ACE_WIN32) - handle_set.rd_mask_.sync (this->handler_rep_.max_handlep1 ()); - handle_set.wr_mask_.sync (this->handler_rep_.max_handlep1 ()); - handle_set.ex_mask_.sync (this->handler_rep_.max_handlep1 ()); -#endif /* ACE_WIN32 */ - } - - return nfound; - // Timed out or input available -} - -int -ACE_FoxReactor::FoxWaitForMultipleEvents (int width, - ACE_Select_Reactor_Handle_Set &wait_set, - ACE_Time_Value */*max_wait_time*/) -{ - // Check to make sure our handle's are all usable. - ACE_Select_Reactor_Handle_Set temp_set = wait_set; - - if (ACE_OS::select (width, - temp_set.rd_mask_, - temp_set.wr_mask_, - temp_set.ex_mask_, - (ACE_Time_Value *) &ACE_Time_Value::zero ) == -1) - return -1; // Bad file arguments... - - // Qt processing. - this->fxapp->runOneEvent () ; - - // Reset the width, in case it changed during the upcalls. - width = handler_rep_.max_handlep1 (); - - // Now actually read the result needed by the using - // modifies the @c fd_set. - */ - void sync (ACE_HANDLE max); - - /// Returns a pointer to the underlying @c fd_set. Returns 0 if - /// there are no handle bits set ( == 0). - operator fd_set *(); - - /// Returns a pointer to the underlying @c fd_set. Returns 0 if - /// there are no handle bits set ( == 0). - fd_set *fdset (void); - -#if defined (ACE_HAS_BIG_FD_SET) - /// Assignment operator optimizes for cases where == 0. - ACE_Handle_Set & operator= (const ACE_Handle_Set &); -#endif /* ACE_HAS_BIG_FD_SET */ - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - /// Size of the set, i.e., a count of the number of enabled bits. - int size_; - - /// Current max handle. - ACE_HANDLE max_handle_; - -#if defined (ACE_HAS_BIG_FD_SET) - /// Current min handle. - ACE_HANDLE min_handle_; -#endif /* ACE_HAS_BIG_FD_SET */ - - /// Bitmask. - fd_set mask_; - - enum - { - WORDSIZE = NFDBITS, -#if !defined (ACE_WIN32) - NUM_WORDS = howmany (MAXSIZE, NFDBITS), -#endif /* ACE_WIN32 */ - NBITS = 256 - }; - - /// Counts the number of bits enabled in N. Uses a table lookup to - /// speed up the count. - static int count_bits (u_long n); - -#if defined (ACE_HAS_BIG_FD_SET) - /// Find the position of the bit counting from right to left. - static int bitpos (u_long bit); -#endif /* ACE_HAS_BIG_FD_SET */ - - /// Resets the after a clear of the original - /// . - void set_max (ACE_HANDLE max); - - /// Table that maps bytes to counts of the enabled bits in each value - /// from 0 to 255. - static const char nbits_[NBITS]; -}; - -/** - * @class ACE_Handle_Set_Iterator - * - * @brief Iterator for the ACE_Handle_Set abstraction. - */ -class ACE_Export ACE_Handle_Set_Iterator -{ -public: - /// Constructor. - ACE_Handle_Set_Iterator (const ACE_Handle_Set &hs); - - /// Default dtor. - ~ACE_Handle_Set_Iterator (void); - - /// Reset the state of the iterator by reinitializing the state - /// that we maintain. - void reset_state (void); - - /** - * "Next" operator. Returns the next unseen ACE_HANDLE in the - * up to ). When all the - * handles have been seen returns . Advances - * the iterator automatically, so you need not call - * (which is now obsolete). - */ - ACE_HANDLE operator () (void); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - /// The we are iterating through. - const ACE_Handle_Set &handles_; - - /// Index of the bit we're examining in the current word. -#if defined (ACE_WIN32) - u_int handle_index_; -#elif !defined (ACE_HAS_BIG_FD_SET) - int handle_index_; -#elif defined (ACE_HAS_BIG_FD_SET) - int handle_index_; - u_long oldlsb_; -#endif /* ACE_WIN32 */ - - /// Number of the word we're iterating over (typically between 0..7). - int word_num_; - -#if defined (ACE_HAS_BIG_FD_SET) - /// Number max of the words with a possible bit on. - int word_max_; -#endif /* ACE_HAS_BIG_FD_SET */ - -#if !defined (ACE_WIN32) && !defined (ACE_HAS_BIG_FD_SET) - /// Value of the bits in the word we're iterating on. - fd_mask word_val_; -#elif !defined (ACE_WIN32) && defined (ACE_HAS_BIG_FD_SET) - /// Value of the bits in the word we're iterating on. - u_long word_val_; -#endif /* !ACE_WIN32 && !ACE_HAS_BIG_FD_SET */ -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Handle_Set.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_HANDLE_SET */ diff --git a/ACE/ace/Handle_Set.inl b/ACE/ace/Handle_Set.inl deleted file mode 100644 index a4b1fccaebb..00000000000 --- a/ACE/ace/Handle_Set.inl +++ /dev/null @@ -1,193 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/Log_Msg.h" - -// todo: This should be cleaned up a bit. -// memset for FD_ZERO on OpenBSD and Solaris w/ gcc 2.95.3 -#include "ace/os_include/os_string.h" - -// FreeBSD 4.8-RC? for bzero() used by FD_ZERO -#include "ace/os_include/os_strings.h" - -// IRIX5 defines bzero() in this odd file... used by FD_ZERO -#if defined (ACE_HAS_BSTRING) -# include /**/ -#endif /* ACE_HAS_BSTRING */ - -// AIX defines bzero() in this odd file... used by FD_ZERO -#if defined (ACE_HAS_STRINGS) -# include "ace/os_include/os_strings.h" -#endif /* ACE_HAS_STRINGS */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Initialize the bitmask to all 0s and reset the associated fields. - -ACE_INLINE void -ACE_Handle_Set::reset (void) -{ - ACE_TRACE ("ACE_Handle_Set::reset"); - this->max_handle_ = - ACE_INVALID_HANDLE; -#if defined (ACE_HAS_BIG_FD_SET) - this->min_handle_ = - NUM_WORDS * WORDSIZE; -#endif /* ACE_HAS_BIG_FD_SET */ - this->size_ = 0; - // #if !defined (ACE_HAS_BIG_FD_SET) Why is this here? -Steve Huston - FD_ZERO (&this->mask_); - // #endif /* ACE_HAS_BIG_FD_SET */ -} - -#if defined (ACE_HAS_BIG_FD_SET) -ACE_INLINE ACE_Handle_Set & -ACE_Handle_Set::operator = (const ACE_Handle_Set &rhs) -{ - ACE_TRACE ("ACE_Handle_Set::operator ="); - - if (rhs.size_ > 0) - { - this->size_ = - rhs.size_; - this->max_handle_ = - rhs.max_handle_; - this->min_handle_ = - rhs.min_handle_; - this->mask_ = - rhs.mask_; - } - else - this->reset (); - - return *this; -} -#endif /* ACE_HAS_BIG_FD_SET */ - -// Returns the number of the large bit. - -ACE_INLINE ACE_HANDLE -ACE_Handle_Set::max_set (void) const -{ - ACE_TRACE ("ACE_Handle_Set::max_set"); - return this->max_handle_; -} - -// Checks whether handle is enabled. - -ACE_INLINE int -ACE_Handle_Set::is_set (ACE_HANDLE handle) const -{ - ACE_TRACE ("ACE_Handle_Set::is_set"); -#if defined (ACE_HAS_BIG_FD_SET) - return FD_ISSET (handle, - &this->mask_) - && this->size_ > 0; -#elif defined (ACE_HAS_NONCONST_FD_ISSET) - return FD_ISSET (handle, - const_cast (&this->mask_)); -#else - return FD_ISSET (handle, - &this->mask_); -#endif /* ACE_HAS_BIG_FD_SET */ -} - -// Enables the handle. - -ACE_INLINE void -ACE_Handle_Set::set_bit (ACE_HANDLE handle) -{ - ACE_TRACE ("ACE_Handle_Set::set_bit"); - if ((handle != ACE_INVALID_HANDLE) - && (!this->is_set (handle))) - { -#if defined (ACE_WIN32) - FD_SET ((SOCKET) handle, - &this->mask_); - ++this->size_; -#else /* ACE_WIN32 */ -#if defined (ACE_HAS_BIG_FD_SET) - if (this->size_ == 0) - FD_ZERO (&this->mask_); - - if (handle < this->min_handle_) - this->min_handle_ = handle; -#endif /* ACE_HAS_BIG_FD_SET */ - - FD_SET (handle, - &this->mask_); - ++this->size_; - - if (handle > this->max_handle_) - this->max_handle_ = handle; -#endif /* ACE_WIN32 */ - } -} - -// Disables the handle. - -ACE_INLINE void -ACE_Handle_Set::clr_bit (ACE_HANDLE handle) -{ - ACE_TRACE ("ACE_Handle_Set::clr_bit"); - - if ((handle != ACE_INVALID_HANDLE) && - (this->is_set (handle))) - { - FD_CLR ((ACE_SOCKET) handle, - &this->mask_); - --this->size_; - -#if !defined (ACE_WIN32) - if (handle == this->max_handle_) - this->set_max (this->max_handle_); -#endif /* !ACE_WIN32 */ - } -} - -// Returns a count of the number of enabled bits. - -ACE_INLINE int -ACE_Handle_Set::num_set (void) const -{ - ACE_TRACE ("ACE_Handle_Set::num_set"); -#if defined (ACE_WIN32) - return this->mask_.fd_count; -#else /* !ACE_WIN32 */ - return this->size_; -#endif /* ACE_WIN32 */ -} - -// Returns a pointer to the underlying fd_set. - -ACE_INLINE -ACE_Handle_Set::operator fd_set *() -{ - ACE_TRACE ("ACE_Handle_Set::operator fd_set *"); - - if (this->size_ > 0) - return (fd_set *) &this->mask_; - else - return (fd_set *) 0; -} - -// Returns a pointer to the underlying fd_set. - -ACE_INLINE fd_set * -ACE_Handle_Set::fdset (void) -{ - ACE_TRACE ("ACE_Handle_Set::fdset"); - - if (this->size_ > 0) - return (fd_set *) &this->mask_; - else - return (fd_set *) 0; -} - -ACE_INLINE -ACE_Handle_Set_Iterator::~ACE_Handle_Set_Iterator (void) -{ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Hash_Cache_Map_Manager_T.cpp b/ACE/ace/Hash_Cache_Map_Manager_T.cpp deleted file mode 100644 index 86af4960a85..00000000000 --- a/ACE/ace/Hash_Cache_Map_Manager_T.cpp +++ /dev/null @@ -1,232 +0,0 @@ -// $Id$ - -#ifndef ACE_HASH_CACHE_MAP_MANAGER_T_CPP -#define ACE_HASH_CACHE_MAP_MANAGER_T_CPP - -#include "ace/Hash_Cache_Map_Manager_T.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (__ACE_INLINE__) -#include "ace/Hash_Cache_Map_Manager_T.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Cache_Map_Manager) - -#define ACE_T1 class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES -#define ACE_T2 KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES - -template -ACE_Hash_Cache_Map_Manager::ACE_Hash_Cache_Map_Manager (CACHING_STRATEGY &caching_s, - size_t size, - ACE_Allocator *alloc) - : ACE_HCMM_BASE (caching_s, - size, - alloc) -{ -} - -template -ACE_Hash_Cache_Map_Manager::~ACE_Hash_Cache_Map_Manager (void) -{ -} - -template int -ACE_Hash_Cache_Map_Manager::bind (const KEY &key, - const VALUE &value, - CACHE_ENTRY *&entry) -{ - // Insert a entry which has the and the which is - // the combination of the and the attributes of the caching - // strategy. - CACHE_VALUE cache_value (value, - this->caching_strategy_.attributes ()); - - int bind_result = this->map_.bind (key, - cache_value, - entry); - - if (bind_result != -1) - { - - int result = this->caching_strategy_.notify_bind (bind_result, - cache_value.second ()); - - if (result == -1) - { - - this->map_.unbind (key); - - // Unless the notification goes thru the bind operation is - // not complete. - bind_result = -1; - - } - } - - return bind_result; -} - -template int -ACE_Hash_Cache_Map_Manager::rebind (const KEY &key, - const VALUE &value, - CACHE_ENTRY *&entry) -{ - CACHE_VALUE cache_value (value, - this->caching_strategy_.attributes ()); - - int rebind_result = this->map_.rebind (key, - cache_value, - entry); - - if (rebind_result != -1) - { - - int result = this->caching_strategy_.notify_rebind (rebind_result, - cache_value.second ()); - - if (result == -1) - { - - // Make sure the unbind operation is done only when the - // notification fails after a bind which is denoted by - // rebind_result = 0 - if (rebind_result == 0) - this->map_.unbind (key); - - // Unless the notification goes thru the rebind operation is - // not complete. - rebind_result = -1; - - } - - } - - return rebind_result; -} - -template int -ACE_Hash_Cache_Map_Manager::trybind (const KEY &key, - VALUE &value, - CACHE_ENTRY *&entry) -{ - CACHE_VALUE cache_value (value, - this->caching_strategy_.attributes ()); - - int trybind_result = this->map_.trybind (key, - cache_value, - entry); - - if (trybind_result != -1) - { - int result = this->caching_strategy_.notify_trybind (trybind_result, - cache_value.second ()); - - if (result == -1) - { - - // If the entry has got inserted into the map, it is removed - // due to failure. - if (trybind_result == 0) - this->map_.unbind (key); - - trybind_result = -1; - - } - else - { - - // If an attempt is made to bind an existing entry the value - // is overwritten with the value from the map. - if (trybind_result == 1) - value = cache_value.first (); - - } - - } - - return trybind_result; -} - -template int -ACE_Hash_Cache_Map_Manager::find (const KEY &key, - CACHE_ENTRY *&entry) -{ - // Lookup the key and populate the . - int find_result = this->map_.find (key, - entry); - - if (find_result != -1) - { - - int result = this->caching_strategy_.notify_find (find_result, - entry->int_id_.second ()); - - // Unless the find and notification operations go thru, this - // method is not successful. - if (result == -1) - find_result = -1; - else - find_result = 0; - - } - - return find_result; -} - -template int -ACE_Hash_Cache_Map_Manager::find (const KEY &key, - VALUE &value) -{ - CACHE_ENTRY *entry = 0; - - int result = this->find (key, - entry); - - if (result != -1) - { - value = entry->int_id_.first (); - } - - return result; -} - -template int -ACE_Hash_Cache_Map_Manager::find (const KEY &key) -{ - CACHE_ENTRY *entry = 0; - - return this->find (key, - entry); -} - -template int -ACE_Hash_Cache_Map_Manager::unbind (CACHE_ENTRY *entry) -{ - // Remove the entry from the cache. - int unbind_result = this->map_.unbind (entry); - - if (unbind_result != -1) - { - - int result = this->caching_strategy_.notify_unbind (unbind_result, - entry->int_id_.second ()); - - if (result == -1) - unbind_result = -1; - - } - - return unbind_result; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#undef ACE_T1 -#undef ACE_T2 - -#endif /* ACE_HASH_CACHE_MAP_MANAGER_T_CPP */ diff --git a/ACE/ace/Hash_Cache_Map_Manager_T.h b/ACE/ace/Hash_Cache_Map_Manager_T.h deleted file mode 100644 index 66cc3b83b53..00000000000 --- a/ACE/ace/Hash_Cache_Map_Manager_T.h +++ /dev/null @@ -1,214 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Hash_Cache_Map_Manager_T.h - * - * $Id$ - * - * @author Kirthika Parameswaran - */ -//============================================================================= - - -#ifndef HASH_CACHE_MAP_MANAGER_T_H -#define HASH_CACHE_MAP_MANAGER_T_H - -#include /**/ "ace/pre.h" - -#include "ace/Hash_Map_Manager_T.h" -#include "ace/Cache_Map_Manager_T.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Null_Mutex.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Forward declaration. -class ACE_Allocator; - -#define ACE_CACHE_MAP_MANAGER \ - ACE_Cache_Map_Manager, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>, \ - ACE_Hash_Map_Iterator_Ex, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>, \ - ACE_Hash_Map_Reverse_Iterator_Ex, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>, \ - CACHING_STRATEGY, \ - ATTRIBUTES> - -// For linkers that cant grok long names. -#define ACE_Hash_Cache_Map_Manager AHCMM - - /** - * @class ACE_Hash_Cache_Map_Manager - * - * @brief Defines a abstraction which will purge entries from a map. - * The map considered is the ACE_Hash_Map_Manager_Ex. - * - * The Hash_Cache_Map_Manager will manage the map it contains - * and provide purging on demand from the map. The strategy for - * caching is decided by the user and provided to the Cache - * Manager. The Cache Manager acts as a agent and communicates - * between the Map and the Strategy for purging entries from the - * map. To tap the optimal methods like find(key,value,entry) - * present in the ACE_Hash_Map_Manager, - * Hash_Cache_Map_Manager provides extra functionality on top - * of the Cache_Map_Manager. - * No locking mechanism provided since locking at this level - * isnt efficient. Locking has to be provided by the - * application. - */ -template -class ACE_Hash_Cache_Map_Manager : public ACE_CACHE_MAP_MANAGER -{ - public: - - /** - * The actual value mapped to the key in the map. The - * are used by the strategy and is transparent to the user of this - * class. - */ - typedef ACE_Pair CACHE_VALUE; - typedef ACE_Hash_Map_Manager_Ex HASH_MAP; - typedef ACE_Hash_Map_Entry CACHE_ENTRY; - typedef KEY key_type; - typedef VALUE mapped_type; - - // = Initialization and termination methods. - /// Initialize a with @a size entries. - ACE_Hash_Cache_Map_Manager (CACHING_STRATEGY &caching_s, - size_t size = ACE_DEFAULT_MAP_SIZE, - ACE_Allocator *alloc = 0); - - /// Close down a and release dynamically allocated - /// resources. - ~ACE_Hash_Cache_Map_Manager (void); - - /** - * Associate @a key with @a value. If @a key is already in the - * MAP then the ENTRY is not changed. Returns 0 if a new entry is - * bound successfully, returns 1 if an attempt is made to bind an - * existing entry, and returns -1 if failures occur. - */ - int bind (const KEY &key, - const VALUE &value); - - /** - * Same as a normal bind, except the cache entry is also passed back - * to the caller. The entry in this case will either be the newly - * created entry, or the existing one. - */ - int bind (const KEY &key, - const VALUE &value, - CACHE_ENTRY *&entry); - - /// Loopkup entry in the cache. - int find (const KEY &key, - VALUE &value); - - /// Is @a key in the cache? - int find (const KEY &key); - - /// Obtain the entry when the find succeeds. - int find (const KEY &key, - CACHE_ENTRY *&entry); - - /** - * Reassociate the @a key with @a value. If the @a key already exists - * in the cache then returns 1, on a new bind returns 0 and returns - * -1 in case of any failures. - */ - int rebind (const KEY &key, - const VALUE &value); - - /** - * Reassociate @a key with @a value, storing the old value into the - * "out" parameter @a old_value. The function fails if @a key is not - * in the cache for caches that do not allow user specified keys. - * However, for caches that allow user specified keys, if the key is - * not in the cache, a new @a key / @a value association is created. - */ - int rebind (const KEY &key, - const VALUE &value, - VALUE &old_value); - - /** - * Reassociate @a key with @a value, storing the old key and value - * into the "out" parameters @a old_key and @a old_value. The - * function fails if @a key is not in the cache for caches that do not - * allow user specified keys. However, for caches that allow user - * specified keys, if the key is not in the cache, a new @a key / @a value - * association is created. - */ - int rebind (const KEY &key, - const VALUE &value, - KEY &old_key, - VALUE &old_value); - - /** - * Same as a normal rebind, except the cache entry is also passed back - * to the caller. The entry in this case will either be the newly - * created entry, or the existing one. - */ - int rebind (const KEY &key, - const VALUE &value, - CACHE_ENTRY *&entry); - - /** - * Associate @a key with @a value if and only if @a key is not in the - * cache. If @a key is already in the cache, then the @a value parameter - * is overwritten with the existing value in the cache. Returns 0 if a - * new @a key / @a value association is created. Returns 1 if an - * attempt is made to bind an existing entry. This function fails - * for maps that do not allow user specified keys. - */ - int trybind (const KEY &key, - VALUE &value); - - /** - * Same as a normal trybind, except the cache entry is also passed - * back to the caller. The entry in this case will either be the - * newly created entry, or the existing one. - */ - int trybind (const KEY &key, - VALUE &value, - CACHE_ENTRY *&entry); - - /// Remove @a key from the cache. - int unbind (const KEY &key); - - /// Remove @a key from the cache, and return the @a value associated with - /// @a key. - int unbind (const KEY &key, - VALUE &value); - - /// Remove entry from map. - int unbind (CACHE_ENTRY *entry); - -protected: - - /// Base class. - typedef ACE_CACHE_MAP_MANAGER ACE_HCMM_BASE; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - - -#if defined (__ACE_INLINE__) -#include "ace/Hash_Cache_Map_Manager_T.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Hash_Cache_Map_Manager_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Hash_Cache_Map_Manager_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" - -#endif /* HASH_CACHE_MAP_MANAGER_T_H */ diff --git a/ACE/ace/Hash_Cache_Map_Manager_T.inl b/ACE/ace/Hash_Cache_Map_Manager_T.inl deleted file mode 100644 index 0388abd6c6e..00000000000 --- a/ACE/ace/Hash_Cache_Map_Manager_T.inl +++ /dev/null @@ -1,73 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#define ACE_T1 class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES -#define ACE_T2 KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template ACE_INLINE int -ACE_Hash_Cache_Map_Manager::bind (const KEY &key, - const VALUE &value) -{ - return ACE_HCMM_BASE::bind (key, - value); -} - -template ACE_INLINE int -ACE_Hash_Cache_Map_Manager::rebind (const KEY &key, - const VALUE &value) -{ - return ACE_HCMM_BASE::rebind (key, - value); -} - -template ACE_INLINE int -ACE_Hash_Cache_Map_Manager::rebind (const KEY &key, - const VALUE &value, - VALUE &old_value) -{ - return ACE_HCMM_BASE::rebind (key, - value, - old_value); -} - -template ACE_INLINE int -ACE_Hash_Cache_Map_Manager::rebind (const KEY &key, - const VALUE &value, - KEY &old_key, - VALUE &old_value) -{ - return ACE_HCMM_BASE::rebind (key, - value, - old_key, - old_value); -} - -template ACE_INLINE int -ACE_Hash_Cache_Map_Manager::trybind (const KEY &key, - VALUE &value) -{ - return ACE_HCMM_BASE::trybind (key, - value); -} - -template ACE_INLINE int -ACE_Hash_Cache_Map_Manager::unbind (const KEY &key) -{ - return ACE_HCMM_BASE::unbind (key); -} - -template ACE_INLINE int -ACE_Hash_Cache_Map_Manager::unbind (const KEY &key, - VALUE &value) -{ - return ACE_HCMM_BASE::unbind (key, - value); -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#undef ACE_T1 -#undef ACE_T2 diff --git a/ACE/ace/Hash_Map_Manager.h b/ACE/ace/Hash_Map_Manager.h deleted file mode 100644 index ed34b24f5b5..00000000000 --- a/ACE/ace/Hash_Map_Manager.h +++ /dev/null @@ -1,31 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Hash_Map_Manager.h - * - * $Id$ - * - * Backward compatibility header. - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_HASH_MAP_MANAGER_H -#define ACE_HASH_MAP_MANAGER_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -// Include the templates here. -#include "ace/Hash_Map_Manager_T.h" - -#include /**/ "ace/post.h" - -#endif /* ACE_HASH_MAP_MANAGER_H */ diff --git a/ACE/ace/Hash_Map_Manager_T.cpp b/ACE/ace/Hash_Map_Manager_T.cpp deleted file mode 100644 index 3119c109cd2..00000000000 --- a/ACE/ace/Hash_Map_Manager_T.cpp +++ /dev/null @@ -1,530 +0,0 @@ - -//============================================================================= -/** - * @file Hash_Map_Manager_T.cpp - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - - -#ifndef ACE_HASH_MAP_MANAGER_T_CPP -#define ACE_HASH_MAP_MANAGER_T_CPP - -#include "ace/Hash_Map_Manager_T.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (__ACE_INLINE__) -# include "ace/Hash_Map_Manager_T.inl" -#endif /* __ACE_INLINE__ */ - -#include "ace/Malloc_Base.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template -ACE_Hash_Map_Entry::ACE_Hash_Map_Entry (ACE_Hash_Map_Entry *next, - ACE_Hash_Map_Entry *prev) - : next_ (next), - prev_ (prev) -{ -} - -template -ACE_Hash_Map_Entry::ACE_Hash_Map_Entry (const EXT_ID &ext_id, - const INT_ID &int_id, - ACE_Hash_Map_Entry *next, - ACE_Hash_Map_Entry *prev) - : ext_id_ (ext_id), - int_id_ (int_id), - next_ (next), - prev_ (prev) -{ -} - -template -ACE_Hash_Map_Entry::~ACE_Hash_Map_Entry (void) -{ -} - -template EXT_ID & -ACE_Hash_Map_Entry::key () -{ - return ext_id_; -} - -template INT_ID & -ACE_Hash_Map_Entry::item () -{ - return int_id_; -} - -template void -ACE_Hash_Map_Entry::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("next_ = %d"), this->next_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("prev_ = %d"), this->prev_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -template void -ACE_Hash_Map_Manager_Ex::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("total_size_ = %d"), this->total_size_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncur_size_ = %d"), this->cur_size_)); - this->table_allocator_->dump (); - this->entry_allocator_->dump (); - this->lock_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -template int -ACE_Hash_Map_Manager_Ex::create_buckets (size_t size) -{ - size_t bytes = size * sizeof (ACE_Hash_Map_Entry); - void *ptr; - - ACE_ALLOCATOR_RETURN (ptr, - this->table_allocator_->malloc (bytes), - -1); - - this->table_ = (ACE_Hash_Map_Entry *) ptr; - - this->total_size_ = size; - - // Initialize each entry in the hash table to be a circular linked - // list with the dummy node in the front serving as the anchor of - // the list. - for (size_t i = 0; i < size; i++) - new (&this->table_[i]) ACE_Hash_Map_Entry (&this->table_[i], - &this->table_[i]); - return 0; -} - -template int -ACE_Hash_Map_Manager_Ex::open (size_t size, - ACE_Allocator *table_alloc, - ACE_Allocator *entry_alloc) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - // Calling this->close_i () to ensure we release previous allocated - // memory before allocating new one. - this->close_i (); - - if (table_alloc == 0) - table_alloc = ACE_Allocator::instance (); - - this->table_allocator_ = table_alloc; - - if (entry_alloc == 0) - entry_alloc = table_alloc; - - this->entry_allocator_ = entry_alloc; - - // This assertion is here to help track a situation that shouldn't - // happen, but did with Sun C++ 4.1 (before a change to this class - // was made: it used to have an enum that was supposed to be defined - // to be ACE_DEFAULT_MAP_SIZE, but instead was defined to be 0). - if (size == 0) - return -1; - - return this->create_buckets (size); -} - -template int -ACE_Hash_Map_Manager_Ex::close_i (void) -{ - // Protect against "double-deletion" in case the destructor also - // gets called. - if (this->table_ != 0) - { - // Remove all the entries. - this->unbind_all_i (); - - // Iterate through the buckets cleaning up the sentinels. - for (size_t i = 0; i < this->total_size_; i++) - { - // Destroy the dummy entry. - ACE_Hash_Map_Entry *entry = &this->table_[i]; - - // The second argument results in a no-op instead of - // deallocation. - ACE_DES_FREE_TEMPLATE2 (entry, ACE_NOOP, - ACE_Hash_Map_Entry, EXT_ID, INT_ID); - } - - // Reset size. - this->total_size_ = 0; - - // Free table memory. - this->table_allocator_->free (this->table_); - - // Should be done last... - this->table_ = 0; - } - - return 0; -} - -template int -ACE_Hash_Map_Manager_Ex::unbind_all_i (void) -{ - // Iterate through the entire map calling the destuctor of each - // . - for (size_t i = 0; i < this->total_size_; i++) - { - for (ACE_Hash_Map_Entry *temp_ptr = this->table_[i].next_; - temp_ptr != &this->table_[i]; - ) - { - ACE_Hash_Map_Entry *hold_ptr = temp_ptr; - temp_ptr = temp_ptr->next_; - - // Explicitly call the destructor. - ACE_DES_FREE_TEMPLATE2 (hold_ptr, this->entry_allocator_->free, - ACE_Hash_Map_Entry, EXT_ID, INT_ID); - } - - // Restore the sentinel. - this->table_[i].next_ = &this->table_[i]; - this->table_[i].prev_ = &this->table_[i]; - } - - this->cur_size_ = 0; - - return 0; -} - -template int -ACE_Hash_Map_Manager_Ex::bind_i (const EXT_ID &ext_id, - const INT_ID &int_id, - ACE_Hash_Map_Entry *&entry) -{ - size_t loc; - int result = this->shared_find (ext_id, entry, loc); - - if (result == -1) - { - void *ptr; - // Not found. - ACE_ALLOCATOR_RETURN (ptr, - this->entry_allocator_->malloc (sizeof (ACE_Hash_Map_Entry)), - -1); - - entry = new (ptr) ACE_Hash_Map_Entry (ext_id, - int_id, - this->table_[loc].next_, - &this->table_[loc]); - this->table_[loc].next_ = entry; - entry->next_->prev_ = entry; - this->cur_size_++; - return 0; - } - else - return 1; -} - -template int -ACE_Hash_Map_Manager_Ex::trybind_i (const EXT_ID &ext_id, - INT_ID &int_id, - ACE_Hash_Map_Entry *&entry) -{ - size_t loc; - int result = this->shared_find (ext_id, entry, loc); - - if (result == -1) - { - // Not found. - void *ptr; - ACE_ALLOCATOR_RETURN (ptr, - this->entry_allocator_->malloc (sizeof (ACE_Hash_Map_Entry)), - -1); - - entry = new (ptr) ACE_Hash_Map_Entry (ext_id, - int_id, - this->table_[loc].next_, - &this->table_[loc]); - this->table_[loc].next_ = entry; - entry->next_->prev_ = entry; - this->cur_size_++; - return 0; - } - else - return 1; -} - -template int -ACE_Hash_Map_Manager_Ex::unbind_i (const EXT_ID &ext_id, - INT_ID &int_id) -{ - ACE_Hash_Map_Entry *temp; - - size_t loc; - int result = this->shared_find (ext_id, temp, loc); - - if (result == -1) - { - errno = ENOENT; - return -1; - } - - int_id = temp->int_id_; - - return this->unbind_i (temp); -} - -template int -ACE_Hash_Map_Manager_Ex::unbind_i (ACE_Hash_Map_Entry *entry) -{ - entry->next_->prev_ = entry->prev_; - entry->prev_->next_ = entry->next_; - - // Explicitly call the destructor. - ACE_DES_FREE_TEMPLATE2 (entry, this->entry_allocator_->free, - ACE_Hash_Map_Entry, EXT_ID, INT_ID); - - this->cur_size_--; - return 0; -} - -template int -ACE_Hash_Map_Manager_Ex::shared_find (const EXT_ID &ext_id, - ACE_Hash_Map_Entry *&entry, - size_t &loc) -{ - loc = this->hash (ext_id) % this->total_size_; - - ACE_Hash_Map_Entry *temp = this->table_[loc].next_; - - while (temp != &this->table_[loc] && this->equal (temp->ext_id_, ext_id) == 0) - temp = temp->next_; - - if (temp == &this->table_[loc]) - { - errno = ENOENT; - return -1; - } - else - { - entry = temp; - return 0; - } -} - -template int -ACE_Hash_Map_Manager_Ex::rebind_i (const EXT_ID &ext_id, - const INT_ID &int_id, - ACE_Hash_Map_Entry *&entry) -{ - size_t dummy; - if (this->shared_find (ext_id, entry, dummy) == -1) - return this->bind_i (ext_id, int_id); - else - { - entry->ext_id_ = ext_id; - entry->int_id_ = int_id; - return 1; - } -} - -template int -ACE_Hash_Map_Manager_Ex::rebind_i (const EXT_ID &ext_id, - const INT_ID &int_id, - INT_ID &old_int_id, - ACE_Hash_Map_Entry *&entry) -{ - size_t dummy; - if (this->shared_find (ext_id, entry, dummy) == -1) - return this->bind_i (ext_id, int_id); - else - { - old_int_id = entry->int_id_; - entry->ext_id_ = ext_id; - entry->int_id_ = int_id; - return 1; - } -} - -template int -ACE_Hash_Map_Manager_Ex::rebind_i (const EXT_ID &ext_id, - const INT_ID &int_id, - EXT_ID &old_ext_id, - INT_ID &old_int_id, - ACE_Hash_Map_Entry *&entry) -{ - size_t dummy; - if (this->shared_find (ext_id, entry, dummy) == -1) - return this->bind_i (ext_id, int_id); - else - { - old_ext_id = entry->ext_id_; - old_int_id = entry->int_id_; - entry->ext_id_ = ext_id; - entry->int_id_ = int_id; - return 1; - } -} - -// ------------------------------------------------------------ - -ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Iterator_Base_Ex) - -template void -ACE_Hash_Map_Iterator_Base_Ex::dump_i (void) const -{ - ACE_TRACE ("ACE_Hash_Map_Iterator_Base_Ex::dump_i"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("index_ = %d "), this->index_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("next_ = %x"), this->next_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -} - -template int -ACE_Hash_Map_Iterator_Base_Ex::forward_i (void) -{ - ACE_TRACE ("ACE_Hash_Map_Iterator_Base_Ex::forward_i"); - - if (this->map_man_->table_ == 0) - return -1; - // Handle initial case specially. - else if (this->index_ == -1) - { - this->index_++; - return this->forward_i (); - } - else if (this->index_ >= static_cast (this->map_man_->total_size_)) - return 0; - - this->next_ = this->next_->next_; - if (this->next_ == &this->map_man_->table_[this->index_]) - { - while (++this->index_ < static_cast (this->map_man_->total_size_)) - { - this->next_ = this->map_man_->table_[this->index_].next_; - if (this->next_ != &this->map_man_->table_[this->index_]) - break; - } - } - - return this->index_ < static_cast (this->map_man_->total_size_); -} - -template int -ACE_Hash_Map_Iterator_Base_Ex::reverse_i (void) -{ - ACE_TRACE ("ACE_Hash_Map_Iterator_Base_Ex::reverse_i"); - - if (this->map_man_->table_ == 0) - return -1; - else if (this->index_ == static_cast (this->map_man_->total_size_)) - { - this->index_--; - return this->reverse_i (); - } - else if (this->index_ < 0) - return 0; - - this->next_ = this->next_->prev_; - if (this->next_ == &this->map_man_->table_[this->index_]) - { - while (--this->index_ >= 0) - { - this->next_ = this->map_man_->table_[this->index_].prev_; - if (this->next_ != &this->map_man_->table_[this->index_]) - break; - } - } - - return this->index_ >= 0; -} - -// ------------------------------------------------------------ - -ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Const_Iterator_Base_Ex) - -template void -ACE_Hash_Map_Const_Iterator_Base_Ex::dump_i (void) const -{ - ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex::dump_i"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("index_ = %d "), this->index_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("next_ = %x"), this->next_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -} - -template int -ACE_Hash_Map_Const_Iterator_Base_Ex::forward_i (void) -{ - ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex::forward_i"); - - if (this->map_man_->table_ == 0) - return -1; - // Handle initial case specially. - else if (this->index_ == -1) - { - this->index_++; - return this->forward_i (); - } - else if (this->index_ >= (ssize_t) this->map_man_->total_size_) - return 0; - - this->next_ = this->next_->next_; - if (this->next_ == &this->map_man_->table_[this->index_]) - { - while (++this->index_ < (ssize_t) this->map_man_->total_size_) - { - this->next_ = this->map_man_->table_[this->index_].next_; - if (this->next_ != &this->map_man_->table_[this->index_]) - break; - } - } - - return this->index_ < (ssize_t) this->map_man_->total_size_; -} - -template int -ACE_Hash_Map_Const_Iterator_Base_Ex::reverse_i (void) -{ - ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex::reverse_i"); - - if (this->map_man_->table_ == 0) - return -1; - else if (this->index_ == (ssize_t) this->map_man_->total_size_) - { - this->index_--; - return this->reverse_i (); - } - else if (this->index_ < 0) - return 0; - - this->next_ = this->next_->prev_; - if (this->next_ == &this->map_man_->table_[this->index_]) - { - while (--this->index_ >= 0) - { - this->next_ = this->map_man_->table_[this->index_].prev_; - if (this->next_ != &this->map_man_->table_[this->index_]) - break; - } - } - - return this->index_ >= 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HASH_MAP_MANAGER_T_CPP */ diff --git a/ACE/ace/Hash_Map_Manager_T.h b/ACE/ace/Hash_Map_Manager_T.h deleted file mode 100644 index 7d4f270584f..00000000000 --- a/ACE/ace/Hash_Map_Manager_T.h +++ /dev/null @@ -1,1274 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Hash_Map_Manager_T.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_HASH_MAP_MANAGER_T_H -#define ACE_HASH_MAP_MANAGER_T_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Default_Constants.h" -#include "ace/Functor_T.h" -#include "ace/Log_Msg.h" -#include - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Hash_Map_Entry - * - * @brief Define an entry in the hash table. - */ -template -class ACE_Hash_Map_Entry -{ -public: - // = Initialization and termination methods. - /// Constructor. - ACE_Hash_Map_Entry (const EXT_ID &ext_id, - const INT_ID &int_id, - ACE_Hash_Map_Entry *next = 0, - ACE_Hash_Map_Entry *prev = 0); - - /// Constructor. - ACE_Hash_Map_Entry (ACE_Hash_Map_Entry *next, - ACE_Hash_Map_Entry *prev); - - /// Destructor. - ~ACE_Hash_Map_Entry (void); - - /// Key accessor. - EXT_ID& key (void); - - /// Item accessor. - INT_ID& item (void); - - /// Key used to look up an entry. - /// @deprecated Use key() - EXT_ID ext_id_; - - /// The contents of the entry itself. - /// @deprecated Use item() - INT_ID int_id_; - - /// Pointer to the next item in the bucket of overflow nodes. - ACE_Hash_Map_Entry *next_; - - /// Pointer to the prev item in the bucket of overflow nodes. - ACE_Hash_Map_Entry *prev_; - - /// Dump the state of an object. - void dump (void) const; -}; - -// Forward decl. -template -class ACE_Hash_Map_Iterator_Base_Ex; - -// Forward decl. -template -class ACE_Hash_Map_Const_Iterator_Base_Ex; - -// Forward decl. -template -class ACE_Hash_Map_Iterator_Ex; - -// Forward decl. -template -class ACE_Hash_Map_Const_Iterator_Ex; - -// Forward decl. -template -class ACE_Hash_Map_Reverse_Iterator_Ex; - -// Forward decl. -template -class ACE_Hash_Map_Const_Reverse_Iterator_Ex; - -// Forward decl. -template -class ACE_Hash_Map_Bucket_Iterator; - -// Forward decl. -class ACE_Allocator; - -/** - * @class ACE_Hash_Map_Manager_Ex - * - * @brief Define a map abstraction that efficiently associates - * @c EXT_ID type objects with @c INT_ID type objects. - * - * This implementation of a map uses a hash table. Key hashing - * is achieved through the @c HASH_KEY object and key comparison is - * achieved through the @c COMPARE_KEYS object. - * This class uses an ACE_Allocator to allocate memory. The - * user can make this a persistent class by providing an - * ACE_Allocator with a persistable memory pool. - */ - -template -class ACE_Hash_Map_Manager_Ex -{ -public: - friend class ACE_Hash_Map_Iterator_Base_Ex; - friend class ACE_Hash_Map_Iterator_Ex; - friend class ACE_Hash_Map_Const_Iterator_Base_Ex; - friend class ACE_Hash_Map_Const_Iterator_Ex; - friend class ACE_Hash_Map_Reverse_Iterator_Ex; - friend class ACE_Hash_Map_Const_Reverse_Iterator_Ex; - friend class ACE_Hash_Map_Bucket_Iterator; - - typedef EXT_ID - KEY; - typedef INT_ID - VALUE; - typedef ACE_LOCK lock_type; - typedef ACE_Hash_Map_Entry - ENTRY; - - // = ACE-style iterator typedefs. - typedef ACE_Hash_Map_Iterator_Ex - ITERATOR; - typedef ACE_Hash_Map_Const_Iterator_Ex - CONST_ITERATOR; - typedef ACE_Hash_Map_Reverse_Iterator_Ex - REVERSE_ITERATOR; - typedef ACE_Hash_Map_Const_Reverse_Iterator_Ex - CONST_REVERSE_ITERATOR; - - // = STL-style iterator typedefs. - typedef ACE_Hash_Map_Iterator_Ex - iterator; - typedef ACE_Hash_Map_Const_Iterator_Ex - const_iterator; - typedef ACE_Hash_Map_Reverse_Iterator_Ex - reverse_iterator; - typedef ACE_Hash_Map_Const_Reverse_Iterator_Ex - const_reverse_iterator; - - // = STL-style typedefs/traits. - typedef EXT_ID key_type; - typedef INT_ID data_type; - typedef ACE_Hash_Map_Entry value_type; - typedef value_type & reference; - typedef value_type const & const_reference; - typedef value_type * pointer; - typedef value_type const * const_pointer; - typedef ptrdiff_t difference_type; - typedef size_t size_type; - - // = Initialization and termination methods. - - /** - * Initialize an ACE_Hash_Map_Manager_Ex with a default number of elements. - * - * @param table_alloc is a pointer to a memory allocator used for - * table_, so it should supply size*sizeof (ACE_Hash_Map_Entry). - * If @a table_alloc is 0 it defaults to ACE_Allocator::instance(). - * @param entry_alloc is a pointer to an additional allocator for - * entries, so it should be able to allocate 'size' / chunks - * of sizeof(ACE_Hash_Map_Entry) bytes each. - * If @a entry_alloc is 0 it defaults to the same allocator as - * @a table_alloc. - */ - ACE_Hash_Map_Manager_Ex (ACE_Allocator *table_alloc = 0, - ACE_Allocator *entry_alloc = 0); - - /** - * Initialize an ACE_Hash_Map_Manager_Ex with @a size elements. - * - * @param table_alloc is a pointer to a memory allocator used for - * table_, so it should supply size*sizeof (ACE_Hash_Map_Entry). - * If @a table_alloc is 0 it defaults to ACE_Allocator::instance(). - * @param entry_alloc is a pointer to an additional allocator for - * entries, so it should be able to allocate 'size' / chunks - * of sizeof(ACE_Hash_Map_Entry) bytes each. - * If @a entry_alloc is 0 it defaults to the same allocator as - * @a table_alloc. - */ - ACE_Hash_Map_Manager_Ex (size_t size, - ACE_Allocator *table_alloc = 0, - ACE_Allocator *entry_alloc = 0); - - /** - * Initialize an ACE_Hash_Map_Manager_Ex with @a size elements. - * @param table_alloc is a pointer to a memory allocator used for - * table_, so it should supply size*sizeof (ACE_Hash_Map_Entry). - * If @a table_alloc is 0 it defaults to ACE_Allocator::instance(). - * @param entry_alloc is a pointer to an additional allocator for - * entries, so it should be able to allocate 'size' / chunks - * of sizeof(ACE_Hash_Map_Entry) bytes each. - * If @a entry_alloc is 0 then it defaults to the same allocator as - * @a table_alloc. - * @return -1 on failure, 0 on success - */ - - int open (size_t size = ACE_DEFAULT_MAP_SIZE, - ACE_Allocator *table_alloc = 0, - ACE_Allocator *entry_alloc = 0); - - /// Close down the ACE_Hash_Map_Manager_Ex and release dynamically allocated - /// resources. - int close (void); - - /// Removes all the entries in the ACE_Hash_Map_Manager_Ex. - int unbind_all (void); - - /// Cleanup the ACE_Hash_Map_Manager_Ex. - ~ACE_Hash_Map_Manager_Ex (void); - - /** - * Associate @a item with @a int_id. If @a item is already in the - * map then the map is not changed. - * - * @retval 0 if a new entry is bound successfully. - * @retval 1 if an attempt is made to bind an existing entry. - * @retval -1 if a failure occurs; check @c errno for more information. - */ - int bind (const EXT_ID &item, - const INT_ID &int_id); - - /** - * Same as a normal bind, except the map entry is also passed back - * to the caller. The entry in this case will either be the newly - * created entry, or the existing one. - */ - int bind (const EXT_ID &ext_id, - const INT_ID &int_id, - ACE_Hash_Map_Entry *&entry); - - /** - * Associate @a ext_id with @a int_id if and only if @a ext_id is not - * in the map. If @a ext_id is already in the map then the @a int_id - * parameter is assigned the existing value in the map. Returns 0 - * if a new entry is bound successfully, returns 1 if an attempt is - * made to bind an existing entry, and returns -1 if failures occur. - */ - int trybind (const EXT_ID &ext_id, - INT_ID &int_id); - - /** - * Same as a normal trybind, except the map entry is also passed - * back to the caller. The entry in this case will either be the - * newly created entry, or the existing one. - */ - int trybind (const EXT_ID &ext_id, - INT_ID &int_id, - ACE_Hash_Map_Entry *&entry); - - /** - * Reassociate @a ext_id with @a int_id. If @a ext_id is not in the - * map then behaves just like . Returns 0 if a new entry is - * bound successfully, returns 1 if an existing entry was rebound, - * and returns -1 if failures occur. - */ - int rebind (const EXT_ID &ext_id, - const INT_ID &int_id); - - /** - * Same as a normal rebind, except the map entry is also passed back - * to the caller. The entry in this case will either be the newly - * created entry, or the existing one. - */ - int rebind (const EXT_ID &ext_id, - const INT_ID &int_id, - ACE_Hash_Map_Entry *&entry); - - /** - * Associate @a ext_id with @a int_id. If @a ext_id is not in the map - * then behaves just like . Otherwise, store the old value of - * @a int_id into the "out" parameter and rebind the new parameters. - * Returns 0 if a new entry is bound successfully, returns 1 if an - * existing entry was rebound, and returns -1 if failures occur. - */ - int rebind (const EXT_ID &ext_id, - const INT_ID &int_id, - INT_ID &old_int_id); - - /** - * Same as a normal rebind, except the map entry is also passed back - * to the caller. The entry in this case will either be the newly - * created entry, or the existing one. - */ - int rebind (const EXT_ID &ext_id, - const INT_ID &int_id, - INT_ID &old_int_id, - ACE_Hash_Map_Entry *&entry); - - /** - * Associate @a ext_id with @a int_id. If @a ext_id is not in the map - * then behaves just like . Otherwise, store the old values - * of @a ext_id and @a int_id into the "out" parameters and rebind the - * new parameters. This is very useful if you need to have an - * atomic way of updating ACE_Hash_Map_Entrys and you also need - * full control over memory allocation. Returns 0 if a new entry is - * bound successfully, returns 1 if an existing entry was rebound, - * and returns -1 if failures occur. - */ - int rebind (const EXT_ID &ext_id, - const INT_ID &int_id, - EXT_ID &old_ext_id, - INT_ID &old_int_id); - - /** - * Same as a normal rebind, except the map entry is also passed back - * to the caller. The entry in this case will either be the newly - * created entry, or the existing one. - */ - int rebind (const EXT_ID &ext_id, - const INT_ID &int_id, - EXT_ID &old_ext_id, - INT_ID &old_int_id, - ACE_Hash_Map_Entry *&entry); - - /// Locate @a ext_id and pass out parameter via @a int_id. - /// Return 0 if found, returns -1 if not found. - int find (const EXT_ID &ext_id, - INT_ID &int_id) const; - - /// Returns 0 if the @a ext_id is in the mapping, otherwise -1. - int find (const EXT_ID &ext_id) const; - - /// Locate @a ext_id and pass out parameter via @a entry. If found, - /// return 0, returns -1 if not found. - int find (const EXT_ID &ext_id, - ACE_Hash_Map_Entry *&entry) const; - - /// Locate @a ext_id and pass out an iterator that points to its - /// corresponding value. - /** - * @param pos @a pos will be set to @c end() if not found. - */ - void find (EXT_ID const & ext_id, iterator & pos) const; - - /** - * Unbind (remove) the @a ext_id from the map. Don't return the - * @a int_id to the caller (this is useful for collections where the - * @a int_ids are *not* dynamically allocated...) - */ - int unbind (const EXT_ID &ext_id); - - /// Break any association of @a ext_id. Returns the value of @a int_id - /// in case the caller needs to deallocate memory. Return 0 if the - /// unbind was successful, and returns -1 if failures occur. - int unbind (const EXT_ID &ext_id, - INT_ID &int_id); - - /// Remove entry from map. - /** - * This unbind operation is fast relative to those that accept an - * external ID parameter since no map lookup is performed. - * - * @return 0 if the unbind was successful, and -1 if failures - * occur. - */ - int unbind (ACE_Hash_Map_Entry *entry); - - /// Remove entry from map pointed to by @c iterator @a pos. - /** - * This unbind operation is fast relative to those that accept an - * external ID parameter since no map lookup is performed. - * - * @return 0 if the unbind was successful, and -1 if failures - * occur. - */ - int unbind (iterator pos); - - /// Returns the current number of ACE_Hash_Map_Entry objects in the - /// hash table. - size_t current_size (void) const; - - /// Return the size of the array that's used to point to the - /// linked lists of ACE_Hash_Map_Entry objects in the hash table. - size_t total_size (void) const; - - /** - * Returns a reference to the underlying . This makes it - * possible to acquire the lock explicitly, which can be useful in - * some cases if you instantiate the ACE_Atomic_Op with an - * ACE_Recursive_Mutex or ACE_Process_Mutex, or if you need to - * guard the state of an iterator. - * @note The right name would be , but HP/C++ will choke on that! - */ - ACE_LOCK &mutex (void); - - /// Dump the state of an object. - void dump (void) const; - - // = STL styled iterator factory functions. - - /// Return forward iterator. - iterator begin (void); - iterator end (void); - const_iterator begin (void) const; - const_iterator end (void) const; - - /// Return reverse iterator. - reverse_iterator rbegin (void); - reverse_iterator rend (void); - const_reverse_iterator rbegin (void) const; - const_reverse_iterator rend (void) const; - -protected: - // = The following methods do the actual work. - - /// Returns 1 if == , else 0. This is defined as a - /// separate method to facilitate template specialization. - int equal (const EXT_ID &id1, const EXT_ID &id2); - - /// Compute the hash value of the @a ext_id. This is defined as a - /// separate method to facilitate template specialization. - u_long hash (const EXT_ID &ext_id); - - // = These methods assume locks are held by private methods. - - /// Performs bind. Must be called with locks held. - int bind_i (const EXT_ID &ext_id, - const INT_ID &int_id); - - /// Performs bind. Must be called with locks held. - int bind_i (const EXT_ID &ext_id, - const INT_ID &int_id, - ACE_Hash_Map_Entry *&entry); - - /// Performs trybind. Must be called with locks held. - int trybind_i (const EXT_ID &ext_id, - INT_ID &int_id); - - /// Performs trybind. Must be called with locks held. - int trybind_i (const EXT_ID &ext_id, - INT_ID &int_id, - ACE_Hash_Map_Entry *&entry); - - /// Performs rebind. Must be called with locks held. - int rebind_i (const EXT_ID &ext_id, - const INT_ID &int_id); - - /// Performs rebind. Must be called with locks held. - int rebind_i (const EXT_ID &ext_id, - const INT_ID &int_id, - ACE_Hash_Map_Entry *&entry); - - /// Performs rebind. Must be called with locks held. - int rebind_i (const EXT_ID &ext_id, - const INT_ID &int_id, - INT_ID &old_int_id); - - /// Performs rebind. Must be called with locks held. - int rebind_i (const EXT_ID &ext_id, - const INT_ID &int_id, - INT_ID &old_int_id, - ACE_Hash_Map_Entry *&entry); - - /// Performs rebind. Must be called with locks held. - int rebind_i (const EXT_ID &ext_id, - const INT_ID &int_id, - EXT_ID &old_ext_id, - INT_ID &old_int_id); - - /// Performs rebind. Must be called with locks held. - int rebind_i (const EXT_ID &ext_id, - const INT_ID &int_id, - EXT_ID &old_ext_id, - INT_ID &old_int_id, - ACE_Hash_Map_Entry *&entry); - - /// Performs a find of @a int_id using @a ext_id as the key. Must be - /// called with locks held. - int find_i (const EXT_ID &ext_id, - INT_ID &int_id); - - /// Performs a find using @a ext_id as the key. Must be called with - /// locks held. - int find_i (const EXT_ID &ext_id); - - /// Performs a find using @a ext_id as the key. Must be called with - /// locks held. - int find_i (const EXT_ID &ext_id, - ACE_Hash_Map_Entry *&entry); - - /// Performs unbind. Must be called with locks held. - int unbind_i (const EXT_ID &ext_id, - INT_ID &int_id); - - /// Performs unbind. Must be called with locks held. - int unbind_i (const EXT_ID &ext_id); - - /// Performs unbind. Must be called with locks held. - int unbind_i (ACE_Hash_Map_Entry *entry); - - /** - * Resize the map. Must be called with locks held. - * @note This method should never be called more than once or else all the - * hashing will get screwed up as the size will change. - */ - int create_buckets (size_t size); - - /// Close down a . Must be called with - /// locks held. - int close_i (void); - - /// Removes all the entries in . Must be called with - /// locks held. - int unbind_all_i (void); - - /// Pointer to a memory allocator used for table_, so it should - /// supply size*sizeof (ACE_Hash_Map_Entry), - ACE_Allocator *table_allocator_; - - /// Addidtional allocator for entries, so it should be able to - /// allocate 'size' / chunks of sizeof(ACE_Hash_Map_Entry) bytes each. - ACE_Allocator *entry_allocator_; - - /// Synchronization variable for the MT_SAFE - /// @c ACE_Hash_Map_Manager_Ex. - mutable ACE_LOCK lock_; - - /// Function object used for hashing keys. - HASH_KEY hash_key_; - - /// Function object used for comparing keys. - COMPARE_KEYS compare_keys_; - -protected: - /// Returns the that corresponds to @a ext_id. - int shared_find (const EXT_ID &ext_id, - ACE_Hash_Map_Entry *&entry, - size_t &loc); - - /// Accessor of the underlying table - ACE_Hash_Map_Entry *table (void); - - /// Accessor of the current size attribute - size_t cur_size (void) const; - -private: - /** - * Array of *s, each of which points to an - * that serves as the beginning of a linked - * list of s that hash to that bucket. - */ - ACE_Hash_Map_Entry *table_; - - /// Total size of the hash table. - size_t total_size_; - - /// Current number of entries in the table - /// @note That this can be larger than due to the - /// bucket chaining). - size_t cur_size_; - - // = Disallow these operations. - ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Hash_Map_Manager_Ex &)) - ACE_UNIMPLEMENTED_FUNC (ACE_Hash_Map_Manager_Ex (const ACE_Hash_Map_Manager_Ex &)) -}; - -/** - * @class ACE_Hash_Map_Iterator_Base_Ex - * - * @brief Base iterator for the ACE_Hash_Map_Manager_Ex - * - * This class factors out common code from its templatized - * subclasses. - */ -template -class ACE_Hash_Map_Iterator_Base_Ex -{ -public: - // = STL-style typedefs/traits. - typedef ACE_Hash_Map_Manager_Ex - container_type; - - // = std::iterator_traits typedefs/traits. - typedef typename container_type::value_type value_type; - typedef typename container_type::reference reference; - typedef typename container_type::pointer pointer; - typedef typename container_type::difference_type difference_type; - - // = Initialization method. - /// Contructor. - /** - * If @a head != @c false, the iterator constructed is positioned - * at the head of the map. It is positioned at the end otherwise. - * @par - */ - ACE_Hash_Map_Iterator_Base_Ex ( - ACE_Hash_Map_Manager_Ex &mm, - bool head); - - /// Contructor. - /** - * This constructor positions the iterator to the given @a entry. - */ - ACE_Hash_Map_Iterator_Base_Ex ( - ACE_Hash_Map_Manager_Ex & mm, - ACE_Hash_Map_Entry * entry, - size_t index); - - // = ITERATION methods. - - /// Pass back the next that hasn't been seen in the Set. - /// Returns 0 when all items have been seen, else 1. - int next (ACE_Hash_Map_Entry *&next_entry) const; - - /// Returns 1 when all items have been seen, else 0. - int done (void) const; - - /// Returns a reference to the interal element @c this is pointing to. - ACE_Hash_Map_Entry& operator* (void) const; - - /// Returns a pointer to the interal element @c this is pointing to. - ACE_Hash_Map_Entry* operator-> (void) const; - - /// Returns reference the Hash_Map_Manager_Ex that is being iterated - /// over. - ACE_Hash_Map_Manager_Ex& map (void); - - /// Check if two iterators point to the same position - bool operator== (const ACE_Hash_Map_Iterator_Base_Ex &) const; - bool operator!= (const ACE_Hash_Map_Iterator_Base_Ex &) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - /// Move forward by one element in the set. Returns 0 when there's - /// no more item in the set after the current items, else 1. - int forward_i (void); - - /// Move backward by one element in the set. Returns 0 when there's - /// no more item in the set before the current item, else 1. - int reverse_i (void); - - /// Dump the state of an object. - void dump_i (void) const; - - /// Map we are iterating over. - ACE_Hash_Map_Manager_Ex *map_man_; - - /// Keeps track of how far we've advanced in the table. - ssize_t index_; - - /// Keeps track of how far we've advanced in a linked list in each - /// table slot. - ACE_Hash_Map_Entry *next_; -}; - -/** - * @class ACE_Hash_Map_Const_Iterator_Base_Ex - * - * @brief Base const iterator for the ACE_Hash_Map_Manager_Ex - * - * This class factors out common code from its templatized - * subclasses. - */ -template -class ACE_Hash_Map_Const_Iterator_Base_Ex -{ -public: - // = STL-style typedefs/traits. - typedef ACE_Hash_Map_Manager_Ex - container_type; - - // = std::iterator_traits typedefs/traits. - typedef typename container_type::value_type value_type; - typedef typename container_type::const_reference reference; - typedef typename container_type::const_pointer pointer; - typedef typename container_type::difference_type difference_type; - - // = Initialization method. - /// Contructor. If head != 0, the iterator constructed is positioned - /// at the head of the map, it is positioned at the end otherwise. - ACE_Hash_Map_Const_Iterator_Base_Ex (const ACE_Hash_Map_Manager_Ex &mm, - int head); - - // = ITERATION methods. - - /// Pass back the next that hasn't been seen in the Set. - /// Returns 0 when all items have been seen, else 1. - int next (ACE_Hash_Map_Entry *&next_entry) const; - - /// Returns 1 when all items have been seen, else 0. - int done (void) const; - - /// Returns a reference to the interal element @c this is pointing to. - ACE_Hash_Map_Entry& operator* (void) const; - - /// Returns a pointer to the interal element @c this is pointing to. - ACE_Hash_Map_Entry* operator-> (void) const; - - /// Returns reference the Hash_Map_Manager_Ex that is being iterated - /// over. - const ACE_Hash_Map_Manager_Ex& map (void); - - /// Check if two iterators point to the same position - bool operator== (const ACE_Hash_Map_Const_Iterator_Base_Ex &) const; - bool operator!= (const ACE_Hash_Map_Const_Iterator_Base_Ex &) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - /// Move forward by one element in the set. Returns 0 when there's - /// no more item in the set after the current items, else 1. - int forward_i (void); - - /// Move backward by one element in the set. Returns 0 when there's - /// no more item in the set before the current item, else 1. - int reverse_i (void); - - /// Dump the state of an object. - void dump_i (void) const; - - /// Map we are iterating over. - const ACE_Hash_Map_Manager_Ex *map_man_; - - /// Keeps track of how far we've advanced in the table. - ssize_t index_; - - /// Keeps track of how far we've advanced in a linked list in each - /// table slot. - ACE_Hash_Map_Entry *next_; -}; - -/** - * @class ACE_Hash_Map_Iterator_Ex - * - * @brief Forward iterator for the ACE_Hash_Map_Manager_Ex. - * - * This class does not perform any internal locking of the - * ACE_Hash_Map_Manager_Ex it is iterating upon since locking is - * inherently inefficient and/or error-prone within an STL-style - * iterator. If you require locking, you can explicitly use an - * ACE_Guard or ACE_Read_Guard on the ACE_Hash_Map_Manager_Ex's - * internal lock, which is accessible via its method. - */ -template -class ACE_Hash_Map_Iterator_Ex : public ACE_Hash_Map_Iterator_Base_Ex -{ -public: - // = STL-style traits/typedefs - typedef typename ACE_Hash_Map_Iterator_Base_Ex::container_type - container_type; - - // = STL-style traits/typedefs - typedef std::bidirectional_iterator_tag iterator_category; - typedef typename container_type::value_type value_type; - typedef typename container_type::reference reference; - typedef typename container_type::pointer pointer; - typedef typename container_type::difference_type difference_type; - - // = Initialization method. - ACE_Hash_Map_Iterator_Ex (ACE_Hash_Map_Manager_Ex &mm, - int tail = 0); - - /// Contructor. - /** - * This constructor positions the iterator to the given @a entry. - */ - ACE_Hash_Map_Iterator_Ex ( - ACE_Hash_Map_Manager_Ex & mm, - ACE_Hash_Map_Entry * entry, - size_t index); - - // = Iteration methods. - /// Move forward by one element in the set. Returns 0 when all the - /// items in the set have been seen, else 1. - int advance (void); - - /// Dump the state of an object. - void dump (void) const; - - // = STL styled iteration, compare, and reference functions. - - /// Prefix advance. - ACE_Hash_Map_Iterator_Ex &operator++ (void); - - /// Postfix advance. - ACE_Hash_Map_Iterator_Ex operator++ (int); - - /// Prefix reverse. - ACE_Hash_Map_Iterator_Ex &operator-- (void); - - /// Postfix reverse. - ACE_Hash_Map_Iterator_Ex operator-- (int); - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; -}; - -/** - * @class ACE_Hash_Map_Const_Iterator_Ex - * - * @brief Const forward iterator for the ACE_Hash_Map_Manager_Ex. - * - * This class does not perform any internal locking of the - * ACE_Hash_Map_Manager_Ex it is iterating upon since locking is - * inherently inefficient and/or error-prone within an STL-style - * iterator. If you require locking, you can explicitly use an - * ACE_Guard or ACE_Read_Guard on the ACE_Hash_Map_Manager_Ex's - * internal lock, which is accessible via its method. - */ -template -class ACE_Hash_Map_Const_Iterator_Ex : public ACE_Hash_Map_Const_Iterator_Base_Ex -{ -public: - // = STL-style traits/typedefs - typedef typename ACE_Hash_Map_Const_Iterator_Base_Ex::container_type - container_type; - - // = std::iterator_trait traits/typedefs - typedef std::bidirectional_iterator_tag iterator_category; - typedef typename container_type::value_type value_type; - typedef typename container_type::reference reference; - typedef typename container_type::pointer pointer; - typedef typename container_type::difference_type difference_type; - - // = Initialization method. - ACE_Hash_Map_Const_Iterator_Ex (const ACE_Hash_Map_Manager_Ex &mm, - int tail = 0); - - // = Iteration methods. - /// Move forward by one element in the set. Returns 0 when all the - /// items in the set have been seen, else 1. - int advance (void); - - /// Dump the state of an object. - void dump (void) const; - - // = STL styled iteration, compare, and reference functions. - - /// Prefix advance. - ACE_Hash_Map_Const_Iterator_Ex &operator++ (void); - - /// Postfix advance. - ACE_Hash_Map_Const_Iterator_Ex operator++ (int); - - /// Prefix reverse. - ACE_Hash_Map_Const_Iterator_Ex &operator-- (void); - - /// Postfix reverse. - ACE_Hash_Map_Const_Iterator_Ex operator-- (int); - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; -}; - -/** - * @class ACE_Hash_Map_Bucket_Iterator - * - * @brief Forward iterator for the ACE_Hash_Map_Manager_Ex which - * only traverses a particular bucket. The particular bucket is - * specified by the parameter specified in the constructor. - * - * This class does not perform any internal locking of the - * ACE_Hash_Map_Manager_Ex it is iterating upon since locking is - * inherently inefficient and/or error-prone within an STL-style - * iterator. If you require locking, you can explicitly use an - * ACE_Guard or ACE_Read_Guard on the ACE_Hash_Map_Manager_Ex's - * internal lock, which is accessible via its method. - * - * Note that a creation method for this new iterator cannot be added - * to the hash map, since this would require adding explicit template - * instantiations for bucket iterators on platforms with broken - * templates. - */ -template -class ACE_Hash_Map_Bucket_Iterator -{ -public: - // = STL-style traits/typedefs - typedef ACE_Hash_Map_Manager_Ex - container_type; - - // = std::iterator traits/typedefs - typedef std::bidirectional_iterator_tag iterator_category; - typedef typename container_type::value_type value_type; - typedef typename container_type::reference reference; - typedef typename container_type::pointer pointer; - typedef typename container_type::difference_type difference_type; - - // = Initialization method. - ACE_Hash_Map_Bucket_Iterator (ACE_Hash_Map_Manager_Ex &mm, - const EXT_ID &ext_id, - int tail = 0); - - // = STL styled iteration, compare, and reference functions. - - /// Prefix advance. - ACE_Hash_Map_Bucket_Iterator &operator++ (void); - - /// Postfix advance. - ACE_Hash_Map_Bucket_Iterator operator++ (int); - - /// Prefix reverse. - ACE_Hash_Map_Bucket_Iterator &operator-- (void); - - /// Postfix reverse. - ACE_Hash_Map_Bucket_Iterator operator-- (int); - - /// Returns a reference to the interal element @c this is pointing to. - ACE_Hash_Map_Entry& operator* (void) const; - - /// Returns a pointer to the interal element @c this is pointing to. - ACE_Hash_Map_Entry* operator-> (void) const; - - /// Returns reference the Hash_Map_Manager_Ex that is being iterated - /// over. - ACE_Hash_Map_Manager_Ex& map (void); - - /// Check if two iterators point to the same position - bool operator== (const ACE_Hash_Map_Bucket_Iterator &) const; - bool operator!= (const ACE_Hash_Map_Bucket_Iterator &) const; - -protected: - /// Move forward by one element in the set. Returns 0 when there's - /// no more item in the set after the current items, else 1. - int forward_i (void); - - /// Move backward by one element in the set. Returns 0 when there's - /// no more item in the set before the current item, else 1. - int reverse_i (void); - - /// Map we are iterating over. - ACE_Hash_Map_Manager_Ex *map_man_; - - /// Keeps track of how far we've advanced in the table. - ssize_t index_; - - /// Keeps track of how far we've advanced in a linked list in each - /// table slot. - ACE_Hash_Map_Entry *next_; -}; - -/** - * @class ACE_Hash_Map_Reverse_Iterator_Ex - * - * @brief Reverse iterator for the ACE_Hash_Map_Manager_Ex. - * - * This class does not perform any internal locking of the - * ACE_Hash_Map_Manager_Ex it is iterating upon since locking is - * inherently inefficient and/or error-prone within an STL-style - * iterator. If you require locking, you can explicitly use an - * ACE_Guard or ACE_Read_Guard on the ACE_Hash_Map_Manager_Ex's - * internal lock, which is accessible via its method. - */ -template -class ACE_Hash_Map_Reverse_Iterator_Ex : public ACE_Hash_Map_Iterator_Base_Ex -{ -public: - // = STL-style traits/typedefs - typedef typename ACE_Hash_Map_Iterator_Base_Ex::container_type - container_type; - - // = std::iterator_traits typedefs - typedef std::bidirectional_iterator_tag iterator_category; - typedef typename container_type::value_type value_type; - typedef typename container_type::reference reference; - typedef typename container_type::pointer pointer; - typedef typename container_type::difference_type difference_type; - - // = Initialization method. - ACE_Hash_Map_Reverse_Iterator_Ex (ACE_Hash_Map_Manager_Ex &mm, - int head = 0); - - // = Iteration methods. - /// Move forward by one element in the set. Returns 0 when all the - /// items in the set have been seen, else 1. - int advance (void); - - /// Dump the state of an object. - void dump (void) const; - - // = STL styled iteration, compare, and reference functions. - - /// Prefix reverse. - ACE_Hash_Map_Reverse_Iterator_Ex &operator++ (void); - - /// Postfix reverse. - ACE_Hash_Map_Reverse_Iterator_Ex operator++ (int); - - /// Prefix advance. - ACE_Hash_Map_Reverse_Iterator_Ex &operator-- (void); - - /// Postfix advance. - ACE_Hash_Map_Reverse_Iterator_Ex operator-- (int); - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; -}; - -/** - * @class ACE_Hash_Map_Const_Reverse_Iterator_Ex - * - * @brief Const reverse iterator for the ACE_Hash_Map_Manager_Ex. - * - * This class does not perform any internal locking of the - * ACE_Hash_Map_Manager_Ex it is iterating upon since locking is - * inherently inefficient and/or error-prone within an STL-style - * iterator. If you require locking, you can explicitly use an - * ACE_Guard or ACE_Read_Guard on the ACE_Hash_Map_Manager_Ex's - * internal lock, which is accessible via its method. - */ -template -class ACE_Hash_Map_Const_Reverse_Iterator_Ex : public ACE_Hash_Map_Const_Iterator_Base_Ex -{ -public: - // = STL-style traits/typedefs - typedef typename ACE_Hash_Map_Const_Iterator_Base_Ex::container_type - container_type; - - // = std::iterator_traits typedefs - typedef std::bidirectional_iterator_tag iterator_category; - typedef typename container_type::value_type value_type; - typedef typename container_type::reference reference; - typedef typename container_type::pointer pointer; - typedef typename container_type::difference_type difference_type; - - // = Initialization method. - ACE_Hash_Map_Const_Reverse_Iterator_Ex (const ACE_Hash_Map_Manager_Ex &mm, - int head = 0); - - // = Iteration methods. - /// Move forward by one element in the set. Returns 0 when all the - /// items in the set have been seen, else 1. - int advance (void); - - /// Dump the state of an object. - void dump (void) const; - - // = STL styled iteration, compare, and reference functions. - - /// Prefix reverse. - ACE_Hash_Map_Const_Reverse_Iterator_Ex &operator++ (void); - - /// Postfix reverse. - ACE_Hash_Map_Const_Reverse_Iterator_Ex operator++ (int); - - /// Prefix advance. - ACE_Hash_Map_Const_Reverse_Iterator_Ex &operator-- (void); - - /// Postfix advance. - ACE_Hash_Map_Const_Reverse_Iterator_Ex operator-- (int); - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; -}; - -/** - * @class ACE_Hash_Map_Manager - * - * @brief Wrapper for backward compatibility. - * - * This implementation of a map uses a hash table. This class - * expects that the contains a method called . - * In addition, the must support . Both of - * these constraints can be alleviated via template - * specialization, as shown in the $ACE_ROOT/tests/Conn_Test.cpp - * test. - * - * Requirements and Performance Characteristics - * - Internal Structure - * Hash Table - * - Duplicates allowed? - * No - * - Random access allowed? - * Yes - * - Search speed - * O(1) - * - Insert/replace speed - * O(1), can be longer if the hash map has to resize - * - Iterator still valid after change to container? - * Yes - * - Frees memory for removed elements? - * Yes - * - Items inserted by - * Value - * - Requirements for key type - * -# Default constructor - * -# Copy constructor - * -# operator= - * -# operator== - * - Requirements for object type - * -# Default constructor - * -# Copy constructor - * -# operator= - * -# operator< - */ -template -class ACE_Hash_Map_Manager : public ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_LOCK> -{ -public: - - /** - * Initialize a @c Hash_Map_Manager with default size elements. - * @param table_alloc is a pointer to a memory allocator used for - * table_, so it should supply size*sizeof (ACE_Hash_Map_Entry). - * @param entry_alloc is a pointer to an additional allocator for - * entries, so it should be able to allocate 'size' / chunks - * of sizeof(ACE_Hash_Map_Entry) bytes each. - * If @c table_alloc is 0 it defaults to @c ACE_Allocator::instance(). - * If @c entry_alloc is 0 then it defaults to the same allocator as - * @c table_alloc. - */ - ACE_Hash_Map_Manager (ACE_Allocator *table_alloc = 0, - ACE_Allocator *entry_alloc = 0); - - /** - * Initialize a @c Hash_Map_Manager with @c size elements. - * @param table_alloc is a pointer to a memory allocator used for - * table_, so it should supply size*sizeof (ACE_Hash_Map_Entry). - * @param entry_alloc is a pointer to an additional allocator for - * entries, so it should be able to allocate 'size' / chunks - * of sizeof(ACE_Hash_Map_Entry) bytes each. - * If @c table_alloc is 0 it defaults to @c ACE_Allocator::instance(). - * If @c entry_alloc is 0 then it defaults to the same allocator as - * @c table_alloc. - */ - ACE_Hash_Map_Manager (size_t size, - ACE_Allocator *table_alloc = 0, - ACE_Allocator *entry_alloc = 0); - - // = The following two are necessary for template specialization of - // ACE_Hash_Map_Manager to work. - int equal (const EXT_ID &id1, const EXT_ID &id2); - u_long hash (const EXT_ID &ext_id); -}; - -/** - * @class ACE_Hash_Map_Iterator - * - * @brief Wrapper for backward compatibility. - */ -template -class ACE_Hash_Map_Iterator : public ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_LOCK> -{ -public: -#if defined (ACE_HAS_STL_ITERATOR_TRAITS) - typedef typename ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_LOCK>::iterator_category iterator_category; - typedef typename ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_LOCK>::value_type value_type; - typedef typename ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_LOCK>::reference reference; - typedef typename ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_LOCK>::pointer pointer; - typedef typename ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_LOCK>::difference_type difference_type; -#endif - - // = Initialization method. - /// Construct from map - ACE_Hash_Map_Iterator (ACE_Hash_Map_Manager &mm, - int tail = 0); - - /// Construct from base - ACE_Hash_Map_Iterator (const ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_LOCK> &base); - - /// Assignment from base - ACE_Hash_Map_Iterator & - operator= (const ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_LOCK> &base); -}; - -/** - * @class ACE_Hash_Map_Const_Iterator - * - * @brief Wrapper for backward compatibility. - */ -template -class ACE_Hash_Map_Const_Iterator : public ACE_Hash_Map_Const_Iterator_Ex, ACE_Equal_To, ACE_LOCK> -{ -public: - // = STL-style traits/typedefs - typedef typename ACE_Hash_Map_Const_Iterator_Ex, ACE_Equal_To, ACE_LOCK>::container_type - container_type; - - // = std::iterator_traits typedefs - typedef typename container_type::iterator_category iterator_category; - typedef typename container_type::value_type value_type; - typedef typename container_type::reference reference; - typedef typename container_type::pointer pointer; - typedef typename container_type::difference_type difference_type; - - // = Initialization method. - /// Construct from map - ACE_Hash_Map_Const_Iterator (const ACE_Hash_Map_Manager &mm, - int tail = 0); - - /// Construct from base - ACE_Hash_Map_Const_Iterator (const ACE_Hash_Map_Const_Iterator_Ex, ACE_Equal_To, ACE_LOCK> &base); - - /// Assignment from base - ACE_Hash_Map_Const_Iterator & - operator= (const ACE_Hash_Map_Const_Iterator_Ex, ACE_Equal_To, ACE_LOCK> &base); -}; - -/** - * @class ACE_Hash_Map_Reverse_Iterator - * - * @brief Wrapper for backward compatibility. - */ -template -class ACE_Hash_Map_Reverse_Iterator : public ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_LOCK> -{ -public: - // = STL-style traits/typedefs - typedef typename ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_LOCK>::container_type - container_type; - - // = std::iterator_traits typedefs - typedef typename container_type::iterator_category iterator_category; - typedef typename container_type::value_type value_type; - typedef typename container_type::reference reference; - typedef typename container_type::pointer pointer; - typedef typename container_type::difference_type difference_type; - - // = Initialization method. - ACE_Hash_Map_Reverse_Iterator (ACE_Hash_Map_Manager &mm, - int head = 0); - - /// Construct from base - ACE_Hash_Map_Reverse_Iterator (const ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_LOCK> &base); - - /// Assignment from base - ACE_Hash_Map_Reverse_Iterator & - operator= (const ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_LOCK> &base); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -# include "ace/Hash_Map_Manager_T.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Hash_Map_Manager_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Hash_Map_Manager_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" -#endif /* ACE_HASH_MAP_MANAGER_T_H */ diff --git a/ACE/ace/Hash_Map_Manager_T.inl b/ACE/ace/Hash_Map_Manager_T.inl deleted file mode 100644 index 1385ea3e5b2..00000000000 --- a/ACE/ace/Hash_Map_Manager_T.inl +++ /dev/null @@ -1,1253 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/Guard_T.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template ACE_INLINE -ACE_Hash_Map_Manager_Ex::ACE_Hash_Map_Manager_Ex (size_t size, - ACE_Allocator *table_alloc, - ACE_Allocator *entry_alloc) - : table_allocator_ (table_alloc), - entry_allocator_ (entry_alloc), - table_ (0), - total_size_ (0), - cur_size_ (0) -{ - if (this->open (size, table_alloc, entry_alloc) == -1) - ACE_ERROR ((LM_ERROR, ACE_TEXT ("ACE_Hash_Map_Manager_Ex\n"))); -} - -template ACE_INLINE -ACE_Hash_Map_Manager_Ex::ACE_Hash_Map_Manager_Ex (ACE_Allocator *table_alloc, - ACE_Allocator *entry_alloc) - : table_allocator_ (table_alloc), - entry_allocator_ (entry_alloc), - table_ (0), - total_size_ (0), - cur_size_ (0) -{ - if (this->open (ACE_DEFAULT_MAP_SIZE, table_alloc, entry_alloc) == -1) - ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Hash_Map_Manager_Ex open"))); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::close (void) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->close_i (); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::unbind_all (void) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->unbind_all_i (); -} - -template ACE_INLINE -ACE_Hash_Map_Manager_Ex::~ACE_Hash_Map_Manager_Ex (void) -{ - this->close (); -} - -template ACE_INLINE size_t -ACE_Hash_Map_Manager_Ex::current_size (void) const -{ - return this->cur_size_; -} - -template ACE_INLINE size_t -ACE_Hash_Map_Manager_Ex::total_size (void) const -{ - return this->total_size_; -} - -template ACE_INLINE ACE_LOCK & -ACE_Hash_Map_Manager_Ex::mutex (void) -{ - ACE_TRACE ("ACE_Hash_Map_Manager_Ex::mutex"); - return this->lock_; -} - -template ACE_INLINE u_long -ACE_Hash_Map_Manager_Ex::hash (const EXT_ID &ext_id) -{ - return this->hash_key_ (ext_id); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::equal (const EXT_ID &id1, - const EXT_ID &id2) -{ - return this->compare_keys_ (id1, id2); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::bind_i (const EXT_ID &ext_id, - const INT_ID &int_id) -{ - ACE_Hash_Map_Entry *temp; - - return this->bind_i (ext_id, int_id, temp); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::bind (const EXT_ID &ext_id, - const INT_ID &int_id) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->bind_i (ext_id, int_id); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::bind (const EXT_ID &ext_id, - const INT_ID &int_id, - ACE_Hash_Map_Entry *&entry) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->bind_i (ext_id, int_id, entry); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::trybind_i (const EXT_ID &ext_id, - INT_ID &int_id) -{ - ACE_Hash_Map_Entry *temp; - - int result = this->trybind_i (ext_id, int_id, temp); - if (result == 1) - int_id = temp->int_id_; - return result; -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::trybind (const EXT_ID &ext_id, - INT_ID &int_id) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->trybind_i (ext_id, int_id); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::trybind (const EXT_ID &ext_id, - INT_ID &int_id, - ACE_Hash_Map_Entry *&entry) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->trybind_i (ext_id, int_id, entry); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::unbind_i (const EXT_ID &ext_id) -{ - INT_ID int_id; - - return this->unbind_i (ext_id, int_id); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::unbind (const EXT_ID &ext_id, - INT_ID &int_id) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->unbind_i (ext_id, int_id); -} - -template -ACE_INLINE int -ACE_Hash_Map_Manager_Ex::unbind ( - typename ACE_Hash_Map_Manager_Ex::iterator pos) -{ - return this->unbind (&(*pos)); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::unbind (const EXT_ID &ext_id) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->unbind_i (ext_id) == -1 ? -1 : 0; -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::unbind (ACE_Hash_Map_Entry *entry) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->unbind_i (entry) == -1 ? -1 : 0; -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::find_i (const EXT_ID &ext_id, - INT_ID &int_id) -{ - ACE_Hash_Map_Entry *entry; - - size_t dummy; - if (this->shared_find (ext_id, entry, dummy) == -1) - return -1; - else - { - int_id = entry->int_id_; - return 0; - } -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::find_i (const EXT_ID &ext_id) -{ - ACE_Hash_Map_Entry *entry; - - size_t dummy; - return this->shared_find (ext_id, entry, dummy); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::find (const EXT_ID &ext_id, - INT_ID &int_id) const -{ - ACE_Hash_Map_Manager_Ex *nc_this = - const_cast *> - (this); - - ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return nc_this->find_i (ext_id, int_id); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::find (const EXT_ID &ext_id) const -{ - ACE_Hash_Map_Manager_Ex *nc_this = - const_cast *> - (this); - - ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return nc_this->find_i (ext_id); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::find_i (const EXT_ID &ext_id, - ACE_Hash_Map_Entry *&entry) -{ - size_t dummy; - return this->shared_find (ext_id, entry, dummy); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::find (const EXT_ID &ext_id, - ACE_Hash_Map_Entry *&entry) const -{ - ACE_Hash_Map_Manager_Ex *nc_this = - const_cast *> - (this); - - ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return nc_this->find_i (ext_id, entry); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::rebind_i (const EXT_ID &ext_id, - const INT_ID &int_id) -{ - ACE_Hash_Map_Entry *node; - - return this->rebind_i (ext_id, - int_id, - node); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::rebind_i (const EXT_ID &ext_id, - const INT_ID &int_id, - INT_ID &old_int_id) -{ - ACE_Hash_Map_Entry *node; - - return this->rebind_i (ext_id, - int_id, - old_int_id, - node); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::rebind_i (const EXT_ID &ext_id, - const INT_ID &int_id, - EXT_ID &old_ext_id, - INT_ID &old_int_id) -{ - ACE_Hash_Map_Entry *node; - - return this->rebind_i (ext_id, - int_id, - old_ext_id, - old_int_id, - node); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::rebind (const EXT_ID &ext_id, - const INT_ID &int_id) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->rebind_i (ext_id, int_id); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::rebind (const EXT_ID &ext_id, - const INT_ID &int_id, - ACE_Hash_Map_Entry *&entry) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->rebind_i (ext_id, int_id, entry); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::rebind (const EXT_ID &ext_id, - const INT_ID &int_id, - INT_ID &old_int_id) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->rebind_i (ext_id, int_id, old_int_id); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::rebind (const EXT_ID &ext_id, - const INT_ID &int_id, - INT_ID &old_int_id, - ACE_Hash_Map_Entry *&entry) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->rebind_i (ext_id, int_id, old_int_id, entry); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::rebind (const EXT_ID &ext_id, - const INT_ID &int_id, - EXT_ID &old_ext_id, - INT_ID &old_int_id) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->rebind_i (ext_id, int_id, old_ext_id, old_int_id); -} - -template ACE_INLINE int -ACE_Hash_Map_Manager_Ex::rebind (const EXT_ID &ext_id, - const INT_ID &int_id, - EXT_ID &old_ext_id, - INT_ID &old_int_id, - ACE_Hash_Map_Entry *&entry) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->rebind_i (ext_id, int_id, old_ext_id, old_int_id, entry); -} - -template ACE_INLINE -typename ACE_Hash_Map_Manager_Ex::iterator -ACE_Hash_Map_Manager_Ex::begin (void) -{ - return iterator (*this); -} - -template ACE_INLINE -typename ACE_Hash_Map_Manager_Ex::iterator -ACE_Hash_Map_Manager_Ex::end (void) -{ - return iterator (*this, 1); -} - -template ACE_INLINE -typename ACE_Hash_Map_Manager_Ex::const_iterator -ACE_Hash_Map_Manager_Ex::begin (void) const -{ - return const_iterator (*this); -} - -template ACE_INLINE -typename ACE_Hash_Map_Manager_Ex::const_iterator -ACE_Hash_Map_Manager_Ex::end (void) const -{ - return const_iterator (*this, 1); -} - -template ACE_INLINE -typename ACE_Hash_Map_Manager_Ex::reverse_iterator -ACE_Hash_Map_Manager_Ex::rbegin (void) -{ - return reverse_iterator (*this); -} - -template ACE_INLINE -typename ACE_Hash_Map_Manager_Ex::reverse_iterator -ACE_Hash_Map_Manager_Ex::rend (void) -{ - return reverse_iterator (*this, 1); -} - - template ACE_INLINE - typename ACE_Hash_Map_Manager_Ex::const_reverse_iterator - ACE_Hash_Map_Manager_Ex::rbegin (void) const - { - return const_reverse_iterator (*this); - } - - template ACE_INLINE - typename ACE_Hash_Map_Manager_Ex::const_reverse_iterator - ACE_Hash_Map_Manager_Ex::rend (void) const - { - return const_reverse_iterator (*this, 1); - } - -template ACE_INLINE -ACE_Hash_Map_Entry * -ACE_Hash_Map_Manager_Ex::table (void) -{ - return this->table_; -} - -template ACE_INLINE -size_t -ACE_Hash_Map_Manager_Ex::cur_size (void) const -{ - return this->cur_size_; -} - -template -ACE_INLINE void -ACE_Hash_Map_Manager_Ex::find ( - EXT_ID const &ext_id, - typename ACE_Hash_Map_Manager_Ex::iterator & pos) const -{ - ENTRY * entry = 0; - size_t index = 0; - - ACE_Hash_Map_Manager_Ex *nc_this = - const_cast *> - (this); - - ACE_READ_GUARD (ACE_LOCK, ace_mon, this->lock_); - - if (nc_this->shared_find (ext_id, entry, index) != -1) - pos = iterator (*nc_this, entry, index); - else - pos = nc_this->end (); -} - -// --------------------------------------------------------------------- - -template -ACE_INLINE -ACE_Hash_Map_Iterator_Base_Ex::ACE_Hash_Map_Iterator_Base_Ex ( - ACE_Hash_Map_Manager_Ex &mm, - bool head) - : map_man_ (&mm), - index_ (head ? -1 : (ssize_t) mm.total_size_), - next_ (0) -{ - if (mm.table_ != 0) - this->next_ = &mm.table_[head ? 0 : mm.total_size_ - 1]; -} - -template -ACE_INLINE -ACE_Hash_Map_Iterator_Base_Ex::ACE_Hash_Map_Iterator_Base_Ex ( - ACE_Hash_Map_Manager_Ex & mm, - ACE_Hash_Map_Entry * entry, - size_t index) - : map_man_ (&mm) - , index_ (static_cast (index)) - , next_ (entry) -{ -} - -template ACE_INLINE int -ACE_Hash_Map_Iterator_Base_Ex::next (ACE_Hash_Map_Entry *&entry) const -{ - ACE_TRACE ("ACE_Hash_Map_Iterator_Base_Ex::next"); - - if (this->map_man_->table_ != 0 - && this->index_ < static_cast (this->map_man_->total_size_) - && this->index_ >= 0 - && this->next_ != &this->map_man_->table_[this->index_]) - { - entry = this->next_; - return 1; - } - else - return 0; -} - -template ACE_INLINE int -ACE_Hash_Map_Iterator_Base_Ex::done (void) const -{ - ACE_TRACE ("ACE_Hash_Map_Iterator_Base_Ex::done"); - - return this->map_man_->table_ == 0 - || this->index_ >= static_cast (this->map_man_->total_size_) - || this->index_ < 0; -} - -template ACE_INLINE -ACE_Hash_Map_Entry & -ACE_Hash_Map_Iterator_Base_Ex::operator* (void) const -{ - ACE_TRACE ("ACE_Hash_Map_Iterator_Base_Ex::operator*"); - ACE_Hash_Map_Entry *retv = 0; - - int result = this->next (retv); - - ACE_UNUSED_ARG (result); - ACE_ASSERT (result != 0); - - return *retv; -} - -template ACE_INLINE -ACE_Hash_Map_Entry * -ACE_Hash_Map_Iterator_Base_Ex::operator-> (void) const -{ - ACE_TRACE ("ACE_Hash_Map_Iterator_Base_Ex::operator->"); - ACE_Hash_Map_Entry *retv = 0; - - int result = this->next (retv); - - ACE_UNUSED_ARG (result); - ACE_ASSERT (result != 0); - - return retv; -} - -// Returns the reference to the hash_map_manager_ex that is being -// iterated over. -template ACE_INLINE -ACE_Hash_Map_Manager_Ex& -ACE_Hash_Map_Iterator_Base_Ex::map (void) -{ - ACE_TRACE ("ACE_Hash_Map_Iterator_Base_Ex::map"); - return *this->map_man_; -} - -template ACE_INLINE bool -ACE_Hash_Map_Iterator_Base_Ex::operator== (const ACE_Hash_Map_Iterator_Base_Ex &rhs) const -{ - ACE_TRACE ("ACE_Hash_Map_Iterator_Base_Ex::operator=="); - return this->map_man_ == rhs.map_man_ - && this->index_ == rhs.index_ - && this->next_ == rhs.next_; -} - -template ACE_INLINE bool -ACE_Hash_Map_Iterator_Base_Ex::operator!= (const ACE_Hash_Map_Iterator_Base_Ex &rhs) const -{ - ACE_TRACE ("ACE_Hash_Map_Iterator_Base_Ex::operator!="); - return this->next_ != rhs.next_ - || this->index_ != rhs.index_ - || this->map_man_ != rhs.map_man_; -} - -template ACE_INLINE -ACE_Hash_Map_Const_Iterator_Base_Ex::ACE_Hash_Map_Const_Iterator_Base_Ex (const ACE_Hash_Map_Manager_Ex &mm, - int head) - : map_man_ (&mm), - index_ (head != 0 ? -1 : (ssize_t) mm.total_size_), - next_ (0) -{ - ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex::ACE_Hash_Map_Const_Iterator_Base_Ex"); - - if (mm.table_ != 0) - this->next_ = &mm.table_[head != 0 ? 0 : mm.total_size_ - 1]; -} - -template ACE_INLINE int -ACE_Hash_Map_Const_Iterator_Base_Ex::next (ACE_Hash_Map_Entry *&entry) const -{ - ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex::next"); - - if (this->map_man_->table_ != 0 - && this->index_ < (ssize_t) this->map_man_->total_size_ - && this->index_ >= 0 - && this->next_ != &this->map_man_->table_[this->index_]) - { - entry = this->next_; - return 1; - } - else - return 0; -} - -template ACE_INLINE int -ACE_Hash_Map_Const_Iterator_Base_Ex::done (void) const -{ - ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex::done"); - - return this->map_man_->table_ == 0 - || this->index_ >= (ssize_t) this->map_man_->total_size_ - || this->index_ < 0; -} - -template ACE_INLINE -ACE_Hash_Map_Entry & -ACE_Hash_Map_Const_Iterator_Base_Ex::operator* (void) const -{ - ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex::operator*"); - ACE_Hash_Map_Entry *retv = 0; - - int result = this->next (retv); - - ACE_UNUSED_ARG (result); - ACE_ASSERT (result != 0); - - return *retv; -} - -template ACE_INLINE -ACE_Hash_Map_Entry * -ACE_Hash_Map_Const_Iterator_Base_Ex::operator-> (void) const -{ - ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex::operator->"); - ACE_Hash_Map_Entry *retv = 0; - - int result = this->next (retv); - - ACE_UNUSED_ARG (result); - ACE_ASSERT (result != 0); - - return retv; -} - -// Returns the reference to the hash_map_manager_ex that is being -// iterated over. -template ACE_INLINE -const ACE_Hash_Map_Manager_Ex& -ACE_Hash_Map_Const_Iterator_Base_Ex::map (void) -{ - ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex::map"); - return *this->map_man_; -} - -template ACE_INLINE bool -ACE_Hash_Map_Const_Iterator_Base_Ex::operator== (const ACE_Hash_Map_Const_Iterator_Base_Ex &rhs) const -{ - ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex::operator=="); - return this->map_man_ == rhs.map_man_ - && this->index_ == rhs.index_ - && this->next_ == rhs.next_; -} - -template ACE_INLINE bool -ACE_Hash_Map_Const_Iterator_Base_Ex::operator!= (const ACE_Hash_Map_Const_Iterator_Base_Ex &rhs) const -{ - ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex::operator!="); - return this->next_ != rhs.next_ - || this->index_ != rhs.index_ - || this->map_man_ != rhs.map_man_; -} - -ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Iterator_Ex) - -template ACE_INLINE void -ACE_Hash_Map_Iterator_Ex::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Hash_Map_Iterator_Ex::dump"); - - this->dump_i (); -#endif /* ACE_HAS_DUMP */ -} - -template ACE_INLINE -ACE_Hash_Map_Iterator_Ex::ACE_Hash_Map_Iterator_Ex (ACE_Hash_Map_Manager_Ex &mm, - int tail) - : ACE_Hash_Map_Iterator_Base_Ex (mm, - tail == 0 ? 1 : 0) -{ - ACE_TRACE ("ACE_Hash_Map_Iterator_Ex::ACE_Hash_Map_Iterator_Ex"); - if (tail == 0) - this->forward_i (); -} - -template -ACE_INLINE -ACE_Hash_Map_Iterator_Ex::ACE_Hash_Map_Iterator_Ex ( - ACE_Hash_Map_Manager_Ex & mm, - ACE_Hash_Map_Entry * entry, - size_t index) - : ACE_Hash_Map_Iterator_Base_Ex (mm, - entry, - index) -{ -} - -template ACE_INLINE int -ACE_Hash_Map_Iterator_Ex::advance (void) -{ - ACE_TRACE ("ACE_Hash_Map_Iterator_Ex::advance"); - return this->forward_i (); -} - -template ACE_INLINE -ACE_Hash_Map_Iterator_Ex & -ACE_Hash_Map_Iterator_Ex::operator++ (void) -{ - ACE_TRACE ("ACE_Hash_Map_Iterator_Ex::operator++ (void)"); - - this->forward_i (); - return *this; -} - -template ACE_INLINE -ACE_Hash_Map_Iterator_Ex -ACE_Hash_Map_Iterator_Ex::operator++ (int) -{ - ACE_TRACE ("ACE_Hash_Map_Iterator_Ex::operator++ (int)"); - - ACE_Hash_Map_Iterator_Ex retv (*this); - ++*this; - return retv; -} - -template ACE_INLINE -ACE_Hash_Map_Iterator_Ex & -ACE_Hash_Map_Iterator_Ex::operator-- (void) -{ - ACE_TRACE ("ACE_Hash_Map_Iterator_Ex::operator-- (void)"); - - this->reverse_i (); - return *this; -} - -template ACE_INLINE -ACE_Hash_Map_Iterator_Ex -ACE_Hash_Map_Iterator_Ex::operator-- (int) -{ - ACE_TRACE ("ACE_Hash_Map_Iterator_Ex::operator-- (int)"); - - ACE_Hash_Map_Iterator_Ex retv (*this); - --*this; - return retv; -} - -ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Const_Iterator_Ex) - -template ACE_INLINE void -ACE_Hash_Map_Const_Iterator_Ex::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Ex::dump"); - - this->dump_i (); -#endif /* ACE_HAS_DUMP */ -} - -template ACE_INLINE -ACE_Hash_Map_Const_Iterator_Ex::ACE_Hash_Map_Const_Iterator_Ex (const ACE_Hash_Map_Manager_Ex &mm, - int tail) - : ACE_Hash_Map_Const_Iterator_Base_Ex (mm, - tail == 0 ? 1 : 0) -{ - ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Ex::ACE_Hash_Map_Const_Iterator_Ex"); - if (tail == 0) - this->forward_i (); -} - -template ACE_INLINE int -ACE_Hash_Map_Const_Iterator_Ex::advance (void) -{ - ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Ex::advance"); - return this->forward_i (); -} - -template ACE_INLINE -ACE_Hash_Map_Const_Iterator_Ex & -ACE_Hash_Map_Const_Iterator_Ex::operator++ (void) -{ - ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Ex::operator++ (void)"); - - this->forward_i (); - return *this; -} - -template ACE_INLINE -ACE_Hash_Map_Const_Iterator_Ex -ACE_Hash_Map_Const_Iterator_Ex::operator++ (int) -{ - ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Ex::operator++ (int)"); - - ACE_Hash_Map_Const_Iterator_Ex retv (*this); - ++*this; - return retv; -} - -template ACE_INLINE -ACE_Hash_Map_Const_Iterator_Ex & -ACE_Hash_Map_Const_Iterator_Ex::operator-- (void) -{ - ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Ex::operator-- (void)"); - - this->reverse_i (); - return *this; -} - -template ACE_INLINE -ACE_Hash_Map_Const_Iterator_Ex -ACE_Hash_Map_Const_Iterator_Ex::operator-- (int) -{ - ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Ex::operator-- (int)"); - - ACE_Hash_Map_Const_Iterator_Ex retv (*this); - --*this; - return retv; -} - -template ACE_INLINE -ACE_Hash_Map_Bucket_Iterator::ACE_Hash_Map_Bucket_Iterator (ACE_Hash_Map_Manager_Ex &mm, - const EXT_ID &ext_id, - int tail) - : map_man_ (&mm) -{ - ACE_TRACE ("ACE_Hash_Map_Bucket_Iterator::ACE_Hash_Map_Bucket_Iterator"); - - this->index_ = this->map_man_->hash (ext_id) % this->map_man_->total_size_; - this->next_ = &this->map_man_->table_[this->index_]; - - if (tail == 0) - this->forward_i (); -} - -template ACE_INLINE -ACE_Hash_Map_Bucket_Iterator & -ACE_Hash_Map_Bucket_Iterator::operator++ (void) -{ - ACE_TRACE ("ACE_Hash_Map_Bucket_Iterator::operator++ (void)"); - - this->forward_i (); - return *this; -} - -template ACE_INLINE -ACE_Hash_Map_Bucket_Iterator -ACE_Hash_Map_Bucket_Iterator::operator++ (int) -{ - ACE_TRACE ("ACE_Hash_Map_Bucket_Iterator::operator++ (int)"); - - ACE_Hash_Map_Bucket_Iterator retv (*this); - ++*this; - return retv; -} - -template ACE_INLINE -ACE_Hash_Map_Bucket_Iterator & -ACE_Hash_Map_Bucket_Iterator::operator-- (void) -{ - ACE_TRACE ("ACE_Hash_Map_Bucket_Iterator::operator-- (void)"); - - this->reverse_i (); - return *this; -} - -template ACE_INLINE -ACE_Hash_Map_Bucket_Iterator -ACE_Hash_Map_Bucket_Iterator::operator-- (int) -{ - ACE_TRACE ("ACE_Hash_Map_Bucket_Iterator::operator-- (int)"); - - ACE_Hash_Map_Bucket_Iterator retv (*this); - --*this; - return retv; -} - -template int -ACE_Hash_Map_Bucket_Iterator::forward_i (void) -{ - ACE_TRACE ("ACE_Hash_Map_Bucket_Iterator::forward_i"); - - this->next_ = this->next_->next_; - return this->next_ != &this->map_man_->table_[this->index_]; -} - -template int -ACE_Hash_Map_Bucket_Iterator::reverse_i (void) -{ - ACE_TRACE ("ACE_Hash_Map_Bucket_Iterator::reverse_i"); - - this->next_ = this->next_->prev_; - return this->next_ != &this->map_man_->table_[this->index_]; -} - -template ACE_INLINE -ACE_Hash_Map_Entry & -ACE_Hash_Map_Bucket_Iterator::operator* (void) const -{ - ACE_TRACE ("ACE_Hash_Map_Bucket_Iterator::operator*"); - - return *this->next_; -} - -template ACE_INLINE -ACE_Hash_Map_Entry * -ACE_Hash_Map_Bucket_Iterator::operator-> (void) const -{ - ACE_TRACE ("ACE_Hash_Map_Bucket_Iterator::operator->"); - - return this->next_; -} - -template ACE_INLINE -ACE_Hash_Map_Manager_Ex & -ACE_Hash_Map_Bucket_Iterator::map (void) -{ - ACE_TRACE ("ACE_Hash_Map_Bucket_Iterator::map"); - return *this->map_man_; -} - -template ACE_INLINE bool -ACE_Hash_Map_Bucket_Iterator::operator== (const ACE_Hash_Map_Bucket_Iterator &rhs) const -{ - ACE_TRACE ("ACE_Hash_Map_Bucket_Iterator::operator=="); - return this->map_man_ == rhs.map_man_ - && this->index_ == rhs.index_ - && this->next_ == rhs.next_; -} - -template ACE_INLINE bool -ACE_Hash_Map_Bucket_Iterator::operator!= (const ACE_Hash_Map_Bucket_Iterator &rhs) const -{ - ACE_TRACE ("ACE_Hash_Map_Bucket_Iterator::operator!="); - return this->next_ != rhs.next_ - || this->index_ != rhs.index_ - || this->map_man_ != rhs.map_man_; -} - -ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Reverse_Iterator_Ex) - -template ACE_INLINE void -ACE_Hash_Map_Reverse_Iterator_Ex::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Hash_Map_Reverse_Iterator_Ex::dump"); - - this->dump_i (); -#endif /* ACE_HAS_DUMP */ -} - -template ACE_INLINE -ACE_Hash_Map_Reverse_Iterator_Ex::ACE_Hash_Map_Reverse_Iterator_Ex (ACE_Hash_Map_Manager_Ex &mm, int head) - : ACE_Hash_Map_Iterator_Base_Ex (mm, head) -{ - ACE_TRACE ("ACE_Hash_Map_Reverse_Iterator_Ex::ACE_Hash_Map_Reverse_Iterator_Ex"); - if (head == 0) - this->reverse_i (); -} - -template ACE_INLINE int -ACE_Hash_Map_Reverse_Iterator_Ex::advance (void) -{ - ACE_TRACE ("ACE_Hash_Map_Reverse_Iterator_Ex::advance"); - return this->reverse_i (); -} - -template ACE_INLINE -ACE_Hash_Map_Reverse_Iterator_Ex & -ACE_Hash_Map_Reverse_Iterator_Ex::operator++ (void) -{ - ACE_TRACE ("ACE_Hash_Map_Reverse_Iterator_Ex::operator++ (void)"); - - this->reverse_i (); - return *this; -} - -template ACE_INLINE -ACE_Hash_Map_Reverse_Iterator_Ex -ACE_Hash_Map_Reverse_Iterator_Ex::operator++ (int) -{ - ACE_TRACE ("ACE_Hash_Map_Reverse_Iterator_Ex::operator++ (int)"); - - ACE_Hash_Map_Reverse_Iterator_Ex retv (*this); - ++*this; - return retv; -} - -template ACE_INLINE -ACE_Hash_Map_Reverse_Iterator_Ex & -ACE_Hash_Map_Reverse_Iterator_Ex::operator-- (void) -{ - ACE_TRACE ("ACE_Hash_Map_Reverse_Iterator_Ex::operator-- (void)"); - - this->forward_i (); - return *this; -} - -template ACE_INLINE -ACE_Hash_Map_Reverse_Iterator_Ex -ACE_Hash_Map_Reverse_Iterator_Ex::operator-- (int) -{ - ACE_TRACE ("ACE_Hash_Map_Reverse_Iterator_Ex::operator-- (int)"); - - ACE_Hash_Map_Reverse_Iterator_Ex retv (*this); - --*this; - return retv; -} - -ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Const_Reverse_Iterator_Ex) - -template ACE_INLINE void -ACE_Hash_Map_Const_Reverse_Iterator_Ex::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Hash_Map_Const_Reverse_Iterator_Ex::dump"); - - this->dump_i (); -#endif /* ACE_HAS_DUMP */ -} - -template ACE_INLINE -ACE_Hash_Map_Const_Reverse_Iterator_Ex::ACE_Hash_Map_Const_Reverse_Iterator_Ex (const ACE_Hash_Map_Manager_Ex &mm, int head) - : ACE_Hash_Map_Const_Iterator_Base_Ex (mm, head) -{ - ACE_TRACE ("ACE_Hash_Map_Const_Reverse_Iterator_Ex::ACE_Hash_Map_Const_Reverse_Iterator_Ex"); - if (head == 0) - this->reverse_i (); -} - -template ACE_INLINE int -ACE_Hash_Map_Const_Reverse_Iterator_Ex::advance (void) -{ - ACE_TRACE ("ACE_Hash_Map_Const_Reverse_Iterator_Ex::advance"); - return this->reverse_i (); -} - -template ACE_INLINE -ACE_Hash_Map_Const_Reverse_Iterator_Ex & -ACE_Hash_Map_Const_Reverse_Iterator_Ex::operator++ (void) -{ - ACE_TRACE ("ACE_Hash_Map_Const_Reverse_Iterator_Ex::operator++ (void)"); - - this->reverse_i (); - return *this; -} - -template ACE_INLINE -ACE_Hash_Map_Const_Reverse_Iterator_Ex -ACE_Hash_Map_Const_Reverse_Iterator_Ex::operator++ (int) -{ - ACE_TRACE ("ACE_Hash_Map_Const_Reverse_Iterator_Ex::operator++ (int)"); - - ACE_Hash_Map_Const_Reverse_Iterator_Ex retv (*this); - ++*this; - return retv; -} - -template ACE_INLINE -ACE_Hash_Map_Const_Reverse_Iterator_Ex & -ACE_Hash_Map_Const_Reverse_Iterator_Ex::operator-- (void) -{ - ACE_TRACE ("ACE_Hash_Map_Const_Reverse_Iterator_Ex::operator-- (void)"); - - this->forward_i (); - return *this; -} - -template ACE_INLINE -ACE_Hash_Map_Const_Reverse_Iterator_Ex -ACE_Hash_Map_Const_Reverse_Iterator_Ex::operator-- (int) -{ - ACE_TRACE ("ACE_Hash_Map_Const_Reverse_Iterator_Ex::operator-- (int)"); - - ACE_Hash_Map_Const_Reverse_Iterator_Ex retv (*this); - --*this; - return retv; -} - -template -ACE_Hash_Map_Manager::ACE_Hash_Map_Manager (ACE_Allocator *table_alloc, - ACE_Allocator *entry_alloc) - : ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_LOCK> (table_alloc, - entry_alloc) -{ -} - -template -ACE_Hash_Map_Manager::ACE_Hash_Map_Manager (size_t size, - ACE_Allocator *table_alloc, - ACE_Allocator *entry_alloc) - : ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_LOCK> (size, - table_alloc, - entry_alloc) -{ -} - -template int -ACE_Hash_Map_Manager::equal (const EXT_ID &id1, const EXT_ID &id2) -{ - return ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_LOCK>::equal (id1, id2); -} - -template u_long -ACE_Hash_Map_Manager::hash (const EXT_ID &ext_id) -{ - return ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_LOCK>::hash (ext_id); -} - -template -ACE_Hash_Map_Iterator::ACE_Hash_Map_Iterator (ACE_Hash_Map_Manager &mm, - int tail) - : ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_LOCK> (mm, - tail) -{ -} - -template -ACE_Hash_Map_Iterator::ACE_Hash_Map_Iterator (const ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_LOCK> &base) - : ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_LOCK> (base) -{ -} - -template ACE_Hash_Map_Iterator & -ACE_Hash_Map_Iterator::operator= (const ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_LOCK> &rhs) -{ - if (this != &rhs) - { - ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_LOCK> &base = *this; - - base = rhs; - } - - return *this; -} - -template -ACE_Hash_Map_Const_Iterator::ACE_Hash_Map_Const_Iterator (const ACE_Hash_Map_Manager &mm, - int tail) - : ACE_Hash_Map_Const_Iterator_Ex, ACE_Equal_To, ACE_LOCK> (mm, - tail) -{ -} - -template -ACE_Hash_Map_Const_Iterator::ACE_Hash_Map_Const_Iterator (const ACE_Hash_Map_Const_Iterator_Ex, ACE_Equal_To, ACE_LOCK> &base) - : ACE_Hash_Map_Const_Iterator_Ex, ACE_Equal_To, ACE_LOCK> (base) -{ -} - -template ACE_Hash_Map_Const_Iterator & -ACE_Hash_Map_Const_Iterator::operator= (const ACE_Hash_Map_Const_Iterator_Ex, ACE_Equal_To, ACE_LOCK> &rhs) -{ - if (this != &rhs) - { - ACE_Hash_Map_Const_Iterator_Ex, ACE_Equal_To, ACE_LOCK> &base = *this; - - base = rhs; - } - - return *this; -} - -template -ACE_Hash_Map_Reverse_Iterator::ACE_Hash_Map_Reverse_Iterator (ACE_Hash_Map_Manager &mm, - int head) - : ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_LOCK> (mm, - head) -{ -} - -template -ACE_Hash_Map_Reverse_Iterator::ACE_Hash_Map_Reverse_Iterator (const ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_LOCK> &base) - : ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_LOCK> (base) -{ -} - -template ACE_Hash_Map_Reverse_Iterator & -ACE_Hash_Map_Reverse_Iterator::operator= (const ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_LOCK> &rhs) -{ - ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_LOCK> &base = *this; - - base = rhs; - - return *this; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Hash_Map_With_Allocator_T.cpp b/ACE/ace/Hash_Map_With_Allocator_T.cpp deleted file mode 100644 index 9927147e865..00000000000 --- a/ACE/ace/Hash_Map_With_Allocator_T.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// $Id$ - -#ifndef ACE_HASH_MAP_WITH_ALLOCATOR_T_CPP -#define ACE_HASH_MAP_WITH_ALLOCATOR_T_CPP - -#include "ace/Hash_Map_With_Allocator_T.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (__ACE_INLINE__) -#include "ace/Hash_Map_With_Allocator_T.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template -ACE_Hash_Map_With_Allocator::ACE_Hash_Map_With_Allocator (ACE_Allocator *alloc) - : ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex> (alloc) -{ - ACE_TRACE ("ACE_Hash_Map_With_Allocator::ACE_Hash_Map_With_Allocator"); -} - -template -ACE_Hash_Map_With_Allocator::ACE_Hash_Map_With_Allocator (size_t size, - ACE_Allocator *alloc) - : ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex> (size, alloc) -{ - ACE_TRACE ("ACE_Hash_Map_With_Allocator::ACE_Hash_Map_With_Allocator"); -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HASH_MAP_WITH_ALLOCATOR_T_CPP */ diff --git a/ACE/ace/Hash_Map_With_Allocator_T.h b/ACE/ace/Hash_Map_With_Allocator_T.h deleted file mode 100644 index 1c2413ba3f2..00000000000 --- a/ACE/ace/Hash_Map_With_Allocator_T.h +++ /dev/null @@ -1,112 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Hash_Map_With_Allocator_T.h - * - * $Id$ - * - * @author Marina Spivak - * @author Irfan Pyarali - */ -//============================================================================= - -#ifndef ACE_HASH_MAP_WITH_ALLOCATOR_T_H -#define ACE_HASH_MAP_WITH_ALLOCATOR_T_H -#include /**/ "ace/pre.h" - -#include "ace/Hash_Map_Manager_T.h" -#include "ace/Null_Mutex.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Hash_Map_With_Allocator - * - * @brief This class is a thin wrapper around ACE_Hash_Map_Manager, - * which comes handy when ACE_Hash_Map_Manager is to be used with a - * non-nil ACE_Allocator. This wrapper insures that the appropriate - * allocator is in place for every operation that accesses or - * updates the hash map. - * - * If we use ACE_Hash_Map_Manager with a shared memory allocator - * (or memory-mapped file allocator, for example), the allocator - * pointer used by ACE_Hash_Map_Manager gets stored with it, in - * shared memory (or memory-mapped file). Naturally, this will - * cause horrible problems, since only the first process to set - * that pointer will be guaranteed the address of the allocator - * is meaningful! That is why we need this wrapper, which - * insures that appropriate allocator pointer is in place for - * each call. - * - * At some point it would be a good idea to update this class to - * use the new "two allocator" technique provided by @c - * ACE_Hash_Map_Manager_Ex. - */ -template -class ACE_Hash_Map_With_Allocator : - public ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex> -{ -public: - /// Constructor. - ACE_Hash_Map_With_Allocator (ACE_Allocator *alloc); - - /// Constructor that specifies hash table size. - ACE_Hash_Map_With_Allocator (size_t size, - ACE_Allocator *alloc); - - // = The following methods are Proxies to the corresponding methods - // in ACE_Hash_Map_Manager. Each method sets the allocator to - // the one specified by the invoking entity, and then calls the - // corresponding method in ACE_Hash_Map_Manager to do the - // actual work. - - int bind (const EXT_ID &, - const INT_ID &, - ACE_Allocator *alloc); - - int unbind (const EXT_ID &, - INT_ID &, - ACE_Allocator *alloc); - - int unbind (const EXT_ID &, - ACE_Allocator *alloc); - - int rebind (const EXT_ID &, - const INT_ID &, - EXT_ID &, - INT_ID &, - ACE_Allocator *alloc); - - int find (const EXT_ID &, - INT_ID &, - ACE_Allocator *alloc); - - /// Returns 0 if the @a ext_id is in the mapping, otherwise -1. - int find (const EXT_ID &ext_id, - ACE_Allocator *alloc); - - int close (ACE_Allocator *alloc); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Hash_Map_With_Allocator_T.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Hash_Map_With_Allocator_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Hash_Map_With_Allocator_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - - -#include /**/ "ace/post.h" -#endif /* ACE_HASH_MAP_WITH_ALLOCATOR_T_H */ diff --git a/ACE/ace/Hash_Map_With_Allocator_T.inl b/ACE/ace/Hash_Map_With_Allocator_T.inl deleted file mode 100644 index 4ba51437abf..00000000000 --- a/ACE/ace/Hash_Map_With_Allocator_T.inl +++ /dev/null @@ -1,82 +0,0 @@ -// -*- C++ -*- - -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template ACE_INLINE int -ACE_Hash_Map_With_Allocator::close (ACE_Allocator *alloc) -{ - ACE_TRACE ("ACE_Hash_Map_With_Allocator::close"); - this->table_allocator_ = alloc; - this->entry_allocator_ = alloc; - return this->close_i (); -} - -template ACE_INLINE int -ACE_Hash_Map_With_Allocator::bind (const EXT_ID &ext_id, - const INT_ID &int_id, - ACE_Allocator *alloc) -{ - ACE_TRACE ("ACE_Hash_Map_With_Allocator::bind"); - this->table_allocator_ = alloc; - this->entry_allocator_ = alloc; - return this->bind_i (ext_id, int_id); -} - -template ACE_INLINE int -ACE_Hash_Map_With_Allocator::unbind (const EXT_ID &ext_id, - INT_ID &int_id, - ACE_Allocator *alloc) -{ - ACE_TRACE ("ACE_Hash_Map_With_Allocator::unbind"); - this->table_allocator_ = alloc; - this->entry_allocator_ = alloc; - return this->unbind_i (ext_id, int_id); -} - -template ACE_INLINE int -ACE_Hash_Map_With_Allocator::unbind (const EXT_ID &ext_id, - ACE_Allocator *alloc) -{ - ACE_TRACE ("ACE_Hash_Map_With_Allocator::unbind"); - this->table_allocator_ = alloc; - this->entry_allocator_ = alloc; - return this->unbind_i (ext_id); -} - -template ACE_INLINE int -ACE_Hash_Map_With_Allocator::rebind (const EXT_ID &ext_id, - const INT_ID &int_id, - EXT_ID &old_ext_id, - INT_ID &old_int_id, - ACE_Allocator *alloc) -{ - ACE_TRACE ("ACE_Hash_Map_With_Allocator::rebind"); - this->table_allocator_ = alloc; - this->entry_allocator_ = alloc; - return this->rebind_i (ext_id, int_id, old_ext_id, old_int_id); -} - -template ACE_INLINE int -ACE_Hash_Map_With_Allocator::find (const EXT_ID &ext_id, - INT_ID &int_id, - ACE_Allocator *alloc) -{ - ACE_TRACE ("ACE_Hash_Map_With_Allocator::find"); - this->table_allocator_ = alloc; - this->entry_allocator_ = alloc; - return this->find_i (ext_id, int_id); -} - -template ACE_INLINE int -ACE_Hash_Map_With_Allocator::find (const EXT_ID &ext_id, - ACE_Allocator *alloc) -{ - ACE_TRACE ("ACE_Hash_Map_With_Allocator::find"); - this->table_allocator_ = alloc; - this->entry_allocator_ = alloc; - return this->find_i (ext_id); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Hash_Multi_Map_Manager_T.cpp b/ACE/ace/Hash_Multi_Map_Manager_T.cpp deleted file mode 100644 index 34e8b0406be..00000000000 --- a/ACE/ace/Hash_Multi_Map_Manager_T.cpp +++ /dev/null @@ -1,605 +0,0 @@ - -//============================================================================= -/** - * @file Hash_Multi_Map_Manager_T.cpp - * - * $Id$ - * - * @author Shanshan Jiang - */ -//============================================================================= - - -#ifndef ACE_Hash_Multi_Map_Manager_T_CPP -#define ACE_Hash_Multi_Map_Manager_T_CPP - -#include "ace/Hash_Multi_Map_Manager_T.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (__ACE_INLINE__) -# include "ace/Hash_Multi_Map_Manager_T.inl" -#endif /* __ACE_INLINE__ */ - -#include "ace/Malloc_Base.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - - -template -ACE_Hash_Multi_Map_Entry::ACE_Hash_Multi_Map_Entry (ACE_Hash_Multi_Map_Entry *next, - ACE_Hash_Multi_Map_Entry *prev) - : next_ (next), - prev_ (prev) -{ -} - -template -ACE_Hash_Multi_Map_Entry::ACE_Hash_Multi_Map_Entry (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - ACE_Hash_Multi_Map_Entry *next, - ACE_Hash_Multi_Map_Entry *prev) - : ext_id_ (ext_id), - int_id_set_ (int_id_set), - next_ (next), - prev_ (prev) -{ -} - -# if ! defined (ACE_HAS_BROKEN_NOOP_DTORS) -template -ACE_Hash_Multi_Map_Entry::~ACE_Hash_Multi_Map_Entry (void) -{ -} -# endif /* ! defined (ACE_HAS_BROKEN_NOOP_DTORS) */ - -template EXT_ID & -ACE_Hash_Multi_Map_Entry::key () -{ - return ext_id_; -} - -template ACE_Unbounded_Set & -ACE_Hash_Multi_Map_Entry::item () -{ - return int_id_set_; -} - -template void -ACE_Hash_Multi_Map_Entry::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("next_ = %d"), this->next_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("prev_ = %d"), this->prev_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -template void -ACE_Hash_Multi_Map_Manager::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("total_size_ = %d"), this->total_size_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncur_size_ = %d"), this->cur_size_)); - this->table_allocator_->dump (); - this->entry_allocator_->dump (); - this->lock_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -template int -ACE_Hash_Multi_Map_Manager::create_buckets (size_t size) -{ - size_t bytes = size * sizeof (ACE_Hash_Multi_Map_Entry); - void *ptr; - - ACE_ALLOCATOR_RETURN (ptr, - this->table_allocator_->malloc (bytes), - -1); - - this->table_ = (ACE_Hash_Multi_Map_Entry *) ptr; - - this->total_size_ = size; - - // Initialize each entry in the hash table to be a circular linked - // list with the dummy node in the front serving as the anchor of - // the list. - for (size_t i = 0; i < size; i++) - new (&this->table_[i]) ACE_Hash_Multi_Map_Entry (&this->table_[i], - &this->table_[i]); - return 0; -} - -template int -ACE_Hash_Multi_Map_Manager::open (size_t size, - ACE_Allocator *table_alloc, - ACE_Allocator *entry_alloc) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - // Calling this->close_i () to ensure we release previous allocated - // memory before allocating new one. - this->close_i (); - - if (table_alloc == 0) - table_alloc = ACE_Allocator::instance (); - - this->table_allocator_ = table_alloc; - - if (entry_alloc == 0) - entry_alloc = table_alloc; - - this->entry_allocator_ = entry_alloc; - - // This assertion is here to help track a situation that shouldn't - // happen, but did with Sun C++ 4.1 (before a change to this class - // was made: it used to have an enum that was supposed to be defined - // to be ACE_DEFAULT_MAP_SIZE, but instead was defined to be 0). - if (size == 0) - return -1; - - return this->create_buckets (size); -} - -template int -ACE_Hash_Multi_Map_Manager::close_i (void) -{ - // Protect against "double-deletion" in case the destructor also - // gets called. - if (this->table_ != 0) - { - // Remove all the entries. - this->unbind_all_i (); - - // Iterate through the buckets cleaning up the sentinels. - for (size_t i = 0; i < this->total_size_; i++) - { - // Destroy the dummy entry. - ACE_Hash_Multi_Map_Entry *entry = &this->table_[i]; - - // The second argument results in a no-op instead of - // deallocation. - ACE_DES_FREE_TEMPLATE2 (entry, ACE_NOOP, - ACE_Hash_Multi_Map_Entry, EXT_ID, INT_ID); - } - - // Reset size. - this->total_size_ = 0; - - // Free table memory. - this->table_allocator_->free (this->table_); - - // Should be done last... - this->table_ = 0; - } - - return 0; -} - -template int -ACE_Hash_Multi_Map_Manager::unbind_all_i (void) -{ - // Iterate through the entire map calling the destuctor of each - // . - for (size_t i = 0; i < this->total_size_; i++) - { - for (ACE_Hash_Multi_Map_Entry *temp_ptr = this->table_[i].next_; - temp_ptr != &this->table_[i]; - ) - { - ACE_Hash_Multi_Map_Entry *hold_ptr = temp_ptr; - temp_ptr = temp_ptr->next_; - - // Explicitly call the destructor. - ACE_DES_FREE_TEMPLATE2 (hold_ptr, this->entry_allocator_->free, - ACE_Hash_Multi_Map_Entry, EXT_ID, INT_ID); - } - - // Restore the sentinel. - this->table_[i].next_ = &this->table_[i]; - this->table_[i].prev_ = &this->table_[i]; - } - - this->cur_size_ = 0; - - return 0; -} - -template int -ACE_Hash_Multi_Map_Manager::bind_i (const EXT_ID &ext_id, - const INT_ID &int_id, - ACE_Hash_Multi_Map_Entry *&entry) -{ - size_t loc; - int result = this->shared_find (ext_id, entry, loc); - - ACE_Unbounded_Set int_id_set; - if (result == -1) - { - void *ptr; - // Not found. - ACE_ALLOCATOR_RETURN (ptr, - this->entry_allocator_->malloc (sizeof (ACE_Hash_Multi_Map_Entry)), - -1); - - int_id_set.insert (int_id); - - entry = new (ptr) ACE_Hash_Multi_Map_Entry (ext_id, - int_id_set, - this->table_[loc].next_, - &this->table_[loc]); - this->table_[loc].next_ = entry; - entry->next_->prev_ = entry; - this->cur_size_++; - return 0; - } - else - { - int_id_set = (*entry).int_id_set_; - - if (0 == int_id_set.insert (int_id)) - { - this->unbind_i (entry); - return this->bind_i (ext_id, int_id_set); - } - else - return 1; - } -} - -template int -ACE_Hash_Multi_Map_Manager::bind_i (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - ACE_Hash_Multi_Map_Entry *&entry) -{ - size_t loc; - int result = this->shared_find (ext_id, entry, loc); - - if (result == -1) - { - void *ptr; - // Not found. - ACE_ALLOCATOR_RETURN (ptr, - this->entry_allocator_->malloc (sizeof (ACE_Hash_Multi_Map_Entry)), - -1); - - entry = new (ptr) ACE_Hash_Multi_Map_Entry (ext_id, - int_id_set, - this->table_[loc].next_, - &this->table_[loc]); - this->table_[loc].next_ = entry; - entry->next_->prev_ = entry; - this->cur_size_++; - return 0; - } - else - return 1; -} - -template int -ACE_Hash_Multi_Map_Manager::trybind_i (const EXT_ID &ext_id, - ACE_Unbounded_Set &int_id_set, - ACE_Hash_Multi_Map_Entry *&entry) -{ - size_t loc; - int result = this->shared_find (ext_id, entry, loc); - - if (result == -1) - { - // Not found. - void *ptr; - ACE_ALLOCATOR_RETURN (ptr, - this->entry_allocator_->malloc (sizeof (ACE_Hash_Multi_Map_Entry)), - -1); - - entry = new (ptr) ACE_Hash_Multi_Map_Entry (ext_id, - int_id_set, - this->table_[loc].next_, - &this->table_[loc]); - this->table_[loc].next_ = entry; - entry->next_->prev_ = entry; - this->cur_size_++; - return 0; - } - else - return 1; -} - -template int -ACE_Hash_Multi_Map_Manager::unbind_i (const EXT_ID &ext_id, - ACE_Unbounded_Set &int_id_set) -{ - ACE_Hash_Multi_Map_Entry *temp; - - size_t loc; - int result = this->shared_find (ext_id, temp, loc); - - if (result == -1) - { - errno = ENOENT; - return -1; - } - - int_id_set = temp->int_id_set_; - - return this->unbind_i (temp); -} - -template int -ACE_Hash_Multi_Map_Manager::unbind_i (ACE_Hash_Multi_Map_Entry *entry) -{ - entry->next_->prev_ = entry->prev_; - entry->prev_->next_ = entry->next_; - - // Explicitly call the destructor. - ACE_DES_FREE_TEMPLATE2 (entry, this->entry_allocator_->free, - ACE_Hash_Multi_Map_Entry, EXT_ID, INT_ID); - - this->cur_size_--; - return 0; -} - -template int -ACE_Hash_Multi_Map_Manager::unbind_i (const EXT_ID &ext_id, - const INT_ID &int_id) -{ - ACE_Hash_Multi_Map_Entry *temp; - - size_t loc; - int result = this->shared_find (ext_id, temp, loc); - - if (result == -1) - { - errno = ENOENT; - return -1; - } - - ACE_Unbounded_Set int_id_set = (*temp).int_id_set_; - if (0 == int_id_set.remove (int_id)) - { - this->unbind_i (temp); - - if (0 != int_id_set.size ()) - return this->bind_i (ext_id, int_id_set); - else - return 0; - } - else - return -1; -} - - -template int -ACE_Hash_Multi_Map_Manager::shared_find (const EXT_ID &ext_id, - ACE_Hash_Multi_Map_Entry *&entry, - size_t &loc) -{ - loc = this->hash (ext_id) % this->total_size_; - - ACE_Hash_Multi_Map_Entry *temp = this->table_[loc].next_; - - while (temp != &this->table_[loc] && this->equal (temp->ext_id_, ext_id) == 0) - temp = temp->next_; - - if (temp == &this->table_[loc]) - { - errno = ENOENT; - return -1; - } - else - { - entry = temp; - return 0; - } -} - -template int -ACE_Hash_Multi_Map_Manager::rebind_i (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - ACE_Hash_Multi_Map_Entry *&entry) -{ - size_t dummy; - if (this->shared_find (ext_id, entry, dummy) == -1) - return this->bind_i (ext_id, int_id_set); - else - { - entry->ext_id_ = ext_id; - entry->int_id_set_ = int_id_set; - return 1; - } -} - -template int -ACE_Hash_Multi_Map_Manager::rebind_i (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - ACE_Unbounded_Set &old_int_id_set, - ACE_Hash_Multi_Map_Entry *&entry) -{ - size_t dummy; - if (this->shared_find (ext_id, entry, dummy) == -1) - return this->bind_i (ext_id, int_id_set); - else - { - old_int_id_set = entry->int_id_set_; - entry->ext_id_ = ext_id; - entry->int_id_set_ = int_id_set; - return 1; - } -} - -template int -ACE_Hash_Multi_Map_Manager::rebind_i (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - EXT_ID &old_ext_id, - ACE_Unbounded_Set &old_int_id_set, - ACE_Hash_Multi_Map_Entry *&entry) -{ - size_t dummy; - if (this->shared_find (ext_id, entry, dummy) == -1) - return this->bind_i (ext_id, int_id_set); - else - { - old_ext_id = entry->ext_id_; - old_int_id_set = entry->int_id_set_; - entry->ext_id_ = ext_id; - entry->int_id_set_ = int_id_set; - return 1; - } -} - -// ------------------------------------------------------------ - -ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Multi_Map_Iterator_Base) - -template void -ACE_Hash_Multi_Map_Iterator_Base::dump_i (void) const -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Iterator_Base::dump_i"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("index_ = %d "), this->index_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("next_ = %x"), this->next_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -} - -template int -ACE_Hash_Multi_Map_Iterator_Base::forward_i (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Iterator_Base::forward_i"); - - if (this->map_man_->table_ == 0) - return -1; - // Handle initial case specially. - else if (this->index_ == -1) - { - this->index_++; - return this->forward_i (); - } - else if (this->index_ >= static_cast (this->map_man_->total_size_)) - return 0; - - this->next_ = this->next_->next_; - if (this->next_ == &this->map_man_->table_[this->index_]) - { - while (++this->index_ < static_cast (this->map_man_->total_size_)) - { - this->next_ = this->map_man_->table_[this->index_].next_; - if (this->next_ != &this->map_man_->table_[this->index_]) - break; - } - } - - return this->index_ < static_cast (this->map_man_->total_size_); -} - -template int -ACE_Hash_Multi_Map_Iterator_Base::reverse_i (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Iterator_Base::reverse_i"); - - if (this->map_man_->table_ == 0) - return -1; - else if (this->index_ == static_cast (this->map_man_->total_size_)) - { - this->index_--; - return this->reverse_i (); - } - else if (this->index_ < 0) - return 0; - - this->next_ = this->next_->prev_; - if (this->next_ == &this->map_man_->table_[this->index_]) - { - while (--this->index_ >= 0) - { - this->next_ = this->map_man_->table_[this->index_].prev_; - if (this->next_ != &this->map_man_->table_[this->index_]) - break; - } - } - - return this->index_ >= 0; -} - -// ------------------------------------------------------------ - -ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Multi_Map_Const_Iterator_Base) - -template void -ACE_Hash_Multi_Map_Const_Iterator_Base::dump_i (void) const -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator_Base::dump_i"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("index_ = %d "), this->index_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("next_ = %x"), this->next_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -} - -template int -ACE_Hash_Multi_Map_Const_Iterator_Base::forward_i (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator_Base::forward_i"); - - if (this->map_man_->table_ == 0) - return -1; - // Handle initial case specially. - else if (this->index_ == -1) - { - this->index_++; - return this->forward_i (); - } - else if (this->index_ >= (ssize_t) this->map_man_->total_size_) - return 0; - - this->next_ = this->next_->next_; - if (this->next_ == &this->map_man_->table_[this->index_]) - { - while (++this->index_ < (ssize_t) this->map_man_->total_size_) - { - this->next_ = this->map_man_->table_[this->index_].next_; - if (this->next_ != &this->map_man_->table_[this->index_]) - break; - } - } - - return this->index_ < (ssize_t) this->map_man_->total_size_; -} - -template int -ACE_Hash_Multi_Map_Const_Iterator_Base::reverse_i (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator_Base::reverse_i"); - - if (this->map_man_->table_ == 0) - return -1; - else if (this->index_ == (ssize_t) this->map_man_->total_size_) - { - this->index_--; - return this->reverse_i (); - } - else if (this->index_ < 0) - return 0; - - this->next_ = this->next_->prev_; - if (this->next_ == &this->map_man_->table_[this->index_]) - { - while (--this->index_ >= 0) - { - this->next_ = this->map_man_->table_[this->index_].prev_; - if (this->next_ != &this->map_man_->table_[this->index_]) - break; - } - } - - return this->index_ >= 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_Hash_Multi_Map_Manager_T_CPP */ diff --git a/ACE/ace/Hash_Multi_Map_Manager_T.h b/ACE/ace/Hash_Multi_Map_Manager_T.h deleted file mode 100644 index 11e54292477..00000000000 --- a/ACE/ace/Hash_Multi_Map_Manager_T.h +++ /dev/null @@ -1,967 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Hash_Multi_Map_Manager_T.h - * - * $Id$ - * - * The code in Hash_Multi_Map_Manager_T.* was based on the code in - * Hash_Map_Manager_T.*. - * - * ACE_Hash_Multi_Map_Manager maps a key type to more than one value types. - * The template takes the key and value types as parameters. The bind and - * unbind operations can take a key and the value or the set of the values that - * is to be associated with that key. The find operation can take a key or a - * key and the value that is associated with the key. - * - * ACE_Hash_Multi_Map_Manager uses @c ACE_Unbounded_Set to store differet values - * with the same key. - * - * @author Shanshan Jiang - */ -//============================================================================= - -#ifndef ACE_HASH_MULTI_MAP_MANAGER_T_H -#define ACE_HASH_MULTI_MAP_MANAGER_T_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Default_Constants.h" -#include "ace/Functor_T.h" -#include "ace/Log_Msg.h" - -#include "ace/Unbounded_Set.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Hash_Multi_Map_Entry - * - * @brief Define an entry in the hash table. - */ -template -class ACE_Hash_Multi_Map_Entry -{ -public: - friend class ACE_Unbounded_Set; - - typedef ACE_Unbounded_Set VALUE_SET; - typedef ACE_Unbounded_Set_Iterator VALUE_SET_ITERATOR; - - // = Initialization and termination methods. - /// Constructor. - ACE_Hash_Multi_Map_Entry (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - ACE_Hash_Multi_Map_Entry *next = 0, - ACE_Hash_Multi_Map_Entry *prev = 0); - - /// Constructor. - ACE_Hash_Multi_Map_Entry (ACE_Hash_Multi_Map_Entry *next, - ACE_Hash_Multi_Map_Entry *prev); - - # if ! defined (ACE_HAS_BROKEN_NOOP_DTORS) - /// Destructor. - ~ACE_Hash_Multi_Map_Entry (void); - #endif /* ! defined (ACE_HAS_BROKEN_NOOP_DTORS) */ - - /// Key accessor. - EXT_ID& key (void); - - /// Item accessor. - ACE_Unbounded_Set& item (void); - - /// Key used to look up an entry. - /// @deprecated Use key() - EXT_ID ext_id_; - - /// The contents of the entry itself. - /// @deprecated Use item() - ACE_Unbounded_Set int_id_set_; - - /// Pointer to the next item in the bucket of overflow nodes. - ACE_Hash_Multi_Map_Entry *next_; - - /// Pointer to the prev item in the bucket of overflow nodes. - ACE_Hash_Multi_Map_Entry *prev_; - - /// Dump the state of an object. - void dump (void) const; -}; - -// Forward decl. -template -class ACE_Hash_Multi_Map_Iterator_Base; - -// Forward decl. -template -class ACE_Hash_Multi_Map_Const_Iterator_Base; - -// Forward decl. -template -class ACE_Hash_Multi_Map_Iterator; - -// Forward decl. -template -class ACE_Hash_Multi_Map_Const_Iterator; - -// Forward decl. -template -class ACE_Hash_Multi_Map_Reverse_Iterator; - -// Forward decl. -template -class ACE_Hash_Multi_Map_Bucket_Iterator; - -// Forward decl. -class ACE_Allocator; - -/** - * @class ACE_Hash_Multi_Map_Manager - * - * @brief Define a multi-map abstraction that efficiently associates the keys - * with their different values. - * - * This implementation of a multi-map uses a hash table. Key hashing - * is achieved through the @c HASH_KEY object and key comparison is - * achieved through the @c COMPARE_KEYS object. - * This class uses an @c ACE_Allocator to allocate memory. The - * user can make this a persistent class by providing an - * @c ACE_Allocator with a persistable memory pool. - */ - -template -class ACE_Hash_Multi_Map_Manager -{ -public: - friend class ACE_Hash_Multi_Map_Iterator_Base; - friend class ACE_Hash_Multi_Map_Iterator; - friend class ACE_Hash_Multi_Map_Const_Iterator_Base; - friend class ACE_Hash_Multi_Map_Const_Iterator; - friend class ACE_Hash_Multi_Map_Reverse_Iterator; - friend class ACE_Hash_Multi_Map_Bucket_Iterator; - - typedef EXT_ID - KEY; - typedef INT_ID - VALUE; - typedef ACE_LOCK lock_type; - typedef ACE_Hash_Multi_Map_Entry - ENTRY; - - // = ACE-style iterator typedefs. - typedef ACE_Hash_Multi_Map_Iterator - ITERATOR; - typedef ACE_Hash_Multi_Map_Const_Iterator - CONST_ITERATOR; - typedef ACE_Hash_Multi_Map_Reverse_Iterator - REVERSE_ITERATOR; - - // = STL-style iterator typedefs. - typedef ACE_Hash_Multi_Map_Iterator - iterator; - typedef ACE_Hash_Multi_Map_Const_Iterator - const_iterator; - typedef ACE_Hash_Multi_Map_Reverse_Iterator - reverse_iterator; - - // = Initialization and termination methods. - - /** - * Initialize a @c Hash_Multi_Map_Manager with default size elements. - * @param table_alloc is a pointer to a memory allocator used for - * table_, so it should supply size*sizeof ( - * ACE_Hash_Multi_Map_Entry<@c EXT_ID, @c INT_ID>). - * @param entry_alloc is a pointer to an additional allocator for - * entries, so it should be able to allocate 'size' / chunks - * of sizeof (ACE_Hash_Multi_Map_Entry<@c EXT_ID, @c INT_ID>) bytes - * each. - * If @a table_alloc is 0 it defaults to @c ACE_Allocator::instance(). - * If @a entry_alloc is 0 then it defaults to the same allocator as - * @a table_alloc. - */ - ACE_Hash_Multi_Map_Manager (ACE_Allocator *table_alloc = 0, - ACE_Allocator *entry_alloc = 0); - - /** - * Initialize a @c Hash_Multi_Map_Manager with @a size elements. - * @param size is the number of elements in a Hash_Multi_Map_Manager. - * @param table_alloc is a pointer to a memory allocator used for - * table_, so it should supply size*sizeof ( - * ACE_Hash_Multi_Map_Entry<@c EXT_ID, <@c INT_ID>). - * @param entry_alloc is a pointer to an additional allocator for - * entries, so it should be able to allocate 'size' / chunks - * of sizeof (ACE_Hash_Multi_Map_Entry<@c EXT_ID, @c INT_ID>) bytes - * each. - * If @a table_alloc is 0 it defaults to @c ACE_Allocator::instance(). - * If @a entry_alloc is 0 then it defaults to the same allocator as - * @a table_alloc. - */ - ACE_Hash_Multi_Map_Manager (size_t size, - ACE_Allocator *table_alloc = 0, - ACE_Allocator *entry_alloc = 0); - - /** - * Initialize a @c Hash_Multi_Map_Manager with @a size elements. - * @param size is the number of elements in a Hash_Multi_Map_Manager. - * @param table_alloc is a pointer to a memory allocator used for - * table_, so it should supply size*sizeof - * (ACE_Hash_Multi_Map_Entry<@c EXT_ID, <@c INT_ID>). - * @param entry_alloc is a pointer to an additional allocator for - * entries, so it should be able to allocate 'size' / chunks - * of sizeof (ACE_Hash_Multi_Map_Entry<@c EXT_ID, <@c INT_ID>) bytes - * each. - * If @a table_alloc is 0 it defaults to @c ACE_Allocator::instance(). - * If @a entry_alloc is 0 then it defaults to the same allocator as - * @a table_alloc. - * @return -1 on failure, 0 on success - */ - - int open (size_t size = ACE_DEFAULT_MAP_SIZE, - ACE_Allocator *table_alloc = 0, - ACE_Allocator *entry_alloc = 0); - - /// Close down a Hash_Multi_Map_Manager and release dynamically allocated - /// resources. - int close (void); - - /// Removes all the entries in Hash_Multi_Map_Manager. - int unbind_all (void); - - /// Cleanup the Hash_Multi_Map_Manager. - ~ACE_Hash_Multi_Map_Manager (void); - - /** - * Associate @a ext_id with @a int_id. If @a ext_id and @a int_id is already - * in the map then the @c ACE_Hash_Multi_Map_Entry is not changed. Returns 0 if - * a new entry is bound successfully, returns 1 if an attempt is made - * to bind an existing entry, and returns -1 if failures occur. - */ - int bind (const EXT_ID &ext_id, - const INT_ID &int_id); - - /** - * Same as a normal bind, except the map entry is also passed back - * to the caller. The entry in this case will either be the newly - * created entry, or the existing one. - */ - int bind (const EXT_ID &ext_id, - const INT_ID &int_id, - ACE_Hash_Multi_Map_Entry *&entry); - - /** - * Associate @a ext_id with @a int_id_set. If @a ext_id is already in the - * map then the @c ACE_Hash_Multi_Map_Entry is not changed. Returns 0 if a - * new entry is bound successfully, returns 1 if an attempt is made - * to bind an existing entry, and returns -1 if failures occur. - */ - int bind (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set); - - /** - * Same as a normal bind, except the map entry is also passed back - * to the caller. The entry in this case will either be the newly - * created entry, or the existing one. - */ - int bind (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - ACE_Hash_Multi_Map_Entry *&entry); - - /** - * Associate @a ext_id with @a int_id_set if and only if @a ext_id is - * not in the map. If @a ext_id is already in the map then the @a int_id_set - * parameter is assigned the existing value in the map. Returns 0 - * if a new entry is bound successfully, returns 1 if an attempt is - * made to bind an existing entry, and returns -1 if failures occur. - */ - int trybind (const EXT_ID &ext_id, - ACE_Unbounded_Set &int_id_set); - - /** - * Same as a normal trybind, except the map entry is also passed - * back to the caller. The entry in this case will either be the - * newly created entry, or the existing one. - */ - int trybind (const EXT_ID &ext_id, - ACE_Unbounded_Set &int_id_set, - ACE_Hash_Multi_Map_Entry *&entry); - - /** - * Reassociate @a ext_id with @a int_id_set. If @a ext_id is not in - * the map then behaves just like bind. Returns 0 if a new entry is - * bound successfully, returns 1 if an existing entry was rebound, - * and returns -1 if failures occur. - */ - int rebind (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set); - - /** - * Same as a normal rebind, except the map entry is also passed back - * to the caller. The entry in this case will either be the newly - * created entry, or the existing one. - */ - int rebind (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - ACE_Hash_Multi_Map_Entry *&entry); - - /** - * Associate @a ext_id with @a int_id_set. If @a ext_id is not in the map - * then behaves just like bind. Otherwise, store the old value of - * @a int_id_set into the "out" parameter and rebind the new parameters. - * Returns 0 if a new entry is bound successfully, returns 1 if an - * existing entry was rebound, and returns -1 if failures occur. - */ - int rebind (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - ACE_Unbounded_Set &old_int_id_set); - - /** - * Same as a normal rebind, except the map entry is also passed back - * to the caller. The entry in this case will either be the newly - * created entry, or the existing one. - */ - int rebind (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - ACE_Unbounded_Set &old_int_id_set, - ACE_Hash_Multi_Map_Entry *&entry); - - /** - * Associate @a ext_id with @a int_id_set. If @a ext_id is not in the map - * then behaves just like bind. Otherwise, store the old values - * of @a ext_id and @a int_id_set into the "out" parameters and rebind the - * new parameters. This is very useful if you need to have an - * atomic way of updating @c ACE_Hash_Multi_Map_Entry objects and you also - * need full control over memory allocation. Returns 0 if a new entry - * is bound successfully, returns 1 if an existing entry was rebound, - * and returns -1 if failures occur. - */ - int rebind (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - EXT_ID &old_ext_id, - ACE_Unbounded_Set &old_int_id_set); - - /** - * Same as a normal rebind, except the map entry is also passed back - * to the caller. The entry in this case will either be the newly - * created entry, or the existing one. - */ - int rebind (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - EXT_ID &old_ext_id, - ACE_Unbounded_Set &old_int_id_set, - ACE_Hash_Multi_Map_Entry *&entry); - - /// Locate @a ext_id and pass out parameter via @a int_id_set. - /// Return 0 if found, returns -1 if not found. - int find (const EXT_ID &ext_id, - ACE_Unbounded_Set &int_id_set) const; - - /// Locate @a ext_id and @a int_id. - /// Return 0 if found, returns -1 if not found. - int find (const EXT_ID &ext_id, - const INT_ID &int_id) const; - - /// Returns 0 if the @a ext_id is in the mapping, otherwise -1. - int find (const EXT_ID &ext_id) const; - - /// Locate @a ext_id and pass out parameter via @a entry. If found, - /// return 0, returns -1 if not found. - int find (const EXT_ID &ext_id, - ACE_Hash_Multi_Map_Entry *&entry) const; - - /** - * Unbind (remove) the @a ext_id from the map. Don't return the - * int_id to the caller (this is useful for collections where the - * int_ids are *not* dynamically allocated...) - */ - int unbind (const EXT_ID &ext_id); - - /// Break any association of @a ext_id. Returns the value of @a int_id_set - /// in case the caller needs to deallocate memory. Return 0 if the - /// unbind was successfully, and returns -1 if failures occur. - int unbind (const EXT_ID &ext_id, - ACE_Unbounded_Set &int_id_set); - - /// Break any association of @a ext_id and @a int_id. Return 0 if the - /// unbind was successfully, and returns -1 if failures occur. - int unbind (const EXT_ID &ext_id, - const INT_ID &int_id); - - /// Remove @a entry from map. Return 0 if the unbind was successfully, - /// and returns -1 if failures occur. - int unbind (ACE_Hash_Multi_Map_Entry *entry); - - /// Returns the current number of @c ACE_Hash_Multi_Map_Entry objects in the - /// hash table. - size_t current_size (void) const; - - /// Return the size of the array that's used to point to the - /// linked lists of @c ACE_Hash_Multi_Map_Entry objects in the hash table. - size_t total_size (void) const; - - /** - * Returns a reference to the underlying @c ACE_LOCK. This makes it - * possible to acquire the lock explicitly, which can be useful in - * some cases if you instantiate the @c ACE_Atomic_Op with an - * @c ACE_Recursive_Mutex or @c ACE_Process_Mutex, or if you need to - * guard the state of an iterator. - * @note The right name would be lock, but HP/C++ will choke on that! - */ - ACE_LOCK &mutex (void); - - /// Dump the state of an object. - void dump (void) const; - - // = STL styled iterator factory functions. - - /// Return forward iterator. - ACE_Hash_Multi_Map_Iterator begin (void); - ACE_Hash_Multi_Map_Iterator end (void); - - /// Return reverse iterator. - ACE_Hash_Multi_Map_Reverse_Iterator rbegin (void); - ACE_Hash_Multi_Map_Reverse_Iterator rend (void); - -protected: - // = The following methods do the actual work. - - /// Returns 1 if @a id1 == @a id2, else 0. This is defined as a - /// separate method to facilitate template specialization. - int equal (const EXT_ID &id1, const EXT_ID &id2); - - /// Compute the hash value of the @a ext_id. This is defined as a - /// separate method to facilitate template specialization. - u_long hash (const EXT_ID &ext_id); - - // = These methods assume locks are held by private methods. - - /// Performs bind. Must be called with locks held. - int bind_i (const EXT_ID &ext_id, - const INT_ID &int_id); - - /// Performs bind. Must be called with locks held. - int bind_i (const EXT_ID &ext_id, - const INT_ID &int_id, - ACE_Hash_Multi_Map_Entry *&entry); - - /// Performs bind. Must be called with locks held. - int bind_i (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set); - - /// Performs bind. Must be called with locks held. - int bind_i (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - ACE_Hash_Multi_Map_Entry *&entry); - - /// Performs trybind. Must be called with locks held. - int trybind_i (const EXT_ID &ext_id, - ACE_Unbounded_Set &int_id_set); - - /// Performs trybind. Must be called with locks held. - int trybind_i (const EXT_ID &ext_id, - ACE_Unbounded_Set &int_id_set, - ACE_Hash_Multi_Map_Entry *&entry); - - /// Performs rebind. Must be called with locks held. - int rebind_i (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set); - - /// Performs rebind. Must be called with locks held. - int rebind_i (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - ACE_Hash_Multi_Map_Entry *&entry); - - /// Performs rebind. Must be called with locks held. - int rebind_i (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - ACE_Unbounded_Set &old_int_id); - - /// Performs rebind. Must be called with locks held. - int rebind_i (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - ACE_Unbounded_Set &old_int_id_set, - ACE_Hash_Multi_Map_Entry *&entry); - - /// Performs rebind. Must be called with locks held. - int rebind_i (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - EXT_ID &old_ext_id, - ACE_Unbounded_Set &old_int_id_set); - - /// Performs rebind. Must be called with locks held. - int rebind_i (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - EXT_ID &old_ext_id, - ACE_Unbounded_Set &old_int_id_set, - ACE_Hash_Multi_Map_Entry *&entry); - - /// Performs a find of @a int_id_set using @a ext_id as the key. Must be - /// called with locks held. - int find_i (const EXT_ID &ext_id, - ACE_Unbounded_Set &int_id_set); - - /// Performs a find of @a ext_id and @a int_id. Must be - /// called with locks held. - int find_i (const EXT_ID &ext_id, - const INT_ID &int_id); - - /// Performs a find using @a ext_id as the key. Must be called with - /// locks held. - int find_i (const EXT_ID &ext_id); - - /// Performs a find using @a ext_id as the key. Must be called with - /// locks held. - int find_i (const EXT_ID &ext_id, - ACE_Hash_Multi_Map_Entry *&entry); - - /// Performs unbind. Must be called with locks held. - int unbind_i (const EXT_ID &ext_id, - ACE_Unbounded_Set &int_id_set); - - /// Performs unbind. Must be called with locks held. - int unbind_i (const EXT_ID &ext_id, - const INT_ID &int_id); - - /// Performs unbind. Must be called with locks held. - int unbind_i (const EXT_ID &ext_id); - - /// Performs unbind. Must be called with locks held. - int unbind_i (ACE_Hash_Multi_Map_Entry *entry); - - /** - * Resize the map. Must be called with locks held. - * @note This method should never be called more than once or else all the - * hashing will get screwed up as the size will change. - */ - int create_buckets (size_t size); - - /// Close down a Map_Manager. Must be called with - /// locks held. - int close_i (void); - - /// Removes all the entries in Map_Manager. Must be called with - /// locks held. - int unbind_all_i (void); - - /// Pointer to a memory allocator used for table_, so it should - /// supply size*sizeof (@c ACE_Hash_Multi_Map_Entry<@c EXT_ID, @c INT_ID>), - ACE_Allocator *table_allocator_; - - /// Addidtional allocator for entries, so it should be able to - /// allocate 'size' / chunks of sizeof - /// (@c ACE_Hash_Multi_Map_Entry<@c EXT_ID, @c INT_ID>) bytes each. - ACE_Allocator *entry_allocator_; - - /// Synchronization variable for the MT_SAFE - /// @c ACE_Hash_Multi_Map_Manager. - ACE_LOCK lock_; - - /// Function object used for hashing keys. - HASH_KEY hash_key_; - - /// Function object used for comparing keys. - COMPARE_KEYS compare_keys_; - -protected: - /// Returns the @c ACE_Hash_Multi_Map_Entry object that corresponds to - /// @a ext_id. - int shared_find (const EXT_ID &ext_id, - ACE_Hash_Multi_Map_Entry *&entry, - size_t &loc); - - /// Accessor of the underlying table - ACE_Hash_Multi_Map_Entry *table (void); - - /// Accessor of the current size attribute - size_t cur_size (void) const; - -private: - /** - * Array of the pointers to @c ACE_Hash_Multi_Map_Entry objects, each of - * which points to an @c ACE_Hash_Multi_Map_Entry that serves as the - * beginning of a linked list of @c EXT_ID that hash to that bucket. - */ - ACE_Hash_Multi_Map_Entry *table_; - - /// Total size of the hash table. - size_t total_size_; - - /// Current number of entries in the table - /// @note That this can be larger than total_size_ due to the - /// bucket chaining). - size_t cur_size_; - - // = Disallow these operations. - ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Hash_Multi_Map_Manager &)) - ACE_UNIMPLEMENTED_FUNC (ACE_Hash_Multi_Map_Manager (const ACE_Hash_Multi_Map_Manager &)) -}; - -/** - * @class ACE_Hash_Multi_Map_Iterator_Base - * - * @brief Base iterator for the @c ACE_Hash_Multi_Map_Manager - * - * This class factors out common code from its templatized - * subclasses. - */ -template -class ACE_Hash_Multi_Map_Iterator_Base -{ -public: - // = Initialization method. - /// Contructor. If @a head != 0, the iterator constructed is positioned - /// at the head of the map, it is positioned at the end otherwise. - ACE_Hash_Multi_Map_Iterator_Base (ACE_Hash_Multi_Map_Manager &mm, - int head); - - // = ITERATION methods. - - /// Pass back the @a next_entry that hasn't been seen in the Set. - /// Returns 0 when all items have been seen, else 1. - int next (ACE_Hash_Multi_Map_Entry *&next_entry) const; - - /// Returns 1 when all items have been seen, else 0. - int done (void) const; - - /// Returns a reference to the interal element this object is pointing to. - ACE_Hash_Multi_Map_Entry& operator* (void) const; - - /// Returns a pointer to the interal element this object is pointing to. - ACE_Hash_Multi_Map_Entry* operator-> (void) const; - - /// Returns reference the @c Hash_Multi_Map_Manager that is being iterated - /// over. - ACE_Hash_Multi_Map_Manager& map (void); - - /// Check if two iterators point to the same position - bool operator== (const ACE_Hash_Multi_Map_Iterator_Base &) const; - bool operator!= (const ACE_Hash_Multi_Map_Iterator_Base &) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - /// Move forward by one element in the set. Returns 0 when there's - /// no more item in the set after the current items, else 1. - int forward_i (void); - - /// Move backward by one element in the set. Returns 0 when there's - /// no more item in the set before the current item, else 1. - int reverse_i (void); - - /// Dump the state of an object. - void dump_i (void) const; - - /// Map we are iterating over. - ACE_Hash_Multi_Map_Manager *map_man_; - - /// Keeps track of how far we've advanced in the table. - ssize_t index_; - - /// Keeps track of how far we've advanced in a linked list in each - /// table slot. - ACE_Hash_Multi_Map_Entry *next_; -}; - -/** - * @class ACE_Hash_Multi_Map_Const_Iterator_Base - * - * @brief Base const iterator for the @c ACE_Hash_Multi_Map_Manager - * - * This class factors out common code from its templatized - * subclasses. - */ -template -class ACE_Hash_Multi_Map_Const_Iterator_Base -{ -public: - // = Initialization method. - /// Contructor. If @a head != 0, the iterator constructed is positioned - /// at the head of the map, it is positioned at the end otherwise. - ACE_Hash_Multi_Map_Const_Iterator_Base (const ACE_Hash_Multi_Map_Manager &mm, - int head); - - // = ITERATION methods. - - /// Pass back the @a next_entry that hasn't been seen in the Set. - /// Returns 0 when all items have been seen, else 1. - int next (ACE_Hash_Multi_Map_Entry *&next_entry) const; - - /// Returns 1 when all items have been seen, else 0. - int done (void) const; - - /// Returns a reference to the interal element this object is pointing to. - ACE_Hash_Multi_Map_Entry& operator* (void) const; - - /// Returns a pointer to the interal element this object is pointing to. - ACE_Hash_Multi_Map_Entry* operator-> (void) const; - - /// Returns reference the @c Hash_Multi_Map_Manager that is being iterated - /// over. - const ACE_Hash_Multi_Map_Manager& map (void); - - /// Check if two iterators point to the same position - bool operator== (const ACE_Hash_Multi_Map_Const_Iterator_Base &) const; - bool operator!= (const ACE_Hash_Multi_Map_Const_Iterator_Base &) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - /// Move forward by one element in the set. Returns 0 when there's - /// no more item in the set after the current items, else 1. - int forward_i (void); - - /// Move backward by one element in the set. Returns 0 when there's - /// no more item in the set before the current item, else 1. - int reverse_i (void); - - /// Dump the state of an object. - void dump_i (void) const; - - /// Map we are iterating over. - const ACE_Hash_Multi_Map_Manager *map_man_; - - /// Keeps track of how far we've advanced in the table. - ssize_t index_; - - /// Keeps track of how far we've advanced in a linked list in each - /// table slot. - ACE_Hash_Multi_Map_Entry *next_; -}; - -/** - * @class ACE_Hash_Multi_Map_Iterator - * - * @brief Forward iterator for the @c ACE_Hash_Multi_Map_Manager. - * - * This class does not perform any internal locking of the - * @c ACE_Hash_Multi_Map_Manager it is iterating upon since locking is - * inherently inefficient and/or error-prone within an STL-style - * iterator. If you require locking, you can explicitly use an - * @c ACE_Guard or @c ACE_Read_Guard on the @c ACE_Hash_Multi_Map_Manager's - * internal lock, which is accessible via its @c mutex method. - */ -template -class ACE_Hash_Multi_Map_Iterator : public ACE_Hash_Multi_Map_Iterator_Base -{ -public: - // = Initialization method. - ACE_Hash_Multi_Map_Iterator (ACE_Hash_Multi_Map_Manager &mm, - int tail = 0); - - // = Iteration methods. - /// Move forward by one element in the set. Returns 0 when all the - /// items in the set have been seen, else 1. - int advance (void); - - /// Dump the state of an object. - void dump (void) const; - - // = STL styled iteration, compare, and reference functions. - - /// Prefix advance. - ACE_Hash_Multi_Map_Iterator &operator++ (void); - - /// Postfix advance. - ACE_Hash_Multi_Map_Iterator operator++ (int); - - /// Prefix reverse. - ACE_Hash_Multi_Map_Iterator &operator-- (void); - - /// Postfix reverse. - ACE_Hash_Multi_Map_Iterator operator-- (int); - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; -}; - -/** - * @class ACE_Hash_Multi_Map_Const_Iterator - * - * @brief Const forward iterator for the @c ACE_Hash_Multi_Map_Manager. - * - * This class does not perform any internal locking of the - * @c ACE_Hash_Multi_Map_Manager it is iterating upon since locking is - * inherently inefficient and/or error-prone within an STL-style - * iterator. If you require locking, you can explicitly use an - * @c ACE_Guard or @c ACE_Read_Guard on the @c ACE_Hash_Multi_Map_Manager's - * internal lock, which is accessible via its @c mutex method. - */ -template -class ACE_Hash_Multi_Map_Const_Iterator : public ACE_Hash_Multi_Map_Const_Iterator_Base -{ -public: - // = Initialization method. - ACE_Hash_Multi_Map_Const_Iterator (const ACE_Hash_Multi_Map_Manager &mm, - int tail = 0); - - // = Iteration methods. - /// Move forward by one element in the set. Returns 0 when all the - /// items in the set have been seen, else 1. - int advance (void); - - /// Dump the state of an object. - void dump (void) const; - - // = STL styled iteration, compare, and reference functions. - - /// Prefix advance. - ACE_Hash_Multi_Map_Const_Iterator &operator++ (void); - - /// Postfix advance. - ACE_Hash_Multi_Map_Const_Iterator operator++ (int); - - /// Prefix reverse. - ACE_Hash_Multi_Map_Const_Iterator &operator-- (void); - - /// Postfix reverse. - ACE_Hash_Multi_Map_Const_Iterator operator-- (int); - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; -}; - -/** - * @class ACE_Hash_Multi_Map_Bucket_Iterator - * - * @brief Forward iterator for the @c ACE_Hash_Multi_Map_Manager which - * only traverses a particular bucket. The particular bucket is - * specified by the @c EXT_ID parameter specified in the constructor. - * - * This class does not perform any internal locking of the - * @c ACE_Hash_Multi_Map_Manager it is iterating upon since locking is - * inherently inefficient and/or error-prone within an STL-style - * iterator. If you require locking, you can explicitly use an - * @c ACE_Guard or @c ACE_Read_Guard on the @c ACE_Hash_Multi_Map_Manager's - * internal lock, which is accessible via its @c mutex method. - * - * Note that a creation method for this new iterator cannot be added - * to the hash map, since this would require adding explicit template - * instantiations for bucket iterators on platforms with broken - * templates. - */ -template -class ACE_Hash_Multi_Map_Bucket_Iterator -{ -public: - // = Initialization method. - ACE_Hash_Multi_Map_Bucket_Iterator (ACE_Hash_Multi_Map_Manager &mm, - const EXT_ID &ext_id, - int tail = 0); - - // = STL styled iteration, compare, and reference functions. - - /// Prefix advance. - ACE_Hash_Multi_Map_Bucket_Iterator &operator++ (void); - - /// Postfix advance. - ACE_Hash_Multi_Map_Bucket_Iterator operator++ (int); - - /// Prefix reverse. - ACE_Hash_Multi_Map_Bucket_Iterator &operator-- (void); - - /// Postfix reverse. - ACE_Hash_Multi_Map_Bucket_Iterator operator-- (int); - - /// Returns a reference to the interal element this object is pointing to. - ACE_Hash_Multi_Map_Entry& operator* (void) const; - - /// Returns a pointer to the interal element this object is pointing to. - ACE_Hash_Multi_Map_Entry* operator-> (void) const; - - /// Returns reference the Hash_Multi_Map_Manager that is being iterated - /// over. - ACE_Hash_Multi_Map_Manager& map (void); - - /// Check if two iterators point to the same position - bool operator== (const ACE_Hash_Multi_Map_Bucket_Iterator &) const; - bool operator!= (const ACE_Hash_Multi_Map_Bucket_Iterator &) const; - -protected: - /// Move forward by one element in the set. Returns 0 when there's - /// no more item in the set after the current items, else 1. - int forward_i (void); - - /// Move backward by one element in the set. Returns 0 when there's - /// no more item in the set before the current item, else 1. - int reverse_i (void); - - /// Map we are iterating over. - ACE_Hash_Multi_Map_Manager *map_man_; - - /// Keeps track of how far we've advanced in the table. - ssize_t index_; - - /// Keeps track of how far we've advanced in a linked list in each - /// table slot. - ACE_Hash_Multi_Map_Entry *next_; -}; - -/** - * @class ACE_Hash_Multi_Map_Reverse_Iterator - * - * @brief Reverse iterator for the @c ACE_Hash_Multi_Map_Manager. - * - * This class does not perform any internal locking of the - * @c ACE_Hash_Multi_Map_Manager it is iterating upon since locking is - * inherently inefficient and/or error-prone within an STL-style - * iterator. If you require locking, you can explicitly use an - * @c ACE_Guard or @c ACE_Read_Guard on the @c ACE_Hash_Multi_Map_Manager's - * internal lock, which is accessible via its @c mutex method. - */ -template -class ACE_Hash_Multi_Map_Reverse_Iterator : public ACE_Hash_Multi_Map_Iterator_Base -{ -public: - // = Initialization method. - ACE_Hash_Multi_Map_Reverse_Iterator (ACE_Hash_Multi_Map_Manager &mm, - int head = 0); - - // = Iteration methods. - /// Move forward by one element in the set. Returns 0 when all the - /// items in the set have been seen, else 1. - int advance (void); - - /// Dump the state of an object. - void dump (void) const; - - // = STL styled iteration, compare, and reference functions. - - /// Prefix reverse. - ACE_Hash_Multi_Map_Reverse_Iterator &operator++ (void); - - /// Postfix reverse. - ACE_Hash_Multi_Map_Reverse_Iterator operator++ (int); - - /// Prefix advance. - ACE_Hash_Multi_Map_Reverse_Iterator &operator-- (void); - - /// Postfix advance. - ACE_Hash_Multi_Map_Reverse_Iterator operator-- (int); - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -# include "ace/Hash_Multi_Map_Manager_T.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Hash_Multi_Map_Manager_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Hash_Multi_Map_Manager_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" -#endif /* ACE_HASH_MULTI_MAP_MANAGER_T_H */ diff --git a/ACE/ace/Hash_Multi_Map_Manager_T.inl b/ACE/ace/Hash_Multi_Map_Manager_T.inl deleted file mode 100644 index f0cbcabe599..00000000000 --- a/ACE/ace/Hash_Multi_Map_Manager_T.inl +++ /dev/null @@ -1,994 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/Guard_T.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template ACE_INLINE -ACE_Hash_Multi_Map_Manager::ACE_Hash_Multi_Map_Manager (size_t size, - ACE_Allocator *table_alloc, - ACE_Allocator *entry_alloc) - : table_allocator_ (table_alloc), - entry_allocator_ (entry_alloc), - table_ (0), - total_size_ (0), - cur_size_ (0) -{ - if (this->open (size, table_alloc, entry_alloc) == -1) - ACE_ERROR ((LM_ERROR, ACE_TEXT ("ACE_Hash_Multi_Map_Manager\n"))); -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Manager::ACE_Hash_Multi_Map_Manager (ACE_Allocator *table_alloc, - ACE_Allocator *entry_alloc) - : table_allocator_ (table_alloc), - entry_allocator_ (entry_alloc), - table_ (0), - total_size_ (0), - cur_size_ (0) -{ - if (this->open (ACE_DEFAULT_MAP_SIZE, table_alloc, entry_alloc) == -1) - ACE_ERROR ((LM_ERROR, ACE_TEXT ("ACE_Hash_Multi_Map_Manager\n"))); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::close (void) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->close_i (); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::unbind_all (void) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->unbind_all_i (); -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Manager::~ACE_Hash_Multi_Map_Manager (void) -{ - this->close (); -} - -template ACE_INLINE size_t -ACE_Hash_Multi_Map_Manager::current_size (void) const -{ - return this->cur_size_; -} - -template ACE_INLINE size_t -ACE_Hash_Multi_Map_Manager::total_size (void) const -{ - return this->total_size_; -} - -template ACE_INLINE ACE_LOCK & -ACE_Hash_Multi_Map_Manager::mutex (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Manager::mutex"); - return this->lock_; -} - -template ACE_INLINE u_long -ACE_Hash_Multi_Map_Manager::hash (const EXT_ID &ext_id) -{ - return this->hash_key_ (ext_id); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::equal (const EXT_ID &id1, - const EXT_ID &id2) -{ - return this->compare_keys_ (id1, id2); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::bind_i (const EXT_ID &ext_id, - const INT_ID &int_id) -{ - ACE_Hash_Multi_Map_Entry *temp; - - return this->bind_i (ext_id, int_id, temp); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::bind_i (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set) -{ - ACE_Hash_Multi_Map_Entry *temp; - - return this->bind_i (ext_id, int_id_set, temp); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::bind (const EXT_ID &ext_id, - const INT_ID &int_id) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->bind_i (ext_id, int_id); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::bind (const EXT_ID &ext_id, - const INT_ID &int_id, - ACE_Hash_Multi_Map_Entry *&entry) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->bind_i (ext_id, int_id, entry); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::bind (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->bind_i (ext_id, int_id_set); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::bind (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - ACE_Hash_Multi_Map_Entry *&entry) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->bind_i (ext_id, int_id_set, entry); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::trybind_i (const EXT_ID &ext_id, - ACE_Unbounded_Set &int_id_set) -{ - ACE_Hash_Multi_Map_Entry *temp; - - int result = this->trybind_i (ext_id, int_id_set, temp); - if (result == 1) - int_id_set = temp->int_id_set_; - return result; -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::trybind (const EXT_ID &ext_id, - ACE_Unbounded_Set &int_id_set) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->trybind_i (ext_id, int_id_set); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::trybind (const EXT_ID &ext_id, - ACE_Unbounded_Set &int_id_set, - ACE_Hash_Multi_Map_Entry *&entry) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->trybind_i (ext_id, int_id_set, entry); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::unbind_i (const EXT_ID &ext_id) -{ - ACE_Unbounded_Set int_id_set; - - return this->unbind_i (ext_id, int_id_set); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::unbind (const EXT_ID &ext_id, - ACE_Unbounded_Set &int_id_set) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->unbind_i (ext_id, int_id_set); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::unbind (const EXT_ID &ext_id, - const INT_ID &int_id) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->unbind_i (ext_id, int_id); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::unbind (const EXT_ID &ext_id) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->unbind_i (ext_id) == -1 ? -1 : 0; -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::unbind (ACE_Hash_Multi_Map_Entry *entry) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->unbind_i (entry) == -1 ? -1 : 0; -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::find_i (const EXT_ID &ext_id, - ACE_Unbounded_Set &int_id_set) -{ - ACE_Hash_Multi_Map_Entry *entry; - - size_t dummy; - if (this->shared_find (ext_id, entry, dummy) == -1) - return -1; - else - { - int_id_set = entry->int_id_set_; - return 0; - } -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::find_i (const EXT_ID &ext_id, - const INT_ID &int_id) -{ - ACE_Hash_Multi_Map_Entry *entry; - - size_t dummy; - if (this->shared_find (ext_id, entry, dummy) == -1) - return -1; - else - { - if (0 == entry->int_id_set_.find (int_id)) - return 0; - else - return -1; - } -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::find_i (const EXT_ID &ext_id) -{ - ACE_Hash_Multi_Map_Entry *entry; - - size_t dummy; - return this->shared_find (ext_id, entry, dummy); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::find (const EXT_ID &ext_id, - ACE_Unbounded_Set &int_id_set) const -{ - ACE_Hash_Multi_Map_Manager *nc_this = - const_cast *> - (this); - - ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, nc_this->lock_, -1); - - return nc_this->find_i (ext_id, int_id_set); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::find (const EXT_ID &ext_id, - const INT_ID &int_id) const -{ - ACE_Hash_Multi_Map_Manager *nc_this = - const_cast *> - (this); - - ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, nc_this->lock_, -1); - - return nc_this->find_i (ext_id, int_id); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::find (const EXT_ID &ext_id) const -{ - ACE_Hash_Multi_Map_Manager *nc_this = - const_cast *> - (this); - - ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, nc_this->lock_, -1); - - return nc_this->find_i (ext_id); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::find_i (const EXT_ID &ext_id, - ACE_Hash_Multi_Map_Entry *&entry) -{ - size_t dummy; - return this->shared_find (ext_id, entry, dummy); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::find (const EXT_ID &ext_id, - ACE_Hash_Multi_Map_Entry *&entry) const -{ - ACE_Hash_Multi_Map_Manager *nc_this = - const_cast *> - (this); - - ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, nc_this->lock_, -1); - - return nc_this->find_i (ext_id, entry); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::rebind_i (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set) -{ - ACE_Hash_Multi_Map_Entry *node; - - return this->rebind_i (ext_id, - int_id_set, - node); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::rebind_i (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - ACE_Unbounded_Set &old_int_id_set) -{ - ACE_Hash_Multi_Map_Entry *node; - - return this->rebind_i (ext_id, - int_id_set, - old_int_id_set, - node); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::rebind_i (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - EXT_ID &old_ext_id, - ACE_Unbounded_Set &old_int_id_set) -{ - ACE_Hash_Multi_Map_Entry *node; - - return this->rebind_i (ext_id, - int_id_set, - old_ext_id, - old_int_id_set, - node); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::rebind (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->rebind_i (ext_id, int_id_set); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::rebind (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - ACE_Hash_Multi_Map_Entry *&entry) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->rebind_i (ext_id, int_id_set, entry); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::rebind (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - ACE_Unbounded_Set &old_int_id_set) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->rebind_i (ext_id, int_id_set, old_int_id_set); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::rebind (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - ACE_Unbounded_Set &old_int_id_set, - ACE_Hash_Multi_Map_Entry *&entry) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->rebind_i (ext_id, int_id_set, old_int_id_set, entry); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::rebind (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - EXT_ID &old_ext_id, - ACE_Unbounded_Set &old_int_id_set) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->rebind_i (ext_id, int_id_set, old_ext_id, old_int_id_set); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Manager::rebind (const EXT_ID &ext_id, - const ACE_Unbounded_Set &int_id_set, - EXT_ID &old_ext_id, - ACE_Unbounded_Set &old_int_id_set, - ACE_Hash_Multi_Map_Entry *&entry) -{ - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); - - return this->rebind_i (ext_id, int_id_set, old_ext_id, old_int_id_set, entry); -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Iterator -ACE_Hash_Multi_Map_Manager::begin (void) -{ - return ACE_Hash_Multi_Map_Iterator (*this); -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Iterator -ACE_Hash_Multi_Map_Manager::end (void) -{ - return ACE_Hash_Multi_Map_Iterator (*this, 1); -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Reverse_Iterator -ACE_Hash_Multi_Map_Manager::rbegin (void) -{ - return ACE_Hash_Multi_Map_Reverse_Iterator (*this); -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Reverse_Iterator -ACE_Hash_Multi_Map_Manager::rend (void) -{ - return ACE_Hash_Multi_Map_Reverse_Iterator (*this, 1); -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Entry * -ACE_Hash_Multi_Map_Manager::table (void) -{ - return this->table_; -} - -template ACE_INLINE -size_t -ACE_Hash_Multi_Map_Manager::cur_size (void) const -{ - return this->cur_size_; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Iterator_Base::ACE_Hash_Multi_Map_Iterator_Base (ACE_Hash_Multi_Map_Manager &mm, - int head) - : map_man_ (&mm), - index_ (head != 0 ? -1 : (ssize_t) mm.total_size_), - next_ (0) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Iterator_Base::ACE_Hash_Multi_Map_Iterator_Base"); - - if (mm.table_ != 0) - this->next_ = &mm.table_[head != 0 ? 0 : mm.total_size_ - 1]; -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Iterator_Base::next (ACE_Hash_Multi_Map_Entry *&entry) const -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Iterator_Base::next"); - - if (this->map_man_->table_ != 0 - && this->index_ < static_cast (this->map_man_->total_size_) - && this->index_ >= 0 - && this->next_ != &this->map_man_->table_[this->index_]) - { - entry = this->next_; - return 1; - } - else - return 0; -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Iterator_Base::done (void) const -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Iterator_Base::done"); - - return this->map_man_->table_ == 0 - || this->index_ >= static_cast (this->map_man_->total_size_) - || this->index_ < 0; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Entry & -ACE_Hash_Multi_Map_Iterator_Base::operator* (void) const -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Iterator_Base::operator*"); - ACE_Hash_Multi_Map_Entry *retv = 0; - - int result = this->next (retv); - - ACE_UNUSED_ARG (result); - ACE_ASSERT (result != 0); - - return *retv; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Entry * -ACE_Hash_Multi_Map_Iterator_Base::operator-> (void) const -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Iterator_Base::operator->"); - ACE_Hash_Multi_Map_Entry *retv = 0; - - int result = this->next (retv); - - ACE_UNUSED_ARG (result); - ACE_ASSERT (result != 0); - - return retv; -} - -// Returns the reference to the Hash_Multi_Map_manager_ex that is being -// iterated over. -template ACE_INLINE -ACE_Hash_Multi_Map_Manager& -ACE_Hash_Multi_Map_Iterator_Base::map (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Iterator_Base::map"); - return *this->map_man_; -} - -template ACE_INLINE bool -ACE_Hash_Multi_Map_Iterator_Base::operator== (const ACE_Hash_Multi_Map_Iterator_Base &rhs) const -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Iterator_Base::operator=="); - return this->map_man_ == rhs.map_man_ - && this->index_ == rhs.index_ - && this->next_ == rhs.next_; -} - -template ACE_INLINE bool -ACE_Hash_Multi_Map_Iterator_Base::operator!= (const ACE_Hash_Multi_Map_Iterator_Base &rhs) const -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Iterator_Base::operator!="); - return this->next_ != rhs.next_ - || this->index_ != rhs.index_ - || this->map_man_ != rhs.map_man_; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Const_Iterator_Base::ACE_Hash_Multi_Map_Const_Iterator_Base (const ACE_Hash_Multi_Map_Manager &mm, - int head) - : map_man_ (&mm), - index_ (head != 0 ? -1 : (ssize_t) mm.total_size_), - next_ (0) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator_Base::ACE_Hash_Multi_Map_Const_Iterator_Base"); - - if (mm.table_ != 0) - this->next_ = &mm.table_[head != 0 ? 0 : mm.total_size_ - 1]; -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Const_Iterator_Base::next (ACE_Hash_Multi_Map_Entry *&entry) const -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator_Base::next"); - - if (this->map_man_->table_ != 0 - && this->index_ < (ssize_t) this->map_man_->total_size_ - && this->index_ >= 0 - && this->next_ != &this->map_man_->table_[this->index_]) - { - entry = this->next_; - return 1; - } - else - return 0; -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Const_Iterator_Base::done (void) const -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator_Base::done"); - - return this->map_man_->table_ == 0 - || this->index_ >= (ssize_t) this->map_man_->total_size_ - || this->index_ < 0; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Entry & -ACE_Hash_Multi_Map_Const_Iterator_Base::operator* (void) const -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator_Base::operator*"); - ACE_Hash_Multi_Map_Entry *retv = 0; - - int result = this->next (retv); - - ACE_UNUSED_ARG (result); - ACE_ASSERT (result != 0); - - return *retv; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Entry * -ACE_Hash_Multi_Map_Const_Iterator_Base::operator-> (void) const -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator_Base::operator->"); - ACE_Hash_Multi_Map_Entry *retv = 0; - - int result = this->next (retv); - - ACE_UNUSED_ARG (result); - ACE_ASSERT (result != 0); - - return retv; -} - -// Returns the reference to the Hash_Multi_Map_manager_ex that is being -// iterated over. -template ACE_INLINE -const ACE_Hash_Multi_Map_Manager& -ACE_Hash_Multi_Map_Const_Iterator_Base::map (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator_Base::map"); - return *this->map_man_; -} - -template ACE_INLINE bool -ACE_Hash_Multi_Map_Const_Iterator_Base::operator== (const ACE_Hash_Multi_Map_Const_Iterator_Base &rhs) const -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator_Base::operator=="); - return this->map_man_ == rhs.map_man_ - && this->index_ == rhs.index_ - && this->next_ == rhs.next_; -} - -template ACE_INLINE bool -ACE_Hash_Multi_Map_Const_Iterator_Base::operator!= (const ACE_Hash_Multi_Map_Const_Iterator_Base &rhs) const -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator_Base::operator!="); - return this->next_ != rhs.next_ - || this->index_ != rhs.index_ - || this->map_man_ != rhs.map_man_; -} - -ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Multi_Map_Iterator) - -template ACE_INLINE void -ACE_Hash_Multi_Map_Iterator::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Hash_Multi_Map_Iterator::dump"); - - this->dump_i (); -#endif /* ACE_HAS_DUMP */ -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Iterator::ACE_Hash_Multi_Map_Iterator (ACE_Hash_Multi_Map_Manager &mm, - int tail) - : ACE_Hash_Multi_Map_Iterator_Base (mm, - tail == 0 ? 1 : 0) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Iterator::ACE_Hash_Multi_Map_Iterator"); - if (tail == 0) - this->forward_i (); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Iterator::advance (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Iterator::advance"); - return this->forward_i (); -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Iterator & -ACE_Hash_Multi_Map_Iterator::operator++ (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Iterator::operator++ (void)"); - - this->forward_i (); - return *this; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Iterator -ACE_Hash_Multi_Map_Iterator::operator++ (int) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Iterator::operator++ (int)"); - - ACE_Hash_Multi_Map_Iterator retv (*this); - ++*this; - return retv; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Iterator & -ACE_Hash_Multi_Map_Iterator::operator-- (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Iterator::operator-- (void)"); - - this->reverse_i (); - return *this; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Iterator -ACE_Hash_Multi_Map_Iterator::operator-- (int) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Iterator::operator-- (int)"); - - ACE_Hash_Multi_Map_Iterator retv (*this); - --*this; - return retv; -} - -ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Multi_Map_Const_Iterator) - -template ACE_INLINE void -ACE_Hash_Multi_Map_Const_Iterator::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator::dump"); - - this->dump_i (); -#endif /* ACE_HAS_DUMP */ -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Const_Iterator::ACE_Hash_Multi_Map_Const_Iterator (const ACE_Hash_Multi_Map_Manager &mm, - int tail) - : ACE_Hash_Multi_Map_Const_Iterator_Base (mm, - tail == 0 ? 1 : 0) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator::ACE_Hash_Multi_Map_Const_Iterator"); - if (tail == 0) - this->forward_i (); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Const_Iterator::advance (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator::advance"); - return this->forward_i (); -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Const_Iterator & -ACE_Hash_Multi_Map_Const_Iterator::operator++ (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator::operator++ (void)"); - - this->forward_i (); - return *this; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Const_Iterator -ACE_Hash_Multi_Map_Const_Iterator::operator++ (int) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator::operator++ (int)"); - - ACE_Hash_Multi_Map_Const_Iterator retv (*this); - ++*this; - return retv; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Const_Iterator & -ACE_Hash_Multi_Map_Const_Iterator::operator-- (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator::operator-- (void)"); - - this->reverse_i (); - return *this; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Const_Iterator -ACE_Hash_Multi_Map_Const_Iterator::operator-- (int) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Const_Iterator::operator-- (int)"); - - ACE_Hash_Multi_Map_Const_Iterator retv (*this); - --*this; - return retv; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Bucket_Iterator::ACE_Hash_Multi_Map_Bucket_Iterator (ACE_Hash_Multi_Map_Manager &mm, - const EXT_ID &ext_id, - int tail) - : map_man_ (&mm) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Bucket_Iterator::ACE_Hash_Multi_Map_Bucket_Iterator"); - - this->index_ = this->map_man_->hash (ext_id) % this->map_man_->total_size_; - this->next_ = &this->map_man_->table_[this->index_]; - - if (tail == 0) - this->forward_i (); -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Bucket_Iterator & -ACE_Hash_Multi_Map_Bucket_Iterator::operator++ (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Bucket_Iterator::operator++ (void)"); - - this->forward_i (); - return *this; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Bucket_Iterator -ACE_Hash_Multi_Map_Bucket_Iterator::operator++ (int) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Bucket_Iterator::operator++ (int)"); - - ACE_Hash_Multi_Map_Bucket_Iterator retv (*this); - ++*this; - return retv; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Bucket_Iterator & -ACE_Hash_Multi_Map_Bucket_Iterator::operator-- (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Bucket_Iterator::operator-- (void)"); - - this->reverse_i (); - return *this; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Bucket_Iterator -ACE_Hash_Multi_Map_Bucket_Iterator::operator-- (int) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Bucket_Iterator::operator-- (int)"); - - ACE_Hash_Multi_Map_Bucket_Iterator retv (*this); - --*this; - return retv; -} - -template int -ACE_Hash_Multi_Map_Bucket_Iterator::forward_i (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Bucket_Iterator::forward_i"); - - this->next_ = this->next_->next_; - return this->next_ != &this->map_man_->table_[this->index_]; -} - -template int -ACE_Hash_Multi_Map_Bucket_Iterator::reverse_i (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Bucket_Iterator::reverse_i"); - - this->next_ = this->next_->prev_; - return this->next_ != &this->map_man_->table_[this->index_]; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Entry & -ACE_Hash_Multi_Map_Bucket_Iterator::operator* (void) const -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Bucket_Iterator::operator*"); - - return *this->next_; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Entry * -ACE_Hash_Multi_Map_Bucket_Iterator::operator-> (void) const -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Bucket_Iterator::operator->"); - - return this->next_; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Manager & -ACE_Hash_Multi_Map_Bucket_Iterator::map (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Bucket_Iterator::map"); - return *this->map_man_; -} - -template ACE_INLINE bool -ACE_Hash_Multi_Map_Bucket_Iterator::operator== (const ACE_Hash_Multi_Map_Bucket_Iterator &rhs) const -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Bucket_Iterator::operator=="); - return this->map_man_ == rhs.map_man_ - && this->index_ == rhs.index_ - && this->next_ == rhs.next_; -} - -template ACE_INLINE bool -ACE_Hash_Multi_Map_Bucket_Iterator::operator!= (const ACE_Hash_Multi_Map_Bucket_Iterator &rhs) const -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Bucket_Iterator::operator!="); - return this->next_ != rhs.next_ - || this->index_ != rhs.index_ - || this->map_man_ != rhs.map_man_; -} - -ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Multi_Map_Reverse_Iterator) - -template ACE_INLINE void -ACE_Hash_Multi_Map_Reverse_Iterator::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Hash_Multi_Map_Reverse_Iterator::dump"); - - this->dump_i (); -#endif /* ACE_HAS_DUMP */ -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Reverse_Iterator::ACE_Hash_Multi_Map_Reverse_Iterator (ACE_Hash_Multi_Map_Manager &mm, int head) - : ACE_Hash_Multi_Map_Iterator_Base (mm, head) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Reverse_Iterator::ACE_Hash_Multi_Map_Reverse_Iterator"); - if (head == 0) - this->reverse_i (); -} - -template ACE_INLINE int -ACE_Hash_Multi_Map_Reverse_Iterator::advance (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Reverse_Iterator::advance"); - return this->reverse_i (); -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Reverse_Iterator & -ACE_Hash_Multi_Map_Reverse_Iterator::operator++ (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Reverse_Iterator::operator++ (void)"); - - this->reverse_i (); - return *this; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Reverse_Iterator -ACE_Hash_Multi_Map_Reverse_Iterator::operator++ (int) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Reverse_Iterator::operator++ (int)"); - - ACE_Hash_Multi_Map_Reverse_Iterator retv (*this); - ++*this; - return retv; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Reverse_Iterator & -ACE_Hash_Multi_Map_Reverse_Iterator::operator-- (void) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Reverse_Iterator::operator-- (void)"); - - this->forward_i (); - return *this; -} - -template ACE_INLINE -ACE_Hash_Multi_Map_Reverse_Iterator -ACE_Hash_Multi_Map_Reverse_Iterator::operator-- (int) -{ - ACE_TRACE ("ACE_Hash_Multi_Map_Reverse_Iterator::operator-- (int)"); - - ACE_Hash_Multi_Map_Reverse_Iterator retv (*this); - --*this; - return retv; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Hashable.cpp b/ACE/ace/Hashable.cpp deleted file mode 100644 index cab51f7aa26..00000000000 --- a/ACE/ace/Hashable.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//$Id$ - -#include "ace/Hashable.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Hashable.inl" -#endif /* __ACE_INLINE __ */ - - -ACE_RCSID (ace, - Hashable, - "$Id$") - - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_Hashable::~ACE_Hashable (void) -{ -} - -unsigned long -ACE_Hashable::hash (void) const -{ - // In doing the check below, we take chance of paying a performance - // price when the hash value is zero. But, that will (hopefully) - // happen far less often than a non-zero value, so this caching - // strategy should pay off, esp. if hash computation is expensive - // relative to the simple comparison. - - if (this->hash_value_ == 0) - this->hash_value_ = this->hash_i (); - - return this->hash_value_; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Hashable.h b/ACE/ace/Hashable.h deleted file mode 100644 index d20bb2da1aa..00000000000 --- a/ACE/ace/Hashable.h +++ /dev/null @@ -1,65 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Hashable.h - * - * $Id$ - * - * @author Doug Schmidt - */ -//============================================================================= - -#ifndef ACE_HASHABLE_H -#define ACE_HASHABLE_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Hashable - * - * @brief ACE_Hashable - */ -class ACE_Export ACE_Hashable -{ -public: - - /// Destructor. - virtual ~ACE_Hashable (void); - - /// Computes and returns hash value. This "caches" the hash value to - /// improve performance. - virtual unsigned long hash (void) const; - -protected: - /// Protected constructor. - ACE_Hashable (void); - - /// This is the method that actually performs the non-cached hash - /// computation. - virtual unsigned long hash_i (void) const = 0; - -protected: - - /// Pre-computed hash-value. - mutable unsigned long hash_value_; - -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Hashable.inl" -#endif /* __ACE_INLINE __ */ - -#include /**/ "ace/post.h" - -#endif /*ACE_HASHABLE_H*/ diff --git a/ACE/ace/Hashable.inl b/ACE/ace/Hashable.inl deleted file mode 100644 index 7ec54ea1337..00000000000 --- a/ACE/ace/Hashable.inl +++ /dev/null @@ -1,14 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_Hashable::ACE_Hashable (void) - : hash_value_ (0) -{ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/High_Res_Timer.cpp b/ACE/ace/High_Res_Timer.cpp deleted file mode 100644 index f71b7ebc7d7..00000000000 --- a/ACE/ace/High_Res_Timer.cpp +++ /dev/null @@ -1,537 +0,0 @@ -// $Id$ - -// Be very carefull before changing the calculations inside -// ACE_High_Res_Timer. The precision matters and we are using integer -// calculations not floating point. Also look good at the emulated 64 -// bit int class (inside Basic_Types{h,i,cpp} before changing -// anything. It's operator/ only returns 32 bits not 64 bits, among -// other things. - -#include "ace/High_Res_Timer.h" - -#if !defined (__ACE_INLINE__) -#include "ace/High_Res_Timer.inl" -#endif /* __ACE_INLINE__ */ - -#include "ace/Stats.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_sys_time.h" -#include "ace/OS_NS_time.h" -#include "ace/OS_NS_unistd.h" -#include "ace/OS_NS_stdlib.h" -#include "ace/Truncate.h" - -ACE_RCSID(ace, High_Res_Timer, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_High_Res_Timer) - -ACE_END_VERSIONED_NAMESPACE_DECL - -// For Intel platforms, a scale factor is required for -// ACE_OS::gethrtime. We'll still set this to one to prevent division -// by zero errors. -#if (defined (ACE_WIN32) || defined (ACE_HAS_POWERPC_TIMER) || \ - defined (ACE_HAS_PENTIUM) || defined (ACE_HAS_ALPHA_TIMER)) && \ - !defined (ACE_HAS_HI_RES_TIMER) - -# include "ace/Guard_T.h" -# include "ace/Recursive_Thread_Mutex.h" -# include "ace/Object_Manager.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - - // Initialize the global_scale_factor_ to 1. The first - // ACE_High_Res_Timer instance construction will override this - // value. - /* static */ - ACE_UINT32 ACE_High_Res_Timer::global_scale_factor_ = 1u; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#else /* ! (ACE_WIN32 || ACE_HAS_POWERPC_TIMER || \ - ACE_HAS_PENTIUM || ACE_HAS_ALPHA_TIMER) || - ACE_HAS_HI_RES_TIMER */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - - // A scale_factor of 1000 converts nanosecond ticks to microseconds. - // That is, on these platforms, 1 tick == 1 nanosecond. - /* static */ - ACE_UINT32 ACE_High_Res_Timer::global_scale_factor_ = 1000u; - -ACE_END_VERSIONED_NAMESPACE_DECL -#endif /* ! (ACE_WIN32 || ACE_HAS_POWERPC_TIMER || \ - ACE_HAS_PENTIUM || ACE_HAS_ALPHA_TIMER) || - ACE_HAS_HI_RES_TIMER */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// This is used to tell if the global_scale_factor_ has been -// set, and if high resolution timers are supported. -/* static */ -int ACE_High_Res_Timer::global_scale_factor_status_ = 0; - - -#if defined (linux) -// Determine the apparent CPU clock speed from /proc/cpuinfo -ACE_UINT32 -ACE_High_Res_Timer::get_cpuinfo (void) -{ - ACE_UINT32 scale_factor = 1u; - - // Get the BogoMIPS from /proc/cpuinfo. It works fine on Alpha and - // Pentium Pro. For other CPUs, it will be necessary to interpret - // the BogoMips, as described in the BogoMips mini-HOWTO. Note that - // this code assumes an order to the /proc/cpuinfo contents. The - // BogoMips rating had better come after CPU type and model info. -#if !defined (__alpha__) - int supported = 0; -#endif /* __alpha__ */ - - FILE *cpuinfo = ACE_OS::fopen (ACE_TEXT ("/proc/cpuinfo"), - ACE_TEXT ("r")); - - if (cpuinfo != 0) - { - char buf[128]; - - // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nReading /proc/cpuinfo..."))); - - while (ACE_OS::fgets (buf, sizeof buf, cpuinfo)) - { -#if defined (__alpha__) - ACE_UINT32 whole; - ACE_UINT32 fractional; - if (::sscanf (buf, - "BogoMIPS : %d.%d\n", - &whole, - &fractional) == 2 - || ::sscanf (buf, - "bogomips : %d.%d\n", - &whole, - &fractional) == 2) - { - scale_factor = whole; - break; - } -#else - double mhertz = 1; - double bmips = 1; - char arg[128]; - - // CPU type? - if (::sscanf (buf, "cpu : %s\n", arg) == 1) - { - // If this is an Alpha chip, then the BogoMips rating is - // usable... - if (ACE_OS::strncmp (arg, - "Alpha", - 5) == 0) - { - supported = 1; - // ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" recognized Alpha chip..."))); - } - } - // Pentium CPU model? - else if (supported == 0 - && ::sscanf (buf, "model name : Pentium %s\n", arg) == 1) - { - // But if we don't have the right kind of Intel chip, - // just quit. - if (ACE_OS::strcmp (arg, "II") == 0 - || ACE_OS::strcmp (arg, "III") == 0 - || ACE_OS::strcmp (arg, "IV") == 0 - || ACE_OS::strcmp (arg, "Pro") == 0) - { - supported = 1; - // ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" recognized Pentium Pro/II chip..."))); - } - } - else if (::sscanf (buf, "cpu MHz : %lf\n", &mhertz) == 1) - { - // If the line "cpu MHz : xxx" is present, then it's a - // reliable measure of the CPU speed - according to the - // kernel-source. - scale_factor = (ACE_UINT32) (mhertz + 0.5); - break; - } - else if (::sscanf (buf, "bogomips : %lf\n", &bmips) == 1 - || ::sscanf (buf, "BogoMIPS : %lf\n", &bmips) == 1) - { - if (supported) - { - scale_factor = (ACE_UINT32) (bmips + 0.5); - // ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" setting the clock scale factor to %u"), scale_factor)); - } -#if 0 - else - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("\nThe BogoMIPS metric is not supported on this platform" - "\n\tReport the results of the clock calibration and" - "\n\tthe contents of /proc/cpuinfo to the ace-users mailing list"))); - } -#endif /* 0 */ - break; - } -#endif /* __alpha__ */ - } - - // ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" (done)\n"))); - - ACE_OS::fclose (cpuinfo); - } - - return scale_factor; -} -#endif /* linux */ - -ACE_UINT32 -ACE_High_Res_Timer::global_scale_factor (void) -{ -#if (defined (ACE_WIN32) || defined (ACE_HAS_POWERPC_TIMER) || \ - defined (ACE_HAS_PENTIUM) || defined (ACE_HAS_ALPHA_TIMER)) && \ - !defined (ACE_HAS_HI_RES_TIMER) && \ - ((defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) || \ - defined (ghs) || defined (__GNUG__) || \ - defined (__INTEL_COMPILER)) - // Check if the global scale factor needs to be set, and do if so. - if (ACE_High_Res_Timer::global_scale_factor_status_ == 0) - { - // Grab ACE's static object lock. This doesn't have anything to - // do with static objects; it's just a convenient lock to use. - ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, - *ACE_Static_Object_Lock::instance (), 0)); - - // Double check - if (ACE_High_Res_Timer::global_scale_factor_status_ == 0) - { -# if defined (ACE_WIN32) - LARGE_INTEGER freq; - if (::QueryPerformanceFrequency (&freq)) - { - // We have a high-res timer -# if defined (ACE_LACKS_LONGLONG_T) - ACE_UINT64 uint64_freq(freq.u.LowPart, (ACE_UINT32) freq.u.HighPart); - ACE_High_Res_Timer::global_scale_factor - (uint64_freq / (ACE_UINT32) ACE_ONE_SECOND_IN_USECS); -# else - ACE_High_Res_Timer::global_scale_factor - (static_cast (freq.QuadPart / ACE_HR_SCALE_CONVERSION)); -# endif // (ACE_LACKS_LONGLONG_T) - - ACE_High_Res_Timer::global_scale_factor_status_ = 1; - } - else - // High-Res timers not supported - ACE_High_Res_Timer::global_scale_factor_status_ = -1; - - return ACE_High_Res_Timer::global_scale_factor_; - -# elif defined (linux) - ACE_High_Res_Timer::global_scale_factor (ACE_High_Res_Timer::get_cpuinfo ()); -# endif /* ! ACE_WIN32 && ! (linux && __alpha__) */ - -# if !defined (ACE_WIN32) - if (ACE_High_Res_Timer::global_scale_factor_ == 1u) - // Failed to retrieve CPU speed from system, so calculate it. - ACE_High_Res_Timer::calibrate (); -# endif // (ACE_WIN32) - } - } - - ACE_High_Res_Timer::global_scale_factor_status_ = 1; -#endif /* (ACE_WIN32 || ACE_HAS_POWERPC_TIMER || \ - ACE_HAS_PENTIUM || ACE_HAS_ALPHA_TIMER) && \ - ! ACE_HAS_HI_RES_TIMER && - ((WIN32 && ! WINCE) || ghs || __GNUG__) */ - - return ACE_High_Res_Timer::global_scale_factor_; -} - -ACE_High_Res_Timer::ACE_High_Res_Timer (void) -{ - ACE_TRACE ("ACE_High_Res_Timer::ACE_High_Res_Timer"); - - this->reset (); - - // Make sure that the global scale factor is set. - (void) global_scale_factor (); -} - -ACE_UINT32 -ACE_High_Res_Timer::calibrate (const ACE_UINT32 usec, - const u_int iterations) -{ - const ACE_Time_Value sleep_time (0, usec); - ACE_Stats delta_hrtime; - // In units of 100 usec, to avoid overflow. - ACE_Stats actual_sleeps; - - for (u_int i = 0; - i < iterations; - ++i) - { - const ACE_Time_Value actual_start = - ACE_OS::gettimeofday (); - const ACE_hrtime_t start = - ACE_OS::gethrtime (); - ACE_OS::sleep (sleep_time); - const ACE_hrtime_t stop = - ACE_OS::gethrtime (); - const ACE_Time_Value actual_delta = - ACE_OS::gettimeofday () - actual_start; - - // Store the sample. - delta_hrtime.sample (ACE_Utils::truncate_cast (stop - start)); - actual_sleeps.sample (actual_delta.msec () * 100u); - } - - // Calculate the mean value of the samples, with no fractional - // precision. Use it for the global scale factor. - ACE_Stats_Value ticks (0); - delta_hrtime.mean (ticks); - - ACE_Stats_Value actual_sleep (0); - actual_sleeps.mean (actual_sleep); - - // The addition of 5 below rounds instead of truncates. - const ACE_UINT32 scale_factor = - (ticks.whole () / actual_sleep.whole () + 5) / - 10u /* usec/100 usec */; - ACE_High_Res_Timer::global_scale_factor (scale_factor); - - return scale_factor; -} - -void -ACE_High_Res_Timer::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_High_Res_Timer::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nglobal_scale_factor_: %u\n"), - global_scale_factor ())); -#if defined (ACE_LACKS_LONGLONG_T) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT (":\nstart_.hi (): %8x; start_.lo (): %8x;\n") - ACE_TEXT ("end_.hi (): %8x; end_.lo (): %8x;\n") - ACE_TEXT ("total_.hi (): %8x; total_.lo (): %8x;\n") - ACE_TEXT ("start_incr_.hi () %8x; start_incr_.lo (): %8x;\n"), - start_.hi (), start_.lo (), - end_.hi (), end_.lo (), - total_.hi (), total_.lo (), - start_incr_.hi (), start_incr_.lo ())); -#else /* ! ACE_LACKS_LONGLONG_T */ - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT (":\nstart_.hi (): %8x; start_.lo (): %8x;\n") - ACE_TEXT ("end_.hi (): %8x; end_.lo (): %8x;\n") - ACE_TEXT ("total_.hi (): %8x; total_.lo (): %8x;\n") - ACE_TEXT ("start_incr_.hi () %8x; start_incr_.lo (): %8x;\n"), - static_cast (start_ >> 32), - static_cast (start_ & 0xfffffffful), - static_cast (end_ >> 32), - static_cast (end_ & 0xfffffffful), - static_cast (total_ >> 32), - static_cast (total_ & 0xfffffffful), - static_cast (start_incr_ >> 32), - static_cast (start_incr_ & 0xfffffffful))); -#endif /* ! ACE_LACKS_LONGLONG_T */ - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -void -ACE_High_Res_Timer::reset (void) -{ - ACE_TRACE ("ACE_High_Res_Timer::reset"); - - this->start_ = 0; - this->end_ = 0; - this->total_ = 0; - this->start_incr_ = 0; -} - -void -ACE_High_Res_Timer::elapsed_time (ACE_Time_Value &tv) const -{ - hrtime_to_tv (tv, - ACE_High_Res_Timer::elapsed_hrtime (this->end_, this->start_)); -} - -#if defined (ACE_HAS_POSIX_TIME) -// Note... Win32 does not have ACE_HAS_POSIX_TIME, so the scale factor -// does not need to take into account the different units on Win32. - -void -ACE_High_Res_Timer::elapsed_time (struct timespec &elapsed_time) const -{ - // This implementation should be cleaned up. - - // Just grab the nanoseconds. That is, leave off all values above - // microsecond. This equation is right! Don't mess with me! (It - // first strips off everything but the portion less than 1 usec. - // Then it converts that to nanoseconds by dividing by the scale - // factor to convert to usec, and multiplying by 1000.) The cast - // avoids a MSVC 4.1 compiler warning about narrowing. - ACE_hrtime_t elapsed = - ACE_High_Res_Timer::elapsed_hrtime (this->end_, this->start_); - u_long nseconds = static_cast (elapsed % - global_scale_factor () * 1000u / - global_scale_factor ()); - - // Get just the microseconds (dropping any left over nanoseconds). - ACE_UINT32 useconds = (ACE_UINT32) (elapsed / global_scale_factor ()); - - elapsed_time.tv_sec = (time_t) (useconds / ACE_ONE_SECOND_IN_USECS); - // Transforms one second in microseconds into nanoseconds. - elapsed_time.tv_nsec = (time_t) ((useconds % ACE_ONE_SECOND_IN_USECS) * 1000u + nseconds); -} -#endif /* ACE_HAS_POSIX_TIME */ - -void -ACE_High_Res_Timer::elapsed_time_incr (ACE_Time_Value &tv) const -{ - hrtime_to_tv (tv, total_); -} - -void -ACE_High_Res_Timer::elapsed_time (ACE_hrtime_t &nanoseconds) const -{ - // Please do _not_ rearrange this equation. It is carefully - // designed and tested to avoid overflow on machines that don't have - // native 64-bit ints. In particular, division can be a problem. - // For more background on this, please see bugzilla #1024. - nanoseconds = ACE_High_Res_Timer::elapsed_hrtime (this->end_, this->start_) - * (1024000u / ACE_High_Res_Timer::global_scale_factor ()); - // Caution - Borland has a problem with >>=, so resist the temptation. - nanoseconds = nanoseconds >> 10; - // Right shift is implemented for non native 64-bit ints - // operator/ only for a 32 bit result ! -} - -void -ACE_High_Res_Timer::elapsed_time_incr (ACE_hrtime_t &nanoseconds) const -{ - // Same as above. - nanoseconds = this->total_ - * (1024000u / ACE_High_Res_Timer::global_scale_factor ()); - // Caution - Borland has a problem with >>=, so resist the temptation. - nanoseconds = nanoseconds >> 10; -} - -#if !defined (ACE_HAS_WINCE) -void -ACE_High_Res_Timer::print_ave (const ACE_TCHAR *str, - const int count, - ACE_HANDLE handle) const -{ - ACE_TRACE ("ACE_High_Res_Timer::print_ave"); - - // Get the total number of nanoseconds elapsed. - ACE_hrtime_t total_nanoseconds; - this->elapsed_time (total_nanoseconds); - - // Separate to seconds and nanoseconds. - u_long total_secs = - static_cast (total_nanoseconds / (ACE_UINT32) ACE_ONE_SECOND_IN_NSECS); - ACE_UINT32 extra_nsecs = - static_cast (total_nanoseconds % (ACE_UINT32) ACE_ONE_SECOND_IN_NSECS); - - ACE_TCHAR buf[100]; - if (count > 1) - { - ACE_hrtime_t avg_nsecs = total_nanoseconds / (ACE_UINT32) count; - ACE_OS::sprintf (buf, - ACE_TEXT (" count = %d, total (secs %lu, usecs %u), avg usecs = %lu\n"), - count, - total_secs, - (extra_nsecs + 500u) / 1000u, - (u_long) ((avg_nsecs + 500u) / 1000u)); - } - else - ACE_OS::sprintf (buf, - ACE_TEXT (" total %3lu.%06lu secs\n"), - total_secs, - (extra_nsecs + 500lu) / 1000lu); - - ACE_OS::write (handle, - str, - ACE_OS::strlen (str)); - ACE_OS::write (handle, - buf, - ACE_OS::strlen (buf)); -} - -void -ACE_High_Res_Timer::print_total (const ACE_TCHAR *str, - const int count, - ACE_HANDLE handle) const -{ - ACE_TRACE ("ACE_High_Res_Timer::print_total"); - - // Get the total number of nanoseconds elapsed. - ACE_hrtime_t total_nanoseconds; - this->elapsed_time (total_nanoseconds); - - // Separate to seconds and nanoseconds. - u_long total_secs = - (u_long) (total_nanoseconds / (ACE_UINT32) ACE_ONE_SECOND_IN_NSECS); - ACE_UINT32 extra_nsecs = - (ACE_UINT32) (total_nanoseconds % (ACE_UINT32) ACE_ONE_SECOND_IN_NSECS); - - ACE_TCHAR buf[100]; - if (count > 1) - { - ACE_hrtime_t avg_nsecs = this->total_ / (ACE_UINT32) count; - - ACE_OS::sprintf (buf, - ACE_TEXT (" count = %d, total (secs %lu, usecs %u), avg usecs = %lu\n"), - count, - total_secs, - (extra_nsecs + 500u) / 1000u, - (u_long) ((avg_nsecs + 500u) / 1000u)); - } - else - ACE_OS::sprintf (buf, - ACE_TEXT (" total %3lu.%06u secs\n"), - total_secs, - (extra_nsecs + 500u) / 1000u); - - ACE_OS::write (handle, - str, - ACE_OS::strlen (str)); - ACE_OS::write (handle, - buf, - ACE_OS::strlen (buf)); -} -#endif /* !ACE_HAS_WINCE */ - -int -ACE_High_Res_Timer::get_env_global_scale_factor (const ACE_TCHAR *env) -{ -#if !defined (ACE_HAS_WINCE) - if (env != 0) - { - const char *env_value = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (env)); - if (env_value != 0) - { - int const value = ACE_OS::atoi (env_value); - if (value > 0) - { - ACE_High_Res_Timer::global_scale_factor (value); - return 0; - } - } - } -#else - ACE_UNUSED_ARG (env); -#endif /* !ACE_HAS_WINCE */ - return -1; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/High_Res_Timer.h b/ACE/ace/High_Res_Timer.h deleted file mode 100644 index 249d38078b9..00000000000 --- a/ACE/ace/High_Res_Timer.h +++ /dev/null @@ -1,315 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file High_Res_Timer.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//========================================================================== - -#ifndef ACE_HIGH_RES_TIMER_H -#define ACE_HIGH_RES_TIMER_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Basic_Types.h" -#include "ace/OS_NS_time.h" -#include "ace/Time_Value.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_High_Res_Timer - * - * @brief A high resolution timer class wrapper that encapsulates - * OS-specific high-resolution timers, such as those found on - * Solaris, AIX, Win32/Pentium, and VxWorks. - * - * Most of the member functions don't return values. The only - * reason that one would fail is if high-resolution time isn't - * supported on the platform. To avoid impacting performance - * and complicating the interface, in that case, - * is used instead. - * The global scale factor is required for platforms that have - * high-resolution timers that return units other than - * microseconds, such as clock ticks. It is represented as a - * static u_long, can only be accessed through static methods, - * and is used by all instances of High Res Timer. The member - * functions that return or print times use the global scale - * factor. They divide the "time" that they get from - * by global_scale_factor_ to obtain the - * time in microseconds. Its units are therefore 1/microsecond. - * On Windows the global_scale_factor_ units are 1/millisecond. - * There's a macro which gives the - * units/second. Because it's possible that the units/second - * changes in the future, it's recommended to use it instead - * of a "hard coded" solution. - * Dependend on the platform and used class members, there's a - * maximum elapsed period before overflow (which is not checked). - * Look at the documentation with some members functions. - * On some (most?) implementations it's not recommended to measure - * "long" timeperiods, because the error's can accumulate fast. - * This is probably not a problem profiling code, but could be - * on if the high resolution timer class is used to initiate - * actions after a "long" timeout. - * On Solaris, a scale factor of 1000 should be used because its - * high-resolution timer returns nanoseconds. However, on Intel - * platforms, we use RDTSC which returns the number of clock - * ticks since system boot. For a 200MHz cpu, each clock tick - * is 1/200 of a microsecond; the global_scale_factor_ should - * therefore be 200 or 200000 if it's in unit/millisecond. - * On Windows ::QueryPerformanceCounter() is used, which can be a - * different implementation depending on the used windows HAL - * (Hardware Abstraction Layer). On some it uses the PC "timer chip" - * while it uses RDTSC on others. - * @note The elapsed time calculations in the print methods use - * ACE_hrtime_t values. Those methods do _not_ check for overflow! - * @note Gabe raises this issue regarding - * : on multi-processors, the processor that - * you query for your value might not be the one - * you queried for . Its not clear how much - * divergence there would be, if any. - * This issue is not mentioned in the Solaris 2.5.1 gethrtime - * man page. - * A RDTSC NOTE: RDTSC is the Intel Pentium read-time stamp counter - * and is actualy a 64 bit clock cycle counter, which is increased - * with every cycle. It has a low overhead and can be read within - * 16 (pentium) or 32 (pentium II,III,...) cycles, but it doesn't - * serialize the processor, which could give wrong timings when - * profiling very short code fragments. - * Problematic is that some power sensitive devices - * (laptops for example, but probably also embedded devices), - * do change the cycle rate while running. - * Some pentiums can run on (at least) two clock frequency's. - * Another problem arises with multiprocessor computers, there - * are reports that the different RDTSC's are not always kept - * in sync. - * A windows "timer chip" NOTE: (8254-compatible real-time clock) - * When ::QueryPerformanceCounter() uses the 8254 it has a - * frequency off about 1.193 Mhz (or sometimes 3.579 Mhz?) and - * reading it requires some time (several thousand cycles). - */ -class ACE_Export ACE_High_Res_Timer -{ -public: - // = Initialization method. - - /** - * global_scale_factor_ is set to @a gsf. All High_Res_Timers use - * global_scale_factor_. This allows applications to set the scale - * factor just once for all High_Res_Timers. Check - * High_Res_Timer.cpp for the default global_scale_factors for - * several platforms. For many platforms (e.g., Solaris), the - * global_scale_factor_ is set to 1000 so that need - * not be set. Careful, a of 0 will cause division - * by zero exceptions. - * Depending on the platform its units are 1/microsecond or - * 1/millisecond. Use inside calculations - * instead a hardcoded value. - */ - static void global_scale_factor (ACE_UINT32 gsf); - - /// Returns the global_scale_factor. - static ACE_UINT32 global_scale_factor (void); - -#ifndef ACE_HR_SCALE_CONVERSION -# define ACE_HR_SCALE_CONVERSION (ACE_ONE_SECOND_IN_USECS) -#endif /* ACE_HR_SCALE_CONVERSION */ - - /** - * Sets the global_scale_factor to the value in the - * environment variable. Returns 0 on success, -1 on failure. - * @note If @a env points to string "0" (value zero), this call will fail. - * This is basically a no-op on CE because there is no concept of - * environment variable on CE. - */ - static int get_env_global_scale_factor (const ACE_TCHAR *env - = ACE_TEXT ("ACE_SCALE_FACTOR")); - - /** - * Set (and return, for info) the global scale factor by sleeping - * for @a usec and counting the number of intervening clock cycles. - * Average over @a iterations of @a usec each. On some platforms, - * such as Pentiums, this is called automatically during the first - * ACE_High_Res_Timer construction with the default parameter - * values. An application can override that by calling calibrate - * with any desired parameter values _prior_ to constructing the - * first ACE_High_Res_Timer instance. - * Beware for platforms that can change the cycle rate on the fly. - */ - static ACE_UINT32 calibrate (const ACE_UINT32 usec = 500000, - const u_int iterations = 10); - - /// Initialize the timer. - ACE_High_Res_Timer (void); - - /// Destructor. - ~ACE_High_Res_Timer (void); - - /// Reinitialize the timer. - void reset (void); - - /// Start timing. - void start (const ACE_OS::ACE_HRTimer_Op = ACE_OS::ACE_HRTIMER_GETTIME); - - /// Stop timing. - void stop (const ACE_OS::ACE_HRTimer_Op = ACE_OS::ACE_HRTIMER_GETTIME); - - /// Set @a tv to the number of microseconds elapsed. - /** - * Could overflow within hours on windows with emulated 64 bit int's - * and a fast counter. VC++ and Borland normaly use __int64 and - * so normaly don't have this problem. - */ - void elapsed_time (ACE_Time_Value &tv) const; - - /// Set @a nanoseconds to the number of nanoseconds elapsed. - /** - * Will overflow when measuring more than 194 day's. - */ - void elapsed_time (ACE_hrtime_t &nanoseconds) const; - -#if defined (ACE_HAS_POSIX_TIME) - /// Returns the elapsed (stop - start) time in a struct timespec - /// (sec, nsec). - void elapsed_time (struct timespec &) const; -#endif /* ACE_HAS_POSIX_TIME */ - - /// Sets @a usecs to the elapsed (stop - start) time in microseconds. - /** - * Will overflow on windows when measuring more than appox. 2^^54 ticks. - * Is still more than 48 days with a 4 Ghz counter. - */ - void elapsed_microseconds (ACE_hrtime_t &usecs) const; - - /// Start incremental timing. - void start_incr (const ACE_OS::ACE_HRTimer_Op = ACE_OS::ACE_HRTIMER_GETTIME); - - /// Stop incremental timing. - void stop_incr (const ACE_OS::ACE_HRTimer_Op = ACE_OS::ACE_HRTIMER_GETTIME); - - /// Set @a tv to the number of microseconds elapsed between all calls - /// to start_incr and stop_incr. - void elapsed_time_incr (ACE_Time_Value &tv) const; - - /// Set to the number of nanoseconds elapsed between all calls - /// to start_incr and stop_incr. - void elapsed_time_incr (ACE_hrtime_t &nanoseconds) const; - -#if !defined (ACE_HAS_WINCE) - // @@ WINCE These two functions are currently not supported on Windows CE. - // However, we should probably use the handle and ACE_Log_Msg to - // print out the result. - /// Print total time. - /// @note only use if incremental timings had been used! - void print_total (const ACE_TCHAR *message, - const int iterations = 1, - ACE_HANDLE handle = ACE_STDOUT) const; - - /// Print average time. - void print_ave (const ACE_TCHAR *message, - const int iterations = 1, - ACE_HANDLE handle = ACE_STDOUT) const; -#endif /* !ACE_HAS_WINCE */ - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - - /** - * Get the current "time" as the high resolution counter at this time. - * This is intended to be useful for supplying to a ACE_Timer_Queue - * as the gettimeofday function, thereby basing the timer calculations - * on the high res timer rather than wall clock time. - */ - static ACE_Time_Value gettimeofday_hr (void); - - /** - * @deprecated THIS FUNCTION IS DEPRECATED. PLEASE USE - * INSTEAD! Calls - * passing . This function can be used to parameterize - * objects such as . If - * is not set, and we're on a platform that - * requires (e.g., Win32), - * ACE_OS::gettimeofday will be used instead of . - * This allows applications on Intel to use even - * when is not set. However, setting the - * appropriately will result in the finest - * resolution possible. - */ - static ACE_Time_Value gettimeofday (const ACE_OS::ACE_HRTimer_Op = - ACE_OS::ACE_HRTIMER_GETTIME); - - /// Converts an to @a tv using global_scale_factor_. - static void hrtime_to_tv (ACE_Time_Value &tv, - const ACE_hrtime_t hrt); - -#if defined (linux) - /** - * This is used to find out the Mhz of the machine for the scale - * factor. If there are any problems getting it, we just return 1 - * (the default). - */ - static ACE_UINT32 get_cpuinfo (void); -#endif /* defined (linux) */ - -private: - /** - * For internal use: gets the high-resolution time using - * . Except on platforms that require that the - * be set, such as ACE_WIN32, uses the - * low-resolution clock if the has not been - * set. - */ - static ACE_hrtime_t gettime (const ACE_OS::ACE_HRTimer_Op = - ACE_OS::ACE_HRTIMER_GETTIME); - - /// Calculate the difference between two ACE_hrtime_t values. It is assumed - /// that the end time is later than start time, so if end is a smaller - /// value, the time counter has wrapped around. - static ACE_hrtime_t elapsed_hrtime (const ACE_hrtime_t end, - const ACE_hrtime_t start); - - /// Starting time. - ACE_hrtime_t start_; - - /// Ending time. - ACE_hrtime_t end_; - - /// Total elapsed time. - ACE_hrtime_t total_; - - /// Start time of incremental timing. - ACE_hrtime_t start_incr_; - - /// Converts ticks to microseconds. That is, ticks / - /// global_scale_factor_ == microseconds. - static ACE_UINT32 global_scale_factor_; - - /** - * Indicates the status of the global scale factor, - * 0 = hasn't been set - * 1 = been set - * -1 = HR timer not supported - */ - static int global_scale_factor_status_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/High_Res_Timer.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_HIGH_RES_TIMER_H */ diff --git a/ACE/ace/High_Res_Timer.inl b/ACE/ace/High_Res_Timer.inl deleted file mode 100644 index 2d089d1520c..00000000000 --- a/ACE/ace/High_Res_Timer.inl +++ /dev/null @@ -1,154 +0,0 @@ -// -*- C++ -*- */ -// -// $Id$ - -#include "ace/Global_Macros.h" - -#if defined (ACE_WIN32) -# include "ace/OS_NS_sys_time.h" -#endif /* ACE_WIN32 */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Be very careful before changing the calculations inside -// ACE_High_Res_Timer. The precision matters and we are using integer -// calculations not floating point. Also look closely at the emulated 64 -// bit int class (inside Basic_Types{h,i,cpp} before changing -// anything. It's operator/ only returns 32 bits not 64 bits, among -// other things. - -ACE_INLINE void -ACE_High_Res_Timer::hrtime_to_tv (ACE_Time_Value &tv, - const ACE_hrtime_t hrt) -{ - // The following are based on the units of global_scale_factor_ - // being 1/microsecond. Therefore, dividing by it converts - // clock ticks to microseconds. - tv.sec ((long) (hrt / (ACE_UINT32) ACE_HR_SCALE_CONVERSION / - global_scale_factor ())); - - // Calculate usec in a manner that's compatible with ACE_U_LongLong. - // hrt = (tv.sec * ACE_ONE_SECOND_IN_USECS + tv.usec) * global_scale_factor_ - // tv.usec = hrt / global_scale_factor_ - tv.sec * ACE_ONE_SECOND_IN_USECS - // That first term will be lossy, so factor out global_scale_factor_: - // tv.usec = (hrt - tv.sec * ACE_ONE_SECOND_IN_USECS * global_scale_factor_)/ - // global_scale_factor - ACE_hrtime_t tmp = tv.sec (); - tmp *= ((ACE_UINT32) ACE_HR_SCALE_CONVERSION * global_scale_factor ()); - tv.usec ((long) ((hrt - tmp) / global_scale_factor ())); -} - - -ACE_INLINE ACE_Time_Value -ACE_High_Res_Timer::gettimeofday (const ACE_OS::ACE_HRTimer_Op op) -{ -#if defined (ACE_WIN32) - // Get the global scale factor if there isn't one yet. - if (ACE_High_Res_Timer::global_scale_factor_status_ == 0) - ACE_High_Res_Timer::global_scale_factor (); - - // If there isn't a high-res timer, use gettimeofday (); - if (ACE_High_Res_Timer::global_scale_factor_status_ == -1) - return ACE_OS::gettimeofday (); -#endif /* ACE_WIN32 */ - - ACE_Time_Value tv; - ACE_High_Res_Timer::hrtime_to_tv (tv, - ACE_OS::gethrtime (op)); - return tv; -} - - -// Get the current high res timer as the time of day. This is intended -// to be used for a gettimeofday replacement in ACE_Timer_Queue and -// derived classes so the timers will bebased on high res timers rather -// than wall clock time. It uses the ACE_High_Res_Timer::gettimeofday -// function, which is deprecated. If it gets removed, please move the -// code down here, intact. -ACE_INLINE ACE_Time_Value -ACE_High_Res_Timer::gettimeofday_hr (void) -{ - return ACE_High_Res_Timer::gettimeofday (); -} - - -ACE_INLINE ACE_hrtime_t -ACE_High_Res_Timer::gettime (const ACE_OS::ACE_HRTimer_Op op) -{ -#if defined (ACE_WIN32) - // Get the global scale factor if there isn't one yet. - if (ACE_High_Res_Timer::global_scale_factor_status_ == 0) - ACE_High_Res_Timer::global_scale_factor (); - - // If there isn't a high-res timer, use gettimeofday (); - if (ACE_High_Res_Timer::global_scale_factor_status_ == -1) - { - ACE_Time_Value tv = ACE_OS::gettimeofday (); - // Return the time in microseconds because the global_scale_factor_ - // is 1. - return tv.sec () * ACE_ONE_SECOND_IN_USECS + tv.usec (); - } -#endif /* ACE_WIN32 */ - - return ACE_OS::gethrtime (op); -} - -ACE_INLINE ACE_hrtime_t -ACE_High_Res_Timer::elapsed_hrtime (const ACE_hrtime_t end, - const ACE_hrtime_t start) -{ - if (end > start) - return end - start; - return (~start + 1 + end); // Wrapped-around counter diff -} - -ACE_INLINE -ACE_High_Res_Timer::~ACE_High_Res_Timer (void) -{ -} - -ACE_INLINE void -ACE_High_Res_Timer::start (const ACE_OS::ACE_HRTimer_Op op) -{ - ACE_TRACE ("ACE_High_Res_Timer::start"); - this->start_ = ACE_High_Res_Timer::gettime (op); -} - -ACE_INLINE void -ACE_High_Res_Timer::stop (const ACE_OS::ACE_HRTimer_Op op) -{ - ACE_TRACE ("ACE_High_Res_Timer::stop"); - this->end_ = ACE_High_Res_Timer::gettime (op); -} - -ACE_INLINE void -ACE_High_Res_Timer::start_incr (const ACE_OS::ACE_HRTimer_Op op) -{ - ACE_TRACE ("ACE_High_Res_Timer::start_incr"); - this->start_incr_ = ACE_High_Res_Timer::gettime (op); -} - -ACE_INLINE void -ACE_High_Res_Timer::stop_incr (const ACE_OS::ACE_HRTimer_Op op) -{ - ACE_TRACE ("ACE_High_Res_Timer::stop_incr"); - this->total_ += - ACE_High_Res_Timer::elapsed_hrtime (ACE_High_Res_Timer::gettime (op), - this->start_incr_); -} - -ACE_INLINE void -ACE_High_Res_Timer::elapsed_microseconds (ACE_hrtime_t &usecs) const -{ - ACE_hrtime_t elapsed = ACE_High_Res_Timer::elapsed_hrtime (this->end_, - this->start_); - usecs = (ACE_hrtime_t) (elapsed / global_scale_factor ()); -} - -ACE_INLINE void -ACE_High_Res_Timer::global_scale_factor (ACE_UINT32 gsf) -{ - global_scale_factor_ = gsf; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/ICMP_Socket.cpp b/ACE/ace/ICMP_Socket.cpp deleted file mode 100644 index d3d07c80f36..00000000000 --- a/ACE/ace/ICMP_Socket.cpp +++ /dev/null @@ -1,186 +0,0 @@ -// $Id$ - -#include "ace/ICMP_Socket.h" - -#if defined (ACE_HAS_ICMP_SUPPORT) && (ACE_HAS_ICMP_SUPPORT == 1) - -#include "ace/ACE.h" -#include "ace/Log_Msg.h" -#include "ace/OS_NS_netdb.h" -#include "ace/OS_NS_sys_socket.h" - - -ACE_RCSID (ace, - ICMP_Socket, - "$Id$") - - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE (ACE_ICMP_Socket) - - -void -ACE_ICMP_Socket::dump (void) const -{ - ACE_TRACE ("ACE_ICMP_Socket::dump"); -} - -ACE_ICMP_Socket::ACE_ICMP_Socket (void) -{ - ACE_TRACE ("ACE_ICMP_Socket::ACE_ICMP_Socket"); -} - -ssize_t -ACE_ICMP_Socket::send (void const * buf, - size_t n, - ACE_Addr const & addr, - int flags) const -{ - ACE_TRACE ("ACE_ICMP_Socket::send"); - - return ACE_OS::sendto (this->get_handle (), - (char const *) buf, - n, - flags, - (sockaddr const *) addr.get_addr (), - addr.get_size ()); -} - -ssize_t -ACE_ICMP_Socket::recv (void * buf, - size_t n, - ACE_Addr & addr, - int flags) const -{ - ACE_TRACE ("ACE_ICMP_Socket::recv"); - - int addr_len = addr.get_size (); - ssize_t status = ACE_OS::recvfrom (this->get_handle (), - (char *) buf, - n, - flags, - (sockaddr *) addr.get_addr (), - (int*) &addr_len); - addr.set_size (addr_len); - - return status; -} - -ssize_t -ACE_ICMP_Socket::recv (void * buf, - size_t n, - int flags, - ACE_Time_Value const * timeout) const -{ - ACE_TRACE ("ACE_ICMP_Socket::recv"); - - return ACE::recv (this->get_handle (), - buf, - n, - flags, - timeout); -} - -int -ACE_ICMP_Socket::open (ACE_Addr const & local, - int protocol, - int reuse_addr) -{ - ACE_TRACE ("ACE_ICMP_Socket::open"); - - // Check if icmp protocol is supported on this host - int proto_number = -1; - protoent *proto; - - if (! (proto = getprotobyname ("icmp"))) - { - ACE_ERROR_RETURN - ((LM_ERROR, - ACE_TEXT ("(%P|%t) ACE_ICMP_Socket::open: %p; %s\n"), - ACE_TEXT ("getprotobyname"), - ACE_TEXT ("ICMP protocol is not properly configured ") - ACE_TEXT ("or not supported.")), - -1); - } - proto_number = proto->p_proto; - - if (proto_number != IPPROTO_ICMP || proto_number != protocol) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%P|%t) ACE::ICMP_Socket::open - ") - ACE_TEXT ("only IPPROTO_ICMP protocol is ") - ACE_TEXT ("currently supported.\n")), - -1); - } - - if (ACE_SOCK::open (SOCK_RAW, - AF_INET, - protocol, - reuse_addr) == -1) - { - return -1; - } - - return this->shared_open (local); -} - -int -ACE_ICMP_Socket::shared_open (ACE_Addr const & local) -{ - ACE_TRACE ("ACE_ICMP_Socket::shared_open"); - - int error = 0; - if (local == ACE_Addr::sap_any) - { - if (ACE::bind_port (this->get_handle ()) == -1) - { - error = 1; - } - } - else if (ACE_OS::bind (this->get_handle (), - reinterpret_cast (local.get_addr ()), - local.get_size ()) == -1) - { - error = 1; - } - - if (error != 0) - { - this->close (); - } - - return error ? -1 : 0; -} - -unsigned short -ACE_ICMP_Socket::calculate_checksum (unsigned short * paddress, - int len) -{ - int nleft = len; - int sum = 0; - unsigned short * w = paddress; - unsigned short answer = 0; - while (nleft > 1) - { - sum += *w++; - nleft -= 2; - } - - if (nleft == 1) - { - *((unsigned char *) &answer) = *((unsigned char *) w); - sum += answer; - } - - // add back carry outs from top 16 bits to low 16 bits - sum = (sum >> 16) + (sum & 0xffff); // add hi 16 to low 16 - sum += (sum >> 16); // add carry - answer = ~sum; // truncate to 16 bits - - return (answer); -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_ICMP_SUPPORT == 1 */ diff --git a/ACE/ace/ICMP_Socket.h b/ACE/ace/ICMP_Socket.h deleted file mode 100644 index 104ca3ccbc3..00000000000 --- a/ACE/ace/ICMP_Socket.h +++ /dev/null @@ -1,110 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file ICMP_Socket.h - * - * $Id$ - * - * @author Robert S. Iakobashvili - * @author Gonzalo A. Diethelm - */ -//============================================================================= - -#ifndef ACE_ICMP_SOCKET_H -#define ACE_ICMP_SOCKET_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_ICMP_SUPPORT) && (ACE_HAS_ICMP_SUPPORT == 1) - -#include "ace/SOCK.h" -#include "ace/Time_Value.h" -#include "ace/os_include/netinet/os_in.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_ICMP_Socket - * - * @brief An abstract class that forms the basis for usage of the ICMP - * protocol (that is, support for things such as ping). - */ -class ACE_Export ACE_ICMP_Socket : public ACE_SOCK -{ -public: - // = Initialization methods. - - /** - * @name Data transfer routines. - * - * Data transfer routines. - */ - //@{ - - /// Send an @a n byte @a buf to the datagram socket (uses - /// @c sendto(3) ). - ssize_t send (void const * buf, - size_t n, - ACE_Addr const & addr, - int flags = 0) const; - - /// Receive an @a n byte @a buf from the datagram socket - /// (uses @c recvfrom(3) ). - ssize_t recv (void * buf, - size_t n, - ACE_Addr & addr, - int flags = 0) const; - - /// TODO: comment - ssize_t recv (void * buf, - size_t n, - int flags, - ACE_Time_Value const * timeout) const; - - //@} - - /// Wrapper around the BSD-style @c socket system call (no QoS). - int open (ACE_Addr const & local = ACE_Addr::sap_any, - int protocol = IPPROTO_ICMP, - int reuse_addr = 0); - - /// Dump the state of object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - - // Protected constructors, so the class can only be derived from. - - /// Default constructor. - ACE_ICMP_Socket (void); - - /// Constructor that takes a local listening address. - ACE_ICMP_Socket (ACE_Addr const & local, - int protocol = IPPROTO_ICMP, - int reuse_addr = 0); - - /// Wrapper around BSD-style @c bind system call. - int shared_open (ACE_Addr const & local); - - /// Calculates check-sum. - unsigned short calculate_checksum (unsigned short* paddress, - int len); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_ICMP_SUPPORT == 1 */ - -#include /**/ "ace/post.h" - -#endif /* ACE_ICMP_SOCKET_H */ diff --git a/ACE/ace/INET_Addr.cpp b/ACE/ace/INET_Addr.cpp deleted file mode 100644 index 76c64ce8b74..00000000000 --- a/ACE/ace/INET_Addr.cpp +++ /dev/null @@ -1,1168 +0,0 @@ -// $Id$ - -// Defines the Internet domain address family address format. - -#include "ace/INET_Addr.h" - -#if !defined (__ACE_INLINE__) -#include "ace/INET_Addr.inl" -#endif /* __ACE_INLINE__ */ - -#include "ace/Log_Msg.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_errno.h" -#include "ace/OS_NS_stdlib.h" -#include "ace/OS_Memory.h" -#include "ace/OS_NS_arpa_inet.h" -#include "ace/OS_NS_netdb.h" -#include "ace/OS_NS_unistd.h" -#include "ace/OS_NS_sys_socket.h" - -ACE_RCSID (ace, - INET_Addr, - "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_INET_Addr) - -// Transform the current address into string format. - -int -ACE_INET_Addr::addr_to_string (ACE_TCHAR s[], - size_t size, - int ipaddr_format) const -{ - ACE_TRACE ("ACE_INET_Addr::addr_to_string"); - - // XXX Can we (should we) include the scope id for IPv6 addresses? - char hoststr[MAXHOSTNAMELEN+1]; - - bool result = false; - if (ipaddr_format == 0) - result = (this->get_host_name (hoststr, MAXHOSTNAMELEN+1) == 0); - else - result = (this->get_host_addr (hoststr, MAXHOSTNAMELEN+1) != 0); - - if (!result) - return -1; - - size_t total_len = - ACE_OS::strlen (hoststr) - + 5 // ACE_OS::strlen ("65535"), Assuming the max port number. - + 1 // sizeof (':'), addr/port sep - + 1; // sizeof ('\0'), terminating NUL -#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_TCHAR const *format = ACE_TEXT("%ls:%d"); -#else - ACE_TCHAR const *format = ACE_TEXT("%s:%d"); -#endif /* !ACE_WIN32 && ACE_USES_WCHAR */ -#if defined (ACE_HAS_IPV6) - if (ACE_OS::strchr (hoststr, ACE_TEXT (':')) != 0) - { - total_len += 2; // ACE_OS::strlen ("[]") IPv6 addr frames -# if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - format = ACE_TEXT("[%ls]:%d"); -# else - format = ACE_TEXT("[%s]:%d"); -# endif /* !ACE_WIN32 && ACE_USES_WCHAR */ - } -#endif // ACE_HAS_IPV6 - - if (size < total_len) - return -1; - else - ACE_OS::sprintf (s, format, - ACE_TEXT_CHAR_TO_TCHAR (hoststr), - this->get_port_number ()); - return 0; -} - -void -ACE_INET_Addr::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_INET_Addr::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - - ACE_TCHAR s[ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 16]; - this->addr_to_string(s, ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 16); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s"), s)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -// Compare two addresses for inequality. - -bool -ACE_INET_Addr::operator != (const ACE_INET_Addr &sap) const -{ - ACE_TRACE ("ACE_INET_Addr::operator !="); - return !((*this) == sap); -} - -// Compare two addresses for equality. - -bool -ACE_INET_Addr::operator == (const ACE_INET_Addr &sap) const -{ - ACE_TRACE ("ACE_INET_Addr::operator =="); - - if (this->get_type () != sap.get_type () - || this->get_size () != sap.get_size ()) - return false; - - return (ACE_OS::memcmp (&this->inet_addr_, - &sap.inet_addr_, - this->get_size ()) == 0); -} - -bool -ACE_INET_Addr::is_ip_equal (const ACE_INET_Addr &sap) const -{ - if (this->get_type () != sap.get_type () - || this->get_size () != sap.get_size ()) - return false; - -#if defined (ACE_HAS_IPV6) - if (this->get_type () == PF_INET6) - { - const unsigned int *addr = - reinterpret_cast(this->ip_addr_pointer()); - const unsigned int *saddr = - reinterpret_cast(sap.ip_addr_pointer()); - return (addr[0] == saddr[0] && - addr[1] == saddr[1] && - addr[2] == saddr[2] && - addr[3] == saddr[3]); - } - else -#endif /* ACE_HAS_IPV6 */ - return this->get_ip_address () == sap.get_ip_address(); -} - - -u_long -ACE_INET_Addr::hash (void) const -{ -#if defined (ACE_HAS_IPV6) - if (this->get_type () == PF_INET6) - { - const unsigned int *addr = (const unsigned int*)this->ip_addr_pointer(); - return addr[0] + addr[1] + addr[2] + addr[3] + this->get_port_number(); - } - else -#endif /* ACE_HAS_IPV6 */ - return this->get_ip_address () + this->get_port_number (); -} - -ACE_INET_Addr::ACE_INET_Addr (void) - : ACE_Addr (determine_type (), sizeof (inet_addr_)) -{ - // ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); -} - -int -ACE_INET_Addr::set (const ACE_INET_Addr &sa) -{ - ACE_TRACE ("ACE_INET_Addr::set"); - - if (sa.get_type () == AF_ANY) - // Ugh, this is really a base class, so don't copy it. - ACE_OS::memset (&this->inet_addr_, 0, sizeof (this->inet_addr_)); - else - { - // It's ok to make the copy. - ACE_OS::memcpy (&this->inet_addr_, - &sa.inet_addr_, - sa.get_size ()); - - this->set_type (sa.get_type()); - this->set_size (sa.get_size()); - } - - return 0; -} - -// Transform the string into the current addressing format. - -int -ACE_INET_Addr::string_to_addr (const char s[], int address_family) -{ - ACE_TRACE ("ACE_INET_Addr::string_to_addr"); - int result; - char *ip_buf = 0; - char *ip_addr = 0; - - // Need to make a duplicate since we'll be overwriting the string. - ACE_ALLOCATOR_RETURN (ip_buf, - ACE_OS::strdup (s), - -1); - ip_addr = ip_buf; - // We use strrchr because of IPv6 addresses. - char *port_p = ACE_OS::strrchr (ip_addr, ':'); -#if defined (ACE_HAS_IPV6) - // Check for extended IPv6 format : '[' ']' ':' - if (ip_addr[0] == '[') - { - // find closing bracket - char *cp_pos = ACE_OS::strchr (ip_addr, ']'); - // check for port separator after closing bracket - // if not found leave it, error will come later - if (cp_pos) - { - *cp_pos = '\0'; // blank out ']' - ++ip_addr; // skip over '[' - if (cp_pos[1] == ':') - port_p = cp_pos + 1; - else - port_p = cp_pos; // leads to error on missing port - } - } -#endif /* ACE_HAS_IPV6 */ - - if (port_p == 0) // Assume it's a port number. - { - char *endp = 0; - u_short port = - static_cast (ACE_OS::strtol (ip_addr, &endp, 10)); - if (*endp == '\0') // strtol scanned the entire string - all digits - result = this->set (port, ACE_UINT32 (INADDR_ANY)); - else // port name - result = this->set (ip_addr, ACE_UINT32 (INADDR_ANY)); - } - else - { - *port_p = '\0'; ++port_p; // skip over ':' - - char *endp = 0; - u_short port = static_cast (ACE_OS::strtol (port_p, &endp, 10)); - if (*endp == '\0') // strtol scanned the entire string - all digits - result = this->set (port, ip_addr, 1, address_family); - else - result = this->set (port_p, ip_addr); - } - - ACE_OS::free (ACE_MALLOC_T (ip_buf)); - return result; -} - -int -ACE_INET_Addr::set (const char address[], int address_family) -{ - ACE_TRACE ("ACE_INET_Addr::set"); - return this->string_to_addr (address, address_family); -} - -ACE_INET_Addr::ACE_INET_Addr (const char address[], int address_family) - : ACE_Addr (determine_type (), sizeof (inet_addr_)) -{ - ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); - this->set (address, address_family); -} - -#if defined (ACE_HAS_WCHAR) -ACE_INET_Addr::ACE_INET_Addr (const wchar_t address[], int address_family) - : ACE_Addr (determine_type (), sizeof (inet_addr_)) -{ - ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); - this->set (address, address_family); -} - -#endif /* ACE_HAS_WCHAR */ - -// Copy constructor. - -ACE_INET_Addr::ACE_INET_Addr (const ACE_INET_Addr &sa) - : ACE_Addr (sa.get_type (), sa.get_size()) -{ - ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); - this->set (sa); -} - -// Initializes a ACE_INET_Addr from a PORT_NUMBER and a 32 bit Internet -// address. - -int -ACE_INET_Addr::set (u_short port_number, - ACE_UINT32 inet_address, - int encode, - int map) -{ - ACE_TRACE ("ACE_INET_Addr::set"); - this->set_address (reinterpret_cast (&inet_address), - sizeof inet_address, - encode, map); - this->set_port_number (port_number, encode); - - return 0; -} - - -// Initializes a ACE_INET_Addr from a PORT_NUMBER and the remote -// HOST_NAME. - -int -ACE_INET_Addr::set (u_short port_number, - const char host_name[], - int encode, - int address_family) -{ - ACE_TRACE ("ACE_INET_Addr::set"); - - // Yow, someone gave us a NULL host_name! - if (host_name == 0) - { - errno = EINVAL; - return -1; - } - - ACE_OS::memset ((void *) &this->inet_addr_, - 0, - sizeof this->inet_addr_); - -#if defined (ACE_HAS_IPV6) - struct addrinfo hints; - struct addrinfo *res = 0; - int error = 0; - ACE_OS::memset (&hints, 0, sizeof (hints)); -# if defined (ACE_USES_IPV4_IPV6_MIGRATION) - if (address_family == AF_UNSPEC && !ACE::ipv6_enabled()) - address_family = AF_INET; -# endif /* ACE_USES_IPV4_IPV6_MIGRATION */ - if (address_family == AF_UNSPEC || address_family == AF_INET6) - { - hints.ai_family = AF_INET6; - error = ::getaddrinfo (host_name, 0, &hints, &res); - if (error) - { - if (address_family == AF_INET6) - { - if (res) - ::freeaddrinfo(res); - errno = error; - return -1; - } - address_family = AF_INET; - } - } - if (address_family == AF_INET) - { - hints.ai_family = AF_INET; - error = ::getaddrinfo (host_name, 0, &hints, &res); - if (error) - { - if (res) - ::freeaddrinfo(res); - errno = error; - return -1; - } - } - this->set_type (res->ai_family); - this->set_addr (res->ai_addr, res->ai_addrlen); - this->set_port_number (port_number, encode); - ::freeaddrinfo (res); - return 0; -#else /* ACE_HAS_IPV6 */ - - // IPv6 not supported... insure the family is set to IPv4 - address_family = AF_INET; - this->set_type (address_family); - this->inet_addr_.in4_.sin_family = static_cast (address_family); -#ifdef ACE_HAS_SOCKADDR_IN_SIN_LEN - this->inet_addr_.in4_.sin_len = sizeof (this->inet_addr_.in4_); -#endif - struct in_addr addrv4; - if (ACE_OS::inet_aton (host_name, - &addrv4) == 1) - return this->set (port_number, - encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, - encode); - else - { -# if defined (ACE_VXWORKS) && defined (ACE_LACKS_GETHOSTBYNAME) - hostent *hp = ACE_OS::gethostbyname (host_name); -# else - hostent hentry; - ACE_HOSTENT_DATA buf; - int h_error; // Not the same as errno! - - hostent *hp = ACE_OS::gethostbyname_r (host_name, &hentry, - buf, &h_error); - if (hp == 0) - errno = h_error; -# endif /* ACE_VXWORKS */ - - if (hp == 0) - { - return -1; - } - else - { - (void) ACE_OS::memcpy ((void *) &addrv4.s_addr, - hp->h_addr, - hp->h_length); - return this->set (port_number, - encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, - encode); - } - } -#endif /* ACE_HAS_IPV6 */ -} - -// Helper function to get a port number from a port name. - -static int get_port_number_from_name (const char port_name[], - const char protocol[]) -{ - // Maybe port_name is directly a port number? - char *endp = 0; - int port_number = static_cast (ACE_OS::strtol (port_name, &endp, 10)); - - if (port_number >= 0 && *endp == '\0') - { - // Ok, port_name was really a number, and nothing else. We - // store that value as the port number. NOTE: this number must - // be returned in network byte order! - u_short n = static_cast (port_number); - n = ACE_HTONS (n); - return n; - } - - // We try to resolve port number from its name. - -#if defined (ACE_LACKS_GETSERVBYNAME) - port_number = 0; - ACE_UNUSED_ARG (port_name); - ACE_UNUSED_ARG (protocol); -#else - port_number = -1; - servent sentry; - ACE_SERVENT_DATA buf; - servent *sp = ACE_OS::getservbyname_r (port_name, - protocol, - &sentry, - buf); - if (sp != 0) - port_number = sp->s_port; -#endif /* ACE_LACKS_GETSERVBYNAME */ - - return port_number; -} - -// Initializes a ACE_INET_Addr from a and the remote -// . - -int -ACE_INET_Addr::set (const char port_name[], - const char host_name[], - const char protocol[]) -{ - ACE_TRACE ("ACE_INET_Addr::set"); - - int const port_number = get_port_number_from_name (port_name, protocol); - if (port_number == -1) - { - ACE_NOTSUP_RETURN (-1); - } - - int address_family = PF_UNSPEC; -# if defined (ACE_HAS_IPV6) - if (ACE_OS::strcmp (ACE_TEXT_CHAR_TO_TCHAR(protocol), ACE_TEXT ("tcp6")) == 0) - address_family = AF_INET6; -# endif /* ACE_HAS_IPV6 */ - - return this->set (static_cast (port_number), - host_name, 0, address_family); -} - -// Initializes a ACE_INET_Addr from a and a 32 bit -// Internet address. - -int -ACE_INET_Addr::set (const char port_name[], - ACE_UINT32 inet_address, - const char protocol[]) -{ - ACE_TRACE ("ACE_INET_Addr::set"); - - int const port_number = get_port_number_from_name (port_name, protocol); - if (port_number == -1) - { - ACE_NOTSUP_RETURN (-1); - } - - return this->set (static_cast (port_number), - inet_address, 0); -} - -// Creates a ACE_INET_Addr from a PORT_NUMBER and the remote -// HOST_NAME. - -ACE_INET_Addr::ACE_INET_Addr (u_short port_number, - const char host_name[], - int address_family) - : ACE_Addr (determine_type (), sizeof (inet_addr_)) -{ - ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - ACE_OS::memset (&this->inet_addr_, 0, sizeof (this->inet_addr_)); - if (this->set (port_number, - host_name, - 1, - address_family) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE_INET_Addr::ACE_INET_Addr: %p\n"), - ACE_TEXT_CHAR_TO_TCHAR ((host_name == 0) ? - "" : host_name))); -} - -#if defined (ACE_HAS_WCHAR) -ACE_INET_Addr::ACE_INET_Addr (u_short port_number, - const wchar_t host_name[], - int address_family) - : ACE_Addr (determine_type (), sizeof (inet_addr_)) -{ - ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - ACE_OS::memset (&this->inet_addr_, 0, sizeof (this->inet_addr_)); - if (this->set (port_number, - host_name, - 1, - address_family) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE_INET_Addr::ACE_INET_Addr: %p\n"), - ACE_TEXT_WCHAR_TO_TCHAR ((host_name == 0) ? - ACE_TEXT_WIDE ("") : - host_name))); -} -#endif /* ACE_HAS_WCHAR */ - -// Creates a ACE_INET_Addr from a sockaddr_in structure. - -int -ACE_INET_Addr::set (const sockaddr_in *addr, int len) -{ - ACE_TRACE ("ACE_INET_Addr::set"); - - if (addr->sin_family == AF_INET) - { - int maxlen = static_cast (sizeof (this->inet_addr_.in4_)); - if (len > maxlen) - len = maxlen; - ACE_OS::memcpy (&this->inet_addr_.in4_, addr, len); - this->base_set (AF_INET, len); - return 0; - } -#if defined (ACE_HAS_IPV6) - else if (addr->sin_family == AF_INET6) - { - int maxlen = static_cast (sizeof (this->inet_addr_.in6_)); - if (len > maxlen) - len = maxlen; - ACE_OS::memcpy (&this->inet_addr_.in6_, addr, len); - this->base_set (AF_INET6, len); - return 0; - } -#endif /* ACE_HAS_IPV6 */ - - errno = EAFNOSUPPORT; - return -1; -} - -// Return the address. - -void * -ACE_INET_Addr::get_addr (void) const -{ - ACE_TRACE ("ACE_INET_Addr::get_addr"); - return (void*)&this->inet_addr_; -} - -void -ACE_INET_Addr::set_addr (void *addr, int len) -{ - this->set_addr (addr, len, 0); -} - -// Set a pointer to the address. -void -ACE_INET_Addr::set_addr (void *addr, int /* len */, int map) -{ - ACE_TRACE ("ACE_INET_Addr::set_addr"); - struct sockaddr_in *getfamily = static_cast (addr); - - if (getfamily->sin_family == AF_INET) - { -#if defined (ACE_HAS_IPV6) - if (map) - this->set_type (AF_INET6); - else -#endif /* ACE_HAS_IPV6 */ - this->set_type (AF_INET); - this->set_port_number (getfamily->sin_port, 0); - this->set_address (reinterpret_cast (&getfamily->sin_addr), - sizeof (getfamily->sin_addr), - 0, map); - } -#if defined (ACE_HAS_IPV6) - else if (getfamily->sin_family == AF_INET6) - { - struct sockaddr_in6 *in6 = static_cast (addr); - this->set_port_number (in6->sin6_port, 0); - this->set_address (reinterpret_cast (&in6->sin6_addr), - sizeof (in6->sin6_addr), - 0); - this->inet_addr_.in6_.sin6_scope_id = in6->sin6_scope_id; - } -#endif // ACE_HAS_IPV6 -} - -// Creates a ACE_INET_Addr from a sockaddr_in structure. - -ACE_INET_Addr::ACE_INET_Addr (const sockaddr_in *addr, int len) - : ACE_Addr (determine_type (), sizeof (inet_addr_)) -{ - ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); - this->set (addr, len); -} - -// Creates a ACE_INET_Addr from a PORT_NUMBER and an Internet address. - -ACE_INET_Addr::ACE_INET_Addr (u_short port_number, - ACE_UINT32 inet_address) - : ACE_Addr (determine_type (), sizeof (inet_addr_)) -{ - ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); - if (this->set (port_number, inet_address) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_INET_Addr::ACE_INET_Addr"))); -} - -// Creates a ACE_INET_Addr from a PORT_NAME and the remote -// HOST_NAME. - -ACE_INET_Addr::ACE_INET_Addr (const char port_name[], - const char host_name[], - const char protocol[]) - : ACE_Addr (determine_type (), sizeof (inet_addr_)) -{ - ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); - if (this->set (port_name, - host_name, - protocol) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE_INET_Addr::ACE_INET_Addr"))); -} - -#if defined (ACE_HAS_WCHAR) -ACE_INET_Addr::ACE_INET_Addr (const wchar_t port_name[], - const wchar_t host_name[], - const wchar_t protocol[]) - : ACE_Addr (determine_type (), sizeof (inet_addr_)) -{ - ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); - if (this->set (port_name, - host_name, - protocol) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE_INET_Addr::ACE_INET_Addr"))); -} -#endif /* ACE_HAS_WCHAR */ - -// Creates a ACE_INET_Addr from a PORT_NAME and an Internet address. - -ACE_INET_Addr::ACE_INET_Addr (const char port_name[], - ACE_UINT32 inet_address, - const char protocol[]) - : ACE_Addr (determine_type (), sizeof (inet_addr_)) -{ - ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); -#if !defined (ACE_LACKS_HTONL) - this->reset (); - if (this->set (port_name, - htonl (inet_address), - protocol) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE_INET_Addr::ACE_INET_Addr"))); -#else - ACE_UNUSED_ARG (port_name); - ACE_UNUSED_ARG (inet_address); - ACE_UNUSED_ARG (protocol); -#endif -} - -#if defined (ACE_HAS_WCHAR) -ACE_INET_Addr::ACE_INET_Addr (const wchar_t port_name[], - ACE_UINT32 inet_address, - const wchar_t protocol[]) - : ACE_Addr (determine_type (), sizeof (inet_addr_)) -{ - ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); -#if !defined (ACE_LACKS_HTONL) - this->reset (); - if (this->set (port_name, - htonl (inet_address), - protocol) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE_INET_Addr::ACE_INET_Addr"))); -#else - ACE_UNUSED_ARG (port_name); - ACE_UNUSED_ARG (inet_address); - ACE_UNUSED_ARG (protocol); -#endif -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INET_Addr::~ACE_INET_Addr (void) -{ -} - -int -ACE_INET_Addr::get_host_name (char hostname[], - size_t len) const -{ - ACE_TRACE ("ACE_INET_Addr::get_host_name"); - - int result; - if (len > 1) - { - result = this->get_host_name_i (hostname,len); - if (result < 0) - { - if (result == -2) - // We know that hostname is nul-terminated - result = -1; - else - { - //result == -1; - // This could be worse than hostname[len -1] = '\0'? - hostname[0] = '\0'; - } - } - } - else - { - if (len == 1) - hostname[0] = '\0'; - result = -1; - } - - return result; -} - -#if defined (ACE_HAS_WCHAR) -int -ACE_INET_Addr::get_host_name (wchar_t hostname[], - size_t len) const -{ - ACE_TRACE ("ACE_INET_Addr::get_host_name"); - - char char_hostname [MAXHOSTNAMELEN + 1]; - - // We have a build in limitation of MAXHOSTNAMELEN - if (len > MAXHOSTNAMELEN + 1) - len = MAXHOSTNAMELEN + 1; - - // Call the char version - int result = this->get_host_name (char_hostname, len); - - // And copy it over, if successful - if (result == 0) - ACE_OS::strcpy (hostname, - ACE_Ascii_To_Wide (char_hostname).wchar_rep ()); - - return result; -} -#endif /* ACE_HAS_WCHAR */ - -// Return the character representation of the hostname. - -const char * -ACE_INET_Addr::get_host_name (void) const -{ - ACE_TRACE ("ACE_INET_Addr::get_host_name"); - - static char name[MAXHOSTNAMELEN + 1]; - if (this->get_host_name (name, MAXHOSTNAMELEN + 1) == -1) - ACE_OS::strcpy (name, ""); - return name; -} - -void -ACE_INET_Addr::set_port_number (u_short port_number, - int encode) -{ - ACE_TRACE ("ACE_INET_Addr::set_port_number"); - - if (encode) - port_number = ACE_HTONS (port_number); - -#if defined (ACE_HAS_IPV6) - if (this->get_type () == AF_INET6) - this->inet_addr_.in6_.sin6_port = port_number; - else -#endif /* ACE_HAS_IPV6 */ - this->inet_addr_.in4_.sin_port = port_number; -} - -// returns -2 when the hostname is truncated -int -ACE_INET_Addr::get_host_name_i (char hostname[], size_t len) const -{ - ACE_TRACE ("ACE_INET_Addr::get_host_name_i"); - -#if defined (ACE_HAS_IPV6) - if ((this->get_type () == PF_INET6 && - 0 == ACE_OS::memcmp (&this->inet_addr_.in6_.sin6_addr, - &in6addr_any, - sizeof (this->inet_addr_.in6_.sin6_addr))) - || - (this->get_type () == PF_INET && - this->inet_addr_.in4_.sin_addr.s_addr == INADDR_ANY)) -#else - if (this->inet_addr_.in4_.sin_addr.s_addr == INADDR_ANY) -#endif /* ACE_HAS_IPV6 */ - { - if (ACE_OS::hostname (hostname, len) == -1) - return -1; - else - return 0; - } - else - { -#if defined (ACE_VXWORKS) && defined (ACE_LACKS_GETHOSTBYADDR) - ACE_UNUSED_ARG (len); - int error = - ::hostGetByAddr ((int) this->inet_addr_.in4_.sin_addr.s_addr, - hostname); - if (error == OK) - return 0; - else - { - errno = error; - return -1; - } -#else - void* addr = this->ip_addr_pointer (); - int size = this->ip_addr_size (); - int type = this->get_type (); - -# if defined (ACE_HAS_IPV6) && defined (ACE_HAS_BROKEN_GETHOSTBYADDR_V4MAPPED) - // Most OS can not handle IPv6-mapped-IPv4 addresses (even - // though they are meant to) so map them back to IPv4 addresses - // before trying to resolve them - in_addr demapped_addr; - if (type == PF_INET6 && - (this->is_ipv4_mapped_ipv6 () || this->is_ipv4_compat_ipv6 ())) - { - ACE_OS::memcpy (&demapped_addr.s_addr, &this->inet_addr_.in6_.sin6_addr.s6_addr[12], 4); - addr = &demapped_addr; - size = sizeof(demapped_addr); - type = PF_INET; - } -# endif /* ACE_HAS_IPV6 */ - -# if defined (DIGITAL_UNIX) && defined (__GNUC__) - hostent * const hp = - ACE_OS::gethostbyaddr (static_cast (addr), size, type); -# else - int h_error; // Not the same as errno! - hostent hentry; - ACE_HOSTENT_DATA buf; - hostent * const hp = - ACE_OS::gethostbyaddr_r (static_cast (addr), - size, - type, - &hentry, - buf, - &h_error); -# endif /* DIGITAL_UNIX */ - - if (hp == 0 || hp->h_name == 0) - return -1; - - if (ACE_OS::strlen (hp->h_name) >= len) - { - // We know the length, so use memcpy - if (len > 0) - { - ACE_OS::memcpy (hostname, hp->h_name, len - 1); - hostname[len-1]= '\0'; - } - errno = ENOSPC; - return -2; // -2 Means that we have a good string - // Using errno looks ok, but ENOSPC could be set on - // other places. - } - - ACE_OS::strcpy (hostname, hp->h_name); - return 0; -#endif /* ACE_VXWORKS */ - } -} - -int ACE_INET_Addr::set_address (const char *ip_addr, - int len, - int encode /* = 1 */, - int map /* = 0 */) -{ - ACE_TRACE ("ACE_INET_Addr::set_address"); - // This is really intended for IPv4. If the object is IPv4, or the type - // hasn't been set but it's a 4-byte address, go ahead. If this is an - // IPv6 object and is requested, refuse. - if (encode && len != 4) - { - errno = EAFNOSUPPORT; - return -1; - } - - if (len == 4) - { - ACE_UINT32 ip4 = *reinterpret_cast (ip_addr); - if (encode) - ip4 = ACE_HTONL (ip4); - - - if (this->get_type () == AF_INET && map == 0) { - this->base_set (AF_INET, sizeof (this->inet_addr_.in4_)); -#ifdef ACE_HAS_SOCKADDR_IN_SIN_LEN - this->inet_addr_.in4_.sin_len = sizeof (this->inet_addr_.in4_); -#endif - this->inet_addr_.in4_.sin_family = AF_INET; - this->set_size (sizeof (this->inet_addr_.in4_)); - ACE_OS::memcpy (&this->inet_addr_.in4_.sin_addr, - &ip4, - len); - } -#if defined (ACE_HAS_IPV6) - else if (map == 0) - { - // this->set_type (AF_INET); - this->base_set (AF_INET, sizeof (this->inet_addr_.in4_)); -#ifdef ACE_HAS_SOCKADDR_IN_SIN_LEN - this->inet_addr_.in4_.sin_len = sizeof (this->inet_addr_.in4_); -#endif - this->inet_addr_.in4_.sin_family = AF_INET; - this->set_size (sizeof (this->inet_addr_.in4_)); - ACE_OS::memcpy (&this->inet_addr_.in4_.sin_addr, - &ip4, len); - } - // If given an IPv4 address to copy to an IPv6 object, map it to - // an IPv4-mapped IPv6 address. - else - { - this->base_set (AF_INET6, sizeof (this->inet_addr_.in6_)); -#ifdef ACE_HAS_SOCKADDR_IN6_SIN6_LEN - this->inet_addr_.in6_.sin6_len = sizeof (this->inet_addr_.in6_); -#endif - this->inet_addr_.in6_.sin6_family = AF_INET6; - this->set_size (sizeof (this->inet_addr_.in6_)); - if (ip4 == ACE_HTONL (INADDR_ANY)) - { - in6_addr const ip6 = in6addr_any; - ACE_OS::memcpy (&this->inet_addr_.in6_.sin6_addr, - &ip6, - sizeof (ip6)); - return 0; - } - - // Build up a 128 bit address. An IPv4-mapped IPv6 address - // is defined as 0:0:0:0:0:ffff:IPv4_address. This is defined - // in RFC 1884 */ - ACE_OS::memset (&this->inet_addr_.in6_.sin6_addr, 0, 16); - this->inet_addr_.in6_.sin6_addr.s6_addr[10] = - this->inet_addr_.in6_.sin6_addr.s6_addr[11] = 0xff; - ACE_OS::memcpy - (&this->inet_addr_.in6_.sin6_addr.s6_addr[12], &ip4, 4); - } -#endif /* ACE_HAS_IPV6 */ - return 0; - } /* end if (len == 4) */ -#if defined (ACE_HAS_IPV6) - else if (len == 16) - { - if (this->get_type () != PF_INET6) - { - errno = EAFNOSUPPORT; - return -1; - } - // We protect ourselves up above so IPv6 must be possible here. - this->base_set (AF_INET6, sizeof (this->inet_addr_.in6_)); - this->inet_addr_.in6_.sin6_family = AF_INET6; -#ifdef ACE_HAS_SOCKADDR_IN6_SIN6_LEN - this->inet_addr_.in6_.sin6_len = sizeof (this->inet_addr_.in6_); -#endif - ACE_OS::memcpy (&this->inet_addr_.in6_.sin6_addr, ip_addr, len); - - return 0; - } /* end len == 16 */ -#endif /* ACE_HAS_IPV6 */ - - // Here with an unrecognized length. - errno = EAFNOSUPPORT; - return -1; - -} - -#if (defined (__linux__) || defined (ACE_WIN32)) && defined (ACE_HAS_IPV6) -int -ACE_INET_Addr::set_interface (const char *intf_name) -{ - if (this->get_type () == PF_INET6 && - (IN6_IS_ADDR_LINKLOCAL (&this->inet_addr_.in6_.sin6_addr) || - IN6_IS_ADDR_MC_LINKLOCAL (&this->inet_addr_.in6_.sin6_addr))) - { -#if defined (__linux__) - this->inet_addr_.in6_.sin6_scope_id = - ACE_OS::if_nametoindex (intf_name); -#else - this->inet_addr_.in6_.sin6_scope_id = - intf_name ? ACE_OS::atoi (intf_name) : 0; -#endif - // check to see if the interface lookup succeeded - if (this->inet_addr_.in6_.sin6_scope_id != 0) - return 0; - else - return -1; - } - else - return 0; - -} -#endif /* __linux && ACE_HAS_IPV6 */ - -const char * -ACE_INET_Addr::get_host_addr (char *dst, int size) const -{ -#if defined (ACE_HAS_IPV6) - if (this->get_type () == AF_INET6) - { - // mcorino@remedy.nl - Aug-26, 2005 - // I don't think this should be done because it results in a decimal address - // representation which is not distinguishable from the IPv4 form which makes - // it impossible to resolve back to an IPv6 INET_Addr without prior knowledge - // that this was such an address to begin with. - - //if (IN6_IS_ADDR_V4MAPPED (&this->inet_addr_.in6_.sin6_addr)) - //{ - // ACE_UINT32 addr; - // addr = this->get_ip_address(); - // addr = ACE_HTONL (addr); - // return ACE_OS::inet_ntop (AF_INET, &addr, dst, size); - //} - -# if defined (ACE_WIN32) - if (0 == ::getnameinfo (reinterpret_cast (&this->inet_addr_.in6_), - this->get_size (), - dst, - size, - 0, 0, // Don't want service name - NI_NUMERICHOST)) - return dst; - ACE_OS::set_errno_to_wsa_last_error (); - return 0; -# else - const char *ch = ACE_OS::inet_ntop (AF_INET6, - &this->inet_addr_.in6_.sin6_addr, - dst, - size); -#if defined (__linux__) - if ((IN6_IS_ADDR_LINKLOCAL (&this->inet_addr_.in6_.sin6_addr) || - IN6_IS_ADDR_MC_LINKLOCAL (&this->inet_addr_.in6_.sin6_addr)) && - this->inet_addr_.in6_.sin6_scope_id != 0) - { - char scope_buf[32]; - ACE_OS::sprintf (scope_buf, "%%%u", this->inet_addr_.in6_.sin6_scope_id); - if ((ACE_OS::strlen (ch)+ACE_OS::strlen (scope_buf)) < (size_t)size) - { - ACE_OS::strcat (dst, scope_buf); - } - } -#endif - return ch; -# endif /* ACE_WIN32 */ - } -#endif /* ACE_HAS_IPV6 */ - -#if defined (ACE_VXWORKS) - ACE_UNUSED_ARG (dst); - ACE_UNUSED_ARG (size); - - // It would be nice to be able to encapsulate this into - // ACE_OS::inet_ntoa(), but that would lead to either inefficiencies - // on vxworks or lack of thread safety. - // - // So, we use the way that vxworks suggests. - ACE_INET_Addr *ncthis = const_cast (this); - inet_ntoa_b(this->inet_addr_.in4_.sin_addr, ncthis->buf_); - ACE_OS::strsncpy (dst, &buf_[0], size); - return &buf_[0]; -#else /* ACE_VXWORKS */ - char *ch = ACE_OS::inet_ntoa (this->inet_addr_.in4_.sin_addr); - ACE_OS::strsncpy (dst, ch, size); - return ch; -#endif -} - -// Return the dotted Internet address. -const char * -ACE_INET_Addr::get_host_addr (void) const -{ - ACE_TRACE ("ACE_INET_Addr::get_host_addr"); -#if defined (ACE_HAS_IPV6) - static char buf[INET6_ADDRSTRLEN]; - return this->get_host_addr (buf, INET6_ADDRSTRLEN); -#else /* ACE_HAS_IPV6 */ -# if defined (ACE_VXWORKS) - // It would be nice to be able to encapsulate this into - // ACE_OS::inet_ntoa(), but that would lead to either inefficiencies - // on vxworks or lack of thread safety. - // - // So, we use the way that vxworks suggests. - ACE_INET_Addr *ncthis = const_cast (this); - inet_ntoa_b (this->inet_addr_.in4_.sin_addr, ncthis->buf_); - return &buf_[0]; -# else /* ACE_VXWORKS */ - return ACE_OS::inet_ntoa (this->inet_addr_.in4_.sin_addr); -# endif /* !ACE_VXWORKS */ -#endif /* !ACE_HAS_IPV6 */ -} - -// Return the 4-byte IP address, converting it into host byte order. -ACE_UINT32 -ACE_INET_Addr::get_ip_address (void) const -{ - ACE_TRACE ("ACE_INET_Addr::get_ip_address"); -#if defined (ACE_HAS_IPV6) - if (this->get_type () == AF_INET6) - { - if (IN6_IS_ADDR_V4MAPPED (&this->inet_addr_.in6_.sin6_addr) || - IN6_IS_ADDR_V4COMPAT (&this->inet_addr_.in6_.sin6_addr) ) - { - ACE_UINT32 addr; - // Return the last 32 bits of the address - char *thisaddrptr = (char*)this->ip_addr_pointer (); - thisaddrptr += 128/8 - 32/8; - ACE_OS::memcpy (&addr, thisaddrptr, sizeof (addr)); - return ACE_NTOHL (addr); - } - - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE_INET_Addr::get_ip_address: address is a IPv6 address not IPv4\n"))); - errno = EAFNOSUPPORT; - return 0; - } -#endif /* ACE_HAS_IPV6 */ - return ACE_NTOHL (ACE_UINT32 (this->inet_addr_.in4_.sin_addr.s_addr)); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/INET_Addr.h b/ACE/ace/INET_Addr.h deleted file mode 100644 index 7098314ad37..00000000000 --- a/ACE/ace/INET_Addr.h +++ /dev/null @@ -1,399 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file INET_Addr.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_INET_ADDR_H -#define ACE_INET_ADDR_H -#include /**/ "ace/pre.h" - -#include "ace/Sock_Connect.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Addr.h" - -#if defined(ACE_VXWORKS) - // Needed to get INET_ADDR_LEN -# include /**/ "inetLib.h" -#endif /* ACE_VXWORKS */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_INET_Addr - * - * @brief Defines a C++ wrapper facade for the Internet domain address - * family format. - */ -class ACE_Export ACE_INET_Addr : public ACE_Addr -{ -public: - // = Initialization methods. - - /// Default constructor. - ACE_INET_Addr (void); - - /// Copy constructor. - ACE_INET_Addr (const ACE_INET_Addr &); - - /// Creates an ACE_INET_Addr from a sockaddr_in structure. - ACE_INET_Addr (const sockaddr_in *addr, int len); - - /// Creates an ACE_INET_Addr from a @a port_number and the remote - /// @a host_name. The port number is assumed to be in host byte order. - /// To set a port already in network byte order, please @see set(). - /// Use address_family to select IPv6 (PF_INET6) vs. IPv4 (PF_INET). - ACE_INET_Addr (u_short port_number, - const char host_name[], - int address_family = AF_UNSPEC); - - /** - * Initializes an ACE_INET_Addr from the @a address, which can be - * "ip-number:port-number" (e.g., "tango.cs.wustl.edu:1234" or - * "128.252.166.57:1234"). If there is no ':' in the @a address it - * is assumed to be a port number, with the IP address being - * INADDR_ANY. - */ - explicit ACE_INET_Addr (const char address[], - int address_family = AF_UNSPEC); - - /** - * Creates an ACE_INET_Addr from a @a port_number and an Internet - * . This method assumes that @a port_number and - * are in host byte order. If you have addressing information in - * network byte order, @see set(). - */ - explicit ACE_INET_Addr (u_short port_number, - ACE_UINT32 ip_addr = INADDR_ANY); - - /// Uses to create an ACE_INET_Addr from a - /// , the remote @a host_name, and the @a protocol. - ACE_INET_Addr (const char port_name[], - const char host_name[], - const char protocol[] = "tcp"); - - /** - * Uses to create an ACE_INET_Addr from a - * , an Internet , and the @a protocol. This - * method assumes that is in host byte order. - */ - ACE_INET_Addr (const char port_name[], - ACE_UINT32 ip_addr, - const char protocol[] = "tcp"); - -#if defined (ACE_HAS_WCHAR) - ACE_INET_Addr (u_short port_number, - const wchar_t host_name[], - int address_family = AF_UNSPEC); - - explicit ACE_INET_Addr (const wchar_t address[], - int address_family = AF_UNSPEC); - - ACE_INET_Addr (const wchar_t port_name[], - const wchar_t host_name[], - const wchar_t protocol[] = ACE_TEXT_WIDE ("tcp")); - - ACE_INET_Addr (const wchar_t port_name[], - ACE_UINT32 ip_addr, - const wchar_t protocol[] = ACE_TEXT_WIDE ("tcp")); -#endif /* ACE_HAS_WCHAR */ - - /// Default dtor. - ~ACE_INET_Addr (void); - - // = Direct initialization methods. - - // These methods are useful after the object has been constructed. - - /// Initializes from another ACE_INET_Addr. - int set (const ACE_INET_Addr &); - - /** - * Initializes an ACE_INET_Addr from a @a port_number and the - * remote @a host_name. If @a encode is non-zero then @a port_number is - * converted into network byte order, otherwise it is assumed to be - * in network byte order already and are passed straight through. - * address_family can be used to select IPv4/IPv6 if the OS has - * IPv6 capability (ACE_HAS_IPV6 is defined). To specify IPv6, use - * the value AF_INET6. To specify IPv4, use AF_INET. - */ - int set (u_short port_number, - const char host_name[], - int encode = 1, - int address_family = AF_UNSPEC); - - /** - * Initializes an ACE_INET_Addr from a @a port_number and an Internet - * @a ip_addr. If @a encode is non-zero then the port number and IP address - * are converted into network byte order, otherwise they are assumed to be - * in network byte order already and are passed straight through. - * - * If is non-zero and IPv6 support has been compiled in, - * then this address will be set to the IPv4-mapped IPv6 address of it. - */ - int set (u_short port_number, - ACE_UINT32 ip_addr = INADDR_ANY, - int encode = 1, - int map = 0); - - /// Uses to initialize an ACE_INET_Addr from a - /// , the remote @a host_name, and the @a protocol. - int set (const char port_name[], - const char host_name[], - const char protocol[] = "tcp"); - - /** - * Uses to initialize an ACE_INET_Addr from a - * , an , and the @a protocol. This assumes that - * is already in network byte order. - */ - int set (const char port_name[], - ACE_UINT32 ip_addr, - const char protocol[] = "tcp"); - - /** - * Initializes an ACE_INET_Addr from the @a addr, which can be - * "ip-number:port-number" (e.g., "tango.cs.wustl.edu:1234" or - * "128.252.166.57:1234"). If there is no ':' in the @a address it - * is assumed to be a port number, with the IP address being - * INADDR_ANY. - */ - int set (const char addr[], int address_family = AF_UNSPEC); - - /// Creates an ACE_INET_Addr from a sockaddr_in structure. - int set (const sockaddr_in *, - int len); - -#if defined (ACE_HAS_WCHAR) - int set (u_short port_number, - const wchar_t host_name[], - int encode = 1, - int address_family = AF_UNSPEC); - - int set (const wchar_t port_name[], - const wchar_t host_name[], - const wchar_t protocol[] = ACE_TEXT_WIDE ("tcp")); - - int set (const wchar_t port_name[], - ACE_UINT32 ip_addr, - const wchar_t protocol[] = ACE_TEXT_WIDE ("tcp")); - - int set (const wchar_t addr[], int address_family = AF_UNSPEC); -#endif /* ACE_HAS_WCHAR */ - - /// Return a pointer to the underlying network address. - virtual void *get_addr (void) const; - int get_addr_size(void) const; - - /// Set a pointer to the address. - virtual void set_addr (void *, int len); - - /// Set a pointer to the address. - virtual void set_addr (void *, int len, int map); - - /** - * Transform the current ACE_INET_Addr address into string format. - * If is non-0 this produces "ip-number:port-number" - * (e.g., "128.252.166.57:1234"), whereas if is 0 - * this produces "ip-name:port-number" (e.g., - * "tango.cs.wustl.edu:1234"). Returns -1 if the @a size of the - * is too small, else 0. - */ - virtual int addr_to_string (ACE_TCHAR buffer[], - size_t size, - int ipaddr_format = 1) const; - - /** - * Initializes an ACE_INET_Addr from the @a address, which can be - * "ip-addr:port-number" (e.g., "tango.cs.wustl.edu:1234"), - * "ip-addr:port-name" (e.g., "tango.cs.wustl.edu:telnet"), - * "ip-number:port-number" (e.g., "128.252.166.57:1234"), or - * "ip-number:port-name" (e.g., "128.252.166.57:telnet"). If there - * is no ':' in the @a address it is assumed to be a port number, - * with the IP address being INADDR_ANY. - */ - virtual int string_to_addr (const char address[], - int address_family = AF_UNSPEC); - -#if defined (ACE_HAS_WCHAR) - /* - virtual int string_to_addr (const char address[]); - */ -#endif /* ACE_HAS_WCHAR */ - - /** - * Sets the port number without affecting the host name. If - * @a encode is enabled then @a port_number is converted into network - * byte order, otherwise it is assumed to be in network byte order - * already and are passed straight through. - */ - void set_port_number (u_short, - int encode = 1); - - /** - * Sets the address without affecting the port number. If - * @a encode is enabled then is converted into network - * byte order, otherwise it is assumed to be in network byte order - * already and are passed straight through. The size of the address - * is specified in the @a len parameter. - * If is non-zero, IPv6 support has been compiled in, and - * is an IPv4 address, then this address is set to the IPv4-mapped - * IPv6 address of it. - */ - int set_address (const char *ip_addr, - int len, - int encode = 1, - int map = 0); - -#if (defined (__linux__) || defined (ACE_WIN32)) && defined (ACE_HAS_IPV6) - /** - * Sets the interface that should be used for this address. This only has - * an effect when the address is link local, otherwise it does nothing. - */ - int set_interface (const char *intf_name); -#endif /* (__linux__ || ACE_WIN32) && ACE_HAS_IPV6 */ - - /// Return the port number, converting it into host byte-order. - u_short get_port_number (void) const; - - /** - * Return the character representation of the name of the host, - * storing it in the (which is assumed to be - * bytes long). This version is reentrant. If - * is greater than 0 then will be - * NUL-terminated even if -1 is returned. - */ - int get_host_name (char hostname[], - size_t hostnamelen) const; - -#if defined (ACE_HAS_WCHAR) - int get_host_name (wchar_t hostname[], - size_t hostnamelen) const; -#endif /* ACE_HAS_WCHAR */ - - /** - * Return the character representation of the hostname. This - * version is non-reentrant since it returns a pointer to a static - * data area. You should therefore either (1) do a "deep copy" of - * the address returned by get_host_name(), e.g., using strdup() or - * (2) use the "reentrant" version of get_host_name() described - * above. - */ - const char *get_host_name (void) const; - - /** - * Return the "dotted decimal" Internet address representation of - * the hostname storing it in the @a addr (which is assumed to be - * bytes long). This version is reentrant. - */ - const char *get_host_addr (char *addr, int addr_size) const; - - /** - * Return the "dotted decimal" Internet address representation of - * the hostname. This version is non-reentrant since it returns a - * pointer to a static data area. You should therefore either - * (1) do a "deep copy" of the address returned by get_host_addr(), e.g., - * using strdup() or (2) use the "reentrant" version of - * get_host_addr() described above. - */ - const char *get_host_addr (void) const; - - /// Return the 4-byte IP address, converting it into host byte - /// order. - ACE_UINT32 get_ip_address (void) const; - - /// Return @c true if the IP address is INADDR_ANY or IN6ADDR_ANY. - bool is_any (void) const; - - /// Return @c true if the IP address is IPv4/IPv6 loopback address. - bool is_loopback (void) const; - - /// Return @c true if the IP address is IPv4/IPv6 multicast address. - bool is_multicast (void) const; - -#if defined (ACE_HAS_IPV6) - /// Return @c true if the IP address is IPv6 linklocal address. - bool is_linklocal (void) const; - - /// Return @c true if the IP address is IPv4-mapped IPv6 address. - bool is_ipv4_mapped_ipv6 (void) const; - - /// Return @c true if the IP address is IPv4-compatible IPv6 address. - bool is_ipv4_compat_ipv6 (void) const; -#endif /* ACE_HAS_IPV6 */ - - /** - * Returns @c true if @c this is less than @a rhs. In this context, - * "less than" is defined in terms of IP address and TCP port - * number. This operator makes it possible to use @c ACE_INET_Addrs - * in STL maps. - */ - bool operator < (const ACE_INET_Addr &rhs) const; - - /// Compare two addresses for equality. The addresses are considered - /// equal if they contain the same IP address and port number. - bool operator == (const ACE_INET_Addr &SAP) const; - - /// Compare two addresses for inequality. - bool operator != (const ACE_INET_Addr &SAP) const; - - /// A variation of the equality operator, this method only compares the - /// IP address and ignores the port number. - bool is_ip_equal (const ACE_INET_Addr &SAP) const; - - /// Computes and returns hash value. - virtual u_long hash (void) const; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - /// Insure that @a hostname is properly null-terminated. - int get_host_name_i (char hostname[], size_t hostnamelen) const; - - // Methods to gain access to the actual address of - // the underlying internet address structure. - void *ip_addr_pointer (void) const; - int ip_addr_size (void) const; - int determine_type (void) const; - - /// Initialize underlying inet_addr_ to default values - void reset (void); - - /// Underlying representation. - /// This union uses the knowledge that the two structures share the - /// first member, sa_family (as all sockaddr structures do). - union - { - sockaddr_in in4_; -#if defined (ACE_HAS_IPV6) - sockaddr_in6 in6_; -#endif /* ACE_HAS_IPV6 */ - } inet_addr_; - -#if defined (ACE_VXWORKS) - char buf_[INET_ADDR_LEN]; -#endif -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/INET_Addr.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_INET_ADDR_H */ diff --git a/ACE/ace/INET_Addr.inl b/ACE/ace/INET_Addr.inl deleted file mode 100644 index a05a80db7fb..00000000000 --- a/ACE/ace/INET_Addr.inl +++ /dev/null @@ -1,257 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - - -#include "ace/OS_NS_string.h" -#include "ace/Global_Macros.h" -#include "ace/OS_NS_arpa_inet.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE void -ACE_INET_Addr::reset (void) -{ - ACE_OS::memset (&this->inet_addr_, 0, sizeof (this->inet_addr_)); - if (this->get_type() == AF_INET) - { -#ifdef ACE_HAS_SOCKADDR_IN_SIN_LEN - this->inet_addr_.in4_.sin_len = sizeof (this->inet_addr_.in4_); -#endif - this->inet_addr_.in4_.sin_family = AF_INET; - } -#if defined (ACE_HAS_IPV6) - else if (this->get_type() == AF_INET6) - { -#ifdef ACE_HAS_SOCKADDR_IN6_SIN6_LEN - this->inet_addr_.in6_.sin6_len = sizeof (this->inet_addr_.in6_); -#endif - this->inet_addr_.in6_.sin6_family = AF_INET6; - } -#endif /* ACE_HAS_IPV6 */ -} - -ACE_INLINE int -ACE_INET_Addr::determine_type (void) const -{ -#if defined (ACE_HAS_IPV6) -# if defined (ACE_USES_IPV4_IPV6_MIGRATION) - return ACE::ipv6_enabled () ? AF_INET6 : AF_INET; -# else - return AF_INET6; -# endif /* ACE_USES_IPV4_IPV6_MIGRATION */ -#else - return AF_INET; -#endif /* ACE_HAS_IPV6 */ -} - -ACE_INLINE void * -ACE_INET_Addr::ip_addr_pointer (void) const -{ -#if defined (ACE_HAS_IPV6) - if (this->get_type () == PF_INET) - return (void*)&this->inet_addr_.in4_.sin_addr; - else - return (void*)&this->inet_addr_.in6_.sin6_addr; -#else - return (void*)&this->inet_addr_.in4_.sin_addr; -#endif -} - -ACE_INLINE int -ACE_INET_Addr::ip_addr_size (void) const -{ - // Since this size value is used to pass to other host db-type - // functions (gethostbyaddr, etc.) the length is of int type. - // Thus, cast all these sizes back to int. They're all well - // within the range of an int anyway. -#if defined (ACE_HAS_IPV6) - if (this->get_type () == PF_INET) - return static_cast (sizeof this->inet_addr_.in4_.sin_addr); - else - return static_cast (sizeof this->inet_addr_.in6_.sin6_addr); -#else - // These _UNICOS changes were picked up from pre-IPv6 code in - // get_host_name_i... the IPv6 section above may need something - // similar, so keep an eye out for it. -# if !defined(_UNICOS) - return static_cast (sizeof this->inet_addr_.in4_.sin_addr.s_addr); -# else /* _UNICOS */ - return static_cast (sizeof this->inet_addr_.in4_.sin_addr); -# endif /* ! _UNICOS */ -#endif /* ACE_HAS_IPV6 */ -} - -// Return the port number, converting it into host byte order... - -ACE_INLINE u_short -ACE_INET_Addr::get_port_number (void) const -{ - ACE_TRACE ("ACE_INET_Addr::get_port_number"); -#if defined (ACE_LACKS_NTOHS) - ACE_NOTSUP_RETURN (0); -#elif defined (ACE_HAS_IPV6) - if (this->get_type () == PF_INET) - return ntohs (this->inet_addr_.in4_.sin_port); - else - return ntohs (this->inet_addr_.in6_.sin6_port); -#else - return ntohs (this->inet_addr_.in4_.sin_port); -#endif /* ACE_HAS_IPV6 */ -} - -ACE_INLINE int -ACE_INET_Addr::get_addr_size (void) const -{ - ACE_TRACE ("ACE_INET_Addr::get_addr_size"); -#if defined (ACE_HAS_IPV6) - if (this->get_type () == PF_INET) - return sizeof this->inet_addr_.in4_; - else - return sizeof this->inet_addr_.in6_; -#else - return sizeof this->inet_addr_.in4_; -#endif /* ACE_HAS_IPV6 */ -} - -ACE_INLINE bool -ACE_INET_Addr::operator < (const ACE_INET_Addr &rhs) const -{ -#if defined (ACE_HAS_IPV6) - if (this->get_type() != rhs.get_type()) - { - return this->get_type() < rhs.get_type(); - } - - if (this->get_type() == PF_INET6) - { - int memval = ACE_OS::memcmp (this->ip_addr_pointer(), - rhs.ip_addr_pointer(), - this->ip_addr_size()); - - return memval < 0 - || (memval == 0 - && (this->get_port_number() < rhs.get_port_number() - || (this->get_port_number() == rhs.get_port_number() - && this->inet_addr_.in6_.sin6_scope_id < - rhs.inet_addr_.in6_.sin6_scope_id))); - } -#endif - - return this->get_ip_address () < rhs.get_ip_address () - || (this->get_ip_address () == rhs.get_ip_address () - && this->get_port_number () < rhs.get_port_number ()); -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE int -ACE_INET_Addr::set (u_short port_number, - const wchar_t host_name[], - int encode, - int address_family) -{ - return this->set (port_number, - ACE_Wide_To_Ascii (host_name).char_rep (), - encode, - address_family); -} - -ACE_INLINE int -ACE_INET_Addr::set (const wchar_t port_name[], - const wchar_t host_name[], - const wchar_t protocol[]) -{ - return this->set (ACE_Wide_To_Ascii (port_name).char_rep (), - ACE_Wide_To_Ascii (host_name).char_rep (), - ACE_Wide_To_Ascii (protocol).char_rep ()); -} - -ACE_INLINE int -ACE_INET_Addr::set (const wchar_t port_name[], - ACE_UINT32 ip_addr, - const wchar_t protocol[]) -{ - return this->set (ACE_Wide_To_Ascii (port_name).char_rep (), - ip_addr, - ACE_Wide_To_Ascii (protocol).char_rep ()); -} - -ACE_INLINE int -ACE_INET_Addr::set (const wchar_t addr[], int address_family) -{ - return this->set (ACE_Wide_To_Ascii (addr).char_rep (), address_family); -} - -#endif /* ACE_HAS_WCHAR */ - -// Return @c true if the IP address is INADDR_ANY or IN6ADDR_ANY. -ACE_INLINE bool -ACE_INET_Addr::is_any (void) const -{ -#if defined (ACE_HAS_IPV6) - if (this->get_type () == AF_INET6) - return IN6_IS_ADDR_UNSPECIFIED (&this->inet_addr_.in6_.sin6_addr); -#endif /* ACE_HAS_IPV6 */ - - return (this->inet_addr_.in4_.sin_addr.s_addr == INADDR_ANY); -} - -// Return @c true if the IP address is IPv4/IPv6 loopback address. -ACE_INLINE bool -ACE_INET_Addr::is_loopback (void) const -{ -#if defined (ACE_HAS_IPV6) - if (this->get_type () == AF_INET6) - return IN6_IS_ADDR_LOOPBACK (&this->inet_addr_.in6_.sin6_addr); -#endif /* ACE_HAS_IPV6 */ - - // RFC 3330 defines loopback as any address with 127.x.x.x - return ((this->get_ip_address () & 0XFF000000) == (INADDR_LOOPBACK & 0XFF000000)); -} - -// Return @c true if the IP address is IPv4/IPv6 multicast address. -ACE_INLINE bool -ACE_INET_Addr::is_multicast (void) const -{ -#if defined (ACE_HAS_IPV6) - if (this->get_type() == AF_INET6) - return this->inet_addr_.in6_.sin6_addr.s6_addr[0] == 0xFF; -#endif /* ACE_HAS_IPV6 */ - return - this->inet_addr_.in4_.sin_addr.s_addr >= 0xE0000000 && // 224.0.0.0 - this->inet_addr_.in4_.sin_addr.s_addr <= 0xEFFFFFFF; // 239.255.255.255 -} - -#if defined (ACE_HAS_IPV6) -// Return @c true if the IP address is IPv6 linklocal address. -ACE_INLINE bool -ACE_INET_Addr::is_linklocal (void) const -{ - if (this->get_type () == AF_INET6) - return IN6_IS_ADDR_LINKLOCAL (&this->inet_addr_.in6_.sin6_addr); - - return false; -} - -// Return @c true if the IP address is IPv4 mapped IPv6 address. -ACE_INLINE bool -ACE_INET_Addr::is_ipv4_mapped_ipv6 (void) const -{ - if (this->get_type () == AF_INET6) - return IN6_IS_ADDR_V4MAPPED (&this->inet_addr_.in6_.sin6_addr); - - return false; -} - -// Return @c true if the IP address is IPv4-compatible IPv6 address. -ACE_INLINE bool -ACE_INET_Addr::is_ipv4_compat_ipv6 (void) const -{ - if (this->get_type () == AF_INET6) - return IN6_IS_ADDR_V4COMPAT (&this->inet_addr_.in6_.sin6_addr); - - return false; -} -#endif /* ACE_HAS_IPV6 */ - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/IOStream.cpp b/ACE/ace/IOStream.cpp deleted file mode 100644 index 23790425eeb..00000000000 --- a/ACE/ace/IOStream.cpp +++ /dev/null @@ -1,665 +0,0 @@ -// $Id$ - -#ifndef ACE_IOSTREAM_CPP -#define ACE_IOSTREAM_CPP - -#include "ace/IOStream.h" - -ACE_RCSID(ace, IOStream, "$Id$") - -#if !defined (ACE_LACKS_ACE_IOSTREAM) - -# include "ace/OS_NS_errno.h" -# include "ace/OS_Memory.h" - -/////////////////////////////////////////////////////////////////////////// - -/* Here's a simple example of how iostream's non-virtual operators can - get you in a mess: - - class myiostream : public iostream - { - public: - myiostream& operator>> (String & s) - { - ... - } - }; - - ... - - int i; - String s; - myiostream foo (...); - - foo >> s; - // OK - // invokes myiostream::operator>> (String&) returning myiostream& - - foo >> i; - // OK - // invokes iostream::operator>> (int&) returning iostream& - - foo >> i >> s; - // BAD - // invokes iostream::operator>> (int&) then iostream::operator>> (String&) - // - // What has happened is that the first >> is invoked on the base class and returns - // a reference to iostream. The second >> has no idea of the ACE_IOStream and - // gets invoked on iostream. Probably NOT what you wanted! - - - // In order to make all of this work the way you want, you have to do this: - - class myiostream : public iostream - { - public: - myiostream& operator>> (int & i) - { - return ((myiostream&)iostream::operator>> (i)); - } - - myiostream& operator>> (String & s) - { - ... - } - }; - - ... - - int i; - String s; - myiostream foo (...); - - foo >> s; - // OK - // invokes myiostream::operator>> (String&) returning myiostream& - - foo >> i; - // OK - // invokes myiostream::operator>> (int&) returning myiostream& - - - foo >> i >> s; - // OK - // Because you provided operator>> (int&) in class myiostream, that - // function will be invoked by the first >>. Since it returns - // a myiostream&, the second >> will be invoked as desired. */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_HANDLE -ACE_Streambuf::get_handle (void) -{ - return 0; -} - -ACE_Time_Value * -ACE_Streambuf::recv_timeout (ACE_Time_Value *tv) -{ - ACE_Time_Value * rval = recv_timeout_; - if (tv) - { - recv_timeout_value_ = *tv; - recv_timeout_ = &recv_timeout_value_; - } - else - recv_timeout_ = 0; - - return rval; -} - -int -ACE_Streambuf::underflow (void) -{ - // If input mode is not set, any attempt to read from the stream is - // a failure. - - if (ACE_BIT_DISABLED (mode_, ios::in)) - return EOF; - - // If base () is empty then this is the first time any get/put - // operation has been attempted on the stream. - - if (!this->base ()) - { - // Set base () to use our private read buffer. The arguments are: - // beginning of the buffer (base ()) - // one-beyond the end of the buffer (ebase ()) - // should base () be deleted on destruction - // - // We have to say "no" to the third parameter because we want to - // explicitly handle deletion of the TWO buffers at destruction. - - setb (this->eback_saved_, - this->eback_saved_ + streambuf_size_, 0); - - // Remember that we are now in getMode. This will help us if - // we're called prior to a mode change as well as helping us - // when the mode does change. - this->cur_mode_ = this->get_mode_; - // Using the new values for base (), initialize the get area. - // This simply sets eback (), gptr () and egptr () described - // earlier. - setg (base (), base (), base ()); - - // Set the put buffer such that puts will be disabled. Any - // attempt to put data will now cause overflow to be invoked. - setp (0, 0); - } - else // base () has been initialized already... - { - // If we are in put_mode_ now, then it is time to switch to get_mode_ - // - // 1. get rid of any pending output - // 2. rearrange base () to use our half of the buffer - // 3. reset the mode - // - if (this->cur_mode_ == this->put_mode_) - { - // Dump any pending output to the peer. This is not really - // necessary because of the dual-buffer arrangement we've - // set up but intuitively it makes sense to send the pending - // data before we request data since the peer will probably - // need what we're sending before it can respond. - if (out_waiting () && syncout () == EOF) - return EOF; - - if( ! pbase() ) - { - delete [] pbase_saved_; - (void) reset_put_buffer(); - } - else - { - // We're about to disable put mode but before we do - // that, we want to preserve it's state. - this->pbase_saved_ = pbase (); - this->pptr_saved_ = pptr (); - this->epptr_saved_ = epptr (); - } - - // Disable put mode as described in the constructor. - setp (0, 0); - - // Like the case where base () is false, we now point base - // () to use our private get buffer. - setb (this->eback_saved_, - this->eback_saved_ + streambuf_size_, - 0); - - // And restore the previous state of the get pointers. - - setg (this->eback_saved_, this->gptr_saved_, - this->egptr_saved_); - - // Finally, set our mode so that we don't get back into this - // if () and so that overflow can operate correctly. - cur_mode_ = get_mode_; - } - - // There could be data in the input buffer if we switched to put - // mode before reading everything. In that case, we take this - // opportunity to feed it back to the iostream. - if (in_avail ()) - // Remember that we return an int so that we can give back - // EOF. The explicit cast prevents us from returning a signed - // char when we're not returning EOF. - return (u_char) *gptr (); - } - - // We really shouldn't be here unless there is a lack of data in the - // read buffer. So... go get some more data from the peer. - - int result = fillbuf (); - - // Fillbuf will give us EOF if there was an error with the peer. In - // that case, we can do no more input. - - if (EOF == result) - { - // Disable ourselves and return failure to the iostream. That - // should result in a call to have oursleves closed. - setg (0, 0, 0); - return EOF; - } - - // Return the next available character in the input buffer. Again, - // we protect against sign extension. - - return (u_char) *gptr (); -} - -// Much of this is similar to underflow. I'll just hit the highlights -// rather than repeating a lot of what you've already seen. - -int -ACE_Streambuf::overflow (int c) -{ - // Check to see if output is allowed at all. - if (! (mode_ & ios::out)) - return EOF; - - if (!base ()) - { - // Set base () to use put's private buffer. - // - setb (this->pbase_saved_, - this->pbase_saved_ + streambuf_size_, 0); - - // Set the mode for optimization. - this->cur_mode_ = this->put_mode_; - // Set the put area using the new base () values. - setp (base (), ebuf ()); - - // Disable the get area. - setg (0, 0, 0); - } - else // We're already reading or writing - { - // If we're coming out of get mode... - if (this->cur_mode_ == this->get_mode_) - { - // --> JCEJ 6/6/98 - if (! eback()) - { - /* Something has happened to cause the streambuf - to get rid of our get area. - We could probably do this a bit cleaner but - this method is sure to cleanup the bits and - pieces. - */ - delete [] eback_saved_; - (void) reset_get_buffer(); - } - else - { - // Save the current get mode values - this->eback_saved_ = eback (); - this->gptr_saved_ = gptr (); - this->egptr_saved_ = egptr (); - } - // <-- JCEJ 6/6/98 - - // then disable the get buffer - setg (0, 0, 0); - - // Reconfigure base () and restore the put pointers. - setb (pbase_saved_, pbase_saved_ + streambuf_size_, 0); - setp (base (), ebuf ()); - - // Save the new mode. - this->cur_mode_ = this->put_mode_; - } - - // If there is output to be flushed, do so now. We shouldn't - // get here unless this is the case... - - if (out_waiting () && EOF == syncout ()) - return EOF; - } - - // If we're not putting EOF, then we have to deal with the character - // that is being put. Perhaps we should do something special with EOF??? - - if (c != EOF) - { - // We've already written any data that may have been in the - // buffer, so we're guaranteed to have room in the buffer for - // this new information. So... we add it to the buffer and - // adjust our 'next' pointer acordingly. - *pptr () = (char) c; - pbump (1); - } - - return 0; -} - -// syncin - -int -ACE_Streambuf::syncin (void) -{ - // As discussed, there really isn't any way to sync input from a - // socket-like device. We specifially override this base-class - // function so that it won't do anything evil to us. - return 0; -} - -// syncout - -int -ACE_Streambuf::syncout (void) -{ - // Unlike syncin, syncout is a doable thing. All we have to do is - // write whatever is in the output buffer to the peer. flushbuf () - // is how we do it. - - if (flushbuf () == EOF) - return EOF; - else - return 0; -} - -int -ACE_Streambuf::sync (void) -{ - // sync () is fairly traditional in that it syncs both input and - // output. We could have omitted the call to syncin () but someday, - // we may want it to do something. - - syncin (); - - // Don't bother syncing the output unless there is data to be - // sent... - - if (out_waiting ()) - return syncout (); - else - return 0; -} - -// flushbuf - -int -ACE_Streambuf::flushbuf (void) -{ - // pptr () is one character beyond the last character put into the - // buffer. pbase () points to the beginning of the put buffer. - // Unless pptr () is greater than pbase () there is nothing to be - // sent to the peer. - - if (pptr () <= pbase ()) - return 0; - - // 4/12/97 -- JCEJ - // Kludge!!! - // If the remote side shuts down the connection, an attempt to send - // () to the remote will result in the message 'Broken Pipe' I think - // this is an OS message, I've tracked it down to the ACE_OS::write - // () function. That's the last one to be called before the - // message. I can only test this on Linux though, so I don't know - // how other systems will react. - // - // To get around this gracefully, I do a PEEK recv () with an - // immediate (nearly) timeout. recv () is much more graceful on - // it's failure. If we get -1 from recv () not due to timeout then - // we know we're SOL. - // - // Q: Is 'errno' threadsafe? Should the section below be a - // critical section? - // - // char tbuf[1]; - // ACE_Time_Value to (0,1); - // if (this->recv (tbuf, 1, MSG_PEEK, &to) == -1) - // { - // if (errno != ETIME) - // { - // perror ("OOPS preparing to send to peer"); - // return EOF; - // } - // } - // - // The correct way to handle this is for the application to trap - // (and ignore?) SIGPIPE. Thanks to Amos Shapira for reminding me - // of this. - - // Starting at the beginning of the buffer, send as much data as - // there is waiting. send guarantees that all of the data will be - // sent or an error will be returned. - - if (this->send (pbase (), pptr () - pbase ()) == -1) - return EOF; - - // Now that we've sent everything in the output buffer, we reset the - // buffer pointers to appear empty. - setp (base (), ebuf ()); - - return 0; -} - -int -ACE_Streambuf::get_one_byte (void) -{ - this->timeout_ = 0; - - // The recv function will return immediately if there is no data - // waiting. So, we use recv_n to wait for exactly one byte to come - // from the peer. Later, we can use recv to see if there is - // anything else in the buffer. (Ok, we could use flags to tell it - // to block but I like this better.) - - if (this->recv_n (base (), 1, MSG_PEEK, this->recv_timeout_) != 1) - { - if (errno == ETIME) - this->timeout_ = 1; - return EOF; - } - else - return 1; -} - -// This will be called when the read (get) buffer has been exhausted -// (ie -- gptr == egptr). - -int -ACE_Streambuf::fillbuf (void) -{ - // Invoke recv_n to get exactly one byte from the remote. This will - // block until something shows up. - - if (get_one_byte () == EOF) - return EOF; - - // Now, get whatever else may be in the buffer. This will return if - // there is nothing in the buffer. - - int bc = this->recv (base (), blen (), this->recv_timeout_); - - // recv will give us -1 if there was a problem. If there was - // nothing waiting to be read, it will give us 0. That isn't an - // error. - - if (bc < 0) - { - if (errno == ETIME) - this->timeout_ = 1; - return EOF; - } - - // Move the get pointer to reflect the number of bytes we just read. - - setg (base (), base (), base () + bc); - - // Return the byte-read-count including the one from . - return bc; -} - -ACE_Streambuf::ACE_Streambuf (u_int streambuf_size, int io_mode) - : eback_saved_ (0), // to avoid Purify UMR - pbase_saved_ (0), // to avoid Purify UMR - get_mode_ (1), - put_mode_ (2), - mode_ (io_mode), - streambuf_size_ (streambuf_size), - recv_timeout_ (0) -{ - (void)reset_get_buffer (); - (void)reset_put_buffer (); -} - -u_int -ACE_Streambuf::streambuf_size (void) -{ - return streambuf_size_; -} - -// Return the number of bytes not yet gotten. eback + get_waiting = -// gptr. - -u_int -ACE_Streambuf::get_waiting (void) -{ - return this->gptr_saved_ - this->eback_saved_; -} - -// Return the number of bytes in the get area (includes some already -// gotten); eback + get_avail = egptr. - -u_int -ACE_Streambuf::get_avail (void) -{ - return this->egptr_saved_ - this->eback_saved_; -} - -// Return the number of bytes to be 'put' onto the stream media. -// pbase + put_avail = pptr. - -u_int -ACE_Streambuf::put_avail (void) -{ - return this->pptr_saved_ - this->pbase_saved_; -} - -// Typical usage: -// -// u_int newGptr = otherStream->get_waiting (); -// u_int newEgptr = otherStream->get_avail (); -// char * newBuf = otherStream->reset_get_buffer (); -// char * oldgetbuf = myStream->reset_get_buffer (newBuf, otherStream->streambuf_size (), newGptr, newEgptr); -// -// 'myStream' now has the get buffer of 'otherStream' and can use it in any way. -// 'otherStream' now has a new, empty get buffer. - -char * -ACE_Streambuf::reset_get_buffer (char *newBuffer, - u_int _streambuf_size, - u_int _gptr, - u_int _egptr) -{ - char * rval = this->eback_saved_; - - // The get area is where the iostream will get data from. This is - // our read buffer. There are three pointers which describe the - // read buffer: - // - // eback () - The beginning of the buffer. Also the furthest - // point at which putbacks can be done. Hence the name. - // - // gptr () - Where the next character is to be got from. - // - // egptr () - One position beyond the last get-able character. - // - // So that we can switch quicky from read to write mode without - // any data copying, we keep copies of these three pointers in - // the variables below. Initially, they all point to the beginning - // of our read-dedicated buffer. - // - if (newBuffer) - { - if (streambuf_size_ != _streambuf_size) - return 0; - this->eback_saved_ = newBuffer; - } - else - ACE_NEW_RETURN (this->eback_saved_, - char[streambuf_size_], - 0); - - this->gptr_saved_ = this->eback_saved_ + _gptr; - this->egptr_saved_ = this->eback_saved_ + _egptr; - - // Disable the get area initially. This will cause underflow to be - // invoked on the first get operation. - setg (0, 0, 0); - - reset_base (); - - return rval; -} - -// Typical usage: -// -// u_int newPptr = otherStream->put_avail (); -// char * newBuf = otherStream->reset_put_buffer (); -// char * oldputbuf = otherStream->reset_put_buffer (newBuf, otherStream->streambuf_size (), newPptr); - -char * -ACE_Streambuf::reset_put_buffer (char *newBuffer, - u_int _streambuf_size, - u_int _pptr) -{ - char *rval = this->pbase_saved_; - - // The put area is where the iostream will put data that needs to be - // sent to the peer. This becomes our write buffer. The three - // pointers which maintain this area are: - // - // pbase () - The beginning of the put area. - // - // pptr () - Where the next character is to be put. - // - // epptr () - One beyond the last valid position for putting. - // - // Again to switch quickly between modes, we keep copies of - // these three pointers. - // - if (newBuffer) - { - if (streambuf_size_ != _streambuf_size) - return 0; - this->pbase_saved_ = newBuffer; - } - else - ACE_NEW_RETURN (this->pbase_saved_, - char[streambuf_size_], - 0); - - this->pptr_saved_ = this->pbase_saved_ + _pptr; - this->epptr_saved_ = this->pbase_saved_ + streambuf_size_; - - // Disable the put area. Overflow will be called by the first call - // to any put operator. - setp (0, 0); - - reset_base (); - - return rval; -} - -void -ACE_Streambuf::reset_base (void) -{ - // Until we experience the first get or put operation, we do not - // know what our current IO mode is. - this->cur_mode_ = 0; - - // The common area used for reading and writting is called "base". - // We initialize it this way so that the first get/put operation - // will have to "allocate" base. This allocation will set base to - // the appropriate specific buffer and set the mode to the correct - // value. - setb (0, 0); -} - -// If the default allocation strategey were used the common buffer -// would be deleted when the object destructs. Since we are providing -// separate read/write buffers, it is up to us to manage their memory. - -ACE_Streambuf::~ACE_Streambuf (void) -{ - delete [] this->eback_saved_; - delete [] this->pbase_saved_; -} - -u_char ACE_Streambuf::timeout (void) -{ - u_char rval = this->timeout_; - this->timeout_ = 0; - return rval; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* !ACE_LACKS_ACE_IOSTREAM */ -#endif /* ACE_IOSTREAM_CPP */ diff --git a/ACE/ace/IOStream.h b/ACE/ace/IOStream.h deleted file mode 100644 index c8b3f00c541..00000000000 --- a/ACE/ace/IOStream.h +++ /dev/null @@ -1,512 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file IOStream.h - * - * $Id$ - * - * @author James CE Johnson - * @author Jim Crossley - */ -//============================================================================= - -#ifndef ACE_IOSTREAM_H -#define ACE_IOSTREAM_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -// Needed on Windows for streambuf -// FUZZ: disable check_for_streams_include -#include "ace/streams.h" - -// This is a temporary restriction - ACE_IOStream is only enabled if the -// compiler does not supply the standard C++ library (and standard iostreams) -// or, if it does, the platform is explicitly set to use old iostreams -// by its config.h file. -// This restriction is recorded in Bugzilla entry 857. -#if defined (ACE_HAS_STANDARD_CPP_LIBRARY) && (ACE_HAS_STANDARD_CPP_LIBRARY == 1) -# if !defined (ACE_USES_OLD_IOSTREAMS) && !defined (ACE_LACKS_ACE_IOSTREAM) -# define ACE_LACKS_ACE_IOSTREAM -# endif /* !ACE_USES_OLD_IOSTREAMS && !ACE_LACKS_ACE_IOSTREAM */ -#endif /* ACE_HAS_STANDARD_CPP_LIBRARY */ - -#if !defined (ACE_LACKS_ACE_IOSTREAM) - -# if defined (ACE_HAS_STRING_CLASS) -# if defined (ACE_WIN32) && defined (_MSC_VER) -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -typedef CString ACE_IOStream_String; -ACE_END_VERSIONED_NAMESPACE_DECL -# else -# if !defined (ACE_HAS_STDCPP_STL_INCLUDES) -#include /**/ -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -typedef String ACE_IOStream_String; -ACE_END_VERSIONED_NAMESPACE_DECL -# else -# include /**/ - -# if defined(ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -typedef std::string ACE_IOStream_String; -ACE_END_VERSIONED_NAMESPACE_DECL -# else -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -typedef string ACE_IOStream_String; -ACE_END_VERSIONED_NAMESPACE_DECL -# endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */ -# endif /* ! ACE_HAS_STDCPP_STL_INCLUDES */ -# endif /* ACE_WIN32 && defined (_MSC_VER) */ - -# if defined (__DECCXX_VER) -# if __DECCXX_VER < 50700000 -# include /**/ -# else -# include /**/ -# endif /* __DECCXX_VER < 50700000 */ -# endif /* __DECCXX_VER */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -class ACE_Export ACE_Quoted_String : public ACE_IOStream_String -{ -public: - inline ACE_Quoted_String (void) { *this = ""; } - inline ACE_Quoted_String (const char *c) { *this = ACE_IOStream_String (c); } - inline ACE_Quoted_String (const ACE_IOStream_String &s) { *this = s; } - inline ACE_Quoted_String &operator= (const ACE_IOStream_String& s) - { - return (ACE_Quoted_String &) ACE_IOStream_String::operator= (s); - } - inline ACE_Quoted_String &operator = (const char c) { - return (ACE_Quoted_String &) ACE_IOStream_String::operator= (c); - } - inline ACE_Quoted_String &operator = (const char *c) { - return (ACE_Quoted_String &) ACE_IOStream_String::operator= (c); - } - inline bool operator < (const ACE_Quoted_String &s) const { - return *(ACE_IOStream_String *) this < (ACE_IOStream_String) s; - } -# if defined (ACE_WIN32) && defined (_MSC_VER) - inline int length (void) { return this->GetLength (); } -# endif /* ACE_WIN32 && defined (_MSC_VER) */ -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -# endif /* ACE_HAS_STRING_CLASS */ - -# include "ace/Time_Value.h" -# include "ace/os_include/sys/os_types.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Streambuf - * - * @brief Create your custom streambuf by providing and ACE_*_Stream - * object to this template. I have tested it with - * ACE_SOCK_Stream and it should work fine for others as well. - * - * For any iostream object, the real work is done by the - * underlying streambuf class. That is what we create here. - * A streambuf has an internal buffer area into which data is - * read and written as the iostream requests and provides data. - * At some point during the read process, the iostream will - * realize that the streambuf has no more data. The underflow - * function of the streambuf is then called. - * Likewise, during the write process, the iostream will - * eventually notice that the streabuf's buffer has become full - * and will invoke the overflow function. - * The empty/full state of the read/write "buffers" are - * controled by two sets pointers. One set is dedicated to - * read, the other to write. These pointers, in turn, reference - * a common buffer that is to be shared by both read and write - * operations. It is this common buffer to which data is - * written and from which it is read. - * The common buffer is used by functions of the streambuf as - * well as the iostream. Because of this and the fact that it - * is "shared" by both read and write operators, there is a - * danger of data corruption if read and write operations are - * allowed to take place "at the same time". - * To prevent data corruption, we manipulate the read and write - * pointer sets so that the streambuf is in either a read-mode - * or write-mode at all times and can never be in both modes at - * the same time. - * In the constructor: set the read and write sets to NULL This - * causes the underflow or overflow operators to be invoked at - * the first IO activity of the iostream. - * In the underflow function we arrange for the common buffer to - * reference our read buffer and for the write pointer set to be - * disabled. If a write operation is performed by the iostream - * this will cause the overflow function to be invoked. - * In the overflow function we arrange for the common buffer to - * reference our write buffer and for the read pointer set to be - * disabled. This causes the underflow function to be invoked - * when the iostream "changes our mode". - * The overflow function will also invoke the send_n function to - * flush the buffered data to our peer. Similarly, the sync and - * syncout functions will cause send_n to be invoked to send the - * data. - * Since socket's and the like do not support seeking, there can - * be no method for "syncing" the input. However, since we - * maintain separate read/write buffers, no data is lost by - * "syncing" the input. It simply remains buffered. - */ -class ACE_Export ACE_Streambuf : public streambuf -{ -public: - - /** - * If the default allocation strategey were used the common buffer - * would be deleted when the object destructs. Since we are - * providing separate read/write buffers, it is up to us to manage - * their memory. - */ - virtual ~ACE_Streambuf (void); - - /// Get the current Time_Value pointer and provide a new one. - ACE_Time_Value *recv_timeout (ACE_Time_Value *tv = 0); - - /** - * Use this to allocate a new/different buffer for put operations. - * If you do not provide a buffer pointer, one will be allocated. - * That is the preferred method. If you do provide a buffer, the - * size must match that being used by the get buffer. If - * successful, you will receive a pointer to the current put buffer. - * It is your responsibility to delete this memory when you are done - * with it. - */ - char *reset_put_buffer (char *newBuffer = 0, - u_int _streambuf_size = 0, - u_int _pptr = 0 ); - - /// Return the number of bytes to be 'put' onto the stream media. - /// pbase + put_avail = pptr - u_int put_avail (void); - - /** - * Use this to allocate a new/different buffer for get operations. - * If you do not provide a buffer pointer, one will be allocated. - * That is the preferred method. If you do provide a buffer, the - * size must match that being used by the put buffer. If - * successful, you will receive a pointer to the current get buffer. - * It is your responsibility to delete this memory when you are done - * with it. - */ - char *reset_get_buffer (char *newBuffer = 0, - u_int _streambuf_size = 0, - u_int _gptr = 0, - u_int _egptr = 0); - - /// Return the number of bytes not yet gotten. eback + get_waiting = - /// gptr - u_int get_waiting (void); - - /// Return the number of bytes in the get area (includes some already - /// gotten); eback + get_avail = egptr - u_int get_avail (void); - - /// Query the streambuf for the size of its buffers. - u_int streambuf_size (void); - - /// Did we take an error because of an IO operation timeout? - /// @note Invoking this resets the flag. - u_char timeout (void); - -protected: - ACE_Streambuf (u_int streambuf_size, - int io_mode); - - /// Sync both input and output. See syncin/syncout below for - /// descriptions. - virtual int sync (void); - - // = Signatures for the underflow/overflow discussed above. - virtual int underflow (void); - - /// The overflow function receives the character which caused the - /// overflow. - virtual int overflow (int c = EOF); - - /// Resets the pointer and streambuf mode. This is used - /// internally when get/put buffers are allocatd. - void reset_base (void); - -protected: - // = Two pointer sets for manipulating the read/write areas. - char *eback_saved_; - char *gptr_saved_; - char *egptr_saved_; - char *pbase_saved_; - char *pptr_saved_; - char *epptr_saved_; - - // = With cur_mode_ we keep track of our current IO mode. - - // This helps us to optimize the underflow/overflow functions. - u_char cur_mode_; - const u_char get_mode_; - const u_char put_mode_; - - /// mode tells us if we're working for an istream, ostream, or - /// iostream. - int mode_; - - /// This defines the size of the input and output buffers. It can be - /// set by the object constructor. - const u_int streambuf_size_; - - /// Did we take an error because of an IO operation timeout? - u_char timeout_; - - /// We want to allow the user to provide Time_Value pointers to - /// prevent infinite blocking while waiting to receive data. - ACE_Time_Value recv_timeout_value_; - ACE_Time_Value *recv_timeout_; - - /** - * syncin is called when the input needs to be synced with the - * source file. In a filebuf, this results in the system - * call being used. We can't do that on socket-like connections, so - * this does basically nothing. That's safe because we have a - * separate read buffer to maintain the already-read data. In a - * filebuf, the single common buffer is used forcing the - * call. - */ - int syncin (void); - - /// syncout is called when the output needs to be flushed. This is - /// easily done by calling the peer's send_n function. - int syncout (void); - - /// flushbuf is the worker of syncout. It is a separate function - /// because it gets used sometimes in different context. - int flushbuf (void); - - /** - * fillbuf is called in a couple of places. This is the worker of - * underflow. It will attempt to fill the read buffer from the - * peer. - */ - int fillbuf (void); - - /** - * Used by fillbuf and others to get exactly one byte from the peer. - * recv_n is used to be sure we block until something is available. - * It is virtual because we really need to override it for - * datagram-derived objects. - */ - virtual int get_one_byte (void); - - /** - * Stream connections and "unconnected connections" (ie -- - * datagrams) need to work just a little differently. We derive - * custom Streambuf objects for them and provide these functions at - * that time. - */ - virtual ssize_t send (char *buf, - ssize_t len) = 0; - virtual ssize_t recv (char *buf, - ssize_t len, - ACE_Time_Value *tv = 0) = 0; - virtual ssize_t recv (char *buf, - ssize_t len, - int flags, - ACE_Time_Value *tv = 0) = 0; - virtual ssize_t recv_n (char *buf, - ssize_t len, - int flags = 0, - ACE_Time_Value *tv = 0) = 0; - - virtual ACE_HANDLE get_handle (void); - -# if defined (ACE_HAS_STANDARD_CPP_LIBRARY) && (ACE_HAS_STANDARD_CPP_LIBRARY != 0) && !defined (ACE_USES_OLD_IOSTREAMS) - char *base (void) const - { - return cur_mode_ == get_mode_ ? eback_saved_ - : cur_mode_ == put_mode_ ? pbase_saved_ - : 0; - } - char *ebuf (void) const - { - return cur_mode_ == 0 ? 0 : base () + streambuf_size_; - } - - int blen (void) const - { - return streambuf_size_; - } - - void setb (char* b, char* eb, int /* a */=0) - { - setbuf (b, (eb - b)); - } - - int out_waiting (void) - { - return pptr () - pbase (); - } -# endif /* ACE_HAS_STANDARD_CPP_LIBRARY */ -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -/////////////////////////////////////////////////////////////////////////// - -// These typedefs are provided by G++ (on some systems?) without the -// trailing '_'. Since we can't count on 'em, I've defined them to -// what GNU wants here. -// -typedef ios& (*__manip_)(ios&); -typedef istream& (*__imanip_)(istream&); -typedef ostream& (*__omanip_)(ostream&); - -// Trying to do something like is shown below instead of using the -// __*manip typedefs causes Linux do segfault when "< and functions are used. - -#define GET_SIG(MT,DT) inline virtual MT& operator>> (DT v) -# if (defined (__SUNPRO_CC) && __SUNPRO_CC > 0x510) -#define GET_CODE { \ - if (ipfx (0)) \ - { \ - (*((istream*)this)) >> (v); \ - } \ - isfx (); \ - return *this; \ - } -# else -#define GET_CODE { \ - if (ipfx (0)) \ - { \ - iostream::operator>> (v); \ - } \ - isfx (); \ - return *this; \ - } -# endif -#define GET_PROT(MT,DT,CODE) GET_SIG(MT,DT) CODE -#define GET_FUNC(MT,DT) GET_PROT(MT,DT,GET_CODE) - -// This macro defines the put operator for class MT into datatype DT. -// We will use it below to quickly override most (all?) iostream put -// operators. Notice how the and functions are used. - -#define PUT_SIG(MT,DT) inline virtual MT& operator<< (DT v) -# if (defined (__SUNPRO_CC) && __SUNPRO_CC > 0x510) -#define PUT_CODE { \ - if (opfx ()) \ - { \ - (*((ostream *) this)) << (v); \ - } \ - osfx (); \ - return *this; \ - } -# else -#define PUT_CODE { \ - if (opfx ()) \ - { \ - iostream::operator<< (v); \ - } \ - osfx (); \ - return *this; \ - } -# endif -#define PUT_PROT(MT,DT,CODE) PUT_SIG(MT,DT) CODE -#define PUT_FUNC(MT,DT) PUT_PROT(MT,DT,PUT_CODE) - - -// These are necessary in case somebody wants to derive from us and -// override one of these with a custom approach. - -# if defined (ACE_LACKS_CHAR_RIGHT_SHIFTS) -#define GET_FUNC_SET0(MT,CODE,CODE2) \ - GET_PROT(MT,short &,CODE) \ - GET_PROT(MT,u_short &,CODE) \ - GET_PROT(MT,int &,CODE) \ - GET_PROT(MT,u_int &,CODE) \ - GET_PROT(MT,long &,CODE) \ - GET_PROT(MT,u_long &,CODE) \ - GET_PROT(MT,float &,CODE) \ - GET_PROT(MT,double &,CODE) \ - inline virtual MT& operator>>(__omanip_ func) CODE2 \ - inline virtual MT& operator>>(__manip_ func) CODE2 -# else -#define GET_FUNC_SET0(MT,CODE,CODE2) \ - GET_PROT(MT,short &,CODE) \ - GET_PROT(MT,u_short &,CODE) \ - GET_PROT(MT,int &,CODE) \ - GET_PROT(MT,u_int &,CODE) \ - GET_PROT(MT,long &,CODE) \ - GET_PROT(MT,u_long &,CODE) \ - GET_PROT(MT,float &,CODE) \ - GET_PROT(MT,double &,CODE) \ - GET_PROT(MT,char &,CODE) \ - GET_PROT(MT,u_char &,CODE) \ - GET_PROT(MT,char *,CODE) \ - GET_PROT(MT,u_char *,CODE) \ - inline virtual MT& operator>>(__omanip_ func) CODE2 \ - inline virtual MT& operator>>(__manip_ func) CODE2 -# endif - -#define PUT_FUNC_SET0(MT,CODE,CODE2) \ - PUT_PROT(MT,short,CODE) \ - PUT_PROT(MT,u_short,CODE) \ - PUT_PROT(MT,int,CODE) \ - PUT_PROT(MT,u_int,CODE) \ - PUT_PROT(MT,long,CODE) \ - PUT_PROT(MT,u_long,CODE) \ - PUT_PROT(MT,float,CODE) \ - PUT_PROT(MT,double,CODE) \ - PUT_PROT(MT,char,CODE) \ - PUT_PROT(MT,u_char,CODE) \ - PUT_PROT(MT,const char *,CODE) \ - PUT_PROT(MT,u_char *,CODE) \ - PUT_PROT(MT,void *,CODE) \ - inline virtual MT& operator<<(__omanip_ func) CODE2 \ - inline virtual MT& operator<<(__manip_ func) CODE2 - -# if defined (ACE_LACKS_SIGNED_CHAR) - #define GET_FUNC_SET1(MT,CODE,CODE2) GET_FUNC_SET0(MT,CODE,CODE2) - #define PUT_FUNC_SET1(MT,CODE,CODE2) PUT_FUNC_SET0(MT,CODE,CODE2) -# else - #define GET_FUNC_SET1(MT,CODE,CODE2) \ - GET_PROT(MT,signed char &,CODE) \ - GET_PROT(MT,signed char *,CODE) \ - GET_FUNC_SET0(MT,CODE,CODE2) - - #define PUT_FUNC_SET1(MT,CODE,CODE2) \ - PUT_FUNC(MT,signed char) \ - PUT_FUNC(MT,const signed char *) \ - PUT_FUNC_SET0(MT,CODE,CODE2) -# endif /* ACE_LACKS_SIGNED_CHAR */ - -#define GET_MANIP_CODE { if (ipfx ()) { (*func) (*this); } isfx (); return *this; } -#define PUT_MANIP_CODE { if (opfx ()) { (*func) (*this); } osfx (); return *this; } - -#define GET_FUNC_SET(MT) GET_FUNC_SET1(MT,GET_CODE,GET_MANIP_CODE) -#define PUT_FUNC_SET(MT) PUT_FUNC_SET1(MT,PUT_CODE,PUT_MANIP_CODE) -#define GETPUT_FUNC_SET(MT) GET_FUNC_SET(MT) PUT_FUNC_SET(MT) - -#define GET_SIG_SET(MT) GET_FUNC_SET1(MT,= 0;,= 0;) -#define PUT_SIG_SET(MT) PUT_FUNC_SET1(MT,= 0;,= 0;) -#define GETPUT_SIG_SET(MT) GET_SIG_SET(MT) PUT_SIG_SET(MT) - -// Include the templates here. -# include "ace/IOStream_T.h" -#endif /* !ACE_LACKS_ACE_IOSTREAM && ACE_USES_OLD_IOSTREAMS */ - -#include /**/ "ace/post.h" -#endif /* ACE_IOSTREAM_H */ diff --git a/ACE/ace/IOStream_T.cpp b/ACE/ace/IOStream_T.cpp deleted file mode 100644 index 082274256fe..00000000000 --- a/ACE/ace/IOStream_T.cpp +++ /dev/null @@ -1,247 +0,0 @@ -// $Id$ - -#ifndef ACE_IOSTREAM_T_CPP -#define ACE_IOSTREAM_T_CPP - -#include "ace/IOStream_T.h" -#include "ace/OS_Memory.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (ACE_LACKS_ACE_IOSTREAM) - -#if !defined (__ACE_INLINE__) -#include "ace/IOStream_T.inl" -#endif /* !__ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// We will be given a STREAM by the iostream object which creates us. -// See the ACE_IOStream template for how that works. Like other -// streambuf objects, we can be input-only, output-only or both. - -template -ACE_Streambuf_T::ACE_Streambuf_T (STREAM *peer, - u_int streambuf_size, - int io_mode) - : ACE_Streambuf (streambuf_size, io_mode), - peer_ (peer) -{ - // A streambuf allows for unbuffered IO where every character is - // read as requested and written as provided. To me, this seems - // terribly inefficient for socket-type operations, so I've disabled - // it. All of the work would be done by the underflow/overflow - // functions anyway and I haven't implemented anything there to - // support unbuffered IO. - -#if !defined (ACE_LACKS_UNBUFFERED_STREAMBUF) - this->unbuffered (0); -#endif /* ! ACE_LACKS_UNBUFFERED_STREAMBUF */ - - // Linebuffered is similar to unbuffered. Again, I don't have any - // need for this and I don't see the advantage. I believe this - // would have to be supported by underflow/overflow to be effective. -#if !defined (ACE_LACKS_LINEBUFFERED_STREAMBUF) - this->linebuffered (0); -#endif /* ! ACE_LACKS_LINEBUFFERED_STREAMBUF */ -} - -template ssize_t -ACE_Streambuf_T::send (char *buf, ssize_t len) -{ - return peer_->send_n (buf,len); -} - -template ssize_t -ACE_Streambuf_T::recv (char *buf, - ssize_t len, - ACE_Time_Value *tv) -{ - return this->recv (buf, len, 0, tv); -} - -template ssize_t -ACE_Streambuf_T::recv (char *buf, - ssize_t len, - int flags, - ACE_Time_Value * tv) -{ - this->timeout_ = 0; - errno = ESUCCESS; - ssize_t rval = peer_->recv (buf, len, flags, tv); - if (errno == ETIME) - this->timeout_ = 1; - return rval; -} - -template ssize_t -ACE_Streambuf_T::recv_n (char *buf, - ssize_t len, - int flags, - ACE_Time_Value *tv) -{ - this->timeout_ = 0; - errno = ESUCCESS; - ssize_t rval = peer_->recv_n (buf, len, flags, tv); - if (errno == ETIME) - this->timeout_ = 1; - return rval; -} - -template ACE_HANDLE -ACE_Streambuf_T::get_handle (void) -{ - return peer_ ? peer_->get_handle () : 0; -} - -// The typical constructor. This will initiailze your STREAM and then -// setup the iostream baseclass to use a custom streambuf based on -// STREAM. - -template -ACE_IOStream::ACE_IOStream (STREAM &stream, - u_int streambuf_size) - : iostream (0), - STREAM (stream) -{ - ACE_NEW (streambuf_, - ACE_Streambuf_T ((STREAM *) this, - streambuf_size)); - iostream::init (this->streambuf_); -} - -template -ACE_IOStream::ACE_IOStream (u_int streambuf_size) - : iostream (0) -{ - ACE_NEW (this->streambuf_, - ACE_Streambuf_T ((STREAM *) this, - streambuf_size)); - iostream::init (this->streambuf_); -} - -// We have to get rid of the streambuf_ ourselves since we gave it to -// iostream () - -template -ACE_IOStream::~ACE_IOStream (void) -{ - delete this->streambuf_; -} - -// The only ambituity in the multiple inheritance is the close () -// function. - -template int -ACE_IOStream::close (void) -{ - return STREAM::close (); -} - -template ACE_IOStream & -ACE_IOStream::operator>> (ACE_Time_Value *&tv) -{ - ACE_Time_Value *old_tv = this->streambuf_->recv_timeout (tv); - tv = old_tv; - return *this; -} - -#if defined (ACE_HAS_STRING_CLASS) - -// A simple string operator. The base iostream has 'em for char* but -// that isn't always the best thing for a String. If we don't provide -// our own here, we may not get what we want. - -template ACE_IOStream & -ACE_IOStream::operator>> (ACE_IOStream_String &v) -{ - if (ipfx0 ()) - { - char c; - this->get (c); - - for (v = c; - this->get (c) && !isspace (c); - v += c) - continue; - } - - isfx (); - - return *this; -} - -template ACE_IOStream & -ACE_IOStream::operator<< (ACE_IOStream_String &v) -{ - if (opfx ()) - { -#if defined (ACE_WIN32) && defined (_MSC_VER) - for (int i = 0; i < v.GetLength (); ++i) -#else - for (u_int i = 0; i < (u_int) v.length (); ++i) -#endif /* ACE_WIN32 && defined (_MSC_VER) */ - this->put (v[i]); - } - - osfx (); - - return *this; -} - -// A more clever put operator for strings that knows how to deal with -// quoted strings containing back-quoted quotes. - -template STREAM & -operator>> (STREAM &stream, - ACE_Quoted_String &str) -{ - char c; - - if (!(stream >> c)) // eat space up to the first char - // stream.set (ios::eofbit|ios::failbit); - return stream; - - str = ""; // Initialize the string - - // if we don't have a quote, append until we see space - if (c != '"') - for (str = c; stream.get (c) && !isspace (c); str += c) - continue; - else - for (; stream.get (c) && c != '"'; str += c) - if (c == '\\') - { - stream.get (c); - if (c != '"') - str += '\\'; - } - - return stream; -} - -template STREAM & -operator<< (STREAM &stream, - ACE_Quoted_String &str) -{ - stream.put ('"'); - - for (u_int i = 0; i < str.length (); ++i) - { - if (str[i] == '"') - stream.put ('\\'); - stream.put (str[i]); - } - - stream.put ('"'); - - return stream; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_STRING_CLASS */ -#endif /* ACE_LACKS_ACE_IOSTREAM */ -#endif /* ACE_IOSTREAM_T_CPP */ diff --git a/ACE/ace/IOStream_T.h b/ACE/ace/IOStream_T.h deleted file mode 100644 index 9bf90cee122..00000000000 --- a/ACE/ace/IOStream_T.h +++ /dev/null @@ -1,297 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file IOStream_T.h - * - * $Id$ - * - * @author James CE Johnson - * @author Jim Crossley - * - * This file should not be included directly by application - * code. Instead, it should include "ace/IOStream.h". That's because - * we only put some conditional compilations in that file. - */ -//============================================================================= - -#ifndef ACE_IOSTREAM_T_H -#define ACE_IOSTREAM_T_H -#include /**/ "ace/pre.h" - -#include "ace/IOStream.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (ACE_LACKS_ACE_IOSTREAM) - -# include "ace/INET_Addr.h" -# include "ace/Global_Macros.h" - -# if defined (ACE_LACKS_IOSTREAM_FX) -# include "ace/os_include/os_ctype.h" -# endif /**/ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -# if defined (ACE_HAS_STRING_CLASS) -template STREAM & operator>> (STREAM &stream, ACE_Quoted_String &str); -template STREAM & operator<< (STREAM &stream, ACE_Quoted_String &str); -# endif /* defined (ACE_HAS_STRING_CLASS) */ - -template -class ACE_Streambuf_T : public ACE_Streambuf -{ -public: - /** - * We will be given a STREAM by the iostream object which creates - * us. See the ACE_IOStream template for how that works. Like - * other streambuf objects, we can be input-only, output-only or - * both. - */ - ACE_Streambuf_T (STREAM *peer, - u_int streambuf_size = ACE_STREAMBUF_SIZE, - int io_mode = ios::in | ios::out); - - virtual ssize_t send (char *buf, ssize_t len); - - virtual ssize_t recv (char *buf, - ssize_t len, - ACE_Time_Value *tv = 0); - - virtual ssize_t recv (char *buf, - ssize_t len, - int flags, - ACE_Time_Value * tv = 0); - - virtual ssize_t recv_n (char *buf, - ssize_t len, - int flags = 0, - ACE_Time_Value *tv = 0); - -protected: - virtual ACE_HANDLE get_handle (void); - - /// This will be our ACE_SOCK_Stream or similar object. - STREAM *peer_; -}; - -/** - * @class ACE_IOStream - * - * @brief A template adapter for creating an iostream-like object using - * an ACE IPC Stream for the actual I/O. Iostreams use an - * underlying streambuf object for the IO interface. The - * iostream class and derivatives provide you with a host of - * convenient operators that access the streambuf. - * - * We inherit all characteristics of iostream and your - * class. When you create a new class from this template, you - * can use it anywhere you would have used your original - * class. - * To create an iostream for your favorite ACE IPC class (e.g., - * ACE_SOCK_Stream), feed that class to this template's - * parameter, e.g., - * typedef ACE_Svc_Handler - * Service_Handler; - * Because the operators in the iostream class are not virtual, - * you cannot easily provide overloads in your custom - * ACE_IOStream classes. To make these things work correctly, - * you need to overload ALL operators of the ACE_IOStream you - * create. I've attempted to do that here to make things easier - * for you but there are no guarantees. - * In the iostream.cpp file is an example of why it is necessary - * to overload all of the get/put operators when you want to - * customize only one or two. - */ -template -class ACE_IOStream : public iostream, public STREAM -{ -public: - // = Initialization and termination methods. - ACE_IOStream (STREAM &stream, - u_int streambuf_size = ACE_STREAMBUF_SIZE); - - /** - * The default constructor. This will initiailze your STREAM and - * then setup the iostream baseclass to use a custom streambuf based - * on STREAM. - */ - ACE_IOStream (u_int streambuf_size = ACE_STREAMBUF_SIZE); - - /// We have to get rid of the ourselves since we gave it - /// to the base class; - virtual ~ACE_IOStream (void); - - /// The only ambituity in the multiple inheritance is the - /// function. - virtual int close (void); - - /** - * Returns 1 if we're at the end of the , i.e., if the - * connection has closed down or an error has occurred, else 0. - * Under the covers, calls the streambuf's @a timeout function - * which will reset the timeout flag. As as result, you should save - * the return of and check it instead of calling - * successively. - */ - int eof (void) const; - -# if defined (ACE_HAS_STRING_CLASS) - /** - * A simple string operator. The base has them for char* - * but that isn't always the best thing for a . If we don't - * provide our own here, we may not get what we want. - */ - virtual ACE_IOStream &operator>> (ACE_IOStream_String &v); - - /// The converse of the operator. - virtual ACE_IOStream &operator<< (ACE_IOStream_String &v); - -# endif /* ACE_HAS_STRING_CLASS */ - // = Using the macros to provide get/set operators. - GETPUT_FUNC_SET (ACE_IOStream) - -# if defined (ACE_LACKS_IOSTREAM_FX) - virtual int ipfx (int noskip = 0) - { - if (good ()) - { - if (tie () != 0) - tie ()->flush (); - if (!noskip && flags () & skipws) - { - int ch; - while (isspace (ch = rdbuf ()->sbumpc ())) - continue; - if (ch != EOF) - rdbuf ()->sputbackc (ch); - } - if (good ()) - return 1; - } -# if !defined (ACE_WIN32) - // MS VC++ 5.0 doesn't declare setstate. - setstate (failbit); -# endif /* !ACE_WIN32 */ - return (0); - } - virtual int ipfx0 (void) { return ipfx (0); } // Optimized ipfx(0) - virtual int ipfx1 (void) // Optimized ipfx(1) - { - if (good ()) - { - if (tie () != 0) - tie ()->flush (); - if (good ()) - return 1; - } -# if !defined (ACE_WIN32) - // MS VC++ 5.0 doesn't declare setstate. - setstate (failbit); -# endif /* !ACE_WIN32 */ - return (0); - } - virtual void isfx (void) { return; } - virtual int opfx (void) - { - if (good () && tie () != 0) - tie ()->flush (); - return good (); - } - virtual void osfx (void) { if (flags () & unitbuf) flush (); } -# else -# if defined (__GNUC__) - virtual int ipfx0 (void) { return iostream::ipfx0 (); } // Optimized ipfx(0) - virtual int ipfx1 (void) { return iostream::ipfx1 (); } // Optimized ipfx(1) -# else - virtual int ipfx0 (void) { return iostream::ipfx (0); } - virtual int ipfx1 (void) { return iostream::ipfx (1); } -# endif /* __GNUC__ */ - virtual int ipfx (int need = 0) { return iostream::ipfx (need); } - virtual void isfx (void) { iostream::isfx (); } - virtual int opfx (void) { return iostream::opfx (); } - virtual void osfx (void) { iostream::osfx (); } -# endif /* ACE_LACKS_IOSTREAM_FX */ - - /// Allow the programmer to provide a timeout for read operations. - /// Give it a pointer to NULL to block forever. - ACE_IOStream & operator>> (ACE_Time_Value *&tv); - -protected: - /// This is where all of the action takes place. The streambuf_ is - /// the interface to the underlying STREAM. - ACE_Streambuf_T *streambuf_; - -private: - // = Private methods. - - // We move these into the private section so that they cannot be - // used by the application programmer. This is necessary because - // streambuf_ will be buffering IO on the STREAM object. If these - // functions were used in your program, there is a danger of getting - // the datastream out of sync. - ACE_UNIMPLEMENTED_FUNC (ssize_t send (...)) - ACE_UNIMPLEMENTED_FUNC (ssize_t recv (...)) - ACE_UNIMPLEMENTED_FUNC (ssize_t send_n (...)) - ACE_UNIMPLEMENTED_FUNC (ssize_t recv_n (...)) -}; - -/** - * @class ACE_SOCK_Dgram_SC - * - * @brief "Dgram_SC" is short for "Datagram Self-Contained." - * - * Datagrams don't have the notion of a "peer". Each send and - * receive on a datagram can go to a different peer if you want. - * If you're using datagrams for stream activity, you probably - * want 'em all to go to (and come from) the same place. That's - * what this class is for. Here, we keep an address object so - * that we can remember who last sent us data. When we write - * back, we're then able to write back to that same address. - */ -template -class ACE_SOCK_Dgram_SC : public STREAM -{ -public: - ACE_SOCK_Dgram_SC (void); - ACE_SOCK_Dgram_SC (STREAM &source, - ACE_INET_Addr &dest); - ssize_t send_n (char *buf, ssize_t len); - ssize_t recv (char *buf, - ssize_t len, - ACE_Time_Value *tv = 0); - ssize_t recv (char *buf, - ssize_t len, - int flags, - ACE_Time_Value *tv = 0); - ssize_t recv_n (char *buf, - ssize_t len, - int flags = 0, - ACE_Time_Value *tv = 0); - int get_remote_addr (ACE_INET_Addr &addr) const; - -protected: - ACE_INET_Addr peer_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -# if defined (__ACE_INLINE__) -# include "ace/IOStream_T.inl" -# endif /* __ACE_INLINE__ */ - -# if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -# include "ace/IOStream_T.cpp" -# endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -# if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -# pragma implementation ("IOStream_T.cpp") -# endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ -#endif /* ACE_LACKS_ACE_IOSTREAM */ - -#include /**/ "ace/post.h" -#endif /* ACE_IOSTREAM_T_H */ diff --git a/ACE/ace/IOStream_T.inl b/ACE/ace/IOStream_T.inl deleted file mode 100644 index 12cf0fcffbf..00000000000 --- a/ACE/ace/IOStream_T.inl +++ /dev/null @@ -1,123 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/Handle_Set.h" -#include "ace/OS_NS_errno.h" -#include "ace/OS_NS_sys_select.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template ACE_INLINE int -ACE_IOStream::eof (void) const -{ - // Get the timeout value of the streambuf - ACE_Time_Value *timeout = this->streambuf_->recv_timeout (0); - - // Reset the timeout value of the streambuf. - (void) this->streambuf_->recv_timeout (timeout); - - char c; - int rval = this->streambuf_->recv_n (&c, - sizeof c, - MSG_PEEK, - timeout); - - // Timeout, not an eof - if (this->streambuf_->timeout()) - return 0; - - // No timeout, got enough data: not eof - if (rval == sizeof(char)) - return 0; - - // No timeout, not enough data: definately eof - return 1; -} - -template ACE_INLINE -ACE_SOCK_Dgram_SC::ACE_SOCK_Dgram_SC (void) -{ -} - -template ACE_INLINE -ACE_SOCK_Dgram_SC::ACE_SOCK_Dgram_SC (STREAM &source, - ACE_INET_Addr &dest) - : STREAM (source), - peer_ (dest) -{ -} - -template ACE_INLINE ssize_t -ACE_SOCK_Dgram_SC::send_n (char *buf, - ssize_t len) -{ - return STREAM::send (buf, len, peer_); -} - -template ACE_INLINE ssize_t -ACE_SOCK_Dgram_SC::recv (char *buf, - ssize_t len, - ACE_Time_Value *tv) -{ - //FUZZ: disable check_for_lack_ACE_OS - return recv (buf, len, 0, tv); - //FUZZ: enable check_for_lack_ACE_OS -} - -template ACE_INLINE ssize_t -ACE_SOCK_Dgram_SC::recv (char *buf, - ssize_t len, - int flags, - ACE_Time_Value *tv) -{ - if (tv != 0) - { - ACE_HANDLE handle = this->get_handle (); - ACE_Handle_Set handle_set; - - handle_set.set_bit (handle); - - switch (ACE_OS::select (int (handle) + 1, - (fd_set *) handle_set, // read_fds. - (fd_set *) 0, // write_fds. - (fd_set *) 0, // exception_fds. - tv)) - { - case 0: - errno = ETIME; - case -1: - return -1; - default: - ; // Do the 'recv' below - } - } - - int rval = STREAM::recv (buf, len, peer_, flags); -#if defined (ACE_WIN32) - if (rval == SOCKET_ERROR) - if (::WSAGetLastError () == WSAEMSGSIZE) - if (ACE_BIT_ENABLED (flags, MSG_PEEK)) - rval = len; -#endif /* ACE_WIN32 */ - return rval < len ? rval : len; -} - -template ACE_INLINE ssize_t -ACE_SOCK_Dgram_SC::recv_n (char *buf, - ssize_t len, - int flags, - ACE_Time_Value *tv) -{ - int rval = this->recv (buf, len, flags, tv); - return rval; -} - -template ACE_INLINE int -ACE_SOCK_Dgram_SC::get_remote_addr (ACE_INET_Addr &addr) const -{ - addr = peer_; - return 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/IO_Cntl_Msg.cpp b/ACE/ace/IO_Cntl_Msg.cpp deleted file mode 100644 index 9d64f05dd66..00000000000 --- a/ACE/ace/IO_Cntl_Msg.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// $Id$ - -#include "ace/IO_Cntl_Msg.h" - -#if !defined (__ACE_INLINE__) -#include "ace/IO_Cntl_Msg.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, IO_Cntl_Msg, "$Id$") - -#if 0 -// This is not meant to be used, it's just a place holder... - -#if !defined (__ACE_INLINE__) -#include "ace/Intrusive_List.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Forward decl -template class ACE_Module; - -/** - * @class ACE_Module_Link - * - * @brief Data structure used to link two modules together - */ -class ACE_Module_Link -{ -public: - ACE_Module_Link (ACE_Module *m1, ACE_Module *m2): mod_upper_ (m1), mod_lower_ (m2), count_ (0) {} - - ACE_Module *upper (void) { return this->mod_upper_; } - void upper (ACE_Module *u) { this->mod_upper_ = u; } - - ACE_Module *lower (void) { return this->mod_lower_; } - void lower (ACE_Module *l) { this->mod_lower_ = l; } - - int count (void) const { return this->count_; } - void count (int c) { this->count_ = c; } - -private: - ACE_Module *mod_upper_; - ACE_Module *mod_lower_; - int count_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif - diff --git a/ACE/ace/IO_Cntl_Msg.h b/ACE/ace/IO_Cntl_Msg.h deleted file mode 100644 index 7101284c9f7..00000000000 --- a/ACE/ace/IO_Cntl_Msg.h +++ /dev/null @@ -1,112 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file IO_Cntl_Msg.h - * - * $Id$ - * - * @author Doug Schmidt - */ -//========================================================================== - - -#ifndef ACE_IO_CNTL_MSG_H -#define ACE_IO_CNTL_MSG_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" -#include "ace/os_include/os_stddef.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_IO_Cntl_Msg - * - * @brief Data format for IOCTL messages - */ -class ACE_Export ACE_IO_Cntl_Msg -{ -public: - enum - { - /// Set the low water mark. - SET_LWM = 1, - /// Get the low water mark. - GET_LWM = 2, - /// Set the high water mark. - SET_HWM = 3, - /// Get the high water mark. - GET_HWM = 4, - /// Link modules - MOD_LINK = 5, - /// Unlink modules - MOD_UNLINK = 6 - }; - - typedef unsigned short ACE_IO_Cntl_Cmds; - - // = Initialization method. - /// Initialize the control message. - ACE_IO_Cntl_Msg (ACE_IO_Cntl_Cmds c); - - // = Get/set methods - - /// Get command. - ACE_IO_Cntl_Cmds cmd (void); - - /// Set command. - void cmd (ACE_IO_Cntl_Cmds c); - - /// Get count. - size_t count (void); - - /// Set count. - void count (size_t c); - - /// Get error. - int error (void); - - /// Set error. - void error (int e); - - /// Get return value. - int rval (void); - - /// Set return value. - void rval (int r); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - /// Command. - ACE_IO_Cntl_Cmds cmd_; - - /// Count. - size_t count_; - - /// Error. - int error_; - - /// Return value - int rval_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/IO_Cntl_Msg.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" - -#endif /* ACE_IO_CNTL_MSG_H */ diff --git a/ACE/ace/IO_Cntl_Msg.inl b/ACE/ace/IO_Cntl_Msg.inl deleted file mode 100644 index 0fbf4190f35..00000000000 --- a/ACE/ace/IO_Cntl_Msg.inl +++ /dev/null @@ -1,61 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_IO_Cntl_Msg::ACE_IO_Cntl_Msg (ACE_IO_Cntl_Cmds c) -{ - this->cmd_ = c; -} - -ACE_INLINE ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds -ACE_IO_Cntl_Msg::cmd (void) -{ - return this->cmd_; -} - -ACE_INLINE void -ACE_IO_Cntl_Msg::cmd (ACE_IO_Cntl_Cmds c) -{ - this->cmd_ = c; -} - -ACE_INLINE size_t -ACE_IO_Cntl_Msg::count (void) -{ - return this->count_; -} - -ACE_INLINE void -ACE_IO_Cntl_Msg::count (size_t c) -{ - this->count_ = c; -} - -ACE_INLINE int -ACE_IO_Cntl_Msg::error (void) -{ - return this->error_; -} - -ACE_INLINE void -ACE_IO_Cntl_Msg::error (int e) -{ - this->error_ = e; -} - -ACE_INLINE int -ACE_IO_Cntl_Msg::rval (void) -{ - return this->rval_; -} - -ACE_INLINE void -ACE_IO_Cntl_Msg::rval (int r) -{ - this->rval_ = r; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/IO_SAP.cpp b/ACE/ace/IO_SAP.cpp deleted file mode 100644 index 0e3e2ea73dc..00000000000 --- a/ACE/ace/IO_SAP.cpp +++ /dev/null @@ -1,142 +0,0 @@ -// $Id$ - -#include "ace/IO_SAP.h" - -#include "ace/Log_Msg.h" -#include "ace/OS_NS_unistd.h" -#include "ace/OS_NS_errno.h" -#include "ace/OS_NS_fcntl.h" -#include "ace/os_include/os_signal.h" - -#if !defined (__ACE_INLINE__) -#include "ace/IO_SAP.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, IO_SAP, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_IO_SAP) - -// This is the do-nothing constructor. It does not perform a -// ACE_OS::open system call. - -ACE_IO_SAP::ACE_IO_SAP (void) - : handle_ (ACE_INVALID_HANDLE) -{ - ACE_TRACE ("ACE_IO_SAP::ACE_IO_SAP"); -} - -void -ACE_IO_SAP::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_IO_SAP::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("handle_ = %d"), this->handle_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\npid_ = %d"), this->pid_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -// Cache for the process ID. -pid_t ACE_IO_SAP::pid_ = 0; - -int -ACE_IO_SAP::enable (int value) const -{ - ACE_TRACE ("ACE_IO_SAP::enable"); - /* First-time in initialization. */ - if (ACE_IO_SAP::pid_ == 0) - ACE_IO_SAP::pid_ = ACE_OS::getpid (); - - switch (value) - { -#if defined (SIGURG) - case SIGURG: - case ACE_SIGURG: -#if defined (F_SETOWN) - return ACE_OS::fcntl (this->handle_, - F_SETOWN, - ACE_IO_SAP::pid_); -#else - ACE_NOTSUP_RETURN (-1); -#endif /* F_SETOWN */ -#endif /* SIGURG */ -#if defined (SIGIO) - case SIGIO: - case ACE_SIGIO: -#if defined (F_SETOWN) && defined (FASYNC) - if (ACE_OS::fcntl (this->handle_, - F_SETOWN, - ACE_IO_SAP::pid_) == -1 - || ACE::set_flags (this->handle_, - FASYNC) == -1) - return -1; - break; -#else - ACE_NOTSUP_RETURN (-1); -#endif /* F_SETOWN && FASYNC */ -#else // <== - ACE_NOTSUP_RETURN (-1); -#endif /* SIGIO <== */ - case ACE_NONBLOCK: - if (ACE::set_flags (this->handle_, - ACE_NONBLOCK) == -1) - return -1; - break; - default: - return -1; - } - - return 0; -} - -int -ACE_IO_SAP::disable (int value) const -{ - ACE_TRACE ("ACE_IO_SAP::disable"); - - switch (value) - { -#if defined (SIGURG) - case SIGURG: - case ACE_SIGURG: -#if defined (F_SETOWN) - if (ACE_OS::fcntl (this->handle_, - F_SETOWN, 0) == -1) - return -1; - break; -#else - ACE_NOTSUP_RETURN (-1); -#endif /* F_SETOWN */ -#endif /* SIGURG */ -#if defined (SIGIO) - case SIGIO: - case ACE_SIGIO: -#if defined (F_SETOWN) && defined (FASYNC) - if (ACE_OS::fcntl (this->handle_, - F_SETOWN, - 0) == -1 - || ACE::clr_flags (this->handle_, FASYNC) == -1) - return -1; - break; -#else - ACE_NOTSUP_RETURN (-1); -#endif /* F_SETOWN && FASYNC */ -#else // <== - ACE_NOTSUP_RETURN (-1); -#endif /* SIGIO <== */ - case ACE_NONBLOCK: - if (ACE::clr_flags (this->handle_, - ACE_NONBLOCK) == -1) - return -1; - break; - default: - return -1; - } - return 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/IO_SAP.h b/ACE/ace/IO_SAP.h deleted file mode 100644 index cea8213e177..00000000000 --- a/ACE/ace/IO_SAP.h +++ /dev/null @@ -1,96 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file IO_SAP.h - * - * $Id$ - * - * @author Doug Schmidt - */ -//============================================================================= - - -#ifndef ACE_IO_SAP_H -#define ACE_IO_SAP_H -#include /**/ "ace/pre.h" - -#include "ace/Flag_Manip.h" -#include "ace/os_include/sys/os_types.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_IO_SAP - * - * @brief Defines the methods for the base class of the ACE_IO_SAP - * abstraction, which includes ACE_FILE and ACE_DEV. - */ -class ACE_Export ACE_IO_SAP -{ -public: - enum - { - /// Be consistent with Winsock - INVALID_HANDLE = -1 - }; - - /// Default dtor. - ~ACE_IO_SAP (void); - - /// Interface for ioctl. - int control (int cmd, void *) const; - - // = Common I/O handle options related to files. - - /** - * Enable asynchronous I/O (ACE_SIGIO), urgent data (ACE_SIGURG), - * non-blocking I/O (ACE_NONBLOCK), or close-on-exec (ACE_CLOEXEC), - * which is passed as the @a value. - */ - int enable (int value) const; - - /** - * Disable asynchronous I/O (ACE_SIGIO), urgent data (ACE_SIGURG), - * non-blocking I/O (ACE_NONBLOCK), or close-on-exec (ACE_CLOEXEC), - * which is passed as the @a value. - */ - int disable (int value) const; - - /// Get the underlying handle. - ACE_HANDLE get_handle (void) const; - - /// Set the underlying handle. - void set_handle (ACE_HANDLE handle); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - /// Ensure that ACE_IO_SAP is an abstract base class. - ACE_IO_SAP (void); - -private: - /// Underlying I/O handle. - ACE_HANDLE handle_; - - /// Cache the process ID. - static pid_t pid_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/IO_SAP.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_IO_SAP_H */ diff --git a/ACE/ace/IO_SAP.inl b/ACE/ace/IO_SAP.inl deleted file mode 100644 index 9d7d244e4db..00000000000 --- a/ACE/ace/IO_SAP.inl +++ /dev/null @@ -1,42 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/OS_NS_stropts.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_IO_SAP::~ACE_IO_SAP (void) -{ - ACE_TRACE ("ACE_IO_SAP::~ACE_IO_SAP"); -} - -// Used to return the underlying handle_. - -ACE_INLINE ACE_HANDLE -ACE_IO_SAP::get_handle (void) const -{ - ACE_TRACE ("ACE_IO_SAP::get_handle"); - return this->handle_; -} - -// Used to set the underlying handle_. - -ACE_INLINE void -ACE_IO_SAP::set_handle (ACE_HANDLE handle) -{ - ACE_TRACE ("ACE_IO_SAP::set_handle"); - this->handle_ = handle; -} - -// Provides access to the ACE_OS::ioctl system call. - -ACE_INLINE int -ACE_IO_SAP::control (int cmd, void *arg) const -{ - ACE_TRACE ("ACE_IO_SAP::control"); - return ACE_OS::ioctl (this->handle_, cmd, arg); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/IPC_SAP.cpp b/ACE/ace/IPC_SAP.cpp deleted file mode 100644 index b9ef15c6002..00000000000 --- a/ACE/ace/IPC_SAP.cpp +++ /dev/null @@ -1,193 +0,0 @@ -// $Id$ - -#include "ace/IPC_SAP.h" - -#include "ace/Log_Msg.h" -#include "ace/OS_NS_unistd.h" -#include "ace/os_include/os_signal.h" -#include "ace/OS_NS_errno.h" -#include "ace/OS_NS_fcntl.h" - -#if !defined (__ACE_INLINE__) -#include "ace/IPC_SAP.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, IPC_SAP, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_IPC_SAP) - -void -ACE_IPC_SAP::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_IPC_SAP::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("handle_ = %d"), this->handle_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\npid_ = %d"), this->pid_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -// Cache for the process ID. -pid_t ACE_IPC_SAP::pid_ = 0; - -// This is the do-nothing constructor. It does not perform a -// ACE_OS::socket system call. - -ACE_IPC_SAP::ACE_IPC_SAP (void) - : handle_ (ACE_INVALID_HANDLE) -{ - // ACE_TRACE ("ACE_IPC_SAP::ACE_IPC_SAP"); -} - -int -ACE_IPC_SAP::enable (int value) const -{ - ACE_TRACE ("ACE_IPC_SAP::enable"); - - // First-time in initialization. - if (ACE_IPC_SAP::pid_ == 0) - ACE_IPC_SAP::pid_ = ACE_OS::getpid (); - -#if defined (ACE_WIN32) || defined (ACE_VXWORKS) - switch (value) - { - case ACE_NONBLOCK: - { - // nonblocking argument (1) - // blocking: (0) - int nonblock = 1; - return ACE_OS::ioctl (this->handle_, - FIONBIO, - &nonblock); - } - default: - ACE_NOTSUP_RETURN (-1); - } -#else /* ! ACE_WIN32 && ! ACE_VXWORKS */ - switch (value) - { -#if defined (SIGURG) - case SIGURG: - case ACE_SIGURG: -#if defined (F_SETOWN) - return ACE_OS::fcntl (this->handle_, - F_SETOWN, - ACE_IPC_SAP::pid_); -#else - ACE_NOTSUP_RETURN (-1); -#endif /* F_SETOWN */ -#endif /* SIGURG */ -#if defined (SIGIO) - case SIGIO: - case ACE_SIGIO: -#if defined (F_SETOWN) && defined (FASYNC) - if (ACE_OS::fcntl (this->handle_, - F_SETOWN, - ACE_IPC_SAP::pid_) == -1 - || ACE::set_flags (this->handle_, - FASYNC) == -1) - return -1; - break; -#else - ACE_NOTSUP_RETURN (-1); -#endif /* F_SETOWN && FASYNC */ -#endif /* SIGIO <== */ -#if defined (F_SETFD) - case ACE_CLOEXEC: - // Enables the close-on-exec flag. - if (ACE_OS::fcntl (this->handle_, - F_SETFD, - 1) == -1) - return -1; - break; -#endif /* F_SETFD */ - case ACE_NONBLOCK: - if (ACE::set_flags (this->handle_, - ACE_NONBLOCK) == ACE_INVALID_HANDLE) - return -1; - break; - default: - return -1; - } - return 0; -#endif /* ! ACE_WIN32 && ! ACE_VXWORKS */ - - /* NOTREACHED */ -} - -int -ACE_IPC_SAP::disable (int value) const -{ - ACE_TRACE ("ACE_IPC_SAP::disable"); - -#if defined (ACE_WIN32) || defined (ACE_VXWORKS) - switch (value) - { - case ACE_NONBLOCK: - // nonblocking argument (1) - // blocking: (0) - { - int nonblock = 0; - return ACE_OS::ioctl (this->handle_, - FIONBIO, - &nonblock); - } - default: - ACE_NOTSUP_RETURN (-1); - } -#else /* ! ACE_WIN32 && ! ACE_VXWORKS */ - switch (value) - { -#if defined (SIGURG) - case SIGURG: - case ACE_SIGURG: -#if defined (F_SETOWN) - return ACE_OS::fcntl (this->handle_, - F_SETOWN, - 0); -#else - ACE_NOTSUP_RETURN (-1); -#endif /* F_SETOWN */ -#endif /* SIGURG */ -#if defined (SIGIO) - case SIGIO: - case ACE_SIGIO: -#if defined (F_SETOWN) && defined (FASYNC) - if (ACE_OS::fcntl (this->handle_, - F_SETOWN, - 0) == -1 - || ACE::clr_flags (this->handle_, - FASYNC) == -1) - return -1; - break; -#else - ACE_NOTSUP_RETURN (-1); -#endif /* F_SETOWN && FASYNC */ -#endif /* SIGIO <== */ -#if defined (F_SETFD) - case ACE_CLOEXEC: - // Disables the close-on-exec flag. - if (ACE_OS::fcntl (this->handle_, - F_SETFD, - 0) == -1) - return -1; - break; -#endif /* F_SETFD */ - case ACE_NONBLOCK: - if (ACE::clr_flags (this->handle_, - ACE_NONBLOCK) == -1) - return -1; - break; - default: - return -1; - } - return 0; -#endif /* ! ACE_WIN32 && ! ACE_VXWORKS */ - /* NOTREACHED */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/IPC_SAP.h b/ACE/ace/IPC_SAP.h deleted file mode 100644 index 1fd38007e43..00000000000 --- a/ACE/ace/IPC_SAP.h +++ /dev/null @@ -1,96 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file IPC_SAP.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_IPC_SAP_H -#define ACE_IPC_SAP_H -#include /**/ "ace/pre.h" - -#include "ace/Flag_Manip.h" -#include "ace/os_include/sys/os_types.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_IPC_SAP - * - * @brief Defines the member functions for the base class of the - * ACE_IPC_SAP abstraction. - */ -class ACE_Export ACE_IPC_SAP -{ -public: - - /// Interface for . - int control (int cmd, void *) const; - - // = Common I/O handle options related to sockets. - - /** - * Enable asynchronous I/O (ACE_SIGIO), urgent data (ACE_SIGURG), - * non-blocking I/O (ACE_NONBLOCK), or close-on-exec (ACE_CLOEXEC), - * which is passed as the @a value. - */ - int enable (int value) const; - - /** - * Disable asynchronous I/O (ACE_SIGIO), urgent data (ACE_SIGURG), - * non-blocking I/O (ACE_NONBLOCK), or close-on-exec (ACE_CLOEXEC), - * which is passed as the @a value. - */ - int disable (int value) const; - - /// Get the underlying handle. - ACE_HANDLE get_handle (void) const; - - /// Set the underlying handle. - void set_handle (ACE_HANDLE handle); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - - // = Ensure that ACE_IPC_SAP is an abstract base class. - /// Default constructor. - ACE_IPC_SAP (void); - - /// Protected destructor. - /** - * Not a virtual destructor. Protected destructor to prevent - * operator delete() from being called through a base class - * ACE_IPC_SAP pointer/reference. - */ - ~ACE_IPC_SAP (void); - -private: - /// Underlying I/O handle. - ACE_HANDLE handle_; - - /// Cache the process ID. - static pid_t pid_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/IPC_SAP.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_IPC_SAP_H */ diff --git a/ACE/ace/IPC_SAP.inl b/ACE/ace/IPC_SAP.inl deleted file mode 100644 index 0adcb6e9b09..00000000000 --- a/ACE/ace/IPC_SAP.inl +++ /dev/null @@ -1,40 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/OS_NS_stropts.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_IPC_SAP::~ACE_IPC_SAP (void) -{ - // ACE_TRACE ("ACE_IPC_SAP::~ACE_IPC_SAP"); -} - -ACE_INLINE ACE_HANDLE -ACE_IPC_SAP::get_handle (void) const -{ - ACE_TRACE ("ACE_IPC_SAP::get_handle"); - return this->handle_; -} - -// Used to set the underlying handle_. - -ACE_INLINE void -ACE_IPC_SAP::set_handle (ACE_HANDLE handle) -{ - ACE_TRACE ("ACE_IPC_SAP::set_handle"); - this->handle_ = handle; -} - -// Provides access to the ACE_OS::ioctl system call. - -ACE_INLINE int -ACE_IPC_SAP::control (int cmd, void *arg) const -{ - ACE_TRACE ("ACE_IPC_SAP::control"); - return ACE_OS::ioctl (this->handle_, cmd, arg); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/If_Then_Else.h b/ACE/ace/If_Then_Else.h deleted file mode 100644 index 163219e206b..00000000000 --- a/ACE/ace/If_Then_Else.h +++ /dev/null @@ -1,89 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file If_Then_Else.h - * - * @c ACE::If_Then_Else traits template based on the @c IfThenElse - * template described in the book "C++ Templates" by Vandevoorde and - * Josuttis. - * - * $Id$ - * - * @author Ossama Othman - */ -//============================================================================= - -#ifndef ACE_IF_THEN_ELSE_H -#define ACE_IF_THEN_ELSE_H - -#include "ace/config-lite.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -namespace ACE -{ - - /** - * @struct If_Then_Else - * - * @brief Compile-time selection of type based on a boolean value. - * - * This primary template selects the second or third argument based - * on the value of the boolean first argument. - * - * Usage example: - * - * \code - * - * template - * class Foo - * { - * public: - * // Set "TheType" to be the larger of "T" and "int". - * typedef typename If_Then_Else<(sizeof (T) > sizeof (int)), - * T, - * int>::result_type TheType; - * }; - * - * \endcode - * - * @note This merely a forward declaration since we really only care - * about the partial specializations below. - */ - template - struct If_Then_Else; - - /** - * @struct If_Then_Else - * - * @brief Select of type @a Ta if boolean value is @c true. - * - * This partial specialization selects the type @a Ta if the boolean - * first argument is @c true. - */ - template - struct If_Then_Else - { - typedef Ta result_type; - }; - - /** - * @struct If_Then_Else - * - * @brief Select of type @a Tb if boolean value is @c false. - * - * This partial specialization selects the type @a Tb if the boolean - * first argument is @c false. - */ - template - struct If_Then_Else - { - typedef Tb result_type; - }; - -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_IF_THEN_ELSE_H */ diff --git a/ACE/ace/Init_ACE.cpp b/ACE/ace/Init_ACE.cpp deleted file mode 100644 index f997c09d4f8..00000000000 --- a/ACE/ace/Init_ACE.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "ace/Init_ACE.h" - -#include "ace/Object_Manager.h" - -ACE_RCSID (ace, - Init_ACE, - "$Id$") - - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -unsigned int ACE::init_fini_count_ = 0; - -int -ACE::init (void) -{ - // Don't use ACE_TRACE, because Object_Manager might not have been - // instantiated yet. - // ACE_TRACE ("ACE::init"); - - ++ACE::init_fini_count_; - - return ACE_Object_Manager::instance ()->init (); -} - -int -ACE::fini (void) -{ - ACE_TRACE ("ACE::fini"); - - if (ACE::init_fini_count_ > 0) - { - if (--ACE::init_fini_count_ == 0) - return ACE_Object_Manager::instance ()->fini (); - else - // Wait for remaining fini () calls. - return 1; - } - else - // More ACE::fini () calls than ACE::init () calls. Bad - // application! - return -1; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Init_ACE.h b/ACE/ace/Init_ACE.h deleted file mode 100644 index 164f61e1d70..00000000000 --- a/ACE/ace/Init_ACE.h +++ /dev/null @@ -1,62 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Init_ACE.h - * - * $Id$ - * - * Initialize ACE library services. Can be called only once per - * program invocation. - */ -//============================================================================= - - -#ifndef ACE_INIT_ACE_H -#define ACE_INIT_ACE_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -namespace ACE -{ - /** - * This class implements the functions for the initialization and - * shutting down ACE. These functions are called only once per ACE - * invokation. - * @return Returns 0 on success, -1 on failure, and 1 if it had already been - * called. - */ - extern ACE_Export int init (void); - - /** - * Shut down ACE library services. Can be called only once per - * program invocation. - * @return Returns 0 on success, -1 on failure, and 1 if it had already been - * called. - */ - extern ACE_Export int fini (void); - - // private: - // Used internally, so not exported. - - /** - * Counter to match / calls. must increment it; - * must decrement it. then does nothing until it - * reaches 0. - */ - extern unsigned int init_fini_count_; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#include /**/ "ace/post.h" - -#endif /* ACE_INIT_ACE_H */ diff --git a/ACE/ace/Intrusive_List.cpp b/ACE/ace/Intrusive_List.cpp deleted file mode 100644 index c0006792ce4..00000000000 --- a/ACE/ace/Intrusive_List.cpp +++ /dev/null @@ -1,153 +0,0 @@ -// $Id$ - -#ifndef ACE_INTRUSIVE_LIST_CPP -#define ACE_INTRUSIVE_LIST_CPP - -#include "ace/Intrusive_List.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (__ACE_INLINE__) -#include "ace/Intrusive_List.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template -ACE_Intrusive_List::ACE_Intrusive_List (void) - : head_ (0) - , tail_ (0) -{ -} - -template -ACE_Intrusive_List::~ACE_Intrusive_List (void) -{ -} - -template void -ACE_Intrusive_List::push_back (T *node) -{ - if (this->tail_ == 0) - { - this->tail_ = node; - this->head_ = node; - node->next (0); - node->prev (0); - return; - } - - this->tail_->next (node); - node->prev (this->tail_); - node->next (0); - this->tail_ = node; -} - -template void -ACE_Intrusive_List::push_front (T *node) -{ - if (this->head_ == 0) - { - this->tail_ = node; - this->head_ = node; - node->next (0); - node->prev (0); - return; - } - - this->head_->prev (node); - node->next (this->head_); - node->prev (0); - this->head_ = node; -} - -template T * -ACE_Intrusive_List::pop_front (void) -{ - T *node = this->head_; - if (node == 0) - return 0; - this->unsafe_remove (node); - return node; -} - -template T * -ACE_Intrusive_List::pop_back (void) -{ - T *node = this->tail_; - if (node == 0) - return 0; - this->unsafe_remove (node); - return node; -} - -template void -ACE_Intrusive_List::remove (T *node) -{ - for (T *i = this->head_; i != 0; i = i->next ()) - { - if (node == i) - { - this->unsafe_remove (node); - return; - } - } -} - -template void -ACE_Intrusive_List::unsafe_remove (T *node) -{ - if (node->prev () != 0) - node->prev ()->next (node->next ()); - else - this->head_ = node->next (); - - if (node->next () != 0) - node->next ()->prev (node->prev ()); - else - this->tail_ = node->prev (); - - node->next (0); - node->prev (0); -} - -#if 0 -template void -ACE_Intrusive_List_Node::check_invariants (void) -{ - ACE_ASSERT ((this->next () == 0) || (this->next ()->prev () == this)); - ACE_ASSERT ((this->prev () == 0) || (this->prev ()->next () == this)); -} - -template void -ACE_Intrusive_List::check_invariants (void) -{ - ACE_ASSERT ((this->tail_ == 0) || (this->tail_->next () == 0)); - ACE_ASSERT ((this->head_ == 0) || (this->head_->prev () == 0)); - ACE_ASSERT (!((this->head_ == 0) ^ (this->tail_ == 0))); - - int found_tail = 0; - for (T *i = this->head_; i != 0; i = i->next ()) - { - if (i == this->tail_) - found_tail = 1; - i->check_invariants (); - } - ACE_ASSERT (this->tail_ == 0 || found_tail == 1); - - int found_head = 0; - for (T *j = this->tail_; j != 0; j = j->prev ()) - { - if (j == this->head_) - found_head = 1; - j->check_invariants (); - } - ACE_ASSERT (this->head_ == 0 || found_head == 1); -} -#endif /* 0 */ - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_INTRUSIVE_LIST_CPP */ diff --git a/ACE/ace/Intrusive_List.h b/ACE/ace/Intrusive_List.h deleted file mode 100644 index 59d0c9054a8..00000000000 --- a/ACE/ace/Intrusive_List.h +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file Intrusive_List.h - * - * $Id$ - * - * @author Carlos O'Ryan - */ -//============================================================================= - -#ifndef ACE_INTRUSIVE_LIST_H -#define ACE_INTRUSIVE_LIST_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Intrusive_List - * - * @brief Implement an intrusive double linked list - * - * Intrusive lists assume that the elements they contain the pointers - * required to build the list. They are useful as light-weight - * containers and free-lists. - * - * The template argument T must implement the following methods: - * - * - T* T::next () const; - * - void T::next (T *); - * - T* T::prev () const; - * - void T::prev (T* ); - * - * A simple way to satisfy the Intrusive_List requirements would be to - * implement a helper class: - * - * class My_Object : public ACE_Intrusive_List_Node {
- * ....
- * };
- * - * typedef ACE_Intrusive_List My_Object_List; - * - * However, ACE is supported on platforms that would surely get - * confused using such templates. - * - * @todo The ACE_Message_Queue is an example of an intrusive list (or - * queue) but it is not implemented in terms of this class. - * - */ -template -class ACE_Intrusive_List -{ -public: - // = Initialization and termination methods. - /// Constructor. Use user specified allocation strategy - /// if specified. - ACE_Intrusive_List (void); - - /// Destructor. - ~ACE_Intrusive_List (void); - - // = Check boundary conditions. - - /// Returns 1 if the container is empty, otherwise returns 0. - int is_empty (void) const; - - /// Returns 1 if the container is empty, otherwise returns 0. - /// @deprecated Use is_empty() instead. - int empty (void) const; - - /// Insert an element at the beginning of the list - void push_front (T *node); - - /// Insert an element at the end of the list - void push_back (T *node); - - /// Remove the element at the beginning of the list - T *pop_front (void); - - /// Remove the element at the end of the list - T *pop_back (void); - - /// Get the element at the head of the queue - T *head (void) const; - - /// Get the element at the tail of the queue - T *tail (void) const; - - /// Remove a element from the list - /** - * Verify that the element is still in the list before removing it. - */ - void remove (T *node); - - /// Swap two lists - void swap(ACE_Intrusive_List & rhs); - - /// Remove a element from the list without checking - /** - * No attempts are performed to check if T* really belongs to the - * list. The effects of removing an invalid element are unspecified - */ - void unsafe_remove (T *node); - -private: - /** @name Disallow copying - * - */ - //@{ - ACE_Intrusive_List (const ACE_Intrusive_List &); - ACE_Intrusive_List& operator= (const ACE_Intrusive_List &); - //@} - -private: - /// Head of the list - T *head_; - - /// Tail of the list - T *tail_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Intrusive_List.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Intrusive_List.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Intrusive_List.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" -#endif /* ACE_INTRUSIVE_LIST_H */ diff --git a/ACE/ace/Intrusive_List.inl b/ACE/ace/Intrusive_List.inl deleted file mode 100644 index f76370917e9..00000000000 --- a/ACE/ace/Intrusive_List.inl +++ /dev/null @@ -1,40 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template ACE_INLINE int -ACE_Intrusive_List::is_empty (void) const -{ - return this->head_ == 0; -} - -template ACE_INLINE int -ACE_Intrusive_List::empty (void) const -{ - return this->is_empty (); -} - -template ACE_INLINE T * -ACE_Intrusive_List::head (void) const -{ - return this->head_; -} - -template ACE_INLINE T * -ACE_Intrusive_List::tail (void) const -{ - return this->tail_; -} - -template ACE_INLINE void -ACE_Intrusive_List::swap(ACE_Intrusive_List & rhs) -{ - std::swap(head_, rhs.head_); - std::swap(tail_, rhs.tail_); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Intrusive_List_Node.cpp b/ACE/ace/Intrusive_List_Node.cpp deleted file mode 100644 index cd39a0cc91e..00000000000 --- a/ACE/ace/Intrusive_List_Node.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// $Id$ - -#ifndef ACE_INTRUSIVE_LIST_NODE_CPP -#define ACE_INTRUSIVE_LIST_NODE_CPP - -#include "ace/Intrusive_List_Node.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (__ACE_INLINE__) -#include "ace/Intrusive_List_Node.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template -ACE_Intrusive_List_Node::ACE_Intrusive_List_Node (void) - : prev_ (0) - , next_ (0) -{ -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_INTRUSIVE_LIST_NODE_CPP */ diff --git a/ACE/ace/Intrusive_List_Node.h b/ACE/ace/Intrusive_List_Node.h deleted file mode 100644 index b62d681a047..00000000000 --- a/ACE/ace/Intrusive_List_Node.h +++ /dev/null @@ -1,85 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Intrusive_List_Node.h - * - * $Id$ - * - * @author Carlos O'Ryan - */ -//============================================================================= - -#ifndef ACE_INTRUSIVE_LIST_NODE_H -#define ACE_INTRUSIVE_LIST_NODE_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Intrusive_List_Node - * - * @brief Implement the requirements for ACE_Intrusive_List - * - * The class should be used as follows: - * - * class My_Object : public ACE_Intrusive_List_Node {
- * ....
- * };
- * - * However, ACE is supported on platforms that would surely get - * confused using such templates, the class is provided as a helper - * for our lucky users that only need portability to modern C++ - * compilers. - * - */ -template -class ACE_Intrusive_List_Node -{ -public: - /** @name Accesors and modifiers to the next and previous pointers - * - */ - //@{ - T *prev (void) const; - void prev (T *); - T *next (void) const; - void next (T *); - //@} - -protected: - /// Constructor - /** - * The constructor is protected, because only derived classes should - * be instantiated. - */ - ACE_Intrusive_List_Node (void); - -private: - /// Head and tail of the list - T *prev_; - T *next_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Intrusive_List_Node.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Intrusive_List_Node.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Intrusive_List_Node.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" -#endif /* ACE_INTRUSIVE_LIST_NODE_H */ diff --git a/ACE/ace/Intrusive_List_Node.inl b/ACE/ace/Intrusive_List_Node.inl deleted file mode 100644 index 0672be2f345..00000000000 --- a/ACE/ace/Intrusive_List_Node.inl +++ /dev/null @@ -1,31 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template ACE_INLINE T* -ACE_Intrusive_List_Node::prev (void) const -{ - return this->prev_; -} - -template ACE_INLINE void -ACE_Intrusive_List_Node::prev (T *x) -{ - this->prev_ = x; -} - -template ACE_INLINE T* -ACE_Intrusive_List_Node::next (void) const -{ - return this->next_; -} - -template ACE_INLINE void -ACE_Intrusive_List_Node::next (T *x) -{ - this->next_ = x; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/LOCK_SOCK_Acceptor.cpp b/ACE/ace/LOCK_SOCK_Acceptor.cpp deleted file mode 100644 index 183338b7efa..00000000000 --- a/ACE/ace/LOCK_SOCK_Acceptor.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// $Id$ - -#ifndef ACE_LOCK_SOCK_ACCEPTOR_CPP -#define ACE_LOCK_SOCK_ACCEPTOR_CPP - -#include "ace/Guard_T.h" -#include "ace/LOCK_SOCK_Acceptor.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template int -ACE_LOCK_SOCK_Acceptor::accept (ACE_SOCK_Stream &stream, - ACE_Addr *remote_address, - ACE_Time_Value *timeout, - int restart, - int reset_new_handle) const -{ - ACE_GUARD_RETURN (ACE_LOCK, ace_mon, (ACE_LOCK &) this->lock_, -1); - - return ACE_SOCK_Acceptor::accept (stream, - remote_address, - timeout, - restart, - reset_new_handle); -} - -template ACE_LOCK & -ACE_LOCK_SOCK_Acceptor::lock (void) -{ - return this->lock_; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_LOCK_SOCK_ACCEPTOR_CPP */ diff --git a/ACE/ace/LOCK_SOCK_Acceptor.h b/ACE/ace/LOCK_SOCK_Acceptor.h deleted file mode 100644 index cfca422e8d7..00000000000 --- a/ACE/ace/LOCK_SOCK_Acceptor.h +++ /dev/null @@ -1,67 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file LOCK_SOCK_Acceptor.h - * - * $Id$ - * - * @author James Hu and Irfan Pyarali - */ -//============================================================================= - - -#ifndef ACE_LOCK_SOCK_ACCEPTOR_H -#define ACE_LOCK_SOCK_ACCEPTOR_H -#include /**/ "ace/pre.h" - -#include "ace/SOCK_Acceptor.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_LOCK_SOCK_Acceptor - * - * @brief Specialize ACE_SOCK_Acceptor to lock around ; - * - * This class is necessary since some OS platforms (e.g., - * Solaris 2.5) do not allow multiple threads/processes to - * simultaneously call on the same listen-mode - * port/socket. Thus, we need to protect against multiple - * concurrent accesses by using the appropriate type of lock. - */ -template -class ACE_LOCK_SOCK_Acceptor : public ACE_SOCK_Acceptor -{ -public: - /// Accept the connection under the control of the . - int accept (ACE_SOCK_Stream &new_stream, - ACE_Addr *remote_addr = 0, - ACE_Time_Value *timeout = 0, - int restart = 1, - int reset_new_handle = 0) const; - - /// Return a reference to the lock. - ACE_LOCK &lock (void); - -protected: - /// Type of locking mechanism. - ACE_LOCK lock_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/LOCK_SOCK_Acceptor.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("LOCK_SOCK_Acceptor.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" -#endif /* ACE_LOCK_SOCK_ACCEPTOR_H */ diff --git a/ACE/ace/LSOCK.cpp b/ACE/ace/LSOCK.cpp deleted file mode 100644 index 71f93fdde9c..00000000000 --- a/ACE/ace/LSOCK.cpp +++ /dev/null @@ -1,181 +0,0 @@ -// $Id$ - -#include "ace/LSOCK.h" - -ACE_RCSID(ace, LSOCK, "$Id$") - -#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) - -#include "ace/Log_Msg.h" -#include "ace/OS_NS_sys_socket.h" - -#if !defined (__ACE_INLINE__) -#include "ace/LSOCK.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_LSOCK) - -void -ACE_LSOCK::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_LSOCK::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("aux_handle_ = %d"), this->aux_handle_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -#if defined (ACE_HAS_MSG) -// This routine sends an open file descriptor to handle_>. - -ssize_t -ACE_LSOCK::send_handle (const ACE_HANDLE handle) const -{ - ACE_TRACE ("ACE_LSOCK::send_handle"); - u_char a[2]; - iovec iov; - msghdr send_msg; -#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) - char cmsgbuf[ACE_BSD_CONTROL_MSG_LEN]; - cmsghdr *cmsgptr = (cmsghdr *) cmsgbuf; -#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ - - a[0] = 0xab; - a[1] = 0xcd; - iov.iov_base = (char *) a; - iov.iov_len = sizeof a; - send_msg.msg_iov = &iov; - send_msg.msg_iovlen = 1; - send_msg.msg_name = 0; - send_msg.msg_namelen = 0; - -#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) - cmsgptr->cmsg_level = SOL_SOCKET; - cmsgptr->cmsg_type = SCM_RIGHTS; - cmsgptr->cmsg_len = sizeof cmsgbuf; - send_msg.msg_control = cmsgbuf; - send_msg.msg_controllen = sizeof cmsgbuf; - *(ACE_HANDLE *) CMSG_DATA (cmsgptr) = handle; - send_msg.msg_flags = 0; -#else - send_msg.msg_accrights = (char *) &handle; - send_msg.msg_accrightslen = sizeof handle; -#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ - - return ACE_OS::sendmsg (this->get_handle (), &send_msg, 0); -} - -// This file receives an open file descriptor from handle_>. -// Note, this routine returns -1 if problems occur, 0 if we recv a -// message that does not have file descriptor in it, and 1 otherwise. - -ssize_t -ACE_LSOCK::recv_handle (ACE_HANDLE &handle, char *pbuf, ssize_t *len) const -{ - ACE_TRACE ("ACE_LSOCK::recv_handle"); - u_char a[2]; - iovec iov; - msghdr recv_msg; - -#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) - char cmsgbuf[ACE_BSD_CONTROL_MSG_LEN]; -#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ - - if (pbuf != 0 && len != 0) - { - iov.iov_base = pbuf; - iov.iov_len = *len; - } - else - { - iov.iov_base = (char *) a; - iov.iov_len = sizeof a; - } - - recv_msg.msg_iov = &iov; - recv_msg.msg_iovlen = 1; - recv_msg.msg_name = 0; - recv_msg.msg_namelen = 0; -#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) - recv_msg.msg_control = cmsgbuf; - recv_msg.msg_controllen = sizeof cmsgbuf; -#else - recv_msg.msg_accrights = (char *) &handle; - recv_msg.msg_accrightslen = sizeof handle; -#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ - -#if defined (ACE_HAS_STREAMS) - - ssize_t nbytes = ACE_OS::recvmsg (this->get_handle (), &recv_msg, 0); - - if (nbytes != ACE_INVALID_HANDLE) - { - if (len != 0) - *len = nbytes; - - if (nbytes == sizeof a - && ((u_char *) iov.iov_base)[0] == 0xab - && ((u_char *) iov.iov_base)[1] == 0xcd) - { -#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) - cmsghdr *cmsgptr = (cmsghdr *) cmsgbuf; - handle = *(ACE_HANDLE *) CMSG_DATA (cmsgptr); -#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ - return 1; - } - else - return 0; - } -#else - ssize_t nbytes = ACE_OS::recvmsg (this->get_handle (), - &recv_msg, - MSG_PEEK); - - if (nbytes != ACE_INVALID_HANDLE) - { - if (nbytes == sizeof a - && ((u_char *) iov.iov_base)[0] == 0xab - && ((u_char *) iov.iov_base)[1] == 0xcd) - { -#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) - // Close down the socket that was returned by the MSG_PEEK. - ACE_OS::closesocket (*(ACE_HANDLE *) CMSG_DATA ((cmsghdr *) cmsgbuf)); - recv_msg.msg_control = cmsgbuf; - recv_msg.msg_controllen = sizeof cmsgbuf; -#else - recv_msg.msg_accrights = (char *) &handle; - recv_msg.msg_accrightslen = sizeof handle; -#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ - - if (ACE_OS::recvmsg (this->get_handle (), - &recv_msg, 0) == ACE_INVALID_HANDLE) - return ACE_INVALID_HANDLE; - else - { -#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) - cmsghdr *cmsgptr = (cmsghdr *) cmsgbuf; - handle = *(ACE_HANDLE *) CMSG_DATA (cmsgptr); -#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ - return 1; - } - } - else - { - if (len != 0) - *len = nbytes; - return 0; - } - } -#endif /* ACE_HAS_STREAMS */ - else - return ACE_INVALID_HANDLE; -} -#endif /* ACE_HAS_MSG */ - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ diff --git a/ACE/ace/LSOCK.h b/ACE/ace/LSOCK.h deleted file mode 100644 index 994158f00d3..00000000000 --- a/ACE/ace/LSOCK.h +++ /dev/null @@ -1,84 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file LSOCK.h - * - * $Id$ - * - * @author Doug Schmidt - */ -//============================================================================= - - -#ifndef ACE_LOCAL_SOCK_H -#define ACE_LOCAL_SOCK_H - -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) - -#include "ace/SOCK.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_LSOCK - * - * @brief Create a Local ACE_SOCK, which is used for passing file - * descriptors. - */ -class ACE_Export ACE_LSOCK -{ -public: -#if defined (ACE_HAS_MSG) - /// Send an open FD to another process. - ssize_t send_handle (const ACE_HANDLE handle) const; - - /// Recv an open FD from another process. - ssize_t recv_handle (ACE_HANDLE &handles, - char *pbuf = 0, - ssize_t *len = 0) const; -#endif /* ACE_HAS_MSG */ - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - // = Ensure that ACE_LSOCK is an abstract base class - - /// Default constructor. - ACE_LSOCK (void); - - /// Initialize based on @a handle. - ACE_LSOCK (ACE_HANDLE handle); - - /// Get handle. - ACE_HANDLE get_handle (void) const; - - /// Set handle. - void set_handle (ACE_HANDLE handle); - -private: - /// An auxiliary handle used to avoid virtual base classes... - ACE_HANDLE aux_handle_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/LSOCK.inl" -#endif /* __ACE_INLINE__ */ - -#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ -#include /**/ "ace/post.h" -#endif /* ACE_LOCAL_SOCK_H */ diff --git a/ACE/ace/LSOCK.inl b/ACE/ace/LSOCK.inl deleted file mode 100644 index 5dbbb0626a1..00000000000 --- a/ACE/ace/LSOCK.inl +++ /dev/null @@ -1,43 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Simple-minded constructor. - -ACE_INLINE -ACE_LSOCK::ACE_LSOCK (void) - : aux_handle_ (ACE_INVALID_HANDLE) -{ - ACE_TRACE ("ACE_LSOCK::ACE_LSOCK"); -} - -// Sets the underlying file descriptor. - -ACE_INLINE void -ACE_LSOCK::set_handle (ACE_HANDLE handle) -{ - ACE_TRACE ("ACE_LSOCK::set_handle"); - this->aux_handle_ = handle; -} - -// Gets the underlying file descriptor. - -ACE_INLINE ACE_HANDLE -ACE_LSOCK::get_handle (void) const -{ - ACE_TRACE ("ACE_LSOCK::get_handle"); - return this->aux_handle_; -} - -// Sets the underlying file descriptor. - -ACE_INLINE -ACE_LSOCK::ACE_LSOCK (ACE_HANDLE handle) - : aux_handle_ (handle) -{ - ACE_TRACE ("ACE_LSOCK::ACE_LSOCK"); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/LSOCK_Acceptor.cpp b/ACE/ace/LSOCK_Acceptor.cpp deleted file mode 100644 index ee154e3e087..00000000000 --- a/ACE/ace/LSOCK_Acceptor.cpp +++ /dev/null @@ -1,143 +0,0 @@ -// $Id$ - -#include "ace/LSOCK_Acceptor.h" - -#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) - -#include "ace/Log_Msg.h" -#include "ace/OS_NS_unistd.h" -#include "ace/OS_NS_sys_socket.h" - -ACE_RCSID(ace, LSOCK_Acceptor, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_LSOCK_Acceptor) - -// Return the local endpoint address. - -int -ACE_LSOCK_Acceptor::get_local_addr (ACE_Addr &a) const -{ - ACE_TRACE ("ACE_LSOCK_Acceptor::get_local_addr"); - - ACE_UNIX_Addr& target = dynamic_cast (a); - - target = this->local_addr_; - - return 0; -} - -void -ACE_LSOCK_Acceptor::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_LSOCK_Acceptor::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - this->local_addr_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -// Do nothing routine for constructor. - -ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor (void) -{ - ACE_TRACE ("ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor"); -} - -int -ACE_LSOCK_Acceptor::open (const ACE_Addr &remote_sap, - int reuse_addr, - int protocol_family, - int backlog, - int protocol) -{ - ACE_TRACE ("ACE_LSOCK_Acceptor::open"); - this->local_addr_ = *((ACE_UNIX_Addr *) &remote_sap); // This is a gross hack... - return ACE_SOCK_Acceptor::open (remote_sap, reuse_addr, - protocol_family, backlog, protocol); -} - -// General purpose routine for performing server ACE_SOCK creation. - -ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor (const ACE_Addr &remote_sap, - int reuse_addr, - int protocol_family, - int backlog, - int protocol) -{ - ACE_TRACE ("ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor"); - if (this->open (remote_sap, - reuse_addr, - protocol_family, - backlog, - protocol) == -1) - ACE_ERROR ((LM_ERROR, - "ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor")); -} - -// General purpose routine for accepting new connections. - -int -ACE_LSOCK_Acceptor::accept (ACE_LSOCK_Stream &new_stream, - ACE_Addr *remote_addr, - ACE_Time_Value *timeout, - int restart, - int reset_new_handle) const -{ - ACE_TRACE ("ACE_LSOCK_Acceptor::accept"); - - int in_blocking_mode = 0; - if (this->shared_accept_start (timeout, - restart, - in_blocking_mode) == -1) - return -1; - else - { - sockaddr *addr = 0; - int len = 0; - - if (remote_addr != 0) - { - len = remote_addr->get_size (); - addr = (sockaddr *) remote_addr->get_addr (); - } - - do - new_stream.set_handle (ACE_OS::accept (this->get_handle (), - addr, - &len)); - while (new_stream.get_handle () == ACE_INVALID_HANDLE - && restart != 0 - && errno == EINTR - && timeout == 0); - - // Reset the size of the addr, which is only necessary for UNIX - // domain sockets. - if (new_stream.get_handle () != ACE_INVALID_HANDLE - && remote_addr != 0) - remote_addr->set_size (len); - } - - return this->shared_accept_finish (new_stream, - in_blocking_mode, - reset_new_handle); -} - -// Close down the UNIX domain stream and remove the rendezvous point -// from the file system. - -int -ACE_LSOCK_Acceptor::remove (void) -{ - ACE_TRACE ("ACE_LSOCK_Acceptor::remove"); - int result = this->close (); - return ACE_OS::unlink (this->local_addr_.get_path_name ()) == -1 - || result == -1 ? -1 : 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ diff --git a/ACE/ace/LSOCK_Acceptor.h b/ACE/ace/LSOCK_Acceptor.h deleted file mode 100644 index a215736355e..00000000000 --- a/ACE/ace/LSOCK_Acceptor.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file LSOCK_Acceptor.h - * - * $Id$ - * - * @author Doug Schmidt - */ -//============================================================================= - - -#ifndef ACE_LOCAL_SOCK_ACCEPTOR_H -#define ACE_LOCAL_SOCK_ACCEPTOR_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) - -#include "ace/SOCK_Acceptor.h" -#include "ace/UNIX_Addr.h" -#include "ace/LSOCK_Stream.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Forward decl. -class ACE_Reactor; - -/** - * @class ACE_LSOCK_Acceptor - * - * @brief Defines the format and interface for the acceptor side of the - * local ACE_SOCK ACE_Stream. - */ -class ACE_Export ACE_LSOCK_Acceptor : public ACE_SOCK_Acceptor -{ -public: - // = Initialization methods. - /// Default constructor. - ACE_LSOCK_Acceptor (void); - - /// Initiate a passive mode socket. - ACE_LSOCK_Acceptor (const ACE_Addr &local_sap, - int reuse_addr = 0, - int protocol_family = PF_UNIX, - int backlog = ACE_DEFAULT_BACKLOG, - int protocol = 0); - - /// Initiate a passive mode socket. - int open (const ACE_Addr &local_sap, - int reuse_addr = 0, - int protocol_family = PF_UNIX, - int backlog = ACE_DEFAULT_BACKLOG, - int protocol = 0); - - /// Accept a new data transfer connection. - int accept (ACE_LSOCK_Stream &new_ipc_sap, - ACE_Addr * = 0, - ACE_Time_Value *timeout = 0, - int restart = 1, - int reset_new_handle = 0) const; - - /// Close down the ACE_LSOCK and remove the rendezvous point from the - /// file system. - int remove (void); - - /// Return the local endpoint address. - int get_local_addr (ACE_Addr &) const; - - // = Meta-type info - typedef ACE_UNIX_Addr PEER_ADDR; - typedef ACE_LSOCK_Stream PEER_STREAM; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - /// Address of our rendezvous point. - ACE_UNIX_Addr local_addr_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ -#include /**/ "ace/post.h" -#endif /* ACE_LOCAL_SOCK_ACCEPTOR_H */ diff --git a/ACE/ace/LSOCK_CODgram.cpp b/ACE/ace/LSOCK_CODgram.cpp deleted file mode 100644 index e89607e06ac..00000000000 --- a/ACE/ace/LSOCK_CODgram.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// $Id$ - -#include "ace/LSOCK_CODgram.h" -#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) - -#include "ace/Log_Msg.h" - -ACE_RCSID(ace, LSOCK_CODgram, "$Id$") - -#if !defined (__ACE_INLINE__) -#include "ace/LSOCK_CODgram.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_LSOCK_CODgram) - -void -ACE_LSOCK_CODgram::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_LSOCK_CODgram::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_SOCK_CODgram::dump (); - ACE_LSOCK::dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -/* Here's the general-purpose open routine. */ - -int -ACE_LSOCK_CODgram::open (const ACE_Addr &remote, - const ACE_Addr &local, - int protocol_family, - int protocol) -{ - ACE_TRACE ("ACE_LSOCK_CODgram::open"); - if (ACE_SOCK_CODgram::open (remote, local, protocol_family, - protocol) == -1) - return -1; - ACE_LSOCK::set_handle (this->get_handle ()); - return 0; -} - -/* Create a local ACE_SOCK datagram. */ - -ACE_LSOCK_CODgram::ACE_LSOCK_CODgram (const ACE_Addr &remote, - const ACE_Addr &local, - int protocol_family, - int protocol) -{ - ACE_TRACE ("ACE_LSOCK_CODgram::ACE_LSOCK_CODgram"); - if (this->open (remote, local, protocol_family, - protocol) == -1) - ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_LSOCK_CODgram"))); -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ diff --git a/ACE/ace/LSOCK_CODgram.h b/ACE/ace/LSOCK_CODgram.h deleted file mode 100644 index 667fa210f0d..00000000000 --- a/ACE/ace/LSOCK_CODgram.h +++ /dev/null @@ -1,78 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file LSOCK_CODgram.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - - -#ifndef ACE_LOCAL_SOCK_CODGRAM_H -#define ACE_LOCAL_SOCK_CODGRAM_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) - -#include "ace/LSOCK.h" -#include "ace/SOCK_CODgram.h" -#include "ace/Addr.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_LSOCK_CODgram - * - * @brief Defines the member functions for the connected - * datagram abstraction. - */ -class ACE_Export ACE_LSOCK_CODgram : public ACE_SOCK_CODgram, public ACE_LSOCK -{ -public: - // = Initialization methods. - /// Default constructor. - ACE_LSOCK_CODgram (void); - - /// Initiate a connected-datagram. - ACE_LSOCK_CODgram (const ACE_Addr &remote_sap, - const ACE_Addr &local_sap = ACE_Addr::sap_any, - int protocol_family = PF_UNIX, - int protocol = 0); - - /// Initiate a connected-datagram. - int open (const ACE_Addr &remote_sap, - const ACE_Addr &local_sap = ACE_Addr::sap_any, - int protocol_family = PF_UNIX, - int protocol = 0); - - /// Get underlying handle. - ACE_HANDLE get_handle (void) const; - - /// Set underlying handle. - void set_handle (ACE_HANDLE); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/LSOCK_CODgram.inl" -#endif /* __ACE_INLINE__ */ - -#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ -#include /**/ "ace/post.h" -#endif /* ACE_LOCAL_SOCK_CODGRAM_H */ diff --git a/ACE/ace/LSOCK_CODgram.inl b/ACE/ace/LSOCK_CODgram.inl deleted file mode 100644 index d27ee2fd881..00000000000 --- a/ACE/ace/LSOCK_CODgram.inl +++ /dev/null @@ -1,30 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Do nothing constructor. - -ACE_INLINE -ACE_LSOCK_CODgram::ACE_LSOCK_CODgram (void) -{ - ACE_TRACE ("ACE_LSOCK_CODgram::ACE_LSOCK_CODgram"); -} - -ACE_INLINE void -ACE_LSOCK_CODgram::set_handle (ACE_HANDLE h) -{ - ACE_TRACE ("ACE_LSOCK_CODgram::set_handle"); - this->ACE_SOCK_CODgram::set_handle (h); - this->ACE_LSOCK::set_handle (h); -} - -ACE_INLINE ACE_HANDLE -ACE_LSOCK_CODgram::get_handle (void) const -{ - ACE_TRACE ("ACE_LSOCK_CODgram::get_handle"); - return this->ACE_SOCK_CODgram::get_handle (); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/LSOCK_Connector.cpp b/ACE/ace/LSOCK_Connector.cpp deleted file mode 100644 index 319670f903f..00000000000 --- a/ACE/ace/LSOCK_Connector.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// $Id$ - -#include "ace/LSOCK_Connector.h" -#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) - -#include "ace/Log_Msg.h" - -ACE_RCSID(ace, LSOCK_Connector, "$Id$") - -#if !defined (__ACE_INLINE__) -#include "ace/LSOCK_Connector.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_LSOCK_Connector) - -void -ACE_LSOCK_Connector::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_LSOCK_Connector::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_LSOCK_Connector::ACE_LSOCK_Connector (void) -{ - ACE_TRACE ("ACE_LSOCK_Connector::ACE_LSOCK_Connector"); -} - -// Establish a connection. -ACE_LSOCK_Connector::ACE_LSOCK_Connector (ACE_LSOCK_Stream &new_stream, - const ACE_UNIX_Addr &remote_sap, - ACE_Time_Value *timeout, - const ACE_Addr &local_sap, - int reuse_addr, - int flags, - int perms) - : ACE_SOCK_Connector (new_stream, - remote_sap, - timeout, - local_sap, - reuse_addr, - flags, - perms) -{ - ACE_TRACE ("ACE_LSOCK_Connector::ACE_LSOCK_Connector"); - // This is necessary due to the weird inheritance relationships of - // ACE_LSOCK_Stream. - new_stream.set_handle (new_stream.get_handle ()); -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ diff --git a/ACE/ace/LSOCK_Connector.h b/ACE/ace/LSOCK_Connector.h deleted file mode 100644 index 336fc4a0e77..00000000000 --- a/ACE/ace/LSOCK_Connector.h +++ /dev/null @@ -1,91 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file LSOCK_Connector.h - * - * $Id$ - * - * @author Doug Schmidt - */ -//============================================================================= - -#ifndef ACE_LOCAL_SOCK_CONNECTOR_H -#define ACE_LOCAL_SOCK_CONNECTOR_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) - -#include "ace/SOCK_Connector.h" -#include "ace/LSOCK_Stream.h" -#include "ace/UNIX_Addr.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_LSOCK_Connector - * - * @brief Defines the format and interface for the connector side of - * the ACE_LSOCK_Stream. - */ -class ACE_Export ACE_LSOCK_Connector : public ACE_SOCK_Connector -{ -public: - // = Initialization methods. - /// Default constructor. - ACE_LSOCK_Connector (void); - - /** - * Actively connect and produce a @a new_stream if things go well. - * All arguments are relayed to the ACE_SOCK_Connector constructor - * for handling. - * @see ACE_SOCK_Connector(). - */ - ACE_LSOCK_Connector (ACE_LSOCK_Stream &new_stream, - const ACE_UNIX_Addr &remote_sap, - ACE_Time_Value *timeout = 0, - const ACE_Addr &local_sap = ACE_Addr::sap_any, - int reuse_addr = 0, - int flags = 0, - int perms = 0); - - /** - * Actively connect and produce a @a new_stream if things go well. - * The @c ACE_SOCK_Connector::connect() method is called to perform - * the actual connection attempt. - * @see ACE_SOCK_Connector::connect(). - */ - int connect (ACE_LSOCK_Stream &new_stream, - const ACE_UNIX_Addr &remote_sap, - ACE_Time_Value *timeout = 0, - const ACE_Addr &local_sap = ACE_Addr::sap_any, - int reuse_addr = 0, - int flags = 0, - int perms = 0); - - // = Meta-type info - typedef ACE_UNIX_Addr PEER_ADDR; - typedef ACE_LSOCK_Stream PEER_STREAM; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/LSOCK_Connector.inl" -#endif /* __ACE_INLINE__ */ - -#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ -#include /**/ "ace/post.h" -#endif /* ACE_LOCAL_SOCK_CONNECTOR_H */ diff --git a/ACE/ace/LSOCK_Connector.inl b/ACE/ace/LSOCK_Connector.inl deleted file mode 100644 index f9cdffbf6dc..00000000000 --- a/ACE/ace/LSOCK_Connector.inl +++ /dev/null @@ -1,27 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Establish a connection. -ACE_INLINE int -ACE_LSOCK_Connector::connect (ACE_LSOCK_Stream &new_stream, - const ACE_UNIX_Addr &remote_sap, - ACE_Time_Value *timeout, - const ACE_Addr &local_sap, - int reuse_addr, - int flags, - int perms) -{ - ACE_TRACE ("ACE_LSOCK_Connector::connect"); - int result = ACE_SOCK_Connector::connect (new_stream, remote_sap, - timeout, local_sap, - reuse_addr, flags, perms); - if (result != -1) - // This is necessary due to the weird inheritance relationships of ACE_LSOCK_Stream. - new_stream.set_handle (new_stream.get_handle ()); - return result; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/LSOCK_Dgram.cpp b/ACE/ace/LSOCK_Dgram.cpp deleted file mode 100644 index 268ce44eb36..00000000000 --- a/ACE/ace/LSOCK_Dgram.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// $Id$ - -#include "ace/LSOCK_Dgram.h" -#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) - -#include "ace/Log_Msg.h" - -ACE_RCSID(ace, LSOCK_Dgram, "$Id$") - -#if !defined (__ACE_INLINE__) -#include "ace/LSOCK_Dgram.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_LSOCK_Dgram) - -void -ACE_LSOCK_Dgram::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_LSOCK_Dgram::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_SOCK_Dgram::dump (); - ACE_LSOCK::dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -// The "do nothing" constructor. - -ACE_LSOCK_Dgram::ACE_LSOCK_Dgram (void) -{ - ACE_TRACE ("ACE_LSOCK_Dgram::ACE_LSOCK_Dgram"); -} - -// Here's the general-purpose open routine. - -int -ACE_LSOCK_Dgram::open (const ACE_Addr &local, - int protocol_family, - int protocol) -{ - ACE_TRACE ("ACE_LSOCK_Dgram::open"); - if (ACE_SOCK_Dgram::open (local, - protocol_family, - protocol) == -1) - return -1; - ACE_LSOCK::set_handle (this->ACE_SOCK_Dgram::get_handle ()); - return 0; -} - -// Create a local ACE_SOCK datagram. - -ACE_LSOCK_Dgram::ACE_LSOCK_Dgram (const ACE_Addr &local, - int protocol_family, - int protocol) -{ - ACE_TRACE ("ACE_LSOCK_Dgram::ACE_LSOCK_Dgram"); - if (this->open (local, - protocol_family, - protocol) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_LSOCK_Dgram"))); -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ diff --git a/ACE/ace/LSOCK_Dgram.h b/ACE/ace/LSOCK_Dgram.h deleted file mode 100644 index d93face8cfb..00000000000 --- a/ACE/ace/LSOCK_Dgram.h +++ /dev/null @@ -1,74 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file LSOCK_Dgram.h - * - * $Id$ - * - * @author Doug Schmidt - */ -//============================================================================= - - -#ifndef ACE_LOCAL_SOCK_DGRAM_H -#define ACE_LOCAL_SOCK_DGRAM_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) - -#include "ace/SOCK_Dgram.h" -#include "ace/LSOCK.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_LSOCK_Dgram - * - * @brief Create a Local ACE_SOCK datagram. - */ -class ACE_Export ACE_LSOCK_Dgram : public ACE_SOCK_Dgram, public ACE_LSOCK -{ -public: - // = Initialization methods. - /// Default constructor. - ACE_LSOCK_Dgram (void); - - /// Initiate a local dgram. - ACE_LSOCK_Dgram (const ACE_Addr &local, - int protocol_family = PF_UNIX, - int protocol = 0); - - /// Initiate a local dgram. - int open (const ACE_Addr &local, - int protocol_family = PF_UNIX, - int protocol = 0); - - /// Get handle. - ACE_HANDLE get_handle (void) const; - - /// Set handle. - void set_handle (ACE_HANDLE); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/LSOCK_Dgram.inl" -#endif /* __ACE_INLINE__ */ - -#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ -#include /**/ "ace/post.h" -#endif /* ACE_LOCAL_SOCK_DGRAM_H */ diff --git a/ACE/ace/LSOCK_Dgram.inl b/ACE/ace/LSOCK_Dgram.inl deleted file mode 100644 index 2c29136e06d..00000000000 --- a/ACE/ace/LSOCK_Dgram.inl +++ /dev/null @@ -1,22 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE void -ACE_LSOCK_Dgram::set_handle (ACE_HANDLE h) -{ - ACE_TRACE ("ACE_LSOCK_Dgram::set_handle"); - this->ACE_SOCK_Dgram::set_handle (h); - this->ACE_LSOCK::set_handle (h); -} - -ACE_INLINE ACE_HANDLE -ACE_LSOCK_Dgram::get_handle (void) const -{ - ACE_TRACE ("ACE_LSOCK_Dgram::get_handle"); - return this->ACE_SOCK_Dgram::get_handle (); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/LSOCK_Stream.cpp b/ACE/ace/LSOCK_Stream.cpp deleted file mode 100644 index 6ac123661cf..00000000000 --- a/ACE/ace/LSOCK_Stream.cpp +++ /dev/null @@ -1,137 +0,0 @@ -// $Id$ - -#include "ace/LSOCK_Stream.h" -#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) - -#include "ace/Log_Msg.h" -#include "ace/OS_NS_sys_socket.h" - -ACE_RCSID(ace, LSOCK_Stream, "$Id$") - -#if !defined (__ACE_INLINE__) -#include "ace/LSOCK_Stream.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_LSOCK_Stream) - -int -ACE_LSOCK_Stream::get_local_addr (ACE_Addr &addr) const -{ - ACE_TRACE ("ACE_LSOCK_Stream::get_local_addr"); - - // Perform the downcast since had better be an - // . - ACE_UNIX_Addr *rhs_unix_addr = dynamic_cast (&addr); - ACE_UNIX_Addr lhs_unix_addr; - - if (rhs_unix_addr == 0) - return -1; - else if (ACE_SOCK::get_local_addr (lhs_unix_addr) == -1) - return -1; - else - { - *rhs_unix_addr = lhs_unix_addr; - return 0; - } -} - -int -ACE_LSOCK_Stream::get_remote_addr (ACE_Addr &addr) const -{ - ACE_TRACE ("ACE_LSOCK_Stream::get_remote_addr"); - - return this->get_local_addr (addr); -} - -void -ACE_LSOCK_Stream::dump (void) const -{ - ACE_TRACE ("ACE_LSOCK_Stream::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_SOCK_Stream::dump (); - ACE_LSOCK::dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -} - -#if defined (ACE_HAS_MSG) - -// Send a readv-style vector of buffers, along with an open I/O -// handle. - -ssize_t -ACE_LSOCK_Stream::send_msg (const iovec iov[], - size_t n, - ACE_HANDLE handle) -{ - ACE_TRACE ("ACE_LSOCK_Stream::send_msg"); - msghdr send_msg; -#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) - char cmsgbuf[ACE_BSD_CONTROL_MSG_LEN]; - cmsghdr *cmsgptr = (cmsghdr *) cmsgbuf; -#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ - - send_msg.msg_iov = const_cast (iov); - send_msg.msg_iovlen = n; - send_msg.msg_name = 0; - send_msg.msg_namelen = 0; - -#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) - cmsgptr->cmsg_level = SOL_SOCKET; - cmsgptr->cmsg_type = SCM_RIGHTS; - cmsgptr->cmsg_len = sizeof cmsgbuf; - send_msg.msg_control = cmsgbuf; - send_msg.msg_controllen = sizeof cmsgbuf; - *(ACE_HANDLE *) CMSG_DATA (cmsgptr) = handle; - send_msg.msg_flags = 0 ; -#else - send_msg.msg_accrights = (char *) &handle; - send_msg.msg_accrightslen = sizeof handle; -#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ - - return ACE_OS::sendmsg (this->ACE_SOCK_Stream::get_handle (), - &send_msg, 0); -} - -// Read a readv-style vector of buffers, along with an open I/O -// handle. - -ssize_t -ACE_LSOCK_Stream::recv_msg (iovec iov[], - size_t n, - ACE_HANDLE &handle) -{ - ACE_TRACE ("ACE_LSOCK_Stream::recv_msg"); - msghdr recv_msg; -#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) - char cmsgbuf[ACE_BSD_CONTROL_MSG_LEN]; - cmsghdr *cmsgptr = (cmsghdr *) cmsgbuf; -#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ - - recv_msg.msg_iov = (iovec *) iov; - recv_msg.msg_iovlen = n; - recv_msg.msg_name = 0; - recv_msg.msg_namelen = 0; - -#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) - recv_msg.msg_control = cmsgbuf; - recv_msg.msg_controllen = sizeof cmsgbuf; - ssize_t result = ACE_OS::recvmsg (this->ACE_SOCK_Stream::get_handle (), - &recv_msg, 0); - handle = *(ACE_HANDLE*) CMSG_DATA (cmsgptr) ; - return result; -#else - recv_msg.msg_accrights = (char *) &handle; - recv_msg.msg_accrightslen = sizeof handle; - - return ACE_OS::recvmsg (this->ACE_SOCK_Stream::get_handle (), - &recv_msg, 0); -#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ -} -#endif /* ACE_HAS_MSG */ - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ diff --git a/ACE/ace/LSOCK_Stream.h b/ACE/ace/LSOCK_Stream.h deleted file mode 100644 index 99d50e6dbaf..00000000000 --- a/ACE/ace/LSOCK_Stream.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file LSOCK_Stream.h - * - * $Id$ - * - * @author Doug Schmidt - */ -//============================================================================= - - -#ifndef ACE_LOCAL_SOCK_STREAM_H -#define ACE_LOCAL_SOCK_STREAM_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) - -#include "ace/SOCK_Stream.h" -#include "ace/UNIX_Addr.h" -#include "ace/LSOCK.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_LSOCK_Stream - * - * @brief Create a Local ACE_SOCK stream. - */ -class ACE_Export ACE_LSOCK_Stream : public ACE_SOCK_Stream, public ACE_LSOCK -{ -public: - // = Send/recv methods. - /// Send iovecs via <::writev>. - ssize_t send_msg (const iovec iov[], - size_t n, - ACE_HANDLE handle); - - /// Send iovecs via <::writev>. - ssize_t recv_msg (iovec iov[], - size_t n, - ACE_HANDLE &handle); - - /// Get handle. - ACE_HANDLE get_handle (void) const; - - /// Overrides set_handle from the base classes. - void set_handle (ACE_HANDLE fd); - - // = Meta-type info - typedef ACE_UNIX_Addr PEER_ADDR; - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - - /// This method simply returns the "local" addr. - int get_local_addr (ACE_Addr &) const; - - /// This method returns the "local" addr since it's the same value - /// for UNIX domain sockets. - int get_remote_addr (ACE_Addr &) const; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/LSOCK_Stream.inl" -#endif /* __ACE_INLINE__ */ - -#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ -#include /**/ "ace/post.h" -#endif /* ACE_LOCAL_SOCK_STREAM_H */ diff --git a/ACE/ace/LSOCK_Stream.inl b/ACE/ace/LSOCK_Stream.inl deleted file mode 100644 index bf7e45b376d..00000000000 --- a/ACE/ace/LSOCK_Stream.inl +++ /dev/null @@ -1,25 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// Sets both the file descriptors... Overrides handle from the base -// classes. - -ACE_INLINE void -ACE_LSOCK_Stream::set_handle (ACE_HANDLE fd) -{ - ACE_TRACE ("ACE_LSOCK_Stream::set_handle"); - this->ACE_SOCK_Stream::set_handle (fd); - this->ACE_LSOCK::set_handle (fd); -} - -ACE_INLINE ACE_HANDLE -ACE_LSOCK_Stream::get_handle (void) const -{ - ACE_TRACE ("ACE_LSOCK_Stream::get_handle"); - return this->ACE_SOCK_Stream::get_handle (); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Lib_Find.cpp b/ACE/ace/Lib_Find.cpp deleted file mode 100644 index 6db6d78973b..00000000000 --- a/ACE/ace/Lib_Find.cpp +++ /dev/null @@ -1,769 +0,0 @@ -// $Id$ - -#include "ace/Lib_Find.h" -#include "ace/Log_Msg.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_errno.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_unistd.h" -#include "ace/OS_NS_stdlib.h" -#include "ace/OS_Memory.h" -#include "ace/OS_NS_fcntl.h" - -#if defined (ACE_WIN32) -# include "ace/OS_NS_strings.h" -#endif /* ACE_WIN32 */ - -#if defined (ACE_OPENVMS) -#include "ace/RB_Tree.h" -#include "ace/Thread_Mutex.h" -#include "ace/Singleton.h" - -#include /**/ "descrip.h" -#include /**/ "chfdef.h" -#include /**/ "stsdef.h" -#include /**/ "libdef.h" - -extern "C" int LIB$FIND_IMAGE_SYMBOL(...); - -class ACE_LD_Symbol_Registry -{ - // @internal - // = TITLE - // Implements a class to register symbols and addresses for use with DLL - // symbol retrieval. - // - // = DESCRIPTION - // OpenVMS restricts symbol length to 31 characters encoding any symbols - // longer than that. In these cases dlsym() only works with the encoded - // names. - // This creates serious problems for the service configurator framework - // where the factory method names often exceed 31 chars and where loading - // is based on retrieval of method pointers using the *full* name. - // For OpenVMS we therefor added this singleton class and the - // ACE_Dynamic_Svc_Registrar class which registers full names and function - // pointers with this singleton at the time the static ACE_Dynamic_Svc_Registrar - // object is created in a (service) DLL. - // By forcing the DLL to load using a common symbol ("NULL") we trigger static - // object creation *before* the full names are referenced. - // Symbol references will be resolved as follows on OpenVMS: - // - first try directly from DLL using the RTL dlsym() function and if that fails; - // - try to find symbol in singleton registry. -public: - - typedef ACE_RB_Tree, - ACE_Thread_Mutex> - TREE; - - void register_symbol (const ACE_TCHAR* symname, void* symaddr); - - void* find_symbol (const ACE_TCHAR* symname); - - ACE_LD_Symbol_Registry () {} -private: - - TREE symbol_registry_; -}; - -void -ACE_LD_Symbol_Registry::register_symbol (const ACE_TCHAR* symname, - void* symaddr) -{ - int const result = symbol_registry_.bind (symname, symaddr); - if (result == 1) - { - ACE_DEBUG((LM_INFO, ACE_TEXT ("ACE_LD_Symbol_Registry:") - ACE_TEXT (" duplicate symbol %s registered\n"), - ACE_TEXT_ALWAYS_CHAR (symname))); - } - else if (result == -1) - { - ACE_ERROR((LM_ERROR, ACE_TEXT ("ACE_LD_Symbol_Registry:") - ACE_TEXT (" failed to register symbol %s\n"), - ACE_TEXT_ALWAYS_CHAR (symname))); - } -} - -void* -ACE_LD_Symbol_Registry::find_symbol (const ACE_TCHAR* symname) -{ - void* symaddr = 0; - int const result = symbol_registry_.find (symname, symaddr); - - return (result == 0 ? symaddr : 0); -} - -/// Declare a process wide singleton -ACE_SINGLETON_DECLARE (ACE_Singleton, - ACE_LD_Symbol_Registry, - ACE_Thread_Mutex) - -typedef ACE_Singleton - ACE_LD_SYMBOL_REGISTRY; - -#if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION) -template ACE_Singleton * - ACE_Singleton::singleton_; -#endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */ -#endif - -ACE_RCSID(ace, Lib_Find, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -int -ACE::ldfind (const ACE_TCHAR* filename, - ACE_TCHAR pathname[], - size_t maxpathnamelen) -{ - ACE_TRACE ("ACE::ldfind"); -#if defined (ACE_OPENVMS) - if (ACE_OS::strlen(filename) >= maxpathnamelen) - { - errno = ENOMEM; - return -1; - } - - dsc$descriptor nameDsc; - nameDsc.dsc$b_class = DSC$K_CLASS_S; - nameDsc.dsc$b_dtype = DSC$K_DTYPE_T; - nameDsc.dsc$w_length = ACE_OS::strlen(filename); - nameDsc.dsc$a_pointer = (char*)filename; - - char symbol[] = "NULL"; - dsc$descriptor symbolDsc; - symbolDsc.dsc$b_class = DSC$K_CLASS_S; - symbolDsc.dsc$b_dtype = DSC$K_DTYPE_T; - symbolDsc.dsc$w_length = ACE_OS::strlen(symbol); - symbolDsc.dsc$a_pointer = symbol; - - int symbolValue; - int result; - try - { - result = LIB$FIND_IMAGE_SYMBOL(&nameDsc, &symbolDsc, &symbolValue, 0, 0); - } - catch (chf$signal_array& sig) - { - result = sig.chf$l_sig_name; - } - - int severity = result & STS$M_SEVERITY; - int conditionId = result & STS$M_COND_ID; - if (severity == STS$K_SUCCESS || severity == STS$K_WARNING || severity == STS$K_INFO || - (severity == STS$K_ERROR && conditionId == (LIB$_KEYNOTFOU & STS$M_COND_ID))) - { - ACE_OS::strcpy(pathname, filename); - return 0; - } - - if (ACE_OS::strlen(filename) + ACE_OS::strlen(ACE_DLL_PREFIX) >= maxpathnamelen) - { - errno = ENOMEM; - return -1; - } - - - ACE_OS::strcpy(pathname, ACE_DLL_PREFIX); - ACE_OS::strcat(pathname, filename); - nameDsc.dsc$w_length = ACE_OS::strlen(pathname); - nameDsc.dsc$a_pointer = pathname; - try - { - result = LIB$FIND_IMAGE_SYMBOL(&nameDsc, &symbolDsc, &symbolValue, 0, 0); - } - catch (chf$signal_array& sig) - { - result = sig.chf$l_sig_name; - } - - severity = result & STS$M_SEVERITY; - conditionId = result & STS$M_COND_ID; - if (severity == STS$K_SUCCESS || severity == STS$K_WARNING || severity == STS$K_INFO || - (severity == STS$K_ERROR && conditionId == (LIB$_KEYNOTFOU & STS$M_COND_ID))) - { - return 0; - } - errno = ENOENT; - return -1; -#endif /* ACE_OPENVMS */ - -#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) && \ - !defined (ACE_HAS_PHARLAP) - ACE_TCHAR expanded_filename[MAXPATHLEN]; - if (ACE_TEXT_ExpandEnvironmentStrings (filename, - expanded_filename, - sizeof expanded_filename - / sizeof (ACE_TCHAR))) - filename = expanded_filename; -#endif /* ACE_WIN32 && !ACE_HAS_WINCE && !ACE_HAS_PHARLAP */ - - ACE_TCHAR tempcopy[MAXPATHLEN + 1]; - ACE_TCHAR searchpathname[MAXPATHLEN + 1]; -#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK) - ACE_TCHAR decorator[] = ACE_LD_DECORATOR_STR; - ACE_TCHAR searchfilename[MAXPATHLEN + sizeof(decorator) / sizeof (ACE_TCHAR)]; -#else - ACE_TCHAR searchfilename[MAXPATHLEN + 1]; -#endif /* ACE_WIN32 && ACE_LD_DECORATOR_STR && !ACE_DISABLE_DEBUG_DLL_CHECK */ - - // Create a copy of filename to work with. - if (ACE_OS::strlen (filename) + 1 - > (sizeof tempcopy / sizeof (ACE_TCHAR))) - { - errno = ENOMEM; - return -1; - } - else - ACE_OS::strcpy (tempcopy, filename); - - // Insert canonical directory separators. - ACE_TCHAR *separator_ptr; - -#if (ACE_DIRECTORY_SEPARATOR_CHAR != '/') - // Make all the directory separators "canonical" to simplify - // subsequent code. - ACE::strrepl (tempcopy, ACE_DIRECTORY_SEPARATOR_CHAR, '/'); -#endif /* ACE_DIRECTORY_SEPARATOR_CHAR */ - - // Separate filename from pathname. - separator_ptr = ACE_OS::strrchr (tempcopy, '/'); - - // This is a relative path. - if (separator_ptr == 0) - { - searchpathname[0] = '\0'; - ACE_OS::strcpy (searchfilename, tempcopy); - } - else // This is an absolute path. - { - ACE_OS::strcpy (searchfilename, separator_ptr + 1); - separator_ptr[1] = '\0'; - ACE_OS::strcpy (searchpathname, tempcopy); - } - - bool has_suffix = false; - - // Check to see if this has an appropriate DLL suffix for the OS - // platform. - ACE_TCHAR *s = ACE_OS::strrchr (searchfilename, '.'); - - const ACE_TCHAR *dll_suffix = ACE_DLL_SUFFIX; - - if (s != 0) - { - // If we have a dot, we have a suffix - has_suffix = true; - - // Check whether this matches the appropriate platform-specific - // suffix. -#if defined (ACE_WIN32) - // Use on any platform with - // case-insensitive filenames. - if (ACE_OS::strcasecmp (s, dll_suffix) != 0) -#else - if (ACE_OS::strcmp (s, dll_suffix) != 0) -#endif /* ACE_WIN32 */ - { - ACE_ERROR ((LM_WARNING, - ACE_TEXT ("Warning: improper suffix for a ") - ACE_TEXT ("shared library on this platform: %s\n"), - s)); - } - } - - // Make sure we've got enough space in searchfilename. - if (ACE_OS::strlen (searchfilename) - + ACE_OS::strlen (ACE_DLL_PREFIX) - + (has_suffix ? 0 : ACE_OS::strlen (dll_suffix)) - >= (sizeof searchfilename / sizeof (ACE_TCHAR))) - { - errno = ENOMEM; - return -1; - } - -#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK) - size_t len_searchfilename = ACE_OS::strlen (searchfilename); - if (! has_suffix) - ACE_OS::strcpy (searchfilename + len_searchfilename, - decorator); - - for (int tag = 1; tag >= 0; tag --) - { - if (tag == 0) - searchfilename [len_searchfilename] = 0; - -#endif /* ACE_WIN32 && ACE_LD_DECORATOR_STR && !ACE_DISABLE_DEBUG_DLL_CHECK */ - // Use absolute pathname if there is one. - if (ACE_OS::strlen (searchpathname) > 0) - { - if (ACE_OS::strlen (searchfilename) - + ACE_OS::strlen (searchpathname) >= maxpathnamelen) - { - errno = ENOMEM; - return -1; - } - else - { -#if (ACE_DIRECTORY_SEPARATOR_CHAR != '/') - // Revert to native path name separators. - ACE::strrepl (searchpathname, - '/', - ACE_DIRECTORY_SEPARATOR_CHAR); -#endif /* ACE_DIRECTORY_SEPARATOR_CHAR */ - // First, try matching the filename *without* adding a - // prefix. - ACE_OS::sprintf (pathname, - ACE_TEXT ("%s%s%s"), - searchpathname, - searchfilename, - has_suffix ? ACE_TEXT ("") : dll_suffix); - if (ACE_OS::access (pathname, F_OK) == 0) - return 0; - - // Second, try matching the filename *with* adding a prefix. - ACE_OS::sprintf (pathname, - ACE_TEXT ("%s%s%s%s"), - searchpathname, - ACE_DLL_PREFIX, - searchfilename, - has_suffix ? ACE_TEXT ("") : dll_suffix); - if (ACE_OS::access (pathname, F_OK) == 0) - return 0; - } - } - - // Use relative filenames via LD_LIBRARY_PATH or PATH (depending on - // OS platform). - else - { -#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) - ACE_TCHAR *file_component = 0; - DWORD pathlen = - ACE_TEXT_SearchPath (0, - searchfilename, - dll_suffix, - static_cast (maxpathnamelen), - pathname, - &file_component); - if (pathlen >= maxpathnamelen) - { - errno = ENOMEM; - return -1; - } - else if (pathlen > 0) - return 0; - - // In case not found we should try again with the ACE_DLL_PREFIX - // prefixed - ACE_OS::strcpy (searchfilename, ACE_DLL_PREFIX); - ACE_OS::strcat (searchfilename, tempcopy); - pathlen = - ACE_TEXT_SearchPath (0, - searchfilename, - dll_suffix, - static_cast (maxpathnamelen), - pathname, - &file_component); - if (pathlen >= maxpathnamelen) - { - errno = ENOMEM; - return -1; - } - else if (pathlen > 0) - return 0; -#else - ACE_TCHAR *ld_path; -# if defined ACE_DEFAULT_LD_SEARCH_PATH - ld_path = ACE_DEFAULT_LD_SEARCH_PATH; -# else -# if defined (ACE_WIN32) || !defined (ACE_USES_WCHAR) - ld_path = ACE_OS::getenv (ACE_LD_SEARCH_PATH); -# else - // Wide-char, non-Windows only offers char * getenv. So capture - // it, translate to wide-char, and continue. - ACE_Ascii_To_Wide wide_ldpath - (ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (ACE_LD_SEARCH_PATH))); - ld_path = wide_ldpath.wchar_rep (); -# endif /* ACE_WIN32 || !ACE_USES_WCHAR */ -# endif /* ACE_DEFAULT_LD_SEARCH_PATH */ - -#if defined (ACE_HAS_WINCE) - ACE_TCHAR *ld_path_temp = 0; - if (ld_path != 0) - { - ld_path_temp = (ACE_TCHAR *) - ACE_OS::malloc ((ACE_OS::strlen (ld_path) + 2) - * sizeof (ACE_TCHAR)); - if (ld_path_temp != 0) - { - ACE_OS::strcpy (ld_path_temp, - ACE_LD_SEARCH_PATH_SEPARATOR_STR); - - ACE_OS::strcat (ld_path_temp, ld_path); - ld_path = ld_path_temp; - } - else - { - ACE_OS::free ((void *) ld_path_temp); - ld_path = ld_path_temp = 0; - } - } -#endif /* ACE_HAS_WINCE */ - - if (ld_path != 0 - && (ld_path = ACE_OS::strdup (ld_path)) != 0) - { - // strtok has the strange behavior of not separating the - // string ":/foo:/bar" into THREE tokens. One would expect - // that the first iteration the token would be an empty - // string, the second iteration would be "/foo", and the - // third iteration would be "/bar". However, this is not - // the case; one only gets two iterations: "/foo" followed - // by "/bar". - - // This is especially a problem in parsing Unix paths - // because it is permissible to specify 'the current - // directory' as an empty entry. So, we introduce the - // following special code to cope with this: - - // Look at each dynamic lib directory in the search path. - - ACE_TCHAR *nextholder = 0; - const ACE_TCHAR *path_entry = - ACE::strsplit_r (ld_path, - ACE_LD_SEARCH_PATH_SEPARATOR_STR, - nextholder); - int result = 0; - - for (;;) - { - // Check if at end of search path. - if (path_entry == 0) - { - errno = ENOENT; - result = -1; - break; - } - else if (ACE_OS::strlen (path_entry) - + 1 - + ACE_OS::strlen (searchfilename) - >= maxpathnamelen) - { - errno = ENOMEM; - result = -1; - break; - } - // This works around the issue where a path might have - // an empty component indicating 'current directory'. - // We need to do it here rather than anywhere else so - // that the loop condition will still work. - else if (path_entry[0] == '\0') - path_entry = ACE_TEXT ("."); - - // First, try matching the filename *without* adding a - // prefix. - ACE_OS::sprintf (pathname, - ACE_TEXT ("%s%c%s%s"), - path_entry, - ACE_DIRECTORY_SEPARATOR_CHAR, - searchfilename, - has_suffix ? ACE_TEXT ("") : dll_suffix); - if (ACE_OS::access (pathname, F_OK) == 0) - break; - - // Second, try matching the filename *with* adding a - // prefix. - ACE_OS::sprintf (pathname, - ACE_TEXT ("%s%c%s%s%s"), - path_entry, - ACE_DIRECTORY_SEPARATOR_CHAR, - ACE_DLL_PREFIX, - searchfilename, - has_suffix ? ACE_TEXT ("") : dll_suffix); - if (ACE_OS::access (pathname, F_OK) == 0) - break; - - // Fetch the next item in the path - path_entry = - ACE::strsplit_r (0, - ACE_LD_SEARCH_PATH_SEPARATOR_STR, - nextholder); - } - -#if defined (ACE_HAS_WINCE) - if (ld_path_temp != 0) - ACE_OS::free (ld_path_temp); -#endif /* ACE_HAS_WINCE */ - ACE_OS::free ((void *) ld_path); -#if defined (ACE_HAS_WINCE) && defined (ACE_LD_DECORATOR_STR) && \ - !defined (ACE_DISABLE_DEBUG_DLL_CHECK) - if (result == 0 || tag == 0) -#endif /* ACE_HAS_WINCE && ACE_LD_DECORATOR_STR && !ACE_DISABLE_DEBUG_DLL_CHECK */ - return result; - } -#endif /* ACE_WIN32 && !ACE_HAS_WINCE */ - } -#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK) - } -#endif /* ACE_WIN32 && ACE_LD_DECORATOR_STR && !ACE_DISABLE_DEBUG_DLL_CHECK */ - - errno = ENOENT; - return -1; -} - -FILE * -ACE::ldopen (const ACE_TCHAR *filename, - const ACE_TCHAR *type) -{ - ACE_TRACE ("ACE::ldopen"); - - ACE_TCHAR buf[MAXPATHLEN + 1]; - if (ACE::ldfind (filename, - buf, - sizeof (buf) /sizeof (ACE_TCHAR)) == -1) - return 0; - else - return ACE_OS::fopen (buf, type); -} - -ACE_TCHAR * -ACE::ldname (const ACE_TCHAR *entry_point) -{ - ACE_TRACE ("ACE::ldname"); - -#if defined(ACE_NEEDS_DL_UNDERSCORE) - size_t size = - 1 // leading '_' - + ACE_OS::strlen (entry_point) - + 1; - - ACE_TCHAR *new_name; - ACE_NEW_RETURN (new_name, - ACE_TCHAR[size], - 0); - - ACE_OS::strcpy (new_name, ACE_TEXT ("_")); - ACE_OS::strcat (new_name, entry_point); - - return new_name; -#else /* ACE_NEEDS_DL_UNDERSCORE */ - size_t size = - ACE_OS::strlen (entry_point) - + 1; - - ACE_TCHAR *new_name; - ACE_NEW_RETURN (new_name, - ACE_TCHAR[size], - 0); - - ACE_OS::strcpy (new_name, entry_point); - return new_name; -#endif /* ACE_NEEDS_DL_UNDERSCORE */ -} - -#if defined (ACE_OPENVMS) -void -ACE::ldregister (const ACE_TCHAR *entry_point, - void* entry_addr) -{ - ACE_LD_SYMBOL_REGISTRY::instance ()->register_symbol (entry_point, - entry_addr); -} - -void * -ACE::ldsymbol (ACE_SHLIB_HANDLE sh, const ACE_TCHAR *entry_point) -{ - void* symaddr = ACE_OS::dlsym (sh, entry_point); - // if not found through dlsym() try registry - if (symaddr == 0) - symaddr = ACE_LD_SYMBOL_REGISTRY::instance ()->find_symbol (entry_point); - - return symaddr; -} -#endif - -int -ACE::get_temp_dir (ACE_TCHAR *buffer, size_t buffer_len) -{ - int result; -#if defined (ACE_WIN32) - result = ACE_TEXT_GetTempPath (static_cast (buffer_len), - buffer); - - // Make sure to return -1 if there is an error - if (result == 0 && ::GetLastError () != ERROR_SUCCESS - || result > static_cast (buffer_len)) - result = -1; - -#else /* ACE_WIN32 */ - - // NOTE! Non-Windows platforms don't deal with wide chars for env. - // variables, so do this narrow-char and convert to wide for the - // caller if necessary. - - // On non-win32 platforms, check to see what the TMPDIR environment - // variable is defined to be. If it doesn't exist, just use /tmp - const char *tmpdir = ACE_OS::getenv ("TMPDIR"); - - if (tmpdir == 0) - tmpdir = "/tmp"; - - size_t len = ACE_OS::strlen (tmpdir); - - // Check to see if the buffer is large enough for the string, - // another /, and its null character (hence the + 2) - if ((len + 2) > buffer_len) - { - result = -1; - } - else - { - ACE_OS::strcpy (buffer, ACE_TEXT_CHAR_TO_TCHAR (tmpdir)); - - // Add a trailing slash because we cannot assume there is already one - // at the end. And having an extra one should not cause problems. - buffer[len] = ACE_TEXT ('/'); - buffer[len + 1] = 0; - result = 0; - } -#endif /* ACE_WIN32 */ - return result; -} - -ACE_HANDLE -ACE::open_temp_file (const ACE_TCHAR *name, int mode, int perm) -{ -#if defined (ACE_WIN32) - ACE_UNUSED_ARG (perm); - ACE_HANDLE handle = ACE_OS::open (name, - mode, - FILE_SHARE_READ - | FILE_SHARE_WRITE - | FILE_SHARE_DELETE); -#else - // Open it. - ACE_HANDLE handle = ACE_OS::open (name, mode, perm); -#endif /* ACE_WIN32 */ - - if (handle == ACE_INVALID_HANDLE) - return ACE_INVALID_HANDLE; - - // Unlink it so that the file will be removed automatically when the - // process goes away. - if (ACE_OS::unlink (name) == -1) - return ACE_INVALID_HANDLE; - else - // Return the handle. - return handle; -} - -size_t -ACE::strrepl (char *s, char search, char replace) -{ - ACE_TRACE ("ACE::strrepl"); - - size_t replaced = 0; - - for (size_t i = 0; s[i] != '\0'; i++) - if (s[i] == search) - { - s[i] = replace; - ++replaced; - } - - return replaced; -} - - -// Split a string up into 'token'-delimited pieces, ala Perl's -// "split". - -char * -ACE::strsplit_r (char *str, - const char *token, - char *&next_start) -{ - char *result = 0; - - if (str != 0) - next_start = str; - - if (next_start != 0) - { - char *tok_loc = ACE_OS::strstr (next_start, token); - - if (tok_loc != 0) - { - // Return the beginning of the string. - result = next_start; - - // Insure it's terminated. - *tok_loc = '\0'; - next_start = tok_loc + ACE_OS::strlen (token); - } - else - { - result = next_start; - next_start = (char *) 0; - } - } - - return result; -} - -#if defined (ACE_HAS_WCHAR) -wchar_t * -ACE::strsplit_r (wchar_t *str, - const wchar_t *token, - wchar_t *&next_start) -{ - wchar_t *result = 0; - - if (str != 0) - next_start = str; - - if (next_start != 0) - { - wchar_t *tok_loc = ACE_OS::strstr (next_start, token); - - if (tok_loc != 0) - { - // Return the beginning of the string. - result = next_start; - - // Insure it's terminated. - *tok_loc = '\0'; - next_start = tok_loc + ACE_OS::strlen (token); - } - else - { - result = next_start; - next_start = (wchar_t *) 0; - } - } - - return result; -} - -size_t -ACE::strrepl (wchar_t *s, wchar_t search, wchar_t replace) -{ - ACE_TRACE ("ACE::strrepl"); - - size_t replaced = 0; - - for (size_t i = 0; s[i] != '\0'; i++) - if (s[i] == search) - { - s[i] = replace; - ++replaced; - } - - return replaced; -} -#endif /* ACE_HAS_WCHAR */ - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Lib_Find.h b/ACE/ace/Lib_Find.h deleted file mode 100644 index ef146bb337d..00000000000 --- a/ACE/ace/Lib_Find.h +++ /dev/null @@ -1,131 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Lib_Find.h - * - * All the static function calls needed to search and open shared - * libraries. - * - * $Id$ - */ -//============================================================================= - -#ifndef ACE_LIB_FIND_H -#define ACE_LIB_FIND_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" -#include /**/ "ace/ACE_export.h" -#include "ace/os_include/os_stdio.h" -#if defined (ACE_OPENVMS) -# include "ace/OS_NS_dlfcn.h" -#endif - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -namespace ACE -{ - // = Methods for searching and opening shared libraries. - - /** - * Finds the file @a filename either using an absolute path or using - * a relative path in conjunction with ACE_LD_SEARCH_PATH (e.g., - * $LD_LIBRARY_PATH on UNIX or the directories scaned by Win32 API - * SearchPath on Win32). This function will add appropriate suffix - * (e.g., .dll on Win32 or .so on UNIX) according to the OS - * platform. In addition, this function will apply the appropriate - * prefix (e.g., "lib" on UNIX and "" on Win32) if the @a filename - * doesn't match directly. - */ - extern ACE_Export int ldfind (const ACE_TCHAR* filename, - ACE_TCHAR pathname[], - size_t maxpathnamelen); - - /** - * Uses @c ldfind to locate and open the appropriate @a filename and - * returns a pointer to the file, else it returns a NULL - * pointer. @a type specifies how the file should be open. - */ - extern ACE_Export FILE *ldopen (const ACE_TCHAR *filename, - const ACE_TCHAR *type); - - /** - * Transforms @a entry_point into a form that can be located in a - * dynamic library using . For example, with Win32/Borland - * extern "C" functions which use the default calling convention - * have a '_' prepended. Always returns a buffer that has been - * dynamically allocated using . - */ - extern ACE_Export ACE_TCHAR *ldname (const ACE_TCHAR *entry_point); - - -#if defined (ACE_OPENVMS) - /** - * Registers an @a entry_point and its address for later retrieval - * through the ACE::ldsymbol () method. - * For use in cases where the OS compiler encodes long symbolnames. - */ - extern ACE_Export void ldregister (const ACE_TCHAR *entry_point, - void* entry_addr); - - /** - * Looks up an @a entry_point address either from previously registered - * symbols or through ACE_OS::dlsym (). - * Returns 0 in case the entry_point is not found, otherwise nonzero. - * For use in cases where the OS compiler encodes long symbolnames. - */ - extern ACE_Export void *ldsymbol (ACE_SHLIB_HANDLE sh, - const ACE_TCHAR *entry_point); -#endif - - /** - * Returns the temporary directory including the trailing slash in - * @a buffer. Returns -1 for an error or if the buffer_len is not - * long enough. - */ - extern ACE_Export int get_temp_dir (ACE_TCHAR *buffer, size_t buffer_len); - - /// Opening the temp file. File is automagically unlinked when it is - /// closed. This is useful for have temp files. - extern ACE_Export ACE_HANDLE open_temp_file (const ACE_TCHAR *name, - int mode, - int perm = 0); - - // @@ Though the following functions dont come under the same category as - // above, these are used only in the functions in this class. So it makes - // more sense to move these functions too to this class. - // - /// Replace all instances of @a search in @a s with @a replace. Returns - /// the number of replacements made. - extern ACE_Export size_t strrepl (char *s, char search, char replace); - - /** - * Splits string into pieces separated by the string . - * is an opaque cookie handed back by the call to store - * its state for the next invocation, thus making it re-entrant. - * This operates very similar to Perl's function except that - * it returns pieces one at a time instead of into an array. - */ - extern ACE_Export char *strsplit_r (char *s, - const char *token, - char *&next_start); - -#if defined (ACE_HAS_WCHAR) - /// As strrepl, but for wide characters. - extern ACE_Export size_t strrepl (wchar_t *s, - wchar_t search, - wchar_t replace); - - /// As strsplit_r, but for wide characters. - extern ACE_Export wchar_t *strsplit_r (wchar_t *s, - const wchar_t *token, - wchar_t *&next_start); -#endif /* ACE_HAS_WCHAR */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#include /**/ "ace/post.h" -#endif /* ACE_LIB_FIND_H */ - diff --git a/ACE/ace/Local_Memory_Pool.cpp b/ACE/ace/Local_Memory_Pool.cpp deleted file mode 100644 index 09dbb19000d..00000000000 --- a/ACE/ace/Local_Memory_Pool.cpp +++ /dev/null @@ -1,144 +0,0 @@ -// $Id$ - -// Local_Memory_Pool.cpp -#include "ace/Local_Memory_Pool.h" -#include "ace/Auto_Ptr.h" -#include "ace/OS_Memory.h" -#include "ace/Log_Msg.h" - -ACE_RCSID(ace, Local_Memory_Pool, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_Local_Memory_Pool) - -void -ACE_Local_Memory_Pool::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Local_Memory_Pool::dump"); -#endif /* ACE_HAS_DUMP */ -} - -ACE_Local_Memory_Pool::ACE_Local_Memory_Pool (const ACE_TCHAR *, - const OPTIONS *) -{ - ACE_TRACE ("ACE_Local_Memory_Pool::ACE_Local_Memory_Pool"); -} - -ACE_Local_Memory_Pool::~ACE_Local_Memory_Pool (void) -{ - // Free up all memory allocated by this pool. - this->release (); -} - -// Ask system for initial chunk of local memory. -void * -ACE_Local_Memory_Pool::init_acquire (size_t nbytes, - size_t &rounded_bytes, - int &first_time) -{ - ACE_TRACE ("ACE_Local_Memory_Pool::init_acquire"); - // Note that we assume that when ACE_Local_Memory_Pool is used, - // ACE_Malloc's constructor will only get called once. If this - // assumption doesn't hold, we are in deep trouble! - - first_time = 1; - return this->acquire (nbytes, rounded_bytes); -} - -void * -ACE_Local_Memory_Pool::acquire (size_t nbytes, - size_t &rounded_bytes) -{ - ACE_TRACE ("ACE_Local_Memory_Pool::acquire"); - rounded_bytes = this->round_up (nbytes); - - char *temp = 0; - ACE_NEW_RETURN (temp, - char[rounded_bytes], - 0); - - ACE_Auto_Basic_Array_Ptr cp (temp); - - if (this->allocated_chunks_.insert (cp.get ()) != 0) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%P|%t) insertion into set failed\n")), - 0); - - return cp.release (); -} - -int -ACE_Local_Memory_Pool::release (int) -{ - ACE_TRACE ("ACE_Local_Memory_Pool::release"); - - // Zap the memory we allocated. - for (ACE_Unbounded_Set::iterator i = this->allocated_chunks_.begin (); - i != this->allocated_chunks_.end (); - ++i) - delete [] *i; - this->allocated_chunks_.reset (); - return 0; -} - -int -ACE_Local_Memory_Pool::sync (ssize_t, int) -{ - ACE_TRACE ("ACE_Local_Memory_Pool::sync"); - return 0; -} - -int -ACE_Local_Memory_Pool::sync (void *, size_t, int) -{ - ACE_TRACE ("ACE_Local_Memory_Pool::sync"); - return 0; -} - -int -ACE_Local_Memory_Pool::protect (ssize_t, int) -{ - ACE_TRACE ("ACE_Local_Memory_Pool::protect"); - return 0; -} - -int -ACE_Local_Memory_Pool::protect (void *, size_t, int) -{ - ACE_TRACE ("ACE_Local_Memory_Pool::protect"); - return 0; -} - -#if defined (ACE_WIN32) -int -ACE_Local_Memory_Pool::seh_selector (void *) -{ - return 0; - // Continue propagate the structural exception up. -} -#endif /* ACE_WIN32 */ - -int -ACE_Local_Memory_Pool::remap (void *) -{ - return 0; - // Not much can be done. -} - -void * -ACE_Local_Memory_Pool::base_addr (void) const -{ - return 0; -} - -// Let the underlying new operator figure out the alignment... -size_t -ACE_Local_Memory_Pool::round_up (size_t nbytes) -{ - ACE_TRACE ("ACE_Local_Memory_Pool::round_up"); - return ACE::round_to_pagesize (nbytes); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Local_Memory_Pool.h b/ACE/ace/Local_Memory_Pool.h deleted file mode 100644 index 0a7abe4912a..00000000000 --- a/ACE/ace/Local_Memory_Pool.h +++ /dev/null @@ -1,133 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Local_Memory_Pool.h - * - * $Id$ - * - * @author Dougls C. Schmidt - * @author Prashant Jain - */ -//============================================================================= - -#ifndef ACE_LOCAL_MEMORY_POOL_H -#define ACE_LOCAL_MEMORY_POOL_H -#include /**/ "ace/pre.h" - -#include "ace/os_include/sys/os_mman.h" /* Need PROT_RDWR */ -#include "ace/ACE.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Unbounded_Set.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Local_Memory_Pool_Options - * - * @brief Helper class for Local Memory Pool constructor options. - * - * This should be a nested class, but that breaks too many - * compilers. - */ -class ACE_Export ACE_Local_Memory_Pool_Options -{ -}; - -/** - * @class ACE_Local_Memory_Pool - * - * @brief Make a memory pool that is based on C++ new/delete. This is - * useful for integrating existing components that use new/delete - * into the ACE Malloc scheme... - */ -class ACE_Export ACE_Local_Memory_Pool -{ -public: - typedef ACE_Local_Memory_Pool_Options OPTIONS; - - /// Initialize the pool. - ACE_Local_Memory_Pool (const ACE_TCHAR *backing_store_name = 0, - const OPTIONS *options = 0); - - virtual ~ACE_Local_Memory_Pool (void); - - /// Ask system for initial chunk of local memory. - virtual void *init_acquire (size_t nbytes, - size_t &rounded_bytes, - int &first_time); - - /// Acquire at least @a nbytes from the memory pool. @a rounded_bytes is - /// the actual number of bytes allocated. - virtual void *acquire (size_t nbytes, - size_t &rounded_bytes); - - /// Instruct the memory pool to release all of its resources. - virtual int release (int destroy = 1); - - /** - * Sync @a len bytes of the memory region to the backing store - * starting at base_addr_>. If @a len == -1 then sync the - * whole region. - */ - virtual int sync (ssize_t len = -1, int flags = MS_SYNC); - - /// Sync @a len bytes of the memory region to the backing store - /// starting at @a add_. - virtual int sync (void *addr, size_t len, int flags = MS_SYNC); - - /** - * Change the protection of the pages of the mapped region to @a prot - * starting at base_addr_> up to @a len bytes. If @a len == -1 - * then change protection of all pages in the mapped region. - */ - virtual int protect (ssize_t len = -1, int prot = PROT_RDWR); - - /// Change the protection of the pages of the mapped region to @a prot - /// starting at @a addr up to @a len bytes. - virtual int protect (void *addr, size_t len, int prot = PROT_RDWR); - -#if defined (ACE_WIN32) - /** - * Win32 Structural exception selector. The return value decides - * how to handle memory pool related structural exceptions. Returns - * 1, 0, or , -1. - */ - virtual int seh_selector (void *); -#endif /* ACE_WIN32 */ - - /** - * Try to extend the virtual address space so that @a addr is now - * covered by the address mapping. Always returns 0 since we can't - * remap a local memory pool. - */ - virtual int remap (void *addr); - - /// Return the base address of this memory pool, 0 if base_addr - /// never changes. - virtual void *base_addr (void) const; - - /// Dump the state of an object. - virtual void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -protected: - /// List of memory that we have allocated. - ACE_Unbounded_Set allocated_chunks_; - - /// Implement the algorithm for rounding up the request to an - /// appropriate chunksize. - virtual size_t round_up (size_t nbytes); - -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#include /**/ "ace/post.h" -#endif /* ACE_LOCAL_MEMORY_POOL_H */ diff --git a/ACE/ace/Local_Name_Space.cpp b/ACE/ace/Local_Name_Space.cpp deleted file mode 100644 index 7047c234095..00000000000 --- a/ACE/ace/Local_Name_Space.cpp +++ /dev/null @@ -1,169 +0,0 @@ -#include "ace/Local_Name_Space.h" -#include "ace/ACE.h" -#include "ace/RW_Process_Mutex.h" -#include "ace/SString.h" -#include "ace/OS_NS_string.h" -#include "ace/Truncate.h" - -ACE_RCSID (ace, - Local_Name_Space, - "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_NS_String::~ACE_NS_String (void) -{ - if (this->delete_rep_) - delete [] this->rep_; -} - -ACE_WCHAR_T * -ACE_NS_String::fast_rep (void) const -{ - ACE_TRACE ("ACE_NS_String::fast_rep"); - return this->rep_; -} - -ACE_NS_String::operator ACE_NS_WString () const -{ - ACE_TRACE ("ACE_NS_String::operator ACE_NS_WString"); - return ACE_NS_WString (this->rep_, - (this->len_ / sizeof (ACE_WCHAR_T)) - 1); -} - -size_t -ACE_NS_String::len (void) const -{ - ACE_TRACE ("ACE_NS_String::len"); - return this->len_; -} - -char * -ACE_NS_String::char_rep (void) const -{ - ACE_TRACE ("ACE_NS_String::char_rep"); - ACE_NS_WString w_string (this->rep_, - (this->len_ / sizeof (ACE_WCHAR_T)) - 1); - return w_string.char_rep (); -} - -ACE_NS_String::ACE_NS_String (void) - : len_ (0), - rep_ (0), - delete_rep_ (false) -{ - ACE_TRACE ("ACE_NS_String::ACE_NS_String"); -} - -ACE_NS_String::ACE_NS_String (const ACE_NS_WString &s) - : len_ ((s.length () + 1) * sizeof (ACE_WCHAR_T)), - rep_ (s.rep ()), - delete_rep_ (true) -{ - ACE_TRACE ("ACE_NS_String::ACE_NS_String"); -} - -int -ACE_NS_String::strstr (const ACE_NS_String &s) const -{ - ACE_TRACE ("ACE_NS_String::strstr"); - - if (this->len_ < s.len_) - // If they're larger than we are they can't be a substring of us! - return -1; - else if (this->len_ == s.len_) - // Check if we're equal. - return *this == s ? 0 : -1; - else - { - // They're smaller than we are... - const size_t len = (this->len_ - s.len_) / sizeof (ACE_WCHAR_T); - const size_t pat_len = s.len_ / sizeof (ACE_WCHAR_T) - 1; - - for (size_t i = 0; i <= len; ++i) - { - size_t j; - - for (j = 0; j < pat_len; ++j) - if (this->rep_[i + j] != s.rep_[j]) - break; - - if (j == pat_len) - // Found a match! Return the index. - return ACE_Utils::truncate_cast (i); - } - - return -1; - } -} - -bool -ACE_NS_String::operator == (const ACE_NS_String &s) const -{ - ACE_TRACE ("ACE_NS_String::operator =="); - return this->len_ == s.len_ - && ACE_OS::memcmp ((void *) this->rep_, - (void *) s.rep_, this->len_) == 0; -} - -bool -ACE_NS_String::operator != (const ACE_NS_String &s) const -{ - ACE_TRACE ("ACE_NS_String::operator !="); - return !this->operator == (s); -} - -ACE_NS_String::ACE_NS_String (ACE_WCHAR_T *dst, - const ACE_WCHAR_T *src, - size_t bytes) - : len_ (bytes), - rep_ (dst), - delete_rep_ (false) -{ - ACE_TRACE ("ACE_NS_String::ACE_NS_String"); - ACE_OS::memcpy (this->rep_, src, bytes); -} - -u_long -ACE_NS_String::hash (void) const -{ - return ACE::hash_pjw - (reinterpret_cast (const_cast (this->rep_)), - this->len_); -} - -ACE_NS_Internal::ACE_NS_Internal (void) - : value_ (), - type_ () -{ -} - -ACE_NS_Internal::ACE_NS_Internal (ACE_NS_String &value, const char *type) - : value_ (value), - type_ (type) -{ - ACE_TRACE ("ACE_NS_Internal::ACE_NS_Internal"); -} - -bool -ACE_NS_Internal::operator == (const ACE_NS_Internal &s) const -{ - ACE_TRACE ("ACE_NS_Internal::operator =="); - return this->value_ == s.value_; -} - -ACE_NS_String -ACE_NS_Internal::value (void) -{ - ACE_TRACE ("ACE_NS_Internal::value"); - return this->value_; -} - -const char * -ACE_NS_Internal::type (void) -{ - ACE_TRACE ("ACE_NS_Internal::type"); - return this->type_; -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Local_Name_Space.h b/ACE/ace/Local_Name_Space.h deleted file mode 100644 index 381d2d0d5a4..00000000000 --- a/ACE/ace/Local_Name_Space.h +++ /dev/null @@ -1,132 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Local_Name_Space.h - * - * $Id$ - * - * @author Prashant Jain (pjain@cs.wustl.edu) - * @author Irfan Pyarali (irfan@wuerl.wustl.edu) - * @author Douglas C. Schmidt (schmidt@cs.wustl.edu). - */ -//============================================================================= - -#ifndef ACE_LOCAL_NAME_SPACE_H -#define ACE_LOCAL_NAME_SPACE_H - -#include /**/ "ace/pre.h" - -#include "ace/Malloc_T.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -class ACE_NS_WString; - -/** - * @class ACE_NS_String - * - * @brief This class and ACE_NS_Internal are used as Adapters to work - * with the Map_Manager. - * - * In order to work correctly, this class must be able to - * convert back and forth with . - */ -class ACE_Export ACE_NS_String -{ -public: - // = Initialization. - /// Default "no-op" constructor. - ACE_NS_String (void); - - /// Initialization method. - ACE_NS_String (ACE_WCHAR_T *dst, - const ACE_WCHAR_T *src, - size_t len); - - /// Converts an ACE_NS_WString to an ACE_NS_String; - ACE_NS_String (const ACE_NS_WString &); - - /// Destructor - ~ACE_NS_String (void); - - /// Converts an ACE_NS_String to fresh copy of an ACE_NS_WString; - operator ACE_NS_WString () const; - - /// Return the ASCII character representation. - char *char_rep (void) const; - - /// Matches on substrings. - int strstr (const ACE_NS_String &) const; - - /// Compare an ACE_NS_String. - bool operator == (const ACE_NS_String &) const; - - /// Compare an ACE_NS_String. - bool operator != (const ACE_NS_String &) const; - - /// Returns length of the string - size_t len (void) const; - - /// Returns the underlying representation. - ACE_WCHAR_T *fast_rep (void) const; - - /// Returns a hash value for this string. - u_long hash (void) const; - -private: - /// Length of the string. - size_t len_; - - /// This actually points into shared/persistent memory. - ACE_WCHAR_T *rep_; - - /// Should rep_ be deleted when destructed (only used - /// for WString conversions) - bool delete_rep_; -}; - -/** - * @class ACE_NS_Internal - * - * @brief This class and ACE_NS_String are used as Adapters to work - * with the Map_Manager. - */ -class ACE_Export ACE_NS_Internal -{ -public: - /// No-op constructor. - ACE_NS_Internal (void); - - /// Constructor. - ACE_NS_Internal (ACE_NS_String &value, const char *type); - - /// Compare an ACE_NS_Internal - bool operator == (const ACE_NS_Internal &) const; - - /// Return value. - ACE_NS_String value (void); - - /// Return type. - const char *type (void); - -private: - /// Contains the value of the string. - ACE_NS_String value_; - - /// Contains the type of the string. - const char *type_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -// Include the ACE_Local_Name_Space templates stuff at this point. -#include "ace/Local_Name_Space_T.h" - -#include /**/ "ace/post.h" - -#endif /* ACE_LOCAL_NAME_SPACE_H */ diff --git a/ACE/ace/Local_Name_Space_T.cpp b/ACE/ace/Local_Name_Space_T.cpp deleted file mode 100644 index e59756dcb80..00000000000 --- a/ACE/ace/Local_Name_Space_T.cpp +++ /dev/null @@ -1,966 +0,0 @@ -// $Id$ - -#ifndef ACE_LOCAL_NAME_SPACE_T_CPP -#define ACE_LOCAL_NAME_SPACE_T_CPP - -#include "ace/ACE.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Local_Name_Space.h" -#include "ace/Auto_Ptr.h" -#include "ace/Guard_T.h" -#include "ace/OS_NS_regex.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_unistd.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template -ACE_Name_Space_Map::ACE_Name_Space_Map (ALLOCATOR *alloc) - : MAP_MANAGER (alloc) -{ - ACE_TRACE ("ACE_Name_Space_Map::ACE_Name_Space_Map"); -} - -template int -ACE_Name_Space_Map::close (ALLOCATOR *alloc) -{ - ACE_TRACE ("ACE_Name_Space_Map::close"); - - this->table_allocator_ = alloc; - this->entry_allocator_ = alloc; - return this->close_i (); -} - -template int -ACE_Name_Space_Map::bind (const ACE_NS_String &ext_id, - const ACE_NS_Internal &int_id, - ALLOCATOR *alloc) -{ - ACE_TRACE ("ACE_Name_Space_Map::bind"); - - this->table_allocator_ = alloc; - this->entry_allocator_ = alloc; - return this->bind_i (ext_id, int_id); -} - -template int -ACE_Name_Space_Map::unbind (const ACE_NS_String &ext_id, - ACE_NS_Internal &int_id, - ALLOCATOR *alloc) -{ - ACE_TRACE ("ACE_Name_Space_Map::unbind"); - - this->table_allocator_ = alloc; - this->entry_allocator_ = alloc; - return this->unbind_i (ext_id, int_id); -} - -template int -ACE_Name_Space_Map::rebind (const ACE_NS_String &ext_id, - const ACE_NS_Internal &int_id, - ACE_NS_String &old_ext_id, - ACE_NS_Internal &old_int_id, - ALLOCATOR *alloc) -{ - ACE_TRACE ("ACE_Name_Space_Map::rebind"); - - this->table_allocator_ = alloc; - this->entry_allocator_ = alloc; - return this->rebind_i (ext_id, int_id, old_ext_id, old_int_id); -} - -template int -ACE_Name_Space_Map::find (const ACE_NS_String &ext_id, - ACE_NS_Internal &int_id, - ALLOCATOR *alloc) -{ - ACE_TRACE ("ACE_Name_Space_Map::find"); - - this->table_allocator_ = alloc; - this->entry_allocator_ = alloc; - return this->find_i (ext_id, int_id); -} - -#if defined (ACE_WIN32) -template int -ACE_Local_Name_Space::remap (EXCEPTION_POINTERS *ep) -{ - ACE_TRACE ("ACE_Local_Name_Space::remap"); - - void *addr = (void *) ep->ExceptionRecord->ExceptionInformation[1]; - - // The following requires Memory Pool to have ::remap() - // defined. Thus currently this will only work for - // ACE_MMap_Memory_Pool. - if (this->allocator_->alloc ().memory_pool ().remap (addr) == -1) - // Kick it upstairs... - return EXCEPTION_CONTINUE_SEARCH; - -#if __X86__ - // This is 80x86-specific. - ep->ContextRecord->Edi = (DWORD) addr; -#elif __MIPS__ - ep->ContextRecord->IntA0 = - ep->ContextRecord->IntV0 = (DWORD) addr; - ep->ContextRecord->IntT5 = ep->ContextRecord->IntA0 + 3; -#endif /* __X86__ */ - // Resume execution at the original point of "failure." - return EXCEPTION_CONTINUE_EXECUTION; -} -#endif /* ACE_WIN32 */ - -template int -ACE_Local_Name_Space::shared_bind ( - const ACE_NS_WString &name, - const ACE_NS_WString &value, - const char *type, - int rebind) -{ - // Note that we *must* use structured exception handling here - // because (1) we may need to commit virtual memory pages and (2) - // C++ exception handling doesn't support resumption. - int result = 0; - ACE_SEH_TRY - { - result = this->shared_bind_i (name, value, type, rebind); - } - ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ())) - { - } - return result; -} - -template int -ACE_Local_Name_Space::shared_bind_i ( - const ACE_NS_WString &name, - const ACE_NS_WString &value, - const char *type, - int rebind) -{ - - ACE_TRACE ("ACE_Local_Name_Space::shared_bind_i"); - const size_t name_len = (name.length () + 1) * sizeof (ACE_WCHAR_T); - const size_t value_len = (value.length () + 1) * sizeof (ACE_WCHAR_T); - const size_t type_len = ACE_OS::strlen (type) + 1; - const size_t total_len = name_len + value_len + type_len; - char *ptr = (char *) this->allocator_->malloc (total_len); - - if (ptr == 0) - return -1; - else - { - // Note that the value_rep *must* come first to make sure we can - // retrieve this pointer later on in unbind(). - ACE_WCHAR_T *value_rep = (ACE_WCHAR_T *) (ptr); - ACE_WCHAR_T *name_rep = (ACE_WCHAR_T *) (ptr + value_len); - char *new_type = (char *) (ptr + value_len + name_len); - - ACE_Auto_Basic_Array_Ptr name_urep (name.rep ()); - ACE_Auto_Basic_Array_Ptr value_urep (value.rep ()); - ACE_NS_String new_name (name_rep, name_urep.get (), name_len); - ACE_NS_String new_value (value_rep, value_urep.get (), value_len); - - ACE_OS::strcpy (new_type, type); - ACE_NS_Internal new_internal (new_value, new_type); - int result = -1; - - if (rebind == 0) - { - // Do a normal bind. This will fail if there's already an - // with the same name. - result = this->name_space_map_->bind (new_name, - new_internal, - this->allocator_); - - if (result == 1) - { - // Entry already existed so bind failed. Free our - // dynamically allocated memory. - this->allocator_->free ((void *) ptr); - return result; - } - } - else - { - // Do a rebind. If there's already any entry, this will - // return the existing and and - // overwrite the existing name binding. - ACE_NS_String old_name; - ACE_NS_Internal old_internal; - - result = this->name_space_map_->rebind (new_name, new_internal, - old_name, old_internal, - this->allocator_); - if (result == 1) - { - // Free up the memory we allocated in shared_bind(). - // Note that this assumes that the "value" pointer comes - // first and that the value, name, and type are - // contiguously allocated (see above for details) - this->allocator_->free ((void *) (old_internal.value ()).fast_rep ()); - } - } - - if (result == -1) - // Free our dynamically allocated memory. - this->allocator_->free ((void *) ptr); - else - // If bind() or rebind() succeed, they will automatically sync - // up the map manager entry. However, we must sync up our - // name/value memory. - this->allocator_->sync (ptr, total_len); - - return result; - } -} - -template int -ACE_Local_Name_Space::unbind ( - const ACE_NS_WString &name) -{ - // Note that we *must* use structured exception handling here - // because (1) we may need to commit virtual memory pages and (2) - // C++ exception handling doesn't support resumption. - int result = 0; - ACE_SEH_TRY - { - result = this->unbind_i (name); - } - ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ())) - { - } - return result; - -} - -template int -ACE_Local_Name_Space::unbind_i ( - const ACE_NS_WString &name) -{ - ACE_TRACE ("ACE_Local_Name_Space::unbind_i"); - - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1); - ACE_NS_String ns_name (name); - ACE_NS_Internal ns_internal; - if (this->name_space_map_->unbind (ns_name, - ns_internal, - this->allocator_) != 0) - return -1; - - // Free up the memory we allocated in shared_bind(). Note that this - // assumes that the "value" pointer comes first and that the value, - // name and type are contiguously allocated (see shared_bind() for - // details) - this->allocator_->free ((void *) (ns_internal.value ()).fast_rep ()); - return 0; -} - -template int -ACE_Local_Name_Space::bind ( - const ACE_NS_WString &name, - const ACE_NS_WString &value, - const char *type) -{ - ACE_TRACE ("ACE_Local_Name_Space::bind"); - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1); - - return this->shared_bind (name, value, type, 0); -} - -template int -ACE_Local_Name_Space::rebind ( - const ACE_NS_WString &name, - const ACE_NS_WString &value, - const char *type) -{ - ACE_TRACE ("ACE_Local_Name_Space::rebind"); - ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1); - - return this->shared_bind (name, value, type, 1); -} - -template int -ACE_Local_Name_Space::resolve ( - const ACE_NS_WString &name, - ACE_NS_WString &value, - char *&type) -{ - // Note that we *must* use structured exception handling here - // because (1) we may need to commit virtual memory pages and (2) - // C++ exception handling doesn't support resumption. - int result = 0; - ACE_SEH_TRY - { - result = this->resolve_i (name, value, type); - } - ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ())) - { - } - return result; -} - - -template int -ACE_Local_Name_Space::resolve_i ( - const ACE_NS_WString &name, - ACE_NS_WString &value, - char *&type) -{ - ACE_TRACE ("ACE_Local_Name_Space::resolve_i"); - ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1); - - ACE_NS_String ns_name (name); - ACE_NS_Internal ns_internal; - ACE_NS_String nbc_string; // Note the classy variable name! :) - - if (this->name_space_map_->find (ns_name, - ns_internal, - this->allocator_) != 0) - return -1; - - // Calls conversion operator and then calls the ACE_NS_WString - // assignment operator to get a fresh copy. (*#*(@#&!*@!!*@&( HP - // compiler causes us to add an extra copy explicitly !! :) - nbc_string = ns_internal.value (); - value = nbc_string; - - // Gets type and then the actual reprsentation which is a - // ACE_WCHAR_T - const char *temp = ns_internal.type (); - - size_t len = ACE_OS::strlen (ns_internal.type ()); - // Makes a copy here. Caller needs to call delete to free up - // memory. - char *new_type = 0; - ACE_NEW_RETURN (new_type, - char [len + 1], - -1); - - ACE_OS::strsncpy (new_type, temp, len + 1); - type = new_type; - return 0; -} - -template int -ACE_Local_Name_Space::open ( - ACE_Naming_Context::Context_Scope_Type scope_in) -{ - ACE_TRACE ("ACE_Local_Name_Space::open"); - this->ns_scope_ = scope_in; - - return this->create_manager (); -} - -template -ACE_Local_Name_Space::ACE_Local_Name_Space (void) - : allocator_ (0), - name_space_map_ (0), - name_options_ (0) -{ - ACE_TRACE ("ACE_Local_Name_Space::ACE_Local_Name_Space"); -} - -template -ACE_Local_Name_Space::ACE_Local_Name_Space ( - ACE_Naming_Context::Context_Scope_Type scope_in, - ACE_Name_Options *name_options) - : name_options_ (name_options) -{ - ACE_TRACE ("ACE_Local_Name_Space::ACE_Local_Name_Space"); - if (this->open (scope_in) == -1) - ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_Local_Name_Space::ACE_Local_Name_Space"))); -} - -template -ACE_Local_Name_Space::~ACE_Local_Name_Space (void) -{ - ACE_TRACE ("ACE_Local_Name_Space::~ACE_Local_Name_Space"); - - // Remove the map. - delete this->allocator_; - delete this->lock_; -} - -template int -ACE_Local_Name_Space::create_manager (void) -{ - // Note that we *must* use structured exception handling here - // because (1) we may need to commit virtual memory pages and (2) - // C++ exception handling doesn't support resumption. - int result = 0; - ACE_SEH_TRY - { - result = this->create_manager_i (); - } - ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ())) - { - } - return result; -} - - -template int -ACE_Local_Name_Space::create_manager_i (void) -{ - ACE_TRACE ("ACE_Local_Name_Space::create_manager_i"); - // Get directory name - const ACE_TCHAR *dir = this->name_options_->namespace_dir (); - const ACE_TCHAR *database = this->name_options_->database (); - - // Use process name as the file name. - size_t len = ACE_OS::strlen (dir); - len += ACE_OS::strlen (ACE_DIRECTORY_SEPARATOR_STR); - len += ACE_OS::strlen (database) + 1; - - if (len >= MAXNAMELEN + MAXPATHLEN) - { - errno = ENAMETOOLONG; - return -1; - } - - ACE_OS::strcpy (this->context_file_, dir); - ACE_OS::strcat (this->context_file_, ACE_DIRECTORY_SEPARATOR_STR); - ACE_OS::strcat (this->context_file_, database); - - ACE_MEM_POOL_OPTIONS options (this->name_options_->base_address ()); - - ACE_TCHAR lock_name_for_local_name_space [MAXNAMELEN + MAXPATHLEN]; - ACE_TCHAR lock_name_for_backing_store [MAXPATHLEN + MAXNAMELEN]; - const ACE_TCHAR *postfix = database; - - size_t length = 0; - length = sizeof lock_name_for_local_name_space / sizeof (ACE_TCHAR); - ACE_OS::strsncpy (lock_name_for_local_name_space, - dir, - length); - - ACE_OS::strncat (lock_name_for_local_name_space, - ACE_DIRECTORY_SEPARATOR_STR, - length - ACE_OS::strlen (lock_name_for_local_name_space)); - ACE_OS::strncat (lock_name_for_local_name_space, - ACE_TEXT ("name_space_"), - length - ACE_OS::strlen (lock_name_for_local_name_space)); - ACE_OS::strncat (lock_name_for_local_name_space, - postfix, - length - ACE_OS::strlen (lock_name_for_local_name_space)); - - length = sizeof lock_name_for_backing_store / sizeof (ACE_TCHAR); - ACE_OS::strsncpy (lock_name_for_backing_store, - dir, - length); - ACE_OS::strncat (lock_name_for_backing_store, - ACE_DIRECTORY_SEPARATOR_STR, - length - ACE_OS::strlen (lock_name_for_backing_store)); - ACE_OS::strncat (lock_name_for_backing_store, - ACE_TEXT ("backing_store_"), - length - ACE_OS::strlen (lock_name_for_backing_store)); - ACE_OS::strncat (lock_name_for_backing_store, - postfix, - length - ACE_OS::strlen (ACE_TEXT ("backing_store_"))); - - // Create the allocator with the appropriate options. - ACE_NEW_RETURN (this->allocator_, - ALLOCATOR (this->context_file_, - lock_name_for_backing_store, - &options), -1); - - if (ACE_LOG_MSG->op_status ()) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("Allocator::Allocator\n")), - -1); - - ACE_NEW_RETURN (this->lock_, - ACE_LOCK (lock_name_for_local_name_space), - -1); - -#if !defined (ACE_LACKS_ACCESS) - // Now check if the backing store has been created successfully - if (ACE_OS::access (this->context_file_, F_OK) != 0) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("create_manager\n")), - -1); -#endif /* ACE_LACKS_ACCESS */ - - void *ns_map = 0; - - // This is the easy case since if we find the Name Server Map - // Manager we know it's already initialized. - if (this->allocator_->find (ACE_NAME_SERVER_MAP, ns_map) == 0) - { - this->name_space_map_ = (ACE_Name_Space_Map *) ns_map; - if (ACE::debug ()) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("name_space_map_ = %@, ns_map = %@\n"), - this->name_space_map_, ns_map)); - } - - // This is the hard part since we have to avoid potential race - // conditions... We will use the double check here - else - { - ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1); - - // This is the easy case since if we find the Name Server Map - // Manager we know it's already initialized. - if (this->allocator_->find (ACE_NAME_SERVER_MAP, ns_map) == 0) - { - this->name_space_map_ = (ACE_Name_Space_Map *) ns_map; - if (ACE::debug ()) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("name_space_map_ = %@, ns_map = %@\n"), - this->name_space_map_, ns_map)); - } - else - { - size_t map_size = sizeof *this->name_space_map_; - ns_map = this->allocator_->malloc (map_size); - - // Initialize the map into its memory location (e.g., shared memory). - this->name_space_map_ = - new (ns_map) ACE_Name_Space_Map (this->allocator_); - - if (this->allocator_->bind (ACE_NAME_SERVER_MAP, ns_map) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("create_manager\n")), -1); - } - - if (ACE::debug ()) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("name_space_map_ = %@, ns_map = %@\n"), - this->name_space_map_, ns_map)); - } - - return 0; -} - -template int -ACE_Local_Name_Space::list_names_i ( - ACE_WSTRING_SET &set, - const ACE_NS_WString &pattern) -{ - ACE_TRACE ("ACE_Local_Name_Space::list_names_i"); - ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1); - - MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_); - MAP_MANAGER::ENTRY *map_entry; - - int result = 1; - - for (map_entry = 0; - map_iterator.next (map_entry) != 0; - map_iterator.advance()) - { - if (map_entry->ext_id_.strstr (pattern) != -1) - { - ACE_NS_WString entry (map_entry->ext_id_ ); - - if (set.insert (entry) == -1) - { - result = -1; - break; - } - else - result = 0; - } - } - - return result; -} - -template int -ACE_Local_Name_Space::list_values_i ( - ACE_WSTRING_SET &set, - const ACE_NS_WString &pattern) -{ - ACE_TRACE ("ACE_Local_Name_Space::list_values_i"); - ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1); - - MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_); - MAP_MANAGER::ENTRY *map_entry; - - int result = 1; - - for (map_entry = 0; - map_iterator.next (map_entry) != 0; - map_iterator.advance ()) - { - if (map_entry->int_id_.value ().strstr (pattern) != -1) - { - ACE_NS_WString entry (map_entry->int_id_.value ()); - - if (set.insert (entry) == -1) - { - result = -1; - break; - } - else - result = 0; - } - } - - return result; -} - -template int -ACE_Local_Name_Space::list_types_i ( - ACE_WSTRING_SET &set, - const ACE_NS_WString &pattern) -{ - ACE_TRACE ("ACE_Local_Name_Space::list_types_i"); - ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1); - - MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_); - MAP_MANAGER::ENTRY *map_entry; - - char *compiled_regexp = 0; - - // Note that char_rep() allocates memory so we need to delete it - char *pattern_rep = pattern.char_rep (); - - // Check for wildcard case first. - if (ACE_OS::strcmp ("", pattern_rep) == 0) - ACE_ALLOCATOR_RETURN (compiled_regexp, - ACE_OS::strdup (""), - -1); - else - // Compile the regular expression (the 0's cause ACE_OS::compile - // to allocate space). -#if defined (ACE_HAS_REGEX) - compiled_regexp = ACE_OS::compile (pattern_rep, 0, 0); -#else - // If we don't have regular expressions just use the pattern - // directly. - compiled_regexp = pattern_rep; -#endif /* ACE_HAS_REGEX */ - - int result = 1; - - for (map_entry = 0; - map_iterator.next (map_entry) != 0; - map_iterator.advance ()) - { - // Get the type - const char *type = map_entry->int_id_.type (); - - // Everything matches the wildcard. - if (ACE_OS::strcmp ("", pattern_rep) == 0 -#if defined (ACE_HAS_REGEX) - || ACE_OS::step (type, compiled_regexp) != 0) -#else - // If we don't have regular expressions just use strstr() for - // substring matching. - || ACE_OS::strstr (type, compiled_regexp) != 0) -#endif /* ACE_HAS_REGEX */ - - { - ACE_NS_WString entry (type); - - if (set.insert (entry) == -1) - { - result = -1; - break; - } - else - result = 0; - } - } -#if defined (ACE_HAS_REGEX) - if (compiled_regexp) - ACE_OS::free ((void *) compiled_regexp); -#endif /* ACE_HAS_REGEX */ - delete [] pattern_rep; // delete pattern_rep; - return result; -} - -template int -ACE_Local_Name_Space ::list_name_entries_i ( - ACE_BINDING_SET &set, - const ACE_NS_WString &pattern) -{ - ACE_TRACE ("ACE_Local_Name_Space::list_name_entries_i"); - ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1); - - MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_); - MAP_MANAGER::ENTRY *map_entry; - - for (map_entry = 0; - map_iterator.next (map_entry) != 0; - map_iterator.advance()) - { - if (map_entry->ext_id_.strstr (pattern) != -1) - { - ACE_Name_Binding entry (map_entry->ext_id_, - map_entry->int_id_.value (), - map_entry->int_id_.type ()); - - if (set.insert (entry) == -1) - return -1; - } - } - - return 0; -} - -template int -ACE_Local_Name_Space::list_value_entries_i ( - ACE_BINDING_SET &set, - const ACE_NS_WString &pattern) -{ - ACE_TRACE ("ACE_Local_Name_Space::list_value_entries_i"); - ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1); - - MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_); - MAP_MANAGER::ENTRY *map_entry; - - for (map_entry = 0; - map_iterator.next (map_entry) != 0; - map_iterator.advance ()) - { - if (map_entry->int_id_.value ().strstr (pattern) != -1) - { - ACE_Name_Binding entry (map_entry->ext_id_, - map_entry->int_id_.value (), - map_entry->int_id_.type ()); - - if (set.insert (entry) == -1) - return -1; - } - } - return 0; -} - -template int -ACE_Local_Name_Space::list_type_entries_i ( - ACE_BINDING_SET &set, - const ACE_NS_WString &pattern) -{ - ACE_TRACE ("ACE_Local_Name_Space::list_type_entries_i"); - ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1); - - MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_); - MAP_MANAGER::ENTRY *map_entry; - - char *compiled_regexp = 0; - // Note that char_rep() allocates memory so we need to delete it - char *pattern_rep = pattern.char_rep (); - - // Check for wildcard case first. - if (ACE_OS::strcmp ("", pattern_rep) == 0) - compiled_regexp = ACE_OS::strdup (""); - else - // Compile the regular expression (the 0's cause ACE_OS::compile - // to allocate space). -#if defined (ACE_HAS_REGEX) - compiled_regexp = ACE_OS::compile (pattern_rep, 0, 0); -#else /* If we don't have regular expressions just the pattern - directly. */ - compiled_regexp = pattern_rep; -#endif /* ACE_HAS_REGEX */ - - for (map_entry = 0; - map_iterator.next (map_entry) != 0; - map_iterator.advance ()) - { - // Get the type. - const char *type = map_entry->int_id_.type (); - - if (ACE_OS::strcmp ("", pattern_rep) == 0 // Everything matches - // the wildcard. -#if defined (ACE_HAS_REGEX) - || ACE_OS::step (type, compiled_regexp) != 0) -#else /* If we don't have regular expressions just use strstr() for - substring matching. */ - || ACE_OS::strstr (type, compiled_regexp) != 0) -#endif /* ACE_HAS_REGEX */ - { - ACE_Name_Binding entry (map_entry->ext_id_, - map_entry->int_id_.value (), - map_entry->int_id_.type ()); - - if (set.insert (entry) == -1) - return -1; - } - } -#if defined (ACE_HAS_REGEX) - if (compiled_regexp) - ACE_OS::free ((void *) compiled_regexp); -#endif /* ACE_HAS_REGEX */ - delete [] pattern_rep; // delete pattern_rep; - return 0; -} - -template void -ACE_Local_Name_Space::dump_i (void) const -{ - ACE_TRACE ("ACE_Local_Name_Space::dump_i"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - - MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_); - MAP_MANAGER::ENTRY *map_entry; - - for (map_entry = 0; - map_iterator.next (map_entry) != 0; - map_iterator.advance()) - { - char *key = map_entry->ext_id_.char_rep (); - char *value = map_entry->int_id_.value ().char_rep (); -#if !defined (ACE_NLOGGING) - const char *type = map_entry->int_id_.type (); -#endif /* ! ACE_NLOGGING */ - - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("key=%s\nvalue=%s\ntype=%s\n"), - ACE_TEXT_CHAR_TO_TCHAR (key), ACE_TEXT_CHAR_TO_TCHAR (value), ACE_TEXT_CHAR_TO_TCHAR (type))); - // We need to delete key and value since char_rep allocates - // memory for them - delete [] key; - delete [] value; - } - - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -} - -template int -ACE_Local_Name_Space::list_names ( - ACE_WSTRING_SET &set, - const ACE_NS_WString &pattern) -{ - // Note that we *must* use structured exception handling here - // because (1) we may need to commit virtual memory pages and (2) - // C++ exception handling doesn't support resumption. - int result = 0; - ACE_SEH_TRY - { - result = this->list_names_i (set, pattern); - } - ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ())) - { - } - return result; -} - -template int -ACE_Local_Name_Space::list_values ( - ACE_WSTRING_SET &set, - const ACE_NS_WString &pattern) -{ - // Note that we *must* use structured exception handling here - // because (1) we may need to commit virtual memory pages and (2) - // C++ exception handling doesn't support resumption. - int result = 0; - ACE_SEH_TRY - { - result = this->list_values_i (set, pattern); - } - ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ())) - { - } - return result; -} - -template int -ACE_Local_Name_Space::list_types ( - ACE_WSTRING_SET &set, - const ACE_NS_WString &pattern) -{ - // Note that we *must* use structured exception handling here - // because (1) we may need to commit virtual memory pages and (2) - // C++ exception handling doesn't support resumption. - int result = 0; - ACE_SEH_TRY - { - result = this->list_types_i (set, pattern); - } - ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ())) - { - } - return result; -} - -template int -ACE_Local_Name_Space ::list_name_entries ( - ACE_BINDING_SET &set, - const ACE_NS_WString &pattern) -{ - // Note that we *must* use structured exception handling here - // because (1) we may need to commit virtual memory pages and (2) - // C++ exception handling doesn't support resumption. - int result = 0; - ACE_SEH_TRY - { - result = this->list_name_entries_i (set, pattern); - } - ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ())) - { - } - return result; -} - -template int -ACE_Local_Name_Space::list_value_entries ( - ACE_BINDING_SET &set, - const ACE_NS_WString &pattern) -{ - // Note that we *must* use structured exception handling here - // because (1) we may need to commit virtual memory pages and (2) - // C++ exception handling doesn't support resumption. - int result = 0; - ACE_SEH_TRY - { - result = this->list_value_entries_i (set, pattern); - } - ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ())) - { - } - return result; -} - -template int -ACE_Local_Name_Space::list_type_entries ( - ACE_BINDING_SET &set, - const ACE_NS_WString &pattern) -{ - // Note that we *must* use structured exception handling here - // because (1) we may need to commit virtual memory pages and (2) - // C++ exception handling doesn't support resumption. - int result = 0; - ACE_SEH_TRY - { - result = this->list_type_entries_i (set, pattern); - } - ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ())) - { - } - return result; -} - -template void -ACE_Local_Name_Space::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - // Note that we *must* use structured exception handling here - // because (1) we may need to commit virtual memory pages and (2) - // C++ exception handling doesn't support resumption. - - // This should really be a const cast - ACE_Local_Name_Space *fake_this = - (ACE_Local_Name_Space *) this; - ACE_UNUSED_ARG (fake_this); - - ACE_SEH_TRY - { - this->dump_i (); - } - ACE_SEH_EXCEPT (fake_this->remap (GetExceptionInformation ())) - { - } -#endif /* ACE_HAS_DUMP */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_LOCAL_NAME_SPACE_T_CPP */ diff --git a/ACE/ace/Local_Name_Space_T.h b/ACE/ace/Local_Name_Space_T.h deleted file mode 100644 index 14ed9377b30..00000000000 --- a/ACE/ace/Local_Name_Space_T.h +++ /dev/null @@ -1,280 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Local_Name_Space_T.h - * - * $Id$ - * - * @author Prashant Jain - * @author Irfan Pyarali and - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_LOCAL_NAME_SPACE_T_H -#define ACE_LOCAL_NAME_SPACE_T_H -#include /**/ "ace/pre.h" - -#include "ace/Name_Space.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Naming_Context.h" -#include "ace/SString.h" -#include "ace/Local_Name_Space.h" -#include "ace/Null_Mutex.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/// A short-hand name for our set of name/value/type tuples passed back -/// to callers. -typedef ACE_Unbounded_Set ACE_WSTRING_SET; - -ACE_END_VERSIONED_NAMESPACE_DECL - -// Simplify later usage by defining typedefs. -#if (1) -# include "ace/Hash_Map_Manager_T.h" -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -typedef ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex> MAP_MANAGER; -ACE_END_VERSIONED_NAMESPACE_DECL -#else -# include "ace/Map_Manager.h" -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -typedef ACE_Map_Manager MAP_MANAGER; -ACE_END_VERSIONED_NAMESPACE_DECL -#endif /* 0 */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/// @deprecated Deprecated typedefs. Use the map's traits instead. -typedef MAP_MANAGER::ITERATOR MAP_ITERATOR; -typedef MAP_MANAGER::ENTRY MAP_ENTRY; - - -/** - * @class ACE_Name_Space_Map - * - * @brief This class serves as a Proxy that ensures our process always - * has the appropriate allocator in place for every operation - * that accesses or updates the Map Manager. - * - * We need this class because otherwise the ALLOCATOR - * pointer will be stored in the Map_Manager that resides within - * shared memory. Naturally, this will cause horrible problems - * since only the first process to set that pointer will be - * guaranteed the address of the ALLOCATOR is meaningful! - */ -template -class ACE_Name_Space_Map : public MAP_MANAGER -{ -public: - /// Constructor. - ACE_Name_Space_Map (ALLOCATOR *alloc); - - // = The following methods are Proxies to the underlying methods - // provided by ACE_Hash_Map_Manager. When they are called, they - // acquire the lock, set the allocator to the one specific to this - // process, and then call down to perform the intended operation. - int bind (const ACE_NS_String &, - const ACE_NS_Internal &, - ALLOCATOR *alloc); - - int unbind (const ACE_NS_String &, - ACE_NS_Internal &, - ALLOCATOR *alloc); - - int rebind (const ACE_NS_String &, - const ACE_NS_Internal &, - ACE_NS_String &, - ACE_NS_Internal &, - ALLOCATOR *alloc); - - int find (const ACE_NS_String &, - ACE_NS_Internal &, - ALLOCATOR *alloc); - - int close (ALLOCATOR *alloc); -}; - -/** - * @class ACE_Local_Name_Space - * - * @brief Maintaining accesses Local Name Server Database. Allows to - * add NameBindings, change them, remove them and resolve - * NameBindings. - * - * Manages a Naming Service for a local name space which - * includes bindings for node_local and host_local naming - * contexts. All strings are stored in wide character format. - * A Name Binding consists of a name (that's the key), a value - * string and an optional type string (no wide chars). - */ -template -class ACE_Local_Name_Space : public ACE_Name_Space -{ -public: - // = Initialization and termination methods. - /// "Do-nothing" constructor. - ACE_Local_Name_Space (void); - - /** - * Specifies the scope of this namespace, opens and memory-maps the - * associated file (if accessible) or contacts the dedicated name - * server process for NET_LOCAL namespace. - */ - ACE_Local_Name_Space (ACE_Naming_Context::Context_Scope_Type scope_in, - ACE_Name_Options *name_options); - - /** - * Specifies the scope of this namespace, opens and memory-maps the - * associated file (if accessible) or contacts the dedicated name - * server process for NET_LOCAL namespace. - */ - int open (ACE_Naming_Context::Context_Scope_Type scope_in); - - /// Destructor, do some cleanup :TBD: last dtor should "compress" - /// file - ~ACE_Local_Name_Space (void); - - /// Bind a new name to a naming context (Wide character strings). - virtual int bind (const ACE_NS_WString &name, - const ACE_NS_WString &value, - const char *type = ""); - - /** - * Overwrite the value or type of an existing name in a - * ACE_Local_Name_Space or bind a new name to the context, if it - * didn't exist yet. (Wide charcter strings interface). - */ - virtual int rebind (const ACE_NS_WString &name, - const ACE_NS_WString &value, - const char *type = ""); - - /// Delete a name from a ACE_Local_Name_Space (Wide charcter strings - /// Interface). - virtual int unbind (const ACE_NS_WString &name); - virtual int unbind_i (const ACE_NS_WString &name); - - /// Get value and type of a given name binding (Wide chars). The - /// caller is responsible for deleting @a type! - virtual int resolve (const ACE_NS_WString &name, - ACE_NS_WString &value, - char *&type); - virtual int resolve_i (const ACE_NS_WString &name, - ACE_NS_WString &value, - char *&type); - - /// Get a set of names matching a specified pattern (wchars). Matching - /// means the names must begin with the pattern string. - virtual int list_names (ACE_WSTRING_SET &set, - const ACE_NS_WString &pattern); - virtual int list_names_i (ACE_WSTRING_SET &set, - const ACE_NS_WString &pattern); - - /// Get a set of values matching a specified pattern (wchars). Matching - /// means the values must begin with the pattern string. - virtual int list_values (ACE_WSTRING_SET &set, - const ACE_NS_WString &pattern); - virtual int list_values_i (ACE_WSTRING_SET &set, - const ACE_NS_WString &pattern); - - /// Get a set of types matching a specified pattern (wchars). Matching - /// means the types must begin with the pattern string. - virtual int list_types (ACE_WSTRING_SET &set, - const ACE_NS_WString &pattern); - virtual int list_types_i (ACE_WSTRING_SET &set, - const ACE_NS_WString &pattern); - - /** - * Get a set of names matching a specified pattern (wchars). Matching - * means the names must begin with the pattern string. Returns the - * complete binding associated each pattern match. - */ - virtual int list_name_entries (ACE_BINDING_SET &set, - const ACE_NS_WString &pattern); - virtual int list_name_entries_i (ACE_BINDING_SET &set, - const ACE_NS_WString &pattern); - - /** - * Get a set of values matching a specified pattern (wchars). Matching - * means the values must begin with the pattern string. Returns the - * complete binding associated each pattern match. - */ - virtual int list_value_entries (ACE_BINDING_SET &set, - const ACE_NS_WString &pattern); - virtual int list_value_entries_i (ACE_BINDING_SET &set, - const ACE_NS_WString &pattern); - - /** - * Get a set of types matching a specified pattern (wchars). Matching - * means the types must begin with the pattern string. Returns the - * complete binding associated each pattern match. - */ - virtual int list_type_entries (ACE_BINDING_SET &set, - const ACE_NS_WString &pattern); - virtual int list_type_entries_i (ACE_BINDING_SET &set, - const ACE_NS_WString &pattern); - - /// Dump the state of the object - virtual void dump (void) const; - virtual void dump_i (void) const; - - // = I just know this is going to cause problems on some platform... - typedef ACE_Allocator_Adapter > - ALLOCATOR; - -private: -#if defined (ACE_WIN32) - /// Remap the backing store - int remap (EXCEPTION_POINTERS *ep); -#endif /* ACE_WIN32 */ - - /// Factor out code from bind() and rebind(). - int shared_bind (const ACE_NS_WString &name, - const ACE_NS_WString &value, - const char *type, int rebind); - int shared_bind_i (const ACE_NS_WString &name, - const ACE_NS_WString &value, - const char *type, int rebind); - - /// Allocate the appropriate type of map manager that stores the - /// key/value binding. - int create_manager (void); - int create_manager_i (void); - - /// Pointer to the allocator - ALLOCATOR *allocator_; - - /// Pointer to the allocated map manager. - ACE_Name_Space_Map *name_space_map_; - - /// Scope of this naming context (e.g., PROC_LOCAL, NODE_LOCAL, or - /// NET_LOCAL). - ACE_Naming_Context::Context_Scope_Type ns_scope_; - - /// Keep track of the options such as database name etc - ACE_Name_Options *name_options_; - - /// Name of the file used as the backing store. - ACE_TCHAR context_file_[MAXPATHLEN + MAXNAMELEN]; - - /// Synchronization variable. - ACE_LOCK *lock_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Local_Name_Space_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Local_Name_Space_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" -#endif /* ACE_LOCAL_NAME_SPACE_T_H */ diff --git a/ACE/ace/Local_Tokens.cpp b/ACE/ace/Local_Tokens.cpp deleted file mode 100644 index 17330fe79dd..00000000000 --- a/ACE/ace/Local_Tokens.cpp +++ /dev/null @@ -1,1623 +0,0 @@ -// $Id$ - -#include "ace/Local_Tokens.h" - -#if defined (ACE_HAS_TOKENS_LIBRARY) - -#include "ace/Thread.h" -#include "ace/Token_Manager.h" -#include "ace/OS_NS_unistd.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Local_Tokens.inl" -#endif /* __ACE_INLINE__ */ - - -ACE_RCSID (ace, - Local_Tokens, - "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -void -ACE_Tokens::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Tokens::dump"); - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Tokens::dump:\n") - ACE_TEXT (" reference_cont_ = %d\n") - ACE_TEXT (" token_name_ = %s\n"), - reference_count_, token_name_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("waiters_\n"))); - this->waiters_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_Tokens::ACE_Tokens (void) - : visited_ (0), - reference_count_ (0) -{ - ACE_TRACE ("ACE_Tokens::ACE_Tokens"); -} - -ACE_Tokens::~ACE_Tokens (void) -{ -} - -void -ACE_Tokens::make_owner (ACE_TPQ_Entry *caller) -{ - this->waiters_.remove (caller); - this->waiters_.enqueue (caller, 0); -} - -ACE_Token_Proxy_Queue * -ACE_Tokens::waiters () -{ - ACE_TRACE ("ACE_Tokens::waiters"); - return &this->waiters_; -} - -int -ACE_Tokens::no_of_waiters () -{ - ACE_TRACE ("ACE_Tokens::no_of_waiters"); - return this->waiters_.size (); -} - -#if defined (ACE_LACKS_INLINE_FUNCTIONS) -ACE_Null_Token::ACE_Null_Token (void) -{ -} - -ACE_Null_Token::~ACE_Null_Token (void) -{ -} -#endif /* ACE_LACKS_INLINE_FUNCTIONS */ - -void -ACE_TPQ_Entry::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_TPQ_Entry::dump"); - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("ACE_TPQ_Entry::dump:\n") - ACE_TEXT (" nesting_level_ = %d\n") - ACE_TEXT (" client_id_ = %s\n"), - nesting_level_, - client_id_)); - - if (next_ != 0) - { - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("next:.\n"))); - next_->dump (); - } - - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_TPQ_Entry::dump end.\n"))); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_TPQ_Entry::ACE_TPQ_Entry (const ACE_Token_Proxy *new_proxy, - const ACE_TCHAR *client_id) - : cond_var_ (lock_), - next_ (0), - // This const typecast is safe. - proxy_ ((ACE_Token_Proxy *) new_proxy), - nesting_level_ (0), - sleep_hook_ (0) -{ - ACE_TRACE ("ACE_TPQ_Entry::ACE_TPQ_Entry"); - - if (client_id != 0) - this->client_id (client_id); - else - { - // Just make sure we have enough space. - ACE_TCHAR host_name[MAXHOSTNAMELEN]; - ACE_TCHAR name[(sizeof host_name / sizeof (ACE_TCHAR)) + 256]; - ACE_OS::hostname (host_name, sizeof host_name); - - ACE_thread_t thread_id = ACE_Thread::self (); - - // The cast is an attempt to get this to compile (and run, - // hopefully) regardless of the type of ACE_thread_t. - ACE_OS::sprintf (name, - ACE_TEXT ("/%s/%u/%lu"), - host_name, - static_cast (ACE_OS::getpid ()), - *reinterpret_cast (&thread_id)); - - this->client_id (name); - } -} - -ACE_TPQ_Entry::ACE_TPQ_Entry (void) - : cond_var_ (lock_), - proxy_ (0), - nesting_level_ (0), - sleep_hook_ (0) -{ - ACE_TRACE ("ACE_TPQ_Entry::ACE_TPQ_Entry null const."); -} - -ACE_TPQ_Entry::ACE_TPQ_Entry (const ACE_TPQ_Entry &rhs) -: cond_var_ (lock_) -{ - ACE_TRACE ("ACE_TPQ_Entry::ACE_TPQ_Entry copy const."); - *this = rhs; -} - -ACE_TPQ_Entry::~ACE_TPQ_Entry (void) -{ - ACE_TRACE ("ACE_TPQ_Entry::~ACE_TPQ_Entry"); -} - -void -ACE_TPQ_Entry::operator= (const ACE_TPQ_Entry& rhs) -{ - ACE_TRACE ("ACE_TPQ_Entry::operator="); - if (&rhs == this) - return; - this->proxy_ = rhs.proxy (); - this->nesting_level_ = rhs.nesting_level (); - this->client_id (rhs.client_id ()); - this->sleep_hook_ = rhs.sleep_hook (); -} - -void -ACE_TPQ_Entry::client_id (const ACE_TCHAR *id) -{ - ACE_TRACE ("ACE_TPQ_Entry::client_id"); - - if (id == 0) - return; - - ACE_OS::strsncpy (this->client_id_, - (ACE_TCHAR *) id, - ACE_MAXCLIENTIDLEN); -} - -ACE_TSS_TPQ_Entry::~ACE_TSS_TPQ_Entry (void) -{ -} - -void -ACE_TSS_TPQ_Entry::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_TSS_TPQ_Entry::dump"); - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_TSS_TPQ_Entry::dump:\n") - ACE_TEXT (" client_id_ = %s\n"), - client_id_ == 0 ? ACE_TEXT ("0") : client_id_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("base:\n"))); - ACE_TPQ_ENTRY::dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_TSS_TPQ_Entry::ACE_TSS_TPQ_Entry (const ACE_Token_Proxy *proxy, - const ACE_TCHAR *client_id) -: proxy_ (proxy), - client_id_ (client_id) -{ - ACE_TRACE ("ACE_TSS_TPQ_Entry::ACE_TSS_TPQ_Entry"); -} - -ACE_TPQ_Entry * -ACE_TSS_TPQ_Entry::make_TSS_TYPE (void) const -{ - ACE_TRACE ("ACE_TSS_TPQ_Entry::make_TSS_TYPE"); - ACE_TPQ_Entry *temp; - - ACE_NEW_RETURN (temp, - ACE_TPQ_Entry (this->proxy_, - this->client_id_), - 0); - return temp; -} - -ACE_TSS_TPQ_Entry::operator ACE_TPQ_Entry * (void) -{ -#if !defined (ACE_NO_TSS_TOKENS) - return (ACE_TPQ_Entry *) (*((ACE_TSS *) this)); -#else - // Not sure this is the right thing to do, but it seems to work. - // The base class ALSO has a proxy_ and client_id_ members (weird?) - // which don't get initialised. The following two lines make this - // the same as the subclass, so that the slicing works . - ACE_TPQ_ENTRY::proxy ((ACE_Token_Proxy *)(this->proxy_)); - ACE_TPQ_ENTRY::client_id (this->client_id_); - return (ACE_TPQ_Entry *) this;; -#endif /* !ACE_NO_TSS_TOKENS */ -} - -ACE_TPQ_Iterator::ACE_TPQ_Iterator (ACE_Token_Proxy_Queue &q) - : current_ (q.head_) -{ - ACE_TRACE ("ACE_TPQ_Iterator::ACE_TPQ_Iterator"); -} - -int -ACE_TPQ_Iterator::next (ACE_TPQ_Entry *&next_item) -{ - ACE_TRACE ("ACE_TPQ_Iterator::next"); - - next_item = this->current_; - - return current_ != 0; -} - -int -ACE_TPQ_Iterator::done (void) const -{ - ACE_TRACE ("ACE_TPQ_Iterator::done"); - - return this->current_ == 0; -} - -void -ACE_TPQ_Iterator::advance (void) -{ - ACE_TRACE ("ACE_TPQ_Iterator::advance"); - - if (current_ != 0) - this->current_ = this->current_->next_; -} - -void -ACE_TPQ_Iterator::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_TPQ_Iterator::dump"); - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_TPQ_Iterator::dump:\n") - ACE_TEXT (" current_ = %d\n"), - (long) this->current_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("head_ and tail_\n"))); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -void -ACE_Token_Proxy_Queue::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Token_Proxy_Queue::dump"); - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Token_Proxy_Queue::dump:\n") - ACE_TEXT (" size_ = %d\n"), - size_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("head_ and tail_\n"))); - if (this->head_ != 0) - this->head_->dump (); - - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Token_Proxy_Queue::dump end.\n"))); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_Token_Proxy_Queue::ACE_Token_Proxy_Queue (void) - : head_ (0), - tail_ (0), - size_ (0) -{ - ACE_TRACE ("ACE_Token_Proxy_Queue::ACE_Token_Proxy_Queue"); -} - -void -ACE_Token_Proxy_Queue::enqueue (ACE_TPQ_Entry *tpq, - int position) -{ - ACE_TRACE ("ACE_Token_Proxy_Queue::enqueue"); - tpq->next_ = 0; - - ++this->size_; - - if (this->head_ == 0) - { - // make tpq the entire list - this->head_ = this->tail_ = tpq; - return; - } - - if (position == 0) - { - // make head of list - tpq->next_ = this->head_; - this->head_ = tpq; - return; - } - - if (position == -1) - { - // stick at back of list - this->tail_->next_ = tpq; - this->tail_ = tpq; - return; - } - - // walk through list to insertion point - ACE_TPQ_Entry *temp = head_; - - for (int x = position; - x > 1; - --x) - { - // end of queue? - if (temp->next_ == 0) - break; - // advance pointer - else - temp = temp->next_; - } - - // insert new tpq after temp - tpq->next_ = temp->next_; - temp->next_ = tpq; -} - -void -ACE_Token_Proxy_Queue::dequeue (void) -{ - ACE_TRACE ("ACE_Token_Proxy_Queue::dequeue"); - - if (head_ == 0) - return; - - ACE_TPQ_Entry *temp = this->head_; - - this->head_ = this->head_->next_; - - temp->next_ = 0; - - --this->size_; - - if (this->head_ == 0 && this->size_ != 0) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("incorrect size = %d\n"), - this->size_)); -} - -/* -int -ACE_Token_Proxy_Queue::member (const ACE_TCHAR *id) -{ - ACE_TRACE ("ACE_Token_Proxy_Queue::member"); - - for (ACE_TPQ_Entry *temp = this->head_; - temp != 0; - temp = temp->next_) - if (ACE_OS::strcmp (temp->client_id (), id) == 0) - // We found it! - return 1; - - // We didn't find it :-( - return 0; -} -*/ - -void -ACE_Token_Proxy_Queue::remove (const ACE_TPQ_Entry *remove_me) -{ - ACE_TRACE ("ACE_Token_Proxy_Queue::remove"); - // sanity - if ((remove_me == 0) || (this->head_ == 0)) - return; - - // is it the head? - if (this->head_ == remove_me) // pointer comparison. - { - this->head_ = this->head_->next_; - if (this->head_ == 0) - this->tail_ = 0; - - --this->size_; - return; - } - - ACE_TPQ_Entry *temp = this->head_; - ACE_TPQ_Entry *previous = 0; - - // is it in the middle or tail? - while (temp != 0) - { - if (temp == remove_me) - { - // previous should never be null since the first if - // conditional should always be false - previous->next_ = temp->next_; - // is it the tail? - if (this->tail_ == temp) - this->tail_ = previous; - - --this->size_; - return; - } - - previous = temp; - temp = temp->next_; - } - - // it wasn't in the list. - return; -} - -void -ACE_Mutex_Token::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Mutex_Token::dump"); - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Mutex_Token::dump:\n"))); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("lock_\n"))); - lock_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("base:\n"))); - ACE_Tokens::dump (); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Mutex_Token::dump end.\n"))); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_Mutex_Token::ACE_Mutex_Token (const ACE_TCHAR *name) -{ - ACE_TRACE ("ACE_Mutex_Token::ACE_Mutex_Token"); - - ACE_OS::strsncpy (this->token_name_, - name, - ACE_MAXTOKENNAMELEN); -} - -ACE_Mutex_Token::~ACE_Mutex_Token (void) -{ - ACE_TRACE ("ACE_Mutex_Token::~ACE_Mutex_Token"); -} - -int -ACE_Mutex_Token::acquire (ACE_TPQ_Entry *caller, - int ignore_deadlock, - int notify) -{ - ACE_TRACE ("ACE_Mutex_Token::acquire"); - // We need to acquire two locks. This one to ensure that only one - // thread uses this token at a time. - ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon1, this->lock_, -1); - // This one to ensure an atomic transaction across all tokens. Note - // that this order is crucial too. It's resource coloring for other - // threads which may be calling this same token. - ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon2, ACE_Token_Manager::instance ()->mutex (), -1); - - // Does _anyone_ own the token? - if (this->owner () == 0) - { - // there are no waiters, so queue as the first waiter (the owner.) - this->waiters_.enqueue (caller, -1); - return 0; // success - } - - // Does the caller already own it? - if (this->is_owner (caller->client_id ())) - { - // Recursive acquisition. - caller->nesting_level (1); - return 0; // success - } - - // Check for deadlock. - if (!ignore_deadlock - && ACE_Token_Manager::instance ()->check_deadlock (caller->proxy ()) == 1) - { - errno = EDEADLK; - ACE_RETURN (-1); - } - - // Someone owns it. Sorry, you're getting queued up at the end of - // the waiter queue. - this->waiters_.enqueue (caller, -1); - - if (notify) - this->owner ()->call_sleep_hook (); - - errno = EWOULDBLOCK; - ACE_RETURN (-1); - - ACE_NOTREACHED (return -1); -} - -int -ACE_Mutex_Token::tryacquire (ACE_TPQ_Entry *caller) -{ - ACE_TRACE ("ACE_Mutex_Token::tryacquire"); - // We need to acquire two locks. This one to ensure that only one - // thread uses this token at a time. - ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon1, this->lock_, -1); - // This one to ensure an atomic transaction across all tokens. Note - // that this order is crucial too. It's resource coloring for other - // threads which may be calling this same token. - ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon2, ACE_Token_Manager::instance ()->mutex (), -1); - - // Does _anyone_ own the token? - if (this->owner () == 0) - { - this->waiters_.enqueue (caller, -1); - return 0; // success - } - // Does the caller already own it? - if (this->is_owner (caller->client_id ())) - { - // recursive acquisition - caller->nesting_level (1); - return 0; // success - } - else - // Someone owns it. Fail. - { - errno = EWOULDBLOCK; - ACE_RETURN (-1); - } - - ACE_NOTREACHED (return -1); -} - -int -ACE_Mutex_Token::renew (ACE_TPQ_Entry *caller, - int requeue_position) -{ - ACE_TRACE ("ACE_Mutex_Token::renew"); - ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_, -1); - - // Verify that the caller is the owner. - if (this->is_owner (caller->client_id ()) == 0) - { - errno = EACCES; - ACE_RETURN (-1); - } - - // The caller is the owner, so check to see if there are any - // waiters. If not, we just keep the token. == 1 means that there - // is only the owner. - if (this->waiters_.size () == 1 || requeue_position == 0) - return 0; - - // Requeue the caller. - this->waiters_.dequeue (); - - this->waiters_.enqueue (caller, requeue_position); - - // Notify new owner. - if (this->owner () != 0) - this->owner ()->proxy ()->token_acquired (this->owner ()); - - // Tell the caller that the operation would block. - errno = EWOULDBLOCK; - ACE_RETURN (-1); - - ACE_NOTREACHED (return -1); -} - -// Release the current holder of the token (which had -// better be the caller's thread!). - -int -ACE_Mutex_Token::release (ACE_TPQ_Entry *caller) -{ - ACE_TRACE ("ACE_Mutex_Token::release"); - ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_, -1); - - // Does anyone own the token? - if (this->owner () == 0) - { - errno = EACCES; - ACE_RETURN (-1); - } - - // Is the caller the owner. - if (this->is_owner (caller->client_id ())) - { - // Check the nesting level. - if (caller->nesting_level () > 0) - caller->nesting_level (-1); - else - { - this->waiters_.dequeue (); - // Notify new owner. - if (this->owner () != 0) - this->owner ()->proxy ()->token_acquired (this->owner ()); - } - } - else - this->remove (caller); - - return 0; -} - -int -ACE_Mutex_Token::owners (OWNER_STACK &stack, - const ACE_TCHAR *id) -{ - ACE_TRACE ("ACE_Mutex_Token::owners"); - if (this->owner () != 0) - { - stack.push (this->owner ()); - // If an is specified, return whether it is the owner being - // returned. - if (id != 0) - return this->owner ()->equal_client_id (id); - } - - return 0; -} - -int -ACE_Mutex_Token::is_waiting_for (const ACE_TCHAR *id) -{ - ACE_TRACE ("ACE_Mutex_Token::is_waiting_for"); - // If there is no owner, or is the owner, return false. - if ((this->owner () == 0) || this->is_owner (id)) - return 0; - - // Step through each waiter looking for . - ACE_TPQ_Iterator iterator (waiters_); - iterator.advance (); - for (ACE_TPQ_Entry *temp = 0; - iterator.next (temp) != 0; - iterator.advance ()) - { - if (temp->equal_client_id (id)) - return 1; - } - - return 0; -} - -int -ACE_Mutex_Token::is_owner (const ACE_TCHAR *id) -{ - ACE_TRACE ("ACE_Mutex_Token::is_owner"); - // If there is an owner, return whether it is . - if ((this->owner () != 0) && - this->owner ()->equal_client_id (id)) - return 1; - else - return 0; -} - -int -ACE_Mutex_Token::type (void) const -{ - ACE_TRACE ("ACE_Mutex_Token::type"); - return (int) ACE_Tokens::MUTEX; -} - -// ************************************************************ - -int -ACE_RW_Token::type (void) const -{ - ACE_TRACE ("ACE_RW_Token::type"); - return (int) ACE_Tokens::RWLOCK; -} - -void -ACE_RW_Token::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_RW_Token::dump"); - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_RW_Token::dump:\n") - ACE_TEXT ("num_writers_ = %d\n"), num_writers_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("lock_\n"))); - this->lock_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("base:\n"))); - ACE_Tokens::dump (); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_RW_Token::dump end.\n"))); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -ACE_RW_Token::ACE_RW_Token (const ACE_TCHAR *name) -: num_writers_ (0) -{ - ACE_TRACE ("ACE_RW_Token::ACE_RW_Token"); - - ACE_OS::strsncpy (this->token_name_, - name, - ACE_MAXTOKENNAMELEN); -} - -ACE_RW_Token::~ACE_RW_Token (void) -{ - ACE_TRACE ("ACE_RW_Token::~ACE_RW_Token"); -} - -int -ACE_RW_Token::acquire (ACE_TPQ_Entry *caller, - int ignore_deadlock, - int notify) -{ - ACE_TRACE ("ACE_RW_Token::acquire"); - // We need to acquire two locks. This one to ensure that only one - // thread uses this token at a time. - ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon1, this->lock_, -1); - // This one to ensure an atomic transaction across all tokens. Note - // that this order is crucial too. It's resource coloring for other - // threads which may be calling this same token. - ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon2, ACE_Token_Manager::instance ()->mutex (), -1); - - if (caller->proxy ()->type () == ACE_RW_Token::WRITER) - this->num_writers_++; - - // Does _anyone_ own the token? - if (this->owner () == 0) - { - // There are no waiters, so queue as the first waiter (the owner). - this->waiters_.enqueue (caller, -1); - return 0; - } - - // Check for recursive acquisition. - if (this->is_owner (caller->client_id ())) - { - caller->nesting_level (1); - return 0; // Success. - } - - // Reader. - if (caller->proxy ()->type () == ACE_RW_Token::READER) - { - // Are there any writers? - if (this->num_writers_ == 0) - { - // Queue the caller at the end of the queue. - this->waiters_.enqueue (caller, -1); - return 0; - } - // Else failure. - } - - // Failure code. - - // Check for deadlock. - if (!ignore_deadlock && - ACE_Token_Manager::instance ()->check_deadlock (caller->proxy ()) == 1) - { - if (caller->proxy ()->type () == ACE_RW_Token::WRITER) - this->num_writers_--; - errno = EDEADLK; - ACE_RETURN (-1); - } - - // Queue the caller at the end of the queue. - this->waiters_.enqueue (caller, -1); - - if (notify) - { - // If it's a writer, just notify it. - if (this->owner ()->proxy ()->type () == ACE_RW_Token::WRITER) - this->owner ()->call_sleep_hook (); - else - { - // Call back all reader owners. - ACE_TPQ_Entry *temp = this->owner (); - do - { - temp->call_sleep_hook (); - temp = temp->next_; - } - while (temp != 0 && - temp->proxy ()->type () == ACE_RW_Token::READER); - } - } - - errno = EWOULDBLOCK; - ACE_RETURN (-1); - - ACE_NOTREACHED (return -1); -} - -int -ACE_RW_Token::tryacquire (ACE_TPQ_Entry *caller) -{ - ACE_TRACE ("ACE_RW_Token::tryacquire"); - // We need to acquire two locks. This one to ensure that only one - // thread uses this token at a time. - ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon1, this->lock_, -1); - // This one to ensure an atomic transaction across all tokens. Note - // that this order is crucial too. It's resource coloring for other - // threads which may be calling this same token. - ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon2, ACE_Token_Manager::instance ()->mutex (), -1); - - if (caller->proxy ()->type () == ACE_RW_Token::WRITER) - { - this->num_writers_++; - } - - // Does _anyone_ own the token? - if (this->owner () == 0) - { - // There are no waiters, so queue as the first waiter (the owner). - this->waiters_.enqueue (caller, -1); - return 0; - } - - // Check for recursive acquisition. - if (this->is_owner (caller->client_id ())) - { - caller->nesting_level (1); - return 0; // Success. - } - - // Reader. - if (caller->proxy ()->type () == ACE_RW_Token::READER) - { - // Are there any writers? - if (this->num_writers_ == 0) - { - // queue the caller at the end of the queue. - this->waiters_.enqueue (caller, -1); - return 0; - } - // Else, fail. - } - else // Writer. - // We're going to fail, so decrement the num_writers. - { - this->num_writers_--; - } - - - errno = EWOULDBLOCK; - ACE_RETURN (-1); - - ACE_NOTREACHED (return -1); -} - -int -ACE_RW_Token::renew (ACE_TPQ_Entry *caller, - int requeue_position) -{ - ACE_TRACE ("ACE_RW_Token::renew"); - ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_, -1); - - // Werify that the caller is the owner - if (this->is_owner (caller->client_id ()) == 0) - { - errno = EACCES; - ACE_RETURN (-1); - } - - // The caller is the owner, so check to see if there are any - // waiters. If not, we just keep the token. - if (this->waiters_.size () == 1 || requeue_position == 0) - return 0; - - // There are waiters, so remove the caller. - this->remove (caller); - - // Requeue the caller. - this->waiters_.enqueue (caller, requeue_position); - - if (caller->proxy ()->type () == ACE_RW_Token::READER) - { - // If the caller got queued before any writers, the caller is - // still the owner. - if (this->is_owner (caller->client_id ())) - return 0; // success - // else fallthrough and return would block. - } - // Writers will always have to block since waiters_.size () == 1 or - // requeue_position == 0. - - // Get a new owner. - this->notify_new_owner (caller); - - // Tell the caller that the operation would block. - errno = EWOULDBLOCK; - ACE_RETURN (-1); - - ACE_NOTREACHED (return -1); -} - -int -ACE_RW_Token::release (ACE_TPQ_Entry *caller) -{ - ACE_TRACE ("ACE_RW_Token::release"); - ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_, -1); - - // Check for errors. - if ((this->owner () == 0) || - (this->is_owner (caller->client_id ()) == 0)) - { - errno = EACCES; - ACE_RETURN (-1); - } - - if (caller->proxy ()->type () == ACE_RW_Token::WRITER) - num_writers_--; - - // Recursive release. - if (caller->nesting_level () > 0) - { - caller->nesting_level (-1); - return 0; - } - - // Remove the caller and notify the new owner(s). - this->remove (caller); - this->notify_new_owner (caller); - - return 0; -} - -void -ACE_RW_Token::notify_new_owner (ACE_TPQ_Entry *old_owner) -{ - ACE_TRACE ("ACE_RW_Token::notify_new_owner"); - - if (this->owner () == 0) - return; - - if (this->owner ()->proxy ()->type () == ACE_RW_Token::READER) - { - if (old_owner->proxy ()->type () == ACE_RW_Token::READER) - // the owners already know that they're owners - return; - - // The current owner is a reader and the previous owner was a - // writer, so notify all waiting readers up to the first writer. - // call back all reader owners. - ACE_TPQ_Iterator iterator (waiters_); - for (ACE_TPQ_Entry *temp = 0; - iterator.next (temp) != 0; - iterator.advance ()) - { - if (temp->proxy ()->type () == WRITER) - // We've gone through all the readers. - break; - - temp->proxy ()->token_acquired (temp); - } - } - else // writer - this->owner ()->proxy ()->token_acquired (this->owner ()); -} - - -int -ACE_RW_Token::owners (OWNER_STACK &stack, - const ACE_TCHAR *id) -{ - ACE_TRACE ("ACE_RW_Token::owners"); - - if (this->owner () == 0) - return 0; - - int id_is_owner = 0; - - // The first waiter is a writer, so there is only one owner. - if (this->owner ()->proxy ()->type () == WRITER) - { - stack.push (this->owner ()); - // If an is specified, return whether it is the owner being - // returned. - if ((id != 0) && - (ACE_OS::strcmp (id, this->owner ()->client_id ()) == 0)) - id_is_owner = 1; - } - // The first waiter is a reader, so there can be multiple owning - // readers. - else - { - ACE_TPQ_Iterator iterator (waiters_); - for (ACE_TPQ_Entry *temp = 0; - iterator.next (temp) != 0; - iterator.advance ()) - { - if (temp->proxy ()->type () == WRITER) - // We've gone through all the readers. - break; - - stack.push (temp); - - if (!id_is_owner && (id != 0) && - (ACE_OS::strcmp (id, temp->client_id ()) == 0)) - id_is_owner = 1; - } - } - - return id_is_owner; -} - -int -ACE_RW_Token::is_waiting_for (const ACE_TCHAR *id) -{ - ACE_TRACE ("ACE_RW_Token::is_waiting_for"); - // If there is no owner, or is the owner, return false. - if ((this->owner () == 0) || - this->is_owner (id)) - return 0; - - // Step through each waiter looking for . - ACE_TPQ_Iterator iterator (waiters_); - iterator.advance (); - for (ACE_TPQ_Entry *temp = 0; - iterator.next (temp) != 0; - iterator.advance ()) - { - if (temp->equal_client_id (id)) - return 1; - } - - return 0; -} - -int -ACE_RW_Token::is_owner (const ACE_TCHAR *id) -{ - ACE_TRACE ("ACE_RW_Token::is_owner"); - // If there is no owner, return false. - if (this->owner () == 0) - return 0; - - // A writer owns us. - if (this->owner ()->proxy ()->type () == ACE_RW_Token::WRITER) - return this->owner ()->equal_client_id (id); - - // Readers own us. - // Step through each owning reader looking for . - ACE_TPQ_Iterator iterator (waiters_); - for (ACE_TPQ_Entry *temp = 0; - iterator.next (temp) != 0; - iterator.advance ()) - { - if (temp->proxy ()->type () != ACE_RW_Token::READER) - break; - - if (temp->equal_client_id (id)) - return 1; - } - - return 0; -} - -void -ACE_Token_Proxy::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Token_Proxy::dump"); - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Token_Proxy::dump:\n") - ACE_TEXT (" type = %d\n") - ACE_TEXT (" ignore_deadlock_ = %d\n") - ACE_TEXT (" debug_ = %d\n"), - (int) this->type (), ignore_deadlock_, debug_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("mutex_, and waiter_\n"))); - - if (this->token_ != 0) - this->token_->dump (); - - this->waiter_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Token_Proxy::dump end.\n"))); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -const ACE_TCHAR * -ACE_Token_Proxy::client_id (void) const -{ - ACE_TRACE ("ACE_Token_Proxy::client_id"); - // Thread-specific. - const ACE_TPQ_Entry *temp = this->waiter_.operator->(); - const ACE_TCHAR *id = temp->client_id (); - - if (id == 0) - return ACE_TEXT ("ERROR NO CLIENT ID"); - else - return id; -} - -void -ACE_Token_Proxy::client_id (const ACE_TCHAR *client_id) -{ - ACE_TRACE ("ACE_Token_Proxy::client_id"); - this->waiter_->client_id (client_id); -} - -const ACE_TCHAR * -ACE_Token_Proxy::owner_id (void) -{ - ACE_TRACE ("ACE_Token_Proxy::owner_id"); - return this->token_->owner_id (); -} - -const ACE_TCHAR * -ACE_Token_Proxy::name (void) const -{ - ACE_TRACE ("ACE_Token_Proxy::name"); - return this->token_->name (); -} - -#if defined (ACE_WIN32_VC8) -# pragma warning (push) -# pragma warning (disable:4355) /* Use of 'this' in initializer list */ -#endif -ACE_Token_Proxy::ACE_Token_Proxy (void) -: token_ (0), - waiter_ (this, 0) -{ - ACE_TRACE ("ACE_Token_Proxy::ACE_Token_Proxy"); -} - -// Notice the token_ (0). Do *not* copy the token pointer. This must -// be obtained through the token manager. Also, we don't copy any -// waiter info. A copied Proxy does *not* inherit client_id. - -ACE_Token_Proxy::ACE_Token_Proxy (const ACE_Token_Proxy &) - : token_ (0), - waiter_ (this, 0) -{ - ACE_TRACE ("ACE_Token_Proxy::ACE_Token_Proxy"); -} -#if defined (ACE_WIN32_VC8) -# pragma warning (pop) -#endif - -// @@ should I do a mutex_->release ()? -ACE_Token_Proxy::~ACE_Token_Proxy (void) -{ - ACE_TRACE ("ACE_Token_Proxy::~ACE_Token_Proxy"); - - if (token_ != 0) - // notify token manager that we are done with it so it can - // free it if necessary - ACE_Token_Manager::instance ()->release_token (token_); -} - -int -ACE_Token_Proxy::open (const ACE_TCHAR *token_name, - int ignore_deadlock, - int debug) -{ - ACE_TRACE ("ACE_Token_Proxy::open"); - - // Store some parameters. - this->ignore_deadlock_ = ignore_deadlock; - this->debug_ = debug; - - // Used in case a name was not specified. - ACE_TCHAR name[BUFSIZ]; - - // We must have a name. - if (token_name == 0) - { - ACE_OS::sprintf (name, ACE_TEXT ("token %lx"), - reinterpret_cast (this)); - token_name = name; - } - - // Get or create the underlying token. The Token Manager will call - // us back to set token_. - ACE_Token_Manager::instance ()->get_token (this, token_name); - - // Check for failed get or failed new. - if (this->token_ == 0) - { - errno = ENOMEM; - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Can't allocate mutex")), -1); - } - - return 0; -} - -int -ACE_Token_Proxy::acquire (int notify, - void (*sleep_hook)(void *), - ACE_Synch_Options &options) -{ - ACE_TRACE ("ACE_Token_Proxy::acquire"); - if (this->token_ == 0) - { - errno = ENOENT; - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Not open.\n")), -1); - } - - // Make sure no one calls our token_acquired until we have a chance - // to sleep first! If after we call an EWOULDBLOCK - // mutex_->acquire() below, but before we enter handle_options to - // wait on the cond_var, a thread tries to give take us off the - // waiter queue and signal us, IT WILL FIRST HAVE TO ACQUIRE THIS - // cond_var.mutex (). _This_ is why we acquire it. - this->waiter_->cond_var_.mutex ().acquire (); - - this->waiter_->sleep_hook (sleep_hook); - - if (this->token_->acquire (this->waiter_, this->ignore_deadlock_, notify) == -1) - // acquire failed - { - switch (errno) - { - case EDEADLK : - if (!ignore_deadlock_) - { - waiter_->cond_var_.mutex ().release (); - errno = EDEADLK; - ACE_RETURN (-1); - } - // Else, fallthrough and block! - - case EWOULDBLOCK : - if (this->debug_) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%t) waiting for %s, owner is %s, ") - ACE_TEXT ("total waiters == %d\n"), - this->name (), - this->token_->owner_id (), - token_->no_of_waiters ())); - - // no error, but would block, if error, return error (-1), - // otherwise, return whether we called the holder or not. - int return_value; - if (this->handle_options (options, - waiter_->cond_var_) == -1) - return_value = -1; - else - return_value = notify == 1; - - errno = EWOULDBLOCK; - ACE_RETURN (return_value); - - default : - waiter_->cond_var_.mutex ().release (); - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("Token Proxy acquire.")), - -1); - } - } - else - // we have the token - { - if (debug_) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%t) acquired %s\n"), - this->name ())); - waiter_->cond_var_.mutex ().release (); - } - - return 0; -} - -int -ACE_Token_Proxy::tryacquire (void (*sleep_hook)(void *)) -{ - ACE_TRACE ("ACE_Token_Proxy::tryacquire"); - if (this->token_ == 0) - { - errno = ENOENT; - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("Not open.\n")), - -1); - } - - this->waiter_->sleep_hook (sleep_hook); - - return this->token_->tryacquire (waiter_); -} - -int -ACE_Token_Proxy::renew (int requeue_position, - ACE_Synch_Options &options) -{ - ACE_TRACE ("ACE_Token_Proxy::renew"); - if (this->token_ == 0) - { - errno = ENOENT; - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("Not open.\n")), - -1); - } - - // Make sure no one calls our token_acquired until we have a chance - // to sleep first! - this->waiter_->cond_var_.mutex ().acquire (); - - if (this->token_->renew (this->waiter_, requeue_position) == -1) - { - // check for error - if (errno != EWOULDBLOCK) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p renew failed\n"), ACE_TEXT ("ACE_Token_Proxy")), -1); - - if (this->debug_) - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) renew blocking for %s, owner is %s\n"), - this->name (), - token_->owner_id ())); - - // no error, but would block, so block or return - return this->handle_options (options, waiter_->cond_var_); - } - else - // we have the token - { - if (this->debug_) - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) renewed %s\n"), - this->name ())); - waiter_->cond_var_.mutex ().release (); - return 0; - } -} - -int -ACE_Token_Proxy::handle_options (ACE_Synch_Options &options, - ACE_TOKEN_CONST::COND_VAR &cv) -{ - // Some operation failed with EWOULDBLOCK. - ACE_TRACE ("ACE_Token_Proxy::handle_options"); - - if (options[ACE_Synch_Options::USE_REACTOR] == 1) - // Asynchronous. - { - // Save/restore errno. - ACE_Errno_Guard error (errno); - cv.mutex ().release (); - ACE_RETURN (-1); - } - else - // Synchronous. - { - // Block on condition variable. - while (cv.wait ((ACE_Time_Value *) options.time_value ()) == -1) - { - // Note, this should obey whatever thread-specific - // interrupt policy is currently in place... - if (errno == EINTR) - continue; - // We come here if a timeout occurs or some serious - // ACE_Condition object error. - cv.mutex ().release (); - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("condition variable wait") - ACE_TEXT (" bombed.")), -1); - } - - if (this->debug_) - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) unblocking %s.\n"), - this->client_id ())); - cv.mutex ().release (); - return 0; // operation succeeded - } -} - -int -ACE_Token_Proxy::release (ACE_Synch_Options &) -{ - ACE_TRACE ("ACE_Token_Proxy::release"); - - if (this->token_ == 0) - { - errno = ENOENT; - if (debug_) - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Must open before releasing.\n"))); - ACE_RETURN (-1); - } - - if (this->token_->release (waiter_) != 0) - { - // Release failed. - this->token_->remove (this->waiter_); - if (debug_) - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) %p.\n"), ACE_TEXT ("release failed"))); - return -1; - } - else - { - if (this->debug_) - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) released %s, owner is %s\n"), - this->name (), - token_->owner_id ())); - - return 0; - } -} - -int -ACE_Token_Proxy::remove (ACE_Synch_Options &) -{ - ACE_TRACE ("ACE_Token_Proxy::remove"); - return 0; -} - -void -ACE_Token_Proxy::sleep_hook (void) -{ - ACE_TRACE ("ACE_Token_Proxy::sleep_hook"); - // Somebody wants our token! (Let'em wait...) - return; -} - -void -ACE_Token_Proxy::token_acquired (ACE_TPQ_Entry *e) -{ - ACE_TRACE ("ACE_Token_Proxy::token_acquired"); - e->cond_var_.mutex ().acquire (); - // We've been taken off the waiters list and given the token! - // This implementation signals the internal condition - // variable. Thus, if asynchronous acquires are used, this must be - // overriden to do something more useful! - e->cond_var_.signal (); - e->cond_var_.mutex ().release (); - - return; -} - -int -ACE_Token_Proxy::type (void) const -{ - ACE_TRACE ("ACE_Token_Proxy::type"); - return 0; -} - -int -ACE_Token_Proxy::acquire_read (int notify, - void (*sleep_hook)(void *), - ACE_Synch_Options &options) -{ - return this->acquire (notify, - sleep_hook, - options); -} - -int -ACE_Token_Proxy::acquire_write (int notify, - void (*sleep_hook)(void *), - ACE_Synch_Options &options) -{ - return this->acquire (notify, - sleep_hook, - options); -} - -int -ACE_Token_Proxy::tryacquire_read (void (*sleep_hook)(void *)) -{ - return this->tryacquire (sleep_hook); -} - -int -ACE_Token_Proxy::tryacquire_write (void (*sleep_hook)(void *)) -{ - return this->tryacquire (sleep_hook); -} - -ACE_Token_Name::ACE_Token_Name (const ACE_TCHAR *token_name) -{ - ACE_TRACE ("ACE_Token_Name::ACE_Token_Name"); - this->name (token_name); -} - -ACE_Token_Name::ACE_Token_Name (const ACE_Token_Name &rhs) -{ - ACE_TRACE ("ACE_Token_Name::ACE_Token_Name"); - this->name (rhs.name ()); -} - -ACE_Token_Name::~ACE_Token_Name () -{ - ACE_TRACE ("ACE_Token_Name::~ACE_Token_Name"); -} - -void -ACE_Token_Name::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Token_Name::dump"); - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Token_Name::dump:\n") - ACE_TEXT (" token_name_ = %s\n"), - token_name_ == 0 ? ACE_TEXT ("no name") : token_name_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -// ************************************************************ - -ACE_Token_Proxy * -ACE_Local_Mutex::clone (void) const -{ - ACE_Token_Proxy *temp = 0; - ACE_NEW_RETURN (temp, - ACE_Local_Mutex (token_->name (), - ignore_deadlock_, - debug_), - 0); - return temp; -} - -ACE_Tokens * -ACE_Local_Mutex::create_token (const ACE_TCHAR *name) -{ - ACE_Tokens *temp = 0; - ACE_NEW_RETURN (temp, - ACE_Mutex_Token (name), - 0); - return temp; -} - -ACE_Local_Mutex::~ACE_Local_Mutex (void) -{ -} - -// ************************************************************ - -ACE_Local_RLock::~ACE_Local_RLock (void) -{ -} - -ACE_Tokens * -ACE_Local_RLock::create_token (const ACE_TCHAR *name) -{ - ACE_Tokens *temp = 0; - ACE_NEW_RETURN (temp, - ACE_RW_Token (name), - 0); - return temp; -} - -int -ACE_Local_RLock::type (void) const -{ - return ACE_RW_Token::READER; -} - -ACE_Token_Proxy * -ACE_Local_RLock::clone (void) const -{ - ACE_Token_Proxy *temp = 0; - ACE_NEW_RETURN (temp, - ACE_Local_RLock (token_->name (), - ignore_deadlock_, - debug_), - 0); - return temp; -} - -// ************************************************************ - -ACE_Local_WLock::~ACE_Local_WLock (void) -{ -} - -ACE_Tokens * -ACE_Local_WLock::create_token (const ACE_TCHAR *name) -{ - ACE_Tokens *temp = 0; - ACE_NEW_RETURN (temp, - ACE_RW_Token (name), - 0); - return temp; -} - -int -ACE_Local_WLock::type (void) const -{ - return ACE_RW_Token::WRITER; -} - -ACE_Token_Proxy * -ACE_Local_WLock::clone (void) const -{ - ACE_Token_Proxy *temp = 0; - ACE_NEW_RETURN (temp, - ACE_Local_WLock (token_->name (), - ignore_deadlock_, - debug_), - 0); - return temp; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_TOKENS_LIBRARY */ diff --git a/ACE/ace/Local_Tokens.h b/ACE/ace/Local_Tokens.h deleted file mode 100644 index cea51db5894..00000000000 --- a/ACE/ace/Local_Tokens.h +++ /dev/null @@ -1,1121 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Local_Tokens.h - * - * $Id$ - * - * @author Karl-Heinz Dorn - * @author Douglas C. Schmidt - * @author Tim Harrison - * - * This file contains definitions for the following classes: - * - * public: - * 7. ACE_Token_Proxy - * 8. ACE_Null_Token : public ACE_Token_Proxy - * 9. ACE_Local_Mutex : public ACE_Token_Proxy - * *. ACE_Local_RLock : public ACE_Local_Mutex - * &. ACE_Local_WLock : public ACE_Local_Mutex - * private: - * 1. ACE_TOKEN_CONST - * 3. ACE_TPQ_Entry - * b. ACE_TSS_TPQ_Entry - * c. ACE_TPQ_Iterator - * 4. ACE_Token_Proxy_Queue - * 5. ACE_Tokens - * 6. ACE_Mutex_Token : public ACE_Tokens - * 12. ACE_RW_Token : public ACE_Tokens - * a. ACE_Token_Name - * - * Note that the locking classes defined in this file are *not* - * intended to be used as general-purpose synchronization - * mechanisms, such as mutexes or semaphores. Instead, you should - * use the ACE_Recursive_Thread_Mutex, ACE_Thread_Mutex, - * ACE_Thread_Semaphore, etc., that are defined in - * $ACE_ROOT/ace/Synch.h and $ACE_ROOT/ace/Synch_T.h or the - * ACE_Token that's defined in $ACE_ROOT/ace/Token.h. - * - * - */ -//============================================================================= - -#ifndef ACE_LOCAL_MUTEX_H -#define ACE_LOCAL_MUTEX_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_TOKENS_LIBRARY) - -#include "ace/Synch_Traits.h" -#include "ace/Condition_Thread_Mutex.h" -#include "ace/TSS_T.h" -#include "ace/Containers.h" -#include "ace/Synch_Options.h" -#include "ace/Map_Manager.h" -#include "ace/Log_Msg.h" -#include "ace/OS_NS_string.h" -#include "ace/os_include/os_netdb.h" - -#if !(defined (ACE_HAS_THREADS) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)) -# define ACE_NO_TSS_TOKENS 1 -#endif /* !(defined (ACE_HAS_THREADS) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)) */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// 1. -/** - * @class ACE_TOKEN_CONST - * - * @brief Not a public interface. - * - * Constant definitions and typedefs for Token library. Mostly, - * this class is necessary to fight the compiler with order of - * declaration errors. - */ -namespace ACE_TOKEN_CONST -{ -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) - // ACE platform supports some form of threading. - typedef ACE_Condition_Thread_Mutex COND_VAR; - typedef ACE_Thread_Mutex MUTEX; - typedef ACE_Guard GUARD; -#else - typedef ACE_Null_Condition COND_VAR; - typedef ACE_Null_Mutex MUTEX; - typedef ACE_Guard GUARD; -#endif /* ACE_HAS_THREADS */ -} - -// Forward decl. -class ACE_Token_Proxy; - -// 3.. -/** - * @class ACE_TPQ_Entry - * - * @brief Token Proxy Queue entry. Used in the ACE_Token_Proxy_Queue - * - * Not a public interface. - */ -class ACE_Export ACE_TPQ_Entry -{ - friend class ACE_Token_Manager; -public: - typedef void (*PTVF) (void *); - - /// Null constructor. - ACE_TPQ_Entry (void); - - /// Constructor. - ACE_TPQ_Entry (const ACE_Token_Proxy *proxy, - const ACE_TCHAR *client_id); - - /// Copy constructor. - ACE_TPQ_Entry (const ACE_TPQ_Entry &rhs); - - /// Destructor. - ~ACE_TPQ_Entry (void); - - /// Copy operator use by the queue. - void operator= (const ACE_TPQ_Entry &rhs); - - /// Get top of the queue. - ACE_Token_Proxy *proxy (void) const; - - /// Set top of the queue. - void proxy (ACE_Token_Proxy *); - - /// Get nesting level of the entry. - int nesting_level (void) const; - - /// Delta nesting level of the entry. - void nesting_level (int delta); - - /// Get client_id of the entry. - const ACE_TCHAR *client_id (void) const; - - /// Set client_id of the entry. - void client_id (const ACE_TCHAR *); - - /// Returns 1 if @a id == client id. Does not check for @a id == 0. - int equal_client_id (const ACE_TCHAR *id); - - /// One method for arg and sleep_hook. - void set (void (*sleep_hook)(void *)); - - /// Set sleep hook of the entry. - void sleep_hook (void (*sh)(void *)); - - /// Get sleep hook of the entry. - PTVF sleep_hook (void) const; - - /// Call the sleep hook function or method passing arg. - void call_sleep_hook (void); - - /// Dump the state of the class. - void dump (void) const; - - // = Used to block the thread if an acquire fails with EWOULDBLOCK. - ACE_TOKEN_CONST::COND_VAR cond_var_; - ACE_TOKEN_CONST::MUTEX lock_; - - /// Pointer to next in list. - ACE_TPQ_Entry *next_; - - /// Get whether this client is blocked waiting for a token. - int waiting (void) const; - - /// Set whether this client is blocked waiting for a token. - void waiting (int w); - -private: - /// This client is waiting for a token. - int waiting_; - - /// Proxy. - ACE_Token_Proxy *proxy_; - - /// Nesting level. - int nesting_level_; - - /// Arg. - void *arg_; - - /// Client id. - ACE_TCHAR client_id_[ACE_MAXCLIENTIDLEN]; - - /// Sleep hook. - void (*sleep_hook_)(void *); -}; - -// b.. -#if defined (ACE_NO_TSS_TOKENS) -typedef ACE_TPQ_Entry ACE_TPQ_ENTRY; -#else -typedef ACE_TSS ACE_TPQ_ENTRY; -#endif /* ACE_NO_TSS_TOKENS */ - -/** - * @class ACE_TSS_TPQ_Entry - * - * @brief ACE_TSS_TPQ_Entry - * - * Not a public interface. - */ -class ACE_Export ACE_TSS_TPQ_Entry : public ACE_TPQ_ENTRY -{ -public: - /// These are passed to the constructor of ACE_TPQ_Entry in - /// make_TSS_TYPE - ACE_TSS_TPQ_Entry (const ACE_Token_Proxy *proxy, - const ACE_TCHAR *client_id); - - /// Destructor. - virtual ~ACE_TSS_TPQ_Entry (void); - - /// Allows us to pass args to the construction of the TSS object. - virtual ACE_TPQ_Entry *make_TSS_TYPE (void) const; - - /// Operator overloading and inheritence don't mix. - operator ACE_TPQ_Entry *(void); - - /// Dump the state of the class. - void dump (void) const; - -#if defined (ACE_NO_TSS_TOKENS) - ACE_TPQ_Entry *operator-> (void) - { - return (ACE_TPQ_Entry *) this; - } -#endif /* ACE_NO_TSS_TOKENS */ - -private: - /// Private: should not be used - ACE_TSS_TPQ_Entry (const ACE_TSS_TPQ_Entry &); - void operator= (const ACE_TSS_TPQ_Entry &); - - // = These are passed to the constructor of ACE_TPQ_Entry in - // make_TSS_TYPE - - /// Proxy. - const ACE_Token_Proxy *proxy_; - - /// Client_id. - const ACE_TCHAR *client_id_; -}; - -class ACE_Token_Proxy_Queue; - -// c.. -/** - * @class ACE_TPQ_Iterator - * - * @brief Iterates through ACE_Token_Proxy_Queues. - * - * Not a public interface. - */ -class ACE_Export ACE_TPQ_Iterator -{ -public: - /// Constructor. - ACE_TPQ_Iterator (ACE_Token_Proxy_Queue &q); - - /// Destructor. - ~ACE_TPQ_Iterator (void); - - /// Pass back the . - int next (ACE_TPQ_Entry *&next_item); - - /// Returns 1 when all items have been seen, else 0. - int done (void) const; - - /// Move forward by one element in the queue. - void advance (void); - - /// Dump the state of an object. - void dump (void) const; - -private: - ACE_TPQ_Entry *current_; -}; - -// 4.. -/** - * @class ACE_Token_Proxy_Queue - * - * @brief Token waiter list. - * - * Not a public interface. - * This queue holds all the token proxies waiting for ownership - * of a token. Along with the proxy reference, it also stores - * the nesting level, client id, and a magic cookie from the - * proxy. This queue stores the ACE_TPQ_Entries by pointer - * values. It DOES NOT make copies. Thus, the user is - * responsible to ensure that the TPQ's stick around. This is - * motivated by the need to reduce dynamic memory allocation. - */ -class ACE_Export ACE_Token_Proxy_Queue -{ -public: - friend class ACE_TPQ_Iterator; - - /// Constructor. - ACE_Token_Proxy_Queue (void); - - /// Destructor. - ~ACE_Token_Proxy_Queue (void); - - /** - * Enqueue a proxy, nesting level, client_id, and a magic cookie at - * the given position in the list. If the position is -1, we - * enqueue at the end of the list (I think). - */ - void enqueue (ACE_TPQ_Entry* new_entry, - int position); - - /// Top of the queue. - const ACE_TPQ_Entry* head (void); - -// int member (const ACE_TCHAR *id); - // Is this id in the waiter list? - - /// Remove the top waiter. - void dequeue (void); - - /// Remove the waiter whose proxy ref matches @a remove_me. - void remove (const ACE_TPQ_Entry *remove_me); - - /// The number of waiters. - int size (void); - - /// Dump the state of the class. - void dump (void) const; - -protected: - /// Head. - ACE_TPQ_Entry *head_; - - /// Tail. - ACE_TPQ_Entry *tail_; - - /// Size. - int size_; -}; - -// 5.. -/** - * @class ACE_Tokens - * - * @brief Abstract representation of ACE tokens. - * - * Not a public interface. - * Currently, I don't see a reason for providing an abstract - * interface at this level of the library. As of yet, no one - * uses ACE_Tokens derivatives through this abstract interface - * except for ACE_Token_Manager. It only uses the statistical - * methods which are shared by all Tokens. For that reason, it - * still makes since to have a common base class. However, - * acquire, renew, and release do not need to have matching - * interfaces throughout all Tokens. - * To add a new type of token (e.g. semaphore), this class must - * be subtyped to define the new semantics. See - * ACE_Token_Manager for details. - */ -class ACE_Export ACE_Tokens -{ -public: - - /// Null constructor. - ACE_Tokens (void); - - /// Destructor - virtual ~ACE_Tokens (void); - - /// No implementation. - virtual int acquire (ACE_TPQ_Entry *caller, - int ignore_deadlock, - int notify) = 0; - - /// No implementation. - virtual int tryacquire (ACE_TPQ_Entry *caller) = 0; - - /// No implementation. - virtual int renew (ACE_TPQ_Entry *caller, - int requeue_position) = 0; - - /// No implementation. - virtual int release (ACE_TPQ_Entry *caller) = 0; - - /// Move the caller to the front of the waiter list. This is for use - /// with remote mutexes and shadow mutexes. - void make_owner (ACE_TPQ_Entry *caller); - - /// Remove the caller from the waiter list. - void remove (ACE_TPQ_Entry *caller); - - // = Accessor methods. - - /// Stack of owners. - typedef ACE_Unbounded_Stack OWNER_STACK; - - /// Returns a stack of the current owners. Returns -1 on error, 0 on - /// success. If is non-zero, returns 1 if id is an owner. - virtual int owners (OWNER_STACK &o, const ACE_TCHAR *id) = 0; - - /// Returns 1 if is waiting for this token. 0 otherwise. - virtual int is_waiting_for (const ACE_TCHAR *id) = 0; - - /// Returns 1 if is an owner of this token. 0 otherwise. - virtual int is_owner (const ACE_TCHAR *id) = 0; - - /// Return the queue of waiters. - virtual ACE_Token_Proxy_Queue *waiters (void); - - /// Return the number of proxies that are currently waiting to get - /// the token. - virtual int no_of_waiters (void); - - /// The current owner. - const ACE_TCHAR *owner_id (void); - - /// Token name. - const ACE_TCHAR* name (void); - - // = Reference counting. These are only called by the - // Token_Manager. - void inc_reference (void); - int dec_reference (void); - - /// Dump the state of the class. - void dump (void) const; - - /** - * These are the Token types supported by the library at ship time. - * There is no restriction on the number of Token types added by - * "3rd parties." These are only necessary for the Token Server. - */ - enum TOKEN_TYPES { MUTEX, RWLOCK }; - - /** - * Provides a manual RTTI mechanism. This method is used only by - * ACE_Token_Request so that the type of a token can be sent to a - * remote Token Server. - */ - virtual int type (void) const = 0; - - // = The following methods allow the deadlock detection algorithm to - // check if this token has been visited. - - /// Mark or unmark the token as visited. - void visit (int v); - - /// Check if the token has been visited. - int visited (void); - - /// All the data of the current owner. - ACE_TPQ_Entry *owner (void); - -protected: - - /// For the deadlock detection algorithm. - int visited_; - - /// Reference count. - int reference_count_; - - /// List of client's owning and waiting the token. - ACE_Token_Proxy_Queue waiters_; - - /// Name of token. - ACE_TCHAR token_name_[ACE_MAXTOKENNAMELEN]; -}; - -class ACE_Local_Mutex; - -// 6.. -/** - * @class ACE_Mutex_Token - * - * @brief Class that acquires, renews, and releases a process-local - * synchronization token. - * - * Not a public interface. - * This class is a more general-purpose synchronization mechanism - * than SunOS 5.x mutexes. For example, it implements "recursive - * mutex" semantics, where a thread that owns the token can - * reacquire it without deadlocking. In addition, threads that - * are blocked awaiting the token are serviced in strict FIFO - * order as other threads release the token (SunOS 5.x mutexes - * don't strictly enforce an acquisition order). - */ -class ACE_Export ACE_Mutex_Token : public ACE_Tokens -{ -public: - /// Constructor - explicit ACE_Mutex_Token (const ACE_TCHAR* name); - - /// Destructor - virtual ~ACE_Mutex_Token (void); - - // = Synchronization operations. - // With acquire, renew, and release, the caller must be specified so - // that multiple proxies (e.g. ACE_Local_Mutex) can use the same - // token. - - /** - * Returns 0 on success, -1 on failure with as - * the reason. If errnum == EWOULDBLOCK, and notify == 1, - * has been called on the current - * owner of the token. If ignore_deadlock is passed as 1 and errnum - * == EDEADLK, then deadlock was detected via ace_token_manager. - */ - virtual int acquire (ACE_TPQ_Entry *caller, - int ignore_deadlock, - int notify); - - /// Same as acquire, but fails if would block - virtual int tryacquire (ACE_TPQ_Entry *caller); - - /** - * An optimized method that efficiently reacquires the token if no - * other threads are waiting. This is useful for situations where - * you don't want to degrade the quality of service if there are - * other threads waiting to get the token. If == - * -1 and there are other threads waiting to obtain the token we are - * queued at the end of the list of waiters. If - * > -1 then it indicates how many entries to skip over before - * inserting our thread into the list of waiters (e.g., - * == 0 means "insert at front of the queue"). - * Renew has the rather odd semantics such that if there are other - * waiting threads it will give up the token even if the - * nesting_level_ > 1. I'm not sure if this is really the right - * thing to do (since it makes it possible for shared data to be - * changed unexpectedly) so use with caution... Returns 0 on - * success, -1 on failure with as the reason. - * If errnum == EWOULDBLOCK, and notify == 1, - * has been called on the current - * owner of the token. - */ - virtual int renew (ACE_TPQ_Entry *caller, - int requeue_position); - - /** - * Relinquish the token. If there are any waiters then the next one - * in line gets it. If the caller is not the owner, caller is - * removed from the waiter list. - */ - virtual int release (ACE_TPQ_Entry *caller); - - /// Dump the state of the class. - void dump (void) const; - - /// Returns ACE_Tokens::MUTEX. - virtual int type (void) const; - - /// Returns a stack of the current owners. Returns -1 on error, 0 on - /// success. If is non-zero, returns 1 if id is an owner. - virtual int owners (OWNER_STACK &o, const ACE_TCHAR *id); - - /// Returns 1 if is waiting for this token. 0 otherwise. - virtual int is_waiting_for (const ACE_TCHAR *id); - - /// Returns 1 if is an owner of this token. 0 otherwise. - virtual int is_owner (const ACE_TCHAR *id); - -private: - /// ACE_Mutex_Token used to lock internal data structures. - ACE_TOKEN_CONST::MUTEX lock_; -}; - -// 12.. -/** - * @class ACE_RW_Token - * - * @brief Class that acquires, renews, and releases a process-local - * synchronization token. - * - * Not a public interface. - * This class is a more general-purpose synchronization mechanism - * than SunOS 5.x mutexes. For example, it implements "recursive - * mutex" semantics, where a thread that owns the token can - * reacquire it without deadlocking. In addition, threads that are - * blocked awaiting the token are serviced in strict FIFO order as - * other threads release the token (SunOS 5.x mutexes don't strictly - * enforce an acquisition order). - */ -class ACE_Export ACE_RW_Token : public ACE_Tokens -{ -public: - /// Constructor. - explicit ACE_RW_Token (const ACE_TCHAR* name); - - /// Destructor. - virtual ~ACE_RW_Token (void); - - // = Synchronization operations. - // With acquire, renew, and release, the caller must be specified so - // that multiple proxies (e.g. ACE_Local_Mutex) can use the same - // token. - - /** - * Returns 0 on success, -1 on failure with as - * the reason. If errnum == EWOULDBLOCK, and notify == 1, - * has been called on the current - * owner of the token. If @a ignore_deadlock is passed as 1 and errnum - * == EDEADLK, then deadlock was detected via ACE_Token_Manager. - */ - virtual int acquire (ACE_TPQ_Entry *caller, - int ignore_deadlock, - int notify); - - /// Same as acquire except fails on would block - virtual int tryacquire (ACE_TPQ_Entry *caller); - - /** - * An optimized method that efficiently reacquires the token if no - * other threads are waiting. This is useful for situations where - * you don't want to degrade the quality of service if there are - * other threads waiting to get the token. If == - * -1 and there are other threads waiting to obtain the token we are - * queued at the end of the list of waiters. If - * > -1 then it indicates how many entries to skip over before - * inserting our thread into the list of waiters (e.g., - * == 0 means "insert at front of the queue"). - * Renew has the rather odd semantics such that if there are other - * waiting threads it will give up the token even if the - * nesting_level_ > 1. I'm not sure if this is really the right - * thing to do (since it makes it possible for shared data to be - * changed unexpectedly) so use with caution... Returns 0 on - * success, -1 on failure with as the reason. - * If errnum == EWOULDBLOCK, and notify == 1, - * has been called on the current - * owner of the token. - */ - virtual int renew (ACE_TPQ_Entry *caller, - int requeue_position); - - /** - * Relinquish the token. If there are any waiters then the next one - * in line gets it. If the caller is not the owner, caller is - * removed from the waiter list. - */ - virtual int release (ACE_TPQ_Entry *caller); - - /// Dump the state of the class. - void dump (void) const; - - /// These are the types that proxies can be. - enum PROXY_TYPE { READER, WRITER }; - - /// Returns READER or WRITER. - virtual int type (void) const; - - /// Returns a stack of the current owners. Returns -1 on error, 0 on - /// success. If is non-zero, returns 1 if id is an owner. - virtual int owners (OWNER_STACK &o, const ACE_TCHAR *id); - - /// Returns 1 if is waiting for this token. 0 otherwise. - virtual int is_waiting_for (const ACE_TCHAR *id); - - /// Returns 1 if is an owner of this token. 0 otherwise. - virtual int is_owner (const ACE_TCHAR *id); - -protected: - /// The number of waiting writers. - int num_writers_; - - /// ACE_Mutex_Token used to lock internal data structures. - ACE_TOKEN_CONST::MUTEX lock_; - - /// Sets the new owner. - void notify_new_owner (ACE_TPQ_Entry *caller); -}; - -// a.. -/** - * @class ACE_Token_Name - * - * @brief Allows Token_Manger to identify tokens. - * - * For now, this is just a string. We need a string class - * anyway to use in ACE_Map_Manager. Having this class - * (instead of ) allows us to easily change if - * needed. For instance, we may choose to identify tokens by - * name and *type* in the future. - */ -class ACE_Export ACE_Token_Name -{ -public: - /// Construction. - ACE_Token_Name (const ACE_TCHAR *token_name = 0); - - /// Copy construction. - ACE_Token_Name (const ACE_Token_Name &rhs); - - /// Destructor. - virtual ~ACE_Token_Name (void); - - /// Copy. - void operator= (const ACE_Token_Name &rhs); - - /// Comparison. - bool operator== (const ACE_Token_Name &rhs) const; - - /// Get the token name. - const ACE_TCHAR *name (void) const; - - /// Set the token name. - void name (const ACE_TCHAR *new_name); - - /// Dump the state of the class. - void dump (void) const; - -private: - /// Name of the token. - ACE_TCHAR token_name_[ACE_MAXTOKENNAMELEN]; -}; - -// 7.. -/** - * @class ACE_Token_Proxy - * - * @brief Abstract representation of ACE tokens. - * - * Interface for all Tokens in ACE. This class implements the - * synchronization needed for tokens (condition variables etc.) - * The algorithms for the operations (acquire, release, etc.) - * operate on the generic ACE_Tokens interface. Thus, the _type_ - * of token (mutex, rwlock) can be set at construction of - * ACE_Token_Proxy. You can use all Tokens in ACE through the - * ACE_Token_Proxy by passing the proper values at construction. - * Alternatively, there are class definitions which "know" how to - * do this (ACE_Local_Mutex, ACE_Local_RLock, ACE_Local_WLock). - * To add a new type of token (e.g. semaphore), this class is not - * changed. See ACE_Token_Manager for details. - * Tokens (e.g. ACE_Mutex_Token) assume that it can always call - * on a new token owner. This - * is not a problem for synchronous use of token proxies (that is, - * when acquires block until successful.) However, for - * implementations of the Token Server, which may use asynch - * operations, the proxy can not go away after an acquire until - * the token is acquired. This is not really a problem, but - * should be understood. - */ -class ACE_Export ACE_Token_Proxy -{ -public: - friend class ACE_Token_Manager; - friend class ACE_Token_Invariant_Manager; // For testing. - - // Initialization and termination methods. - /// Construction. - ACE_Token_Proxy (void); - - /// Destructor. - virtual ~ACE_Token_Proxy (void); - - /** - * Open the . - * @param name The string uniquely identifying the token. - * @param ignore_deadlock Can be 1 to disable deadlock notifications. - * @param debug Prints debug messages. - */ - virtual int open (const ACE_TCHAR *name, - int ignore_deadlock = 0, - int debug = 0); - - // = The following methods have implementations which are - // independent of the token semantics (mutex, rwlock, etc.) They - // forward operations to the underlying token and perform the - // necessary blocking semantics for operations (condition variables - // etc.) This allows reuse of the blocking code as well as having - // multiple proxies to the same token. - - /// Calls acquire on the token. Blocks the calling thread if would - /// block. - virtual int acquire (int notify = 0, - void (*sleep_hook)(void *) = 0, - ACE_Synch_Options &options = - ACE_Synch_Options::defaults); - - /// Calls renew on the token. Blocks the calling thread if would block. - virtual int renew (int requeue_position = -1, - ACE_Synch_Options &options = - ACE_Synch_Options::defaults); - - /// Calls renew on the token. - virtual int tryacquire (void (*sleep_hook)(void *) = 0); - - /// Calls release on the token. - virtual int release (ACE_Synch_Options &options = - ACE_Synch_Options::defaults); - - /// Calls remove on the token. - virtual int remove (ACE_Synch_Options &options = - ACE_Synch_Options::defaults); - - /// Since the locking mechanism doesn't support read locks then this - /// just calls . - virtual int acquire_read (int notify = 0, - void (*sleep_hook)(void *) = 0, - ACE_Synch_Options &options = - ACE_Synch_Options::defaults); - - /// Since the locking mechanism doesn't support write locks then this - /// just calls . - virtual int acquire_write (int notify = 0, - void (*sleep_hook)(void *) = 0, - ACE_Synch_Options &options = - ACE_Synch_Options::defaults); - - /// Since the locking mechanism doesn't support read locks then this - /// just calls . - virtual int tryacquire_read (void (*sleep_hook)(void *) = 0); - - /// Since the locking mechanism doesn't support write locks then this - /// just calls . - virtual int tryacquire_write (void (*sleep_hook)(void *) = 0); - - // = Utility methods. - - /// Get the client id of the proxy. This is implemented as - /// thread-specific data. - virtual const ACE_TCHAR *client_id (void) const; - - /** - * Set the client_id for the calling thread. I strongly recommend - * that this not be used unless you really know what you're doing. - * I use this in the Token Server, and it caused many headaches. - */ - virtual void client_id (const ACE_TCHAR *client_id); - - /** - * Return the name of the token. This is important for use within - * the token servers (local and remote) as well as with token - * collections. So, all derivations of ACE_Token_Proxy must be able to - * stringify some name. The name must uniquely identify a token. - * So, for instance, the token within the reactor should probably be - * called "Reactor Token." - */ - virtual const ACE_TCHAR *name (void) const; - - /** - * This should really be called . This is called - * by ACE_Token_xx's when another proxy enters the waiting list and - * requests that the current token holder be notified. - */ - virtual void sleep_hook (void); - - /// This is called when a queued (waiting) proxy is removed from the - /// waiters list and given the token. - virtual void token_acquired (ACE_TPQ_Entry *); - - /// The client id of the current token holder - virtual const ACE_TCHAR *owner_id (void); - - /// Return a dynamically allocated clone of the derived class. - virtual ACE_Token_Proxy *clone (void) const = 0; - - /// Dump the state of the class. - void dump (void) const; - - /** - * This method can be used be Tokens (e.g. Readers/Writer Tokens) to - * distinguish between Proxy types. For instance a Reader proxy - * should return a different type value than a Writer proxy. The - * default implementation returns 0. - */ - virtual int type (void) const; - -protected: - /// Duplication. - ACE_Token_Proxy (const ACE_Token_Proxy &); - - /// If this is set, we ignore deadlock. - int ignore_deadlock_; - - /// Print a bunch of debug messages. - int debug_; - - /// Reference to the actual logical token. Many ACE_Local_Mutex - /// proxies can reference the same ACE_Mutex_Token. - ACE_Tokens *token_; - - /// Handles cond_var waits. - int handle_options (ACE_Synch_Options &options, - ACE_TOKEN_CONST::COND_VAR &cv); - - /// Waiter info used for asynchronous transactions. - ACE_TSS_TPQ_Entry waiter_; - - /// Make the correct type of ACE_Tokens. This is called by the Token - /// Manager. - virtual ACE_Tokens *create_token (const ACE_TCHAR *name) = 0; -}; - -// 8.. -/** - * @class ACE_Null_Token - * - * @brief No op class for nonthreaded platform protocols. - */ -class ACE_Export ACE_Null_Token : public ACE_Token_Proxy -{ -public: -#if defined (ACE_LACKS_INLINE_FUNCTIONS) - // @@ Hopefully, we can remove this ridicules ifdef when CE's compiler becomes more normal. - /// Construction. - ACE_Null_Token (void); - - /// Destructor. - ~ACE_Null_Token (void); -#endif /* ACE_LACKS_INLINE_FUNCTION */ - - /// Acquire. - virtual int acquire (int /* notify */ = 0, - void (* /* sleep_hook */ )(void *) = 0, - ACE_Synch_Options & /* options */ = - ACE_Synch_Options::defaults) { return 0; } - - /// Renew. - virtual int renew (int /* requeue_position */ = -1, - ACE_Synch_Options & /* options */ = - ACE_Synch_Options::defaults) { return 0; } - - /// Try acquire. - virtual int tryacquire (void (* /* sleep_hook */)(void *) = 0) { return 0; } - - /// Release. - virtual int release (ACE_Synch_Options & /* options */ = - ACE_Synch_Options::defaults) { return 0; } - - /// Remove. - virtual int remove (ACE_Synch_Options & /* options */ = - ACE_Synch_Options::defaults) { return 0; } - - /// Return a dynamically allocated clone of the derived class. - virtual ACE_Token_Proxy *clone (void) const { return new ACE_Null_Token; } - - /// Dump the state of the class. - void dump (void) const; - - /// Do not allow the Token Manager to create us. - virtual ACE_Tokens *create_token (const ACE_TCHAR *) { return 0; } -}; - -// 9.. -/** - * @class ACE_Local_Mutex - * - * @brief Class that acquires, renews, and releases a synchronization - * token local to the process. - * - * This class is a more general-purpose synchronization mechanism - * than SunOS 5.x mutexes. For example, it implements "recursive - * mutex" semantics, where a thread that owns the token can - * reacquire it without deadlocking. In addition, threads that - * are blocked awaiting the token are serviced in strict FIFO - * order as other threads release the token (SunOS 5.x mutexes - * don't strictly enforce an acquisition order). Lastly, - * ACE_Local_Mutex performs deadlock detection on acquire calls. - * The interfaces for acquire, tryacquire, renew, release, - * etc. are defined in ACE_Token_Proxy. The semantics for - * ACE_Local_Mutex are that of a mutex. - */ -class ACE_Export ACE_Local_Mutex : public ACE_Token_Proxy -{ -public: - /** - * Constructor. - * @param token_name Uniquely id's the token. - * @param ignore_deadlock Will allow deadlock to occur (useful for testing). - * @param debug Prints a bunch of messages. - */ - ACE_Local_Mutex (const ACE_TCHAR *token_name = 0, - int ignore_deadlock = 0, - int debug = 0); - - /// Destructor - ~ACE_Local_Mutex (void); - - /// Dump the state of the class. - void dump (void) const; - - /// Return deep copy. - virtual ACE_Token_Proxy *clone (void) const; - -protected: - /// Return a new ACE_Local_Mutex. - virtual ACE_Tokens *create_token (const ACE_TCHAR *name); -}; - -// *. -/** - * @class ACE_Local_RLock - * - * @brief Class that acquires, renews, and releases a readers lock that - * is local to the process. - * - * This class implements the reader interface to canonical - * readers/writer locks. Multiple readers can hold the lock - * simultaneously when no writers have the lock. Alternatively, - * when a writer holds the lock, no other participants (readers - * or writers) may hold the lock. This class is a more - * general-purpose synchronization mechanism than SunOS 5.x - * RLocks. For example, it implements "recursive RLock" - * semantics, where a thread that owns the token can reacquire it - * without deadlocking. In addition, threads that are blocked - * awaiting the token are serviced in strict FIFO order as other - * threads release the token (SunOS 5.x RLockes don't strictly - * enforce an acquisition order). - * The interfaces for acquire, tryacquire, renew, release, - * etc. are defined in ACE_Token_Proxy. The semantics for - * ACE_Local_RLock are that of a readers/writers lock. Acquire - * for this class implies a reader acquisition. That is, - * multiple clients may acquire a lock for read only. - */ -class ACE_Export ACE_Local_RLock : public ACE_Token_Proxy -{ -public: - // = Initialization and termination. - - /** - * Constructor. - * @param token_name Uniquely id's the token. - * @param ignore_deadlock Will allow deadlock to occur (useful for testing). - * @param debug Prints a bunch of messages. - */ - ACE_Local_RLock (const ACE_TCHAR *token_name = 0, - int ignore_deadlock = 0, - int debug = 0); - - /// Destructor - ~ACE_Local_RLock (void); - - /// Dump the state of the class. - void dump (void) const; - - /// Returns ACE_RW_Token::RLOCK. - virtual int type (void) const; - - /// Return deep copy. - virtual ACE_Token_Proxy *clone (void) const; - -protected: - /// Return a new ACE_Local_Mutex. - virtual ACE_Tokens *create_token (const ACE_TCHAR *name); -}; - -// *. -/** - * @class ACE_Local_WLock - * - * @brief Class that acquires, renews, and releases a writer lock that - * is local to the process. - * - * This class implements the writer interface to canonical - * readers/writer locks. Multiple readers can hold the lock - * simultaneously when no writers have the lock. Alternatively, - * when a writer holds the lock, no other participants (readers - * or writers) may hold the lock. This class is a more - * general-purpose synchronization mechanism than SunOS 5.x - * WLock. For example, it implements "recursive WLock" - * semantics, where a thread that owns the token can reacquire it - * without deadlocking. In addition, threads that are blocked - * awaiting the token are serviced in strict FIFO order as other - * threads release the token (SunOS 5.x WLocks don't strictly - * enforce an acquisition order). - * The interfaces for acquire, tryacquire, renew, release, - * etc. are defined in ACE_Token_Proxy. The semantics for - * ACE_Local_WLock are that of a readers/writers lock. Acquire - * for this class implies a writer acquisition. That is, only - * one client may hold the lock for writing. - */ -class ACE_Export ACE_Local_WLock : public ACE_Token_Proxy -{ -public: - // = Initialization and termination. - - /** - * Constructor. - * @param token_name Uniquely id's the token. - * @param ignore_deadlock Will allow deadlock to occur (useful for testing). - * @param debug Prints a bunch of messages. - */ - ACE_Local_WLock (const ACE_TCHAR *token_name = 0, - int ignore_deadlock = 0, - int debug = 0); - - /// Destructor - ~ACE_Local_WLock (void); - - /// Dump the state of the class. - void dump (void) const; - - /// Returns ACE_RW_Token::WLOCK. - virtual int type (void) const; - - /// Return deep copy. - virtual ACE_Token_Proxy *clone (void) const; - -protected: - /// Return a new ACE_Local_Mutex. - ACE_Tokens *create_token (const ACE_TCHAR *name); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_TOKENS_LIBRARY */ - -#if defined (__ACE_INLINE__) -#include "ace/Local_Tokens.inl" -#endif /* __ACE_INLINE__ */ -#include /**/ "ace/post.h" -#endif /* ACE_LOCAL_MUTEX_H */ diff --git a/ACE/ace/Local_Tokens.inl b/ACE/ace/Local_Tokens.inl deleted file mode 100644 index 2e27ce4af04..00000000000 --- a/ACE/ace/Local_Tokens.inl +++ /dev/null @@ -1,289 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#if defined (ACE_HAS_TOKENS_LIBRARY) - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// ************************************************************ - -ACE_INLINE int -ACE_Token_Proxy_Queue::size (void) -{ - ACE_TRACE ("ACE_Token_Proxy_Queue::size"); - return this->size_; -} - -// ************************************************************ - -ACE_INLINE int -ACE_TPQ_Entry::waiting (void) const -{ - ACE_TRACE ("ACE_TPQ_Entry::waiting"); - return waiting_; -} - -ACE_INLINE void -ACE_TPQ_Entry::waiting (int v) -{ - ACE_TRACE ("ACE_TPQ_Entry::waiting"); - waiting_ = v; -} - -ACE_INLINE const ACE_TCHAR * -ACE_TPQ_Entry::client_id (void) const -{ - ACE_TRACE ("ACE_TPQ_Entry::client_id"); - return this->client_id_; -} - -ACE_INLINE ACE_Token_Proxy * -ACE_TPQ_Entry::proxy (void) const -{ - ACE_TRACE ("ACE_TPQ_Entry::proxy"); - return this->proxy_; -} - -ACE_INLINE void -ACE_TPQ_Entry::proxy (ACE_Token_Proxy *proxy) -{ - ACE_TRACE ("ACE_TPQ_Entry::proxy"); - this->proxy_ = proxy; -} - -ACE_INLINE -ACE_TPQ_Iterator::~ACE_TPQ_Iterator (void) -{ -} - -ACE_INLINE -ACE_Token_Proxy_Queue::~ACE_Token_Proxy_Queue (void) -{ -} - -ACE_INLINE void -ACE_Tokens::remove (ACE_TPQ_Entry *caller) -{ - this->waiters_.remove (caller); -} - -ACE_INLINE int -ACE_Tokens::dec_reference (void) -{ - ACE_TRACE ("ACE_Tokens::dec_reference"); - if (this->reference_count_ == 0) - { - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("dec_reference already zero"))); - return 0; - } - - return --this->reference_count_; -} - -ACE_INLINE void -ACE_Tokens::inc_reference (void) -{ - ACE_TRACE ("ACE_Tokens::inc_reference"); - ++this->reference_count_; -} - -ACE_INLINE const ACE_TPQ_Entry * -ACE_Token_Proxy_Queue::head (void) -{ - ACE_TRACE ("ACE_Token_Proxy_Queue::head"); - if (this->head_ == 0) - return 0; - else - return this->head_; -} - -// ************************************************** -// ************************************************** -// ************************************************** - -ACE_INLINE void -ACE_Tokens::visit (int v) -{ - ACE_TRACE ("ACE_Tokens::visit"); - visited_ = v; -} - -ACE_INLINE int -ACE_Tokens::visited (void) -{ - ACE_TRACE ("ACE_Tokens::visited"); - return visited_; -} - -ACE_INLINE ACE_TPQ_Entry * -ACE_Tokens::owner (void) -{ - ACE_TRACE ("ACE_Tokens::owner"); - return (ACE_TPQ_Entry *) this->waiters_.head (); -} - -ACE_INLINE const ACE_TCHAR* -ACE_Tokens::owner_id () -{ - ACE_TRACE ("ACE_Tokens::owner_id"); - if (this->owner () == 0) - return ACE_TEXT ("no owner"); - else - return this->owner ()->client_id (); -} - -ACE_INLINE const ACE_TCHAR* -ACE_Tokens::name (void) -{ - ACE_TRACE ("ACE_Tokens::name"); - return this->token_name_; -} - -#if 0 -ACE_INLINE ACE_Token_Proxy * -ACE_Tokens::current_owner (void) -{ - ACE_TRACE ("ACE_Tokens::current_owner"); - // ACE_GUARD_RETURN ??? - - if (this->owner () == 0) - return 0; - else - return this->owner ()->proxy (); -} -#endif /* 0 */ - -// ************************************************************ - -ACE_INLINE int -ACE_TPQ_Entry::nesting_level (void) const -{ - ACE_TRACE ("ACE_TPQ_Entry::nesting_level"); - return this->nesting_level_; -} - -ACE_INLINE void -ACE_TPQ_Entry::nesting_level (int delta) -{ - ACE_TRACE ("ACE_TPQ_Entry::nesting_level"); - this->nesting_level_ += delta; -} - -ACE_INLINE ACE_TPQ_Entry::PTVF -ACE_TPQ_Entry::sleep_hook (void) const -{ - ACE_TRACE ("ACE_TPQ_Entry::sleep_hook"); - return this->sleep_hook_; -} - -ACE_INLINE void -ACE_TPQ_Entry::sleep_hook (void (*sh)(void *)) -{ - ACE_TRACE ("ACE_TPQ_Entry::sleep_hook"); - this->sleep_hook_ = sh; -} - -ACE_INLINE void -ACE_TPQ_Entry::call_sleep_hook (void) -{ - ACE_TRACE ("ACE_TPQ_Entry::call_sleep_hook"); - - // if a function has been registered, call it. - if (this->sleep_hook () != 0) - this->sleep_hook () ((void *) this->proxy ()); - else - // otherwise, call back the sleep_hook method - this->proxy ()->sleep_hook (); -} - -ACE_INLINE int -ACE_TPQ_Entry::equal_client_id (const ACE_TCHAR *id) -{ - ACE_TRACE ("ACE_TPQ_Entry::equal_client_id"); - return (ACE_OS::strcmp (this->client_id (), id) == 0); -} - -// ************************************************************ -// ************************************************************ -// ************************************************************ - -ACE_INLINE -ACE_Local_Mutex::ACE_Local_Mutex (const ACE_TCHAR *token_name, - int ignore_deadlock, - int debug) -{ - ACE_TRACE ("ACE_Local_Mutex::ACE_Local_Mutex"); - this->open (token_name, ignore_deadlock, debug); -} - -ACE_INLINE void -ACE_Token_Name::name (const ACE_TCHAR *new_name) -{ - ACE_TRACE ("ACE_Token_Name::name"); - - if (new_name == 0) - new_name = ACE_TEXT ("no name"); - - size_t n = ACE_OS::strlen (new_name) + 1; - - if (n >= ACE_MAXTOKENNAMELEN) - n = ACE_MAXTOKENNAMELEN - 1; - - ACE_OS::strsncpy (this->token_name_, (ACE_TCHAR *) new_name, n); -} - -ACE_INLINE const ACE_TCHAR* -ACE_Token_Name::name (void) const -{ - ACE_TRACE ("ACE_Token_Name::name"); - return this->token_name_; -} - -// ************************************************************ - -ACE_INLINE -ACE_Local_RLock::ACE_Local_RLock (const ACE_TCHAR *token_name, - int ignore_deadlock, - int debug) -{ - ACE_TRACE ("ACE_Local_RLock::ACE_Local_RLock"); - this->open (token_name, ignore_deadlock, debug); -} - -// ************************************************************ - -ACE_INLINE -ACE_Local_WLock::ACE_Local_WLock (const ACE_TCHAR *token_name, - int ignore_deadlock, - int debug) -{ - ACE_TRACE ("ACE_Local_WLock::ACE_Local_WLock"); - this->open (token_name, ignore_deadlock, debug); -} - -// ************************************************************ - - -ACE_INLINE void -ACE_Token_Name::operator= (const ACE_Token_Name &rhs) -{ - ACE_TRACE ("ACE_Token_Name::operator="); - if (&rhs == this) - return; - else - this->name (rhs.name ()); -} - -ACE_INLINE bool -ACE_Token_Name::operator== (const ACE_Token_Name &rhs) const -{ - ACE_TRACE ("ACE_Token_Name::operator=="); - - // the name and type must be the same - return (ACE_OS::strcmp (this->token_name_, rhs.name ()) == 0); -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_TOKENS_LIBRARY */ diff --git a/ACE/ace/Lock.cpp b/ACE/ace/Lock.cpp deleted file mode 100644 index dca934b8067..00000000000 --- a/ACE/ace/Lock.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// $Id$ - -#include "ace/Lock.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Lock.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, Lock, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_Lock::~ACE_Lock (void) -{ -} - -ACE_Adaptive_Lock::ACE_Adaptive_Lock (void) - : lock_ (0) -{ -} - -ACE_Adaptive_Lock::~ACE_Adaptive_Lock (void) -{ -} - -int -ACE_Adaptive_Lock::remove (void) -{ - return this->lock_->remove (); -} - -int -ACE_Adaptive_Lock::acquire (void) -{ - return this->lock_->acquire (); -} - -int -ACE_Adaptive_Lock::tryacquire (void) -{ - return this->lock_->tryacquire (); -} - -int -ACE_Adaptive_Lock::release (void) -{ - return this->lock_->release (); -} - -int -ACE_Adaptive_Lock::acquire_read (void) -{ - return this->lock_->acquire_read (); -} - -int -ACE_Adaptive_Lock::acquire_write (void) -{ - return this->lock_->acquire_write (); -} - -int -ACE_Adaptive_Lock::tryacquire_read (void) -{ - return this->lock_->tryacquire_read (); -} - -int -ACE_Adaptive_Lock::tryacquire_write (void) -{ - return this->lock_->tryacquire_write (); -} - -int -ACE_Adaptive_Lock::tryacquire_write_upgrade (void) -{ - return this->lock_->tryacquire_write_upgrade (); -} - -void -ACE_Adaptive_Lock::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - // return this->lock_->dump (); -#endif /* ACE_HAS_DUMP */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Lock.h b/ACE/ace/Lock.h deleted file mode 100644 index 2b95c1962da..00000000000 --- a/ACE/ace/Lock.h +++ /dev/null @@ -1,161 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file Lock.h - * - * $Id$ - * - * Moved from Synch.h. - * - * @author Douglas C. Schmidt - */ -//========================================================================== - -#ifndef ACE_LOCK_H -#define ACE_LOCK_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Lock - * - * @brief This is the abstract base class that contains the uniform - * locking API that is supported by all the ACE synchronization - * mechanisms. - * - * This class is typically used in conjunction with the - * ACE_Lock_Adapter in order to provide a polymorphic - * interface to the ACE synchronization mechanisms (e.g., - * ACE_Mutex, ACE_Semaphore, ACE_RW_Mutex, etc). Note that - * the reason that all of ACE doesn't use polymorphic locks is - * that (1) they add ~20% extra overhead for virtual function - * calls and (2) objects with virtual functions can't be placed - * into shared memory. - */ -class ACE_Export ACE_Lock -{ -public: - /// CE needs a default ctor here. - ACE_Lock (void); - - /// Noop virtual destructor - virtual ~ACE_Lock (void); - - /** - * Explicitly destroy the lock. Note that only one thread should - * call this method since it doesn't protect against race - * conditions. - */ - virtual int remove (void) = 0; - - /// Block the thread until the lock is acquired. Returns -1 on - /// failure. - virtual int acquire (void) = 0; - - /** - * Conditionally acquire the lock (i.e., won't block). Returns -1 - * on failure. If we "failed" because someone else already had the - * lock, @c errno is set to @c EBUSY. - */ - virtual int tryacquire (void) = 0; - - /// Release the lock. Returns -1 on failure. - virtual int release (void) = 0; - - /** - * Block until the thread acquires a read lock. If the locking - * mechanism doesn't support read locks then this just calls - * . Returns -1 on failure. - */ - virtual int acquire_read (void) = 0; - - /** - * Block until the thread acquires a write lock. If the locking - * mechanism doesn't support read locks then this just calls - * . Returns -1 on failure. - */ - virtual int acquire_write (void) = 0; - - /** - * Conditionally acquire a read lock. If the locking mechanism - * doesn't support read locks then this just calls . - * Returns -1 on failure. If we "failed" because someone else - * already had the lock, @c errno is set to @c EBUSY. - */ - virtual int tryacquire_read (void) = 0; - - /** - * Conditionally acquire a write lock. If the locking mechanism - * doesn't support read locks then this just calls . - * Returns -1 on failure. If we "failed" because someone else - * already had the lock, @c errno is set to @c EBUSY. - */ - virtual int tryacquire_write (void) = 0; - - /** - * Conditionally try to upgrade a lock held for read to a write lock. - * If the locking mechanism doesn't support read locks then this just - * calls . Returns 0 on success, -1 on failure. - */ - virtual int tryacquire_write_upgrade (void) = 0; -}; - -/** - * @class ACE_Adaptive_Lock - * - * @brief An adaptive general locking class that defers the decision of - * lock type to run time. - * - * This class, as ACE_Lock, provide a set of general locking APIs. - * However, it defers our decision of what kind of lock to use - * to the run time and delegates all locking operations to the actual - * lock. Users must define a constructor in their subclass to - * initialize . - */ -class ACE_Export ACE_Adaptive_Lock : public ACE_Lock -{ -public: - /// You must also override the destructor function to match with how - /// you construct the underneath . - virtual ~ACE_Adaptive_Lock (void); - - // = Lock/unlock operations. - - virtual int remove (void); - virtual int acquire (void); - virtual int tryacquire (void); - virtual int release (void); - virtual int acquire_read (void); - virtual int acquire_write (void); - virtual int tryacquire_read (void); - virtual int tryacquire_write (void); - virtual int tryacquire_write_upgrade (void); - void dump (void) const; - -protected: - /** - * Create and initialize create the actual lcok used in the class. - * The default constructor simply set the to 0 (null). You - * must overwrite this method for this class to work. - */ - ACE_Adaptive_Lock (void); - - ACE_Lock *lock_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Lock.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_LOCK_H */ diff --git a/ACE/ace/Lock.inl b/ACE/ace/Lock.inl deleted file mode 100644 index 7e4842a0e33..00000000000 --- a/ACE/ace/Lock.inl +++ /dev/null @@ -1,12 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -ACE_Lock::ACE_Lock (void) -{ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Lock_Adapter_T.cpp b/ACE/ace/Lock_Adapter_T.cpp deleted file mode 100644 index f26a79fdd4c..00000000000 --- a/ACE/ace/Lock_Adapter_T.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// $Id$ - -#ifndef ACE_LOCK_ADAPTER_T_CPP -#define ACE_LOCK_ADAPTER_T_CPP - -#include "ace/Lock_Adapter_T.h" -#include "ace/OS_Memory.h" // for ACE_NEW - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (__ACE_INLINE__) -#include "ace/Lock_Adapter_T.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// This constructor isn't inlined, because SunPRO C++ 4.2 + patch -// 104631-07 has trouble compiling TAO with it inline. -template -ACE_Lock_Adapter::ACE_Lock_Adapter (void) - : lock_ (0), - delete_lock_ (true) -{ - ACE_NEW (this->lock_, - ACE_LOCKING_MECHANISM); -} - -template -ACE_Lock_Adapter::~ACE_Lock_Adapter (void) -{ - if (this->delete_lock_) - delete this->lock_; -} - -// Explicitly destroy the lock. -template int -ACE_Lock_Adapter::remove (void) -{ - return this->lock_->remove (); -} - -// Block the thread until the lock is acquired. -template int -ACE_Lock_Adapter::acquire (void) -{ - return this->lock_->acquire (); -} - -// Conditionally acquire the lock (i.e., won't block). - -template int -ACE_Lock_Adapter::tryacquire (void) -{ - return this->lock_->tryacquire (); -} - -// Release the lock. - -template int -ACE_Lock_Adapter::release (void) -{ - return this->lock_->release (); -} - -// Block until the thread acquires a read lock. If the locking -// mechanism doesn't support read locks then this just calls -// . - -template int -ACE_Lock_Adapter::acquire_read (void) -{ - return this->lock_->acquire_read (); -} - -// Block until the thread acquires a write lock. If the locking -// mechanism doesn't support read locks then this just calls -// . - -template int -ACE_Lock_Adapter::acquire_write (void) -{ - return this->lock_->acquire_write (); -} - -// Conditionally acquire a read lock. If the locking mechanism -// doesn't support read locks then this just calls . - -template int -ACE_Lock_Adapter::tryacquire_read (void) -{ - return this->lock_->tryacquire_read (); -} - -// Conditionally acquire a write lock. If the locking mechanism -// doesn't support write locks then this just calls . - -template int -ACE_Lock_Adapter::tryacquire_write (void) -{ - return this->lock_->tryacquire_write (); -} - -// Conditionally try to upgrade a lock held for read to a write lock. -// If the locking mechanism doesn't support read locks then this just -// calls . Returns 0 on success, -1 on failure. - -template int -ACE_Lock_Adapter::tryacquire_write_upgrade (void) -{ - return this->lock_->tryacquire_write_upgrade (); -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_LOCK_ADAPTER_T_CPP */ diff --git a/ACE/ace/Lock_Adapter_T.h b/ACE/ace/Lock_Adapter_T.h deleted file mode 100644 index 117684a1a2a..00000000000 --- a/ACE/ace/Lock_Adapter_T.h +++ /dev/null @@ -1,123 +0,0 @@ -// -*- C++ -*- - -//========================================================================== -/** - * @file Lock_Adapter_T.h - * - * $Id$ - * - * Moved from Synch.h. - * - * @author Douglas C. Schmidt - */ -//========================================================================== - -#ifndef ACE_LOCK_ADAPTER_T_H -#define ACE_LOCK_ADAPTER_T_H -#include /**/ "ace/pre.h" - -#include "ace/Lock.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Lock_Adapter - * - * @brief This is an adapter that allows applications to transparently - * combine the abstract base class (which contains - * pure virtual methods) with any of the other concrete ACE - * synchronization classes (e.g., ACE_Mutex, ACE_Semaphore, - * ACE_RW_Mutex, etc.). - * - * This class uses a form of the Adapter pattern. - */ -template -class ACE_Lock_Adapter : public ACE_Lock -{ -public: - typedef ACE_LOCKING_MECHANISM ACE_LOCK; - - // = Initialization/Finalization methods. - - /// Constructor. All locking requests will be forwarded to . - ACE_Lock_Adapter (ACE_LOCKING_MECHANISM &lock); - - /// Constructor. Since no lock is provided by the user, one will be - /// created internally. - ACE_Lock_Adapter (void); - - /// Destructor. If was not passed in by the user, it will be - /// deleted. - virtual ~ACE_Lock_Adapter (void); - - // = Lock accessors. - /// Block the thread until the lock is acquired. - virtual int acquire (void); - - /// Conditionally acquire the lock (i.e., won't block). - virtual int tryacquire (void); - - /// Release the lock. - virtual int release (void); - - /** - * Block until the thread acquires a read lock. If the locking - * mechanism doesn't support read locks then this just calls - * . - */ - virtual int acquire_read (void); - - /** - * Block until the thread acquires a write lock. If the locking - * mechanism doesn't support read locks then this just calls - * . - */ - virtual int acquire_write (void); - - /// Conditionally acquire a read lock. If the locking mechanism - /// doesn't support read locks then this just calls . - virtual int tryacquire_read (void); - - /// Conditionally acquire a write lock. If the locking mechanism - /// doesn't support read locks then this just calls . - virtual int tryacquire_write (void); - - /** - * Conditionally try to upgrade a lock held for read to a write lock. - * If the locking mechanism doesn't support read locks then this just - * calls . Returns 0 on success, -1 on failure. - */ - virtual int tryacquire_write_upgrade (void); - - /// Explicitly destroy the lock. - virtual int remove (void); - -private: - /// The concrete locking mechanism that all the methods delegate to. - ACE_LOCKING_MECHANISM *lock_; - - /// This flag keep track of whether we are responsible for deleting - /// the lock - bool delete_lock_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "ace/Lock_Adapter_T.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Lock_Adapter_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Lock_Adapter_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#include /**/ "ace/post.h" -#endif /* ACE_LOCK_ADAPTER_T_H */ diff --git a/ACE/ace/Lock_Adapter_T.inl b/ACE/ace/Lock_Adapter_T.inl deleted file mode 100644 index bc7899bffb3..00000000000 --- a/ACE/ace/Lock_Adapter_T.inl +++ /dev/null @@ -1,16 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template -ACE_INLINE -ACE_Lock_Adapter::ACE_Lock_Adapter ( - ACE_LOCKING_MECHANISM &lock) - : lock_ (&lock), - delete_lock_ (false) -{ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Log_Msg.cpp b/ACE/ace/Log_Msg.cpp deleted file mode 100644 index 0f2bf798c25..00000000000 --- a/ACE/ace/Log_Msg.cpp +++ /dev/null @@ -1,2510 +0,0 @@ -// $Id$ - -// We need this to get the status of ACE_NTRACE... -#include "ace/config-all.h" - -// Turn off tracing for the duration of this file. -#if defined (ACE_NTRACE) -# undef ACE_NTRACE -#endif /* ACE_NTRACE */ -#define ACE_NTRACE 1 - -#include "ace/ACE.h" -#include "ace/Thread_Manager.h" -#include "ace/Guard_T.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_errno.h" -#include "ace/OS_NS_sys_time.h" -#include "ace/OS_NS_wchar.h" -#include "ace/OS_NS_signal.h" - -#if !defined (ACE_MT_SAFE) || (ACE_MT_SAFE != 0) -# include "ace/Object_Manager_Base.h" -#endif /* ! ACE_MT_SAFE */ - -#if !defined (ACE_LACKS_IOSTREAM_TOTALLY) -// FUZZ: disable check_for_streams_include -# include "ace/streams.h" -#endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */ - -#if defined (ACE_HAS_TRACE) -# include "ace/Trace.h" -#endif /* ACE_HAS_TRACE */ - -#include "ace/Log_Msg.h" -#include "ace/Log_Msg_Callback.h" -#include "ace/Log_Msg_IPC.h" -#include "ace/Log_Msg_NT_Event_Log.h" -#include "ace/Log_Msg_UNIX_Syslog.h" -#include "ace/Log_Record.h" -#include "ace/Recursive_Thread_Mutex.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Log_Msg.inl" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(ace, Log_Msg, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_ALLOC_HOOK_DEFINE(ACE_Log_Msg) - -// only used here... dhinton -#if defined (ACE_HAS_SYS_SIGLIST) -# if !defined (_sys_siglist) -# define _sys_siglist sys_siglist -# endif /* !defined (sys_siglist) */ -//extern char **_sys_siglist; -#endif /* ACE_HAS_SYS_SIGLIST */ - -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) - int ACE_Log_Msg::key_created_ = 0; -# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \ - defined (ACE_HAS_TSS_EMULATION) - -#if defined (ACE_MVS) - static ACE_thread_key_t the_log_msg_tss_key = - #if !defined(_LP64) - { '\0','\0','\0','\0' }; - #else - { '\0','\0','\0','\0','\0','\0','\0','\0' }; - #endif -#else - static ACE_thread_key_t the_log_msg_tss_key = 0; -#endif /* defined (ACE_MVS) */ - -ACE_thread_key_t *log_msg_tss_key (void) -{ - return &the_log_msg_tss_key; -} - -# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */ -#else -static ACE_Cleanup_Adapter* log_msg_cleanup = 0; -class ACE_Msg_Log_Cleanup: public ACE_Cleanup_Adapter -{ -public: - virtual ~ACE_Msg_Log_Cleanup (void) { - if (this == log_msg_cleanup) - log_msg_cleanup = 0; - } -}; -#endif /* ACE_MT_SAFE */ - -#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) && !defined (ACE_HAS_PHARLAP) -# define ACE_LOG_MSG_SYSLOG_BACKEND ACE_Log_Msg_NT_Event_Log -#elif !defined (ACE_LACKS_UNIX_SYSLOG) && !defined (ACE_HAS_WINCE) -# define ACE_LOG_MSG_SYSLOG_BACKEND ACE_Log_Msg_UNIX_Syslog -#else -# define ACE_LOG_MSG_SYSLOG_BACKEND ACE_Log_Msg_IPC -#endif /* ! ACE_WIN32 */ - -// When doing ACE_OS::s[n]printf() calls in log(), we need to update -// the space remaining in the output buffer based on what's returned from -// the output function. If we could rely on more modern compilers, this -// would be in an unnamed namespace, but it's a macro instead. -// count is a size_t, len is an int and assumed to be non-negative. -#define ACE_UPDATE_COUNT(COUNT, LEN) \ - do { if (static_cast (LEN) > COUNT) COUNT = 0; \ - else COUNT -= static_cast (LEN); \ - } while (0) - -/// Instance count for Log_Msg - used to know when dynamically -/// allocated storage (program name and host name) can be safely -/// deleted. -int ACE_Log_Msg::instance_count_ = 0; - -/** - * @class ACE_Log_Msg_Manager - * - * @brief Synchronize output operations. - * - * Provides global point of contact for all ACE_Log_Msg instances - * in a process. - * - * For internal use by ACE, only! - */ -class ACE_Log_Msg_Manager -{ -public: - static ACE_Log_Msg_Backend *log_backend_; - static ACE_Log_Msg_Backend *custom_backend_; - - static u_long log_backend_flags_; - - static int init_backend (const u_long *flags = 0); - -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) - //FUZZ: disable check_for_lack_ACE_OS - static void close (void); - //FUZZ: enable check_for_lack_ACE_OS - - static ACE_Recursive_Thread_Mutex *get_lock (void); - -private: - static ACE_Recursive_Thread_Mutex *lock_; -#endif /* ! ACE_MT_SAFE */ -}; - -ACE_Log_Msg_Backend *ACE_Log_Msg_Manager::log_backend_ = 0; -ACE_Log_Msg_Backend *ACE_Log_Msg_Manager::custom_backend_ = 0; - -u_long ACE_Log_Msg_Manager::log_backend_flags_ = 0; - -int ACE_Log_Msg_Manager::init_backend (const u_long *flags) -{ - // If flags have been supplied, and they are different from the flags - // we had last time, then we may have to re-create the backend as a - // different type. - if (flags) - { - // Sanity check for custom backend. - if (ACE_BIT_ENABLED (*flags, ACE_Log_Msg::CUSTOM) && - ACE_Log_Msg_Manager::custom_backend_ == 0) - { - return -1; - } - - if ((ACE_BIT_ENABLED (*flags, ACE_Log_Msg::SYSLOG) - && ACE_BIT_DISABLED (ACE_Log_Msg_Manager::log_backend_flags_, ACE_Log_Msg::SYSLOG)) - || (ACE_BIT_DISABLED (*flags, ACE_Log_Msg::SYSLOG) - && ACE_BIT_ENABLED (ACE_Log_Msg_Manager::log_backend_flags_, ACE_Log_Msg::SYSLOG))) - { - delete ACE_Log_Msg_Manager::log_backend_; - ACE_Log_Msg_Manager::log_backend_ = 0; - } - - ACE_Log_Msg_Manager::log_backend_flags_ = *flags; - } - - if (ACE_Log_Msg_Manager::log_backend_ == 0) - { - ACE_NO_HEAP_CHECK; - -#if (defined (WIN32) || !defined (ACE_LACKS_UNIX_SYSLOG)) && !defined (ACE_HAS_WINCE) && !defined (ACE_HAS_PHARLAP) - // Allocate the ACE_Log_Msg_Backend instance. - if (ACE_BIT_ENABLED (ACE_Log_Msg_Manager::log_backend_flags_, ACE_Log_Msg::SYSLOG)) - ACE_NEW_RETURN (ACE_Log_Msg_Manager::log_backend_, - ACE_LOG_MSG_SYSLOG_BACKEND, - -1); - else -#endif /* defined (WIN32) && !defined (ACE_HAS_WINCE) && !defined (ACE_HAS_PHARLAP) */ - ACE_NEW_RETURN (ACE_Log_Msg_Manager::log_backend_, - ACE_Log_Msg_IPC, - -1); - } - - return 0; -} - -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) -ACE_Recursive_Thread_Mutex *ACE_Log_Msg_Manager::lock_ = 0; - -ACE_Recursive_Thread_Mutex * -ACE_Log_Msg_Manager::get_lock (void) -{ - // This function is called by the first thread to create an ACE_Log_Msg - // instance. It makes the call while holding a mutex, so we don't have - // to grab another one here. - - if (ACE_Log_Msg_Manager::lock_ == 0) - { - ACE_NO_HEAP_CHECK; - - ACE_NEW_RETURN (ACE_Log_Msg_Manager::lock_, - ACE_Recursive_Thread_Mutex, - 0); - } - - if (init_backend () == -1) - return 0; - - return ACE_Log_Msg_Manager::lock_; -} - -void -ACE_Log_Msg_Manager::close (void) -{ -#if defined (ACE_HAS_STHREADS) && ! defined (ACE_HAS_TSS_EMULATION) && ! defined (ACE_HAS_EXCEPTIONS) - // Delete the (main thread's) Log_Msg instance. I think that this - // is only "necessary" if exception handling is not enabled. - // Without exception handling, main thread TSS destructors don't - // seem to be called. It's not really necessary anyways, because - // this one leak is harmless on Solaris. - delete ACE_Log_Msg::instance (); -#endif /* ACE_HAS_STHREADS && ! TSS_EMULATION && ! ACE_HAS_EXCEPTIONS */ - - // Ugly, ugly, but don't know a better way. - delete ACE_Log_Msg_Manager::lock_; - ACE_Log_Msg_Manager::lock_ = 0; - - delete ACE_Log_Msg_Manager::log_backend_; - ACE_Log_Msg_Manager::log_backend_ = 0; - - // we are never responsible for custom backend - ACE_Log_Msg_Manager::custom_backend_ = 0; -} - -# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \ - defined (ACE_HAS_TSS_EMULATION) -/* static */ -# if defined (ACE_HAS_THR_C_DEST) -# define LOCAL_EXTERN_PREFIX extern "C" -# else -# define LOCAL_EXTERN_PREFIX -# endif /* ACE_HAS_THR_C_DEST */ -LOCAL_EXTERN_PREFIX -void -ACE_TSS_CLEANUP_NAME (void *ptr) -{ - // Delegate to thr_desc if this not has terminated - ACE_Log_Msg* log_msg = (ACE_Log_Msg*) ptr; - if (log_msg->thr_desc()!=0) - log_msg->thr_desc()->log_msg_cleanup(log_msg); - else - delete (ACE_Log_Msg *) ptr; -} -# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */ -#endif /* ! ACE_MT_SAFE */ - -/* static */ -int -ACE_Log_Msg::exists (void) -{ -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) -# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \ - defined (ACE_HAS_TSS_EMULATION) - void *tss_log_msg = 0; // The actual type is ACE_Log_Msg*, but we need this - // void to keep G++ from complaining. - - // Get the tss_log_msg from thread-specific storage. - return key_created_ - && ACE_Thread::getspecific (*(log_msg_tss_key ()), &tss_log_msg) != -1 - && tss_log_msg != 0; -# else -# error "Platform must support thread-specific storage if threads are used." -# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */ -#else /* ! ACE_MT_SAFE */ - return 1; -#endif /* ! ACE_MT_SAFE */ -} - -ACE_Log_Msg * -ACE_Log_Msg::instance (void) -{ -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) -# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \ - defined (ACE_HAS_TSS_EMULATION) - // TSS Singleton implementation. - - if (key_created_ == 0) - { - ACE_thread_mutex_t *lock = - reinterpret_cast ( - ACE_OS_Object_Manager::preallocated_object - [ACE_OS_Object_Manager::ACE_LOG_MSG_INSTANCE_LOCK]); - - if (1 == ACE_OS_Object_Manager::starting_up()) - //This function is called before ACE_OS_Object_Manager is - //initialized. So the lock might not be valid. Assume it's - //single threaded and so don't need the lock. - ; - else - ACE_OS::thread_mutex_lock (lock); - - if (key_created_ == 0) - { - // Allocate the Singleton lock. - ACE_Log_Msg_Manager::get_lock (); - - { - ACE_NO_HEAP_CHECK; - if (ACE_Thread::keycreate (log_msg_tss_key (), - &ACE_TSS_CLEANUP_NAME) != 0) - { - if (1 == ACE_OS_Object_Manager::starting_up()) - //This function is called before ACE_OS_Object_Manager is - //initialized. So the lock might not be valid. Assume it's - //single threaded and so don't need the lock. - ; - else - ACE_OS::thread_mutex_unlock (lock); - return 0; // Major problems, this should *never* happen! - } - } - - key_created_ = 1; - } - - if (1 == ACE_OS_Object_Manager::starting_up()) - //This function is called before ACE_OS_Object_Manager is - //initialized. So the lock might not be valid. Assume it's - //single threaded and so don't need the lock. - ; - else - ACE_OS::thread_mutex_unlock (lock); - } - - ACE_Log_Msg *tss_log_msg = 0; - void *temp = 0; - - // Get the tss_log_msg from thread-specific storage. - if (ACE_Thread::getspecific (*(log_msg_tss_key ()), &temp) == -1) - return 0; // This should not happen! - - tss_log_msg = static_cast (temp); - - // Check to see if this is the first time in for this thread. - if (tss_log_msg == 0) - { - // Allocate memory off the heap and store it in a pointer in - // thread-specific storage (on the stack...). Stop heap - // checking, the memory will always be freed by the thread - // rundown because of the TSS callback set up when the key was - // created. This prevents from getting these blocks reported as - // memory leaks. - { - ACE_NO_HEAP_CHECK; - - ACE_NEW_RETURN (tss_log_msg, - ACE_Log_Msg, - 0); - // Store the dynamically allocated pointer in thread-specific - // storage. It gets deleted via the ACE_TSS_cleanup function - // when the thread terminates. - - if (ACE_Thread::setspecific (*(log_msg_tss_key()), - reinterpret_cast (tss_log_msg)) - != 0) - return 0; // Major problems, this should *never* happen! - } - } - - return tss_log_msg; -# else -# error "Platform must support thread-specific storage if threads are used." -# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */ -#else /* ! ACE_MT_SAFE */ - // We don't have threads, we cannot call - // ACE_Log_Msg_Manager::get_lock () to initialize the logger - // callback, so instead we do it here. - if (ACE_Log_Msg_Manager::init_backend () == -1) - return 0; - - // Singleton implementation. - - if (log_msg_cleanup == 0) - { - ACE_NEW_RETURN (log_msg_cleanup, ACE_Msg_Log_Cleanup, 0); - // Register the instance for destruction at program termination. - ACE_Object_Manager::at_exit (log_msg_cleanup); - } - - return &log_msg_cleanup->object (); -#endif /* ! ACE_MT_SAFE */ -} - -// Not inlined to help prevent having to include OS.h just to -// get ACE_DEBUG, et al, macros. -int -ACE_Log_Msg::last_error_adapter (void) -{ - return ACE_OS::last_error (); -} - -// Sets the flag in the default priority mask used to initialize -// ACE_Log_Msg instances, as well as the current per-thread instance. - -void -ACE_Log_Msg::enable_debug_messages (ACE_Log_Priority priority) -{ - ACE_SET_BITS (ACE_Log_Msg::default_priority_mask_, priority); - ACE_Log_Msg *i = ACE_Log_Msg::instance (); - i->priority_mask (i->priority_mask () | priority); -} - -// Clears the flag in the default priority mask used to initialize -// ACE_Log_Msg instances, as well as the current per-thread instance. - -void -ACE_Log_Msg::disable_debug_messages (ACE_Log_Priority priority) -{ - ACE_CLR_BITS (ACE_Log_Msg::default_priority_mask_, priority); - ACE_Log_Msg *i = ACE_Log_Msg::instance (); - i->priority_mask (i->priority_mask () & ~priority); -} - -const ACE_TCHAR * -ACE_Log_Msg::program_name (void) -{ - return ACE_Log_Msg::program_name_; -} - -/// Name of the local host. -const ACE_TCHAR *ACE_Log_Msg::local_host_ = 0; - -/// Records the program name. -const ACE_TCHAR *ACE_Log_Msg::program_name_ = 0; - -/// Default is to use stderr. -u_long ACE_Log_Msg::flags_ = ACE_Log_Msg::STDERR; - -/// Process id of the current process. -pid_t ACE_Log_Msg::pid_ = -2; - -/// Current offset of msg_[]. -ptrdiff_t ACE_Log_Msg::msg_off_ = 0; - -/// Default per-thread priority mask -/// By default, no priorities are enabled. -u_long ACE_Log_Msg::default_priority_mask_ = 0; - -/// Default per-process priority mask -/// By default, all priorities are enabled. -u_long ACE_Log_Msg::process_priority_mask_ = LM_SHUTDOWN - | LM_TRACE - | LM_DEBUG - | LM_INFO - | LM_NOTICE - | LM_WARNING - | LM_STARTUP - | LM_ERROR - | LM_CRITICAL - | LM_ALERT - | LM_EMERGENCY; - -void -ACE_Log_Msg::close (void) -{ - // This call needs to go here to avoid memory leaks. - ACE_MT (ACE_Log_Msg_Manager::close ()); - - // Please note that this will be called by a statement that is - // harded coded into the ACE_Object_Manager's shutdown sequence, in - // its destructor. - -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) && \ - (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \ - defined (ACE_HAS_TSS_EMULATION)) - - if (key_created_ == 1) - { - ACE_thread_mutex_t *lock = - reinterpret_cast ( - ACE_OS_Object_Manager::preallocated_object - [ACE_OS_Object_Manager::ACE_LOG_MSG_INSTANCE_LOCK]); - ACE_OS::thread_mutex_lock (lock); - - if (key_created_ == 1) - { - // The same as the ACE_TSS_Cleanup's own key doesn't get - // detached, the log_msg_tss_key_ won't get detached - // until ACE_TSS_Cleanup::free_all_keys_left, so it will - // be in the ACE_TSS_Cleanup::table_. However, there's - // no resource associated with it, so we don't need to - // keyfree it. The dynamic memory associated with it was - // already deleted by ACE_TSS_Cleanup::exit (), so we - // don't want to access it again. - key_created_ = 0; -#ifdef ACE_HAS_BROKEN_THREAD_KEYFREE - // for some systems, e.g. LynxOS, we need to ensure that - // any registered thread destructor action for this thread - // is disabled. Otherwise in the event of a dynamic library - // unload of libACE, by a program not linked with libACE, - // ACE_TSS_cleanup will be invoked after libACE has been unloaded. - ACE_Log_Msg *tss_log_msg = 0; - void *temp = 0; - - // Get the tss_log_msg from thread-specific storage. - if (ACE_Thread::getspecific (*(log_msg_tss_key ()), &temp) != -1 - && temp) - { - tss_log_msg = static_cast (temp); - // we haven't been cleaned up - ACE_TSS_CLEANUP_NAME(tss_log_msg); - if (ACE_Thread::setspecific(*(log_msg_tss_key()), - reinterpret_cast (0)) != 0) - { - ACE_OS::printf ("ACE_Log_Msg::close failed to ACE_Thread::setspecific to 0\n"); - } - } -#endif /* ACE_HAS_BROKEN_THREAD_KEYFREE */ - } - - ACE_OS::thread_mutex_unlock (lock); - } -#endif /* (ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION) && ACE_MT_SAFE */ -} - -void -ACE_Log_Msg::sync_hook (const ACE_TCHAR *prg_name) -{ - ACE_LOG_MSG->sync (prg_name); -} - -ACE_OS_Thread_Descriptor * -ACE_Log_Msg::thr_desc_hook (void) -{ - return ACE_LOG_MSG->thr_desc (); -} - -// Call after a fork to resynchronize the PID and PROGRAM_NAME -// variables. -void -ACE_Log_Msg::sync (const ACE_TCHAR *prog_name) -{ - ACE_TRACE ("ACE_Log_Msg::sync"); - - if (prog_name) - { - // Must free if already allocated!!! - ACE_OS::free ((void *) ACE_Log_Msg::program_name_); - - // Stop heap checking, block will be freed by the destructor when - // the last ACE_Log_Msg instance is deleted. - // Heap checking state will be restored when the block is left. - { - ACE_NO_HEAP_CHECK; - - ACE_Log_Msg::program_name_ = ACE_OS::strdup (prog_name); - } - } - - ACE_Log_Msg::pid_ = ACE_OS::getpid (); - ACE_Log_Msg::msg_off_ = 0; -} - -u_long -ACE_Log_Msg::flags (void) -{ - ACE_TRACE ("ACE_Log_Msg::flags"); - u_long result; - ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, - *ACE_Log_Msg_Manager::get_lock (), 0)); - - result = ACE_Log_Msg::flags_; - return result; -} - -void -ACE_Log_Msg::set_flags (u_long flgs) -{ - ACE_TRACE ("ACE_Log_Msg::set_flags"); - ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, - *ACE_Log_Msg_Manager::get_lock ())); - - ACE_SET_BITS (ACE_Log_Msg::flags_, flgs); -} - -void -ACE_Log_Msg::clr_flags (u_long flgs) -{ - ACE_TRACE ("ACE_Log_Msg::clr_flags"); - ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, - *ACE_Log_Msg_Manager::get_lock ())); - - ACE_CLR_BITS (ACE_Log_Msg::flags_, flgs); -} - -int -ACE_Log_Msg::acquire (void) -{ - ACE_TRACE ("ACE_Log_Msg::acquire"); -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) - return ACE_Log_Msg_Manager::get_lock ()->acquire (); -#else /* ! ACE_MT_SAFE */ - return 0; -#endif /* ! ACE_MT_SAFE */ -} - -u_long -ACE_Log_Msg::priority_mask (u_long n_mask, MASK_TYPE mask_type) -{ - u_long o_mask; - - if (mask_type == THREAD) - { - o_mask = this->priority_mask_; - this->priority_mask_ = n_mask; - } - else - { - o_mask = ACE_Log_Msg::process_priority_mask_; - ACE_Log_Msg::process_priority_mask_ = n_mask; - } - - return o_mask; -} - -int -ACE_Log_Msg::release (void) -{ - ACE_TRACE ("ACE_Log_Msg::release"); - -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) - return ACE_Log_Msg_Manager::get_lock ()->release (); -#else /* ! ACE_MT_SAFE */ - return 0; -#endif /* ! ACE_MT_SAFE */ -} - -ACE_Log_Msg::ACE_Log_Msg (void) - : status_ (0), - errnum_ (0), - linenum_ (0), - msg_ (0), - restart_ (1), // Restart by default... - ostream_ (0), - msg_callback_ (0), - trace_depth_ (0), - trace_active_ (false), - tracing_enabled_ (true), // On by default? - delete_ostream_(false), - thr_desc_ (0), - priority_mask_ (default_priority_mask_), - timestamp_ (0) -{ - // ACE_TRACE ("ACE_Log_Msg::ACE_Log_Msg"); - - ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, - *ACE_Log_Msg_Manager::get_lock ())); - ++instance_count_; - - if (this->instance_count_ == 1) - ACE_Base_Thread_Adapter::set_log_msg_hooks (ACE_Log_Msg::init_hook, - ACE_Log_Msg::inherit_hook, - ACE_Log_Msg::close, - ACE_Log_Msg::sync_hook, - ACE_Log_Msg::thr_desc_hook); - - this->conditional_values_.is_set_ = false; - - char *timestamp = ACE_OS::getenv ("ACE_LOG_TIMESTAMP"); - if (timestamp != 0) - { - // If variable is set or is set to date tag so we print date and time. - if (ACE_OS::strcmp (timestamp, "TIME") == 0) - { - this->timestamp_ = 1; - } - else if (ACE_OS::strcmp (timestamp, "DATE") == 0) - { - this->timestamp_ = 2; - } - } - - ACE_NEW_NORETURN (this->msg_, ACE_TCHAR[ACE_MAXLOGMSGLEN+1]); -} - -ACE_Log_Msg::~ACE_Log_Msg (void) -{ -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) - - int instance_count = 0; - - // Only hold the guard while updating the instance_count_. - // If ACE_Log_Msg_Manager::close () is called, the lock will - // be deleted. - { - ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, - *ACE_Log_Msg_Manager::get_lock ())); - instance_count = --instance_count_; - } - // Release the guard. - -#else /* ! ACE_MT_SAFE */ - int instance_count = --instance_count_; -#endif /* ! ACE_MT_SAFE */ - - // If this is the last instance then cleanup. Only the last - // thread to destroy its ACE_Log_Msg instance should execute - // this block. - if (instance_count == 0) - { - // Destroy the message queue instance. - if (ACE_Log_Msg_Manager::log_backend_ != 0) - ACE_Log_Msg_Manager::log_backend_->close (); - - // Close down custom backend - if (ACE_Log_Msg_Manager::custom_backend_ != 0) - ACE_Log_Msg_Manager::custom_backend_->close (); - -# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) -# if defined (ACE_HAS_TSS_EMULATION) - ACE_Log_Msg_Manager::close (); -# endif /* ACE_HAS_TSS_EMULATION */ -# endif /* ACE_MT_SAFE */ - - if (ACE_Log_Msg::program_name_) - { - ACE_OS::free ((void *) ACE_Log_Msg::program_name_); - ACE_Log_Msg::program_name_ = 0; - } - - if (ACE_Log_Msg::local_host_) - { - ACE_OS::free ((void *) ACE_Log_Msg::local_host_); - ACE_Log_Msg::local_host_ = 0; - } - } - - // - // do we need to close and clean up? - // - if (this->delete_ostream_) -#if defined (ACE_LACKS_IOSTREAM_TOTALLY) - { - ACE_OS::fclose (this->ostream_); - } -#else - { - delete ostream_; - ostream_ = 0; - } -#endif - - delete[] this->msg_; -} - -// Open the sender-side of the message queue. - -int -ACE_Log_Msg::open (const ACE_TCHAR *prog_name, - u_long flags, - const ACE_TCHAR *logger_key) -{ - ACE_TRACE ("ACE_Log_Msg::open"); - ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, - *ACE_Log_Msg_Manager::get_lock (), -1)); - - if (prog_name) - { - ACE_OS::free ((void *) ACE_Log_Msg::program_name_); - - // Stop heap checking, block will be freed by the destructor. - { - ACE_NO_HEAP_CHECK; - - ACE_ALLOCATOR_RETURN (ACE_Log_Msg::program_name_, - ACE_OS::strdup (prog_name), - -1); - } - } - else if (ACE_Log_Msg::program_name_ == 0) - { - // Stop heap checking, block will be freed by the destructor. - ACE_NO_HEAP_CHECK; - ACE_ALLOCATOR_RETURN (ACE_Log_Msg::program_name_, - ACE_OS::strdup (ACE_TEXT ("")), - -1); - } - - int status = 0; - - // Be sure that there is a message_queue_, with multiple threads. - ACE_MT (ACE_Log_Msg_Manager::init_backend (&flags)); - - // Always close the current handle before doing anything else. - if (ACE_Log_Msg_Manager::log_backend_ != 0) - ACE_Log_Msg_Manager::log_backend_->reset (); - - if (ACE_Log_Msg_Manager::custom_backend_ != 0) - ACE_Log_Msg_Manager::custom_backend_->reset (); - - // Note that if we fail to open the message queue the default action - // is to use stderr (set via static initialization in the - // Log_Msg.cpp file). - - if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::LOGGER) - || ACE_BIT_ENABLED (flags, ACE_Log_Msg::SYSLOG)) - { - // The SYSLOG backends (both NT and UNIX) can get along fine - // without the logger_key - they will default to prog_name if - // logger key is 0. - if (logger_key == 0 && ACE_BIT_ENABLED (flags, ACE_Log_Msg::LOGGER)) - status = -1; - else - status = ACE_Log_Msg_Manager::log_backend_->open (logger_key); - - if (status == -1) - ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::STDERR); - else - { - if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::LOGGER)) - ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER); - if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::SYSLOG)) - ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::SYSLOG); - } - } - else if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER) - || ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::SYSLOG)) - { - // If we are closing down logger, redirect logging to stderr. - ACE_CLR_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER); - ACE_CLR_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::SYSLOG); - ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::STDERR); - } - - if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::CUSTOM)) - { - status = - ACE_Log_Msg_Manager::custom_backend_->open (logger_key); - - if (status != -1) - ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::CUSTOM); - } - - // Remember, ACE_Log_Msg::STDERR bit is on by default... - if (status != -1 - && ACE_BIT_ENABLED (flags, - ACE_Log_Msg::STDERR) == 0) - ACE_CLR_BITS (ACE_Log_Msg::flags_, - ACE_Log_Msg::STDERR); - - // VERBOSE takes precedence over VERBOSE_LITE... - if (ACE_BIT_ENABLED (flags, - ACE_Log_Msg::VERBOSE_LITE)) - ACE_SET_BITS (ACE_Log_Msg::flags_, - ACE_Log_Msg::VERBOSE_LITE); - else if (ACE_BIT_ENABLED (flags, - ACE_Log_Msg::VERBOSE)) - ACE_SET_BITS (ACE_Log_Msg::flags_, - ACE_Log_Msg::VERBOSE); - - if (ACE_BIT_ENABLED (flags, - ACE_Log_Msg::OSTREAM)) - { - ACE_SET_BITS (ACE_Log_Msg::flags_, - ACE_Log_Msg::OSTREAM); - // Only set this to cerr if it hasn't already been set. - if (this->msg_ostream () == 0) - this->msg_ostream (ACE_DEFAULT_LOG_STREAM); - } - - if (ACE_BIT_ENABLED (flags, - ACE_Log_Msg::MSG_CALLBACK)) - ACE_SET_BITS (ACE_Log_Msg::flags_, - ACE_Log_Msg::MSG_CALLBACK); - - if (ACE_BIT_ENABLED (flags, - ACE_Log_Msg::SILENT)) - ACE_SET_BITS (ACE_Log_Msg::flags_, - ACE_Log_Msg::SILENT); - - return status; -} - -/** - * Valid Options (prefixed by '%', as in printf format strings) include: - * 'A': print an ACE_timer_t value - * 'a': exit the program at this point (var-argument is the exit status!) - * 'b': print a ssize_t value - * 'B': print a size_t value - * 'c': print a character - * 'C': print a character string - * 'i', 'd': print a decimal number - * 'I', indent according to nesting depth - * 'e', 'E', 'f', 'F', 'g', 'G': print a double - * 'l', print line number where an error occurred. - * 'M': print the name of the priority of the message. - * 'm': Return the message corresponding to errno value, e.g., as done by - * 'N': print file name where the error occurred. - * 'n': print the name of the program (or "" if not set) - * 'o': print as an octal number - * 'P': format the current process id - * 'p': format the appropriate errno message from sys_errlist, e.g., as done by - * 'Q': print out the uint64 number - * 'q': print out the int64 number - * '@': print a void* pointer (in hexadecimal) - * 'r': call the function pointed to by the corresponding argument - * 'R': print return status - * 'S': format the appropriate _sys_siglist entry corresponding to var-argument. - * 's': format a character string - * 'T': print timestamp in hour:minute:sec:usec format. - * 'D': print timestamp in month/day/year hour:minute:sec:usec format. - * 't': print thread id (1 if single-threaded) - * 'u': print as unsigned int - * 'x': print as a hex number - * 'X': print as a hex number - * 'w': print a wide character - * 'W': print out a wide character string. - * 'z': print an ACE_OS::WChar character - * 'Z': print an ACE_OS::WChar character string - * ':': print a time_t value as an integral number - * '%': format a single percent sign, '%' - */ -ssize_t -ACE_Log_Msg::log (ACE_Log_Priority log_priority, - const ACE_TCHAR *format_str, ...) -{ - ACE_TRACE ("ACE_Log_Msg::log"); - - // Start of variable args section. - va_list argp; - - va_start (argp, format_str); - - ssize_t const result = this->log (format_str, - log_priority, - argp); - va_end (argp); - - return result; -} - -#if defined (ACE_HAS_WCHAR) -/** - * Since this is the ANTI_TCHAR version, we need to convert - * the format string over. - */ -ssize_t -ACE_Log_Msg::log (ACE_Log_Priority log_priority, - const ACE_ANTI_TCHAR *format_str, ...) -{ - ACE_TRACE ("ACE_Log_Msg::log"); - - // Start of variable args section. - va_list argp; - - va_start (argp, format_str); - - ssize_t const result = this->log (ACE_TEXT_ANTI_TO_TCHAR (format_str), - log_priority, - argp); - va_end (argp); - - return result; -} -#endif /* ACE_HAS_WCHAR */ - -ssize_t -ACE_Log_Msg::log (const ACE_TCHAR *format_str, - ACE_Log_Priority log_priority, - va_list argp) -{ - ACE_TRACE ("ACE_Log_Msg::log"); - // External decls. - - typedef void (*PTF)(...); - - // Check if there were any conditional values set. - bool const conditional_values = this->conditional_values_.is_set_; - - // Reset conditional values. - this->conditional_values_.is_set_ = false; - - // Only print the message if hasn't been reset to - // exclude this logging priority. - if (this->log_priority_enabled (log_priority) == 0) - return 0; - - // If conditional values were set and the log priority is correct, - // then the values are actually set. - if (conditional_values) - this->set (this->conditional_values_.file_, - this->conditional_values_.line_, - this->conditional_values_.op_status_, - this->conditional_values_.errnum_, - this->restart (), - this->msg_ostream (), - this->msg_callback ()); - - // Logging is supposed to be a benign activity (i.e., not interfer - // with normal application operations), so don't inadvertently smash - // errno! - ACE_Errno_Guard guard (errno); - - ACE_Log_Record log_record (log_priority, - ACE_OS::gettimeofday (), - this->getpid ()); - - // bp is pointer to where to put next part of logged message. - // bspace is the number of characters remaining in msg_. - ACE_TCHAR *bp = const_cast (this->msg ()); - size_t bspace = ACE_Log_Record::MAXLOGMSGLEN; // Leave room for Nul term. - if (this->msg_off_ <= ACE_Log_Record::MAXLOGMSGLEN) - bspace -= static_cast (this->msg_off_); - - // If this platform has snprintf() capability to prevent overrunning the - // output buffer, use it. To avoid adding a maintenance-hassle compile- - // time couple between here and OS.cpp, don't try to figure this out at - // compile time. Instead, do a quick check now; if we get a -1 return, - // the platform doesn't support the length-limiting capability. - ACE_TCHAR test[2]; - bool can_check = ACE_OS::snprintf (test, 1, ACE_TEXT ("x")) != -1; - - bool abort_prog = false; - int exit_value = 0; - - if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::VERBOSE)) - { - // Prepend the program name onto this message - - if (ACE_Log_Msg::program_name_ != 0) - { - for (const ACE_TCHAR *s = ACE_Log_Msg::program_name_; - bspace > 1 && (*bp = *s) != '\0'; - ++s, --bspace) - bp++; - - *bp++ = '|'; - --bspace; - } - } - - if (timestamp_ > 0) - { - ACE_TCHAR day_and_time[35]; - const ACE_TCHAR *s; - if (timestamp_ == 1) - { - // Print just the time - s = ACE::timestamp (day_and_time, sizeof day_and_time, 1); - } - else - { - // Print time and date - ACE::timestamp (day_and_time, sizeof day_and_time); - s = day_and_time; - } - - for (; bspace > 1 && (*bp = *s) != '\0'; ++s, --bspace) - ++bp; - - *bp++ = '|'; - --bspace; - } - - while (*format_str != '\0' && bspace > 0) - { - // Copy input to output until we encounter a %, however a - // % followed by another % is not a format specification. - - if (*format_str != '%') - { - *bp++ = *format_str++; - --bspace; - } - else if (format_str[1] == '%') // An "escaped" '%' (just print one '%'). - { - *bp++ = *format_str++; // Store first % - ++format_str; // but skip second % - --bspace; - } - else - { - // This is most likely a format specification that ends with - // one of the valid options described previously. To enable full - // use of all sprintf capabilities, save the format specifier - // from the '%' up to the format letter in a new char array. - // This allows the full sprintf capability for padding, field - // widths, alignment, etc. Any width/precision requiring a - // caller-supplied argument is extracted and placed as text - // into the format array. Lastly, we convert the caller-supplied - // format specifier from the ACE_Log_Msg-supported list to the - // equivalent sprintf specifier, and run the new format spec - // through sprintf, adding it to the bp string. - - const ACE_TCHAR *abort_str = ACE_TEXT ("Aborting..."); - const ACE_TCHAR *start_format = format_str; - ACE_TCHAR format[128]; // Converted format string - ACE_TCHAR *fp; // Current format pointer - int wp = 0; // Width/precision extracted from args - bool done = false; - bool skip_nul_locate = false; - int this_len = 0; // How many chars s[n]printf wrote - - fp = format; - *fp++ = *format_str++; // Copy in the % - - // Initialization to satisfy VC6 - int tmp_indent = 0; - // Work through the format string to copy in the format - // from the caller. While it's going across, extract ints - // for '*' width/precision values from the argument list. - // When the real format specifier is located, change it to - // one recognized by sprintf, if needed, and do the sprintf - // call. - - while (!done) - { - done = true; // Unless a conversion spec changes it - - switch (*format_str) - { - // The initial set of cases are the conversion - // specifiers. Copy them in to the format array. - // Note we don't use 'l', a normal conversion spec, - // as a conversion because it is a ACE_Log_Msg format - // specifier. - case '-': - case '+': - case '0': - case ' ': - case '#': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '.': - case 'L': - case 'h': - *fp++ = *format_str; - done = false; - break; - - case '*': - wp = va_arg (argp, int); - ACE_OS::sprintf (fp, ACE_TEXT ("%d"), wp); - fp += ACE_OS::strlen (fp); - done = false; - break; - - case 'A': // ACE_timer_t - { - ACE_OS::strcpy (fp, ACE_TEXT ("f")); - double value = va_arg (argp, double); - if (can_check) - this_len = ACE_OS::snprintf (bp, bspace, format, value); - else - this_len = ACE_OS::sprintf (bp, format, value); - ACE_UPDATE_COUNT (bspace, this_len); - } - break; - - case 'a': // Abort program after handling all of format string. - abort_prog = true; - exit_value = va_arg (argp, int); - ACE_OS::strsncpy (bp, abort_str, bspace); - if (bspace > ACE_OS::strlen (abort_str)) - bspace -= ACE_OS::strlen (abort_str); - else - bspace = 0; - break; - - case 'l': // Source file line number - ACE_OS::strcpy (fp, ACE_TEXT ("d")); - if (can_check) - this_len = ACE_OS::snprintf (bp, - bspace, - format, - this->linenum ()); - else - this_len = ACE_OS::sprintf (bp, format, this->linenum ()); - ACE_UPDATE_COUNT (bspace, this_len); - break; - - case 'N': // Source file name -#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_OS::strcpy (fp, ACE_TEXT ("ls")); -#else - ACE_OS::strcpy (fp, ACE_TEXT ("s")); -#endif - if (can_check) - this_len = ACE_OS::snprintf (bp, bspace, format, - this->file () ? - ACE_TEXT_CHAR_TO_TCHAR (this->file ()) - : ACE_TEXT ("")); - else - this_len = ACE_OS::sprintf (bp, format, - this->file () ? - ACE_TEXT_CHAR_TO_TCHAR (this->file ()) - : ACE_TEXT ("")); - ACE_UPDATE_COUNT (bspace, this_len); - break; - - case 'n': // Program name -#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_OS::strcpy (fp, ACE_TEXT ("ls")); -#else /* ACE_WIN32 && ACE_USES_WCHAR */ - ACE_OS::strcpy (fp, ACE_TEXT ("s")); -#endif - if (can_check) - this_len = ACE_OS::snprintf (bp, bspace, format, - ACE_Log_Msg::program_name_ ? - ACE_Log_Msg::program_name_ : - ACE_TEXT ("")); - else - this_len = ACE_OS::sprintf (bp, format, - ACE_Log_Msg::program_name_ ? - ACE_Log_Msg::program_name_ : - ACE_TEXT ("")); - ACE_UPDATE_COUNT (bspace, this_len); - break; - - case 'P': // Process ID -#if defined (ACE_OPENVMS) - // Print the process id in hex on OpenVMS. - ACE_OS::strcpy (fp, ACE_TEXT ("x")); -#else - ACE_OS::strcpy (fp, ACE_TEXT ("d")); -#endif - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, - static_cast (this->getpid ())); - else - this_len = ACE_OS::sprintf - (bp, format, static_cast (this->getpid ())); - ACE_UPDATE_COUNT (bspace, this_len); - break; - - case 'p': // string, ala perror() - { - errno = 0; - char *msg = ACE_OS::strerror (ACE::map_errno (this->errnum ())); - // Windows can try to translate the errnum using - // system calls if strerror() doesn't get anything useful. -#if defined (ACE_WIN32) - if (errno == 0) - { -#endif - -#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_OS::strcpy (fp, ACE_TEXT ("ls: %ls")); -#else - ACE_OS::strcpy (fp, ACE_TEXT ("s: %s")); -#endif - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, va_arg (argp, ACE_TCHAR *), - ACE_TEXT_CHAR_TO_TCHAR (msg)); - else - this_len = ACE_OS::sprintf - (bp, format, va_arg (argp, ACE_TCHAR *), - ACE_TEXT_CHAR_TO_TCHAR (msg)); -#if defined (ACE_WIN32) - } - else - { - errno = ACE::map_errno (this->errnum ()); - ACE_TCHAR *lpMsgBuf = 0; - - // PharLap can't do FormatMessage, so try for socket - // error. -# if !defined (ACE_HAS_PHARLAP) - ACE_TEXT_FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER - | FORMAT_MESSAGE_MAX_WIDTH_MASK - | FORMAT_MESSAGE_FROM_SYSTEM, - 0, - errno, - MAKELANGID (LANG_NEUTRAL, - SUBLANG_DEFAULT), - // Default language - (ACE_TCHAR *) &lpMsgBuf, - 0, - 0); -# endif /* ACE_HAS_PHARLAP */ - - // If we don't get a valid response from - // , we'll assume this is a - // WinSock error and so we'll try to convert - // it into a string. If this doesn't work it - // returns "unknown error" which is fine for - // our purposes. - if (lpMsgBuf == 0) - { - const ACE_TCHAR *message = - ACE::sock_error (errno); - ACE_OS::strcpy (fp, ACE_TEXT ("s: %s")); - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, - va_arg (argp, const ACE_TCHAR *), - message); - else - this_len = ACE_OS::sprintf - (bp, format, - va_arg (argp, const ACE_TCHAR *), - message); - } - else - { - ACE_OS::strcpy (fp, ACE_TEXT ("s: %s")); - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, - va_arg (argp, ACE_TCHAR *), - lpMsgBuf); - else - this_len = ACE_OS::sprintf - (bp, format, - va_arg (argp, ACE_TCHAR *), - lpMsgBuf); - // Free the buffer. - ::LocalFree (lpMsgBuf); - } - } -#endif /* ACE_WIN32 */ - ACE_UPDATE_COUNT (bspace, this_len); - break; - } - - case 'M': // Print the name of the priority of the message. -#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_OS::strcpy (fp, ACE_TEXT ("ls")); -#else - ACE_OS::strcpy (fp, ACE_TEXT ("s")); -#endif - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, - ACE_Log_Record::priority_name (log_priority)); - else - this_len = ACE_OS::sprintf - (bp, format, - ACE_Log_Record::priority_name (log_priority)); - ACE_UPDATE_COUNT (bspace, this_len); - break; - - case 'm': // Format the string assocated with the errno value. - { - errno = 0; - char *msg = 0; - msg = ACE_OS::strerror (ACE::map_errno (this->errnum ())); - // Windows can try to translate the errnum using - // system calls if strerror() doesn't get anything useful. -#if defined (ACE_WIN32) - if (errno == 0) - { -#endif - -#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_OS::strcpy (fp, ACE_TEXT ("ls")); -#else /* ACE_WIN32 && ACE_USES_WCHAR */ - ACE_OS::strcpy (fp, ACE_TEXT ("s")); -#endif - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, ACE_TEXT_CHAR_TO_TCHAR (msg)); - else - this_len = ACE_OS::sprintf - (bp, format, ACE_TEXT_CHAR_TO_TCHAR (msg)); -#if defined (ACE_WIN32) - } - else - { - errno = ACE::map_errno (this->errnum ()); - ACE_TCHAR *lpMsgBuf = 0; - - // PharLap can't do FormatMessage, so try for socket - // error. -# if !defined (ACE_HAS_PHARLAP) - ACE_TEXT_FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER - | FORMAT_MESSAGE_MAX_WIDTH_MASK - | FORMAT_MESSAGE_FROM_SYSTEM, - 0, - errno, - MAKELANGID (LANG_NEUTRAL, - SUBLANG_DEFAULT), - // Default language - (ACE_TCHAR *) &lpMsgBuf, - 0, - 0); -# endif /* ACE_HAS_PHARLAP */ - - // If we don't get a valid response from - // , we'll assume this is a - // WinSock error and so we'll try to convert - // it into a string. If this doesn't work it - // returns "unknown error" which is fine for - // our purposes. - if (lpMsgBuf == 0) - { - const ACE_TCHAR *message = - ACE::sock_error (errno); - ACE_OS::strcpy (fp, ACE_TEXT ("s")); - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, message); - else - this_len = ACE_OS::sprintf (bp, format, message); - } - else - { - ACE_OS::strcpy (fp, ACE_TEXT ("s")); - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, lpMsgBuf); - else - this_len = ACE_OS::sprintf - (bp, format, lpMsgBuf); - // Free the buffer. - ::LocalFree (lpMsgBuf); - } - } -#endif /* ACE_WIN32 */ - ACE_UPDATE_COUNT (bspace, this_len); - break; - } - - case 'R': // Format the return status of the operation. - this->op_status (va_arg (argp, int)); - ACE_OS::strcpy (fp, ACE_TEXT ("d")); - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, this->op_status ()); - else - this_len = ACE_OS::sprintf - (bp, format, this->op_status ()); - ACE_UPDATE_COUNT (bspace, this_len); - break; - - case '{': // Increment the trace_depth, then indent - skip_nul_locate = true; - (void) this->inc (); - break; - - case '}': // indent, then decrement trace_depth - skip_nul_locate = true; - (void) this->dec (); - break; - - case '$': // insert a newline, then indent the next line - // according to %I - *bp++ = '\n'; - --bspace; - /* fallthrough */ - - case 'I': // Indent with nesting_depth*width spaces - // Caller can do %*I to override nesting indent, and - // if %*I was done, wp has the extracted width. -#if defined (ACE_HAS_TRACE) - if (0 == wp) - wp = ACE_Trace::get_nesting_indent (); -#else - if (0 == wp) - wp = 4; -#endif /* ACE_HAS_TRACE */ - wp *= this->trace_depth_; - if (static_cast (wp) > bspace) - wp = static_cast (bspace); - for (tmp_indent = wp; - tmp_indent; - --tmp_indent) - *bp++ = ' '; - - *bp = '\0'; - bspace -= static_cast (wp); - skip_nul_locate = true; - break; - - case 'r': // Run (invoke) this subroutine. - { - ptrdiff_t const osave = ACE_Log_Msg::msg_off_; - - if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, - ACE_Log_Msg::SILENT) && - bspace > 1) - { - *bp++ = '{'; - --bspace; - } - ACE_Log_Msg::msg_off_ = bp - this->msg_; - - (*va_arg (argp, PTF))(); - - if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, - ACE_Log_Msg::SILENT) && - bspace > (1 + ACE_OS::strlen (bp))) - { - bspace -= (ACE_OS::strlen (bp) + 1); - bp += ACE_OS::strlen (bp); - *bp++ = '}'; - } - *bp = '\0'; - skip_nul_locate = true; - ACE_Log_Msg::msg_off_ = osave; - break; - } - - case 'S': // format the string for with this signal number. - { - int sig = va_arg (argp, int); -#if defined (ACE_HAS_SYS_SIGLIST) - if (sig >= 0 && sig < ACE_NSIG) - { - ACE_OS::strcpy (fp, ACE_TEXT ("s")); - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, _sys_siglist[sig]); - else - this_len = ACE_OS::sprintf - (bp, format, _sys_siglist[sig]); - } - else - { - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, - ACE_TEXT(" %d"), sig); - else - this_len = ACE_OS::sprintf - (bp, ACE_TEXT (" %d"), sig); - } -#else - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, ACE_TEXT ("signal %d"), sig); - else - this_len = ACE_OS::sprintf - (bp, ACE_TEXT ("signal %d"), sig); -#endif /* ACE_HAS_SYS_SIGLIST */ - ACE_UPDATE_COUNT (bspace, this_len); - break; - } - - case 'D': // Format the timestamp in format: - // Weekday Month day year hour:minute:sec.usec - { - ACE_TCHAR day_and_time[35]; - ACE::timestamp (day_and_time, - sizeof day_and_time); -#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_OS::strcpy (fp, ACE_TEXT ("ls")); -#else - ACE_OS::strcpy (fp, ACE_TEXT ("s")); -#endif - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, day_and_time); - else - this_len = ACE_OS::sprintf (bp, format, day_and_time); - ACE_UPDATE_COUNT (bspace, this_len); - break; - } - - case 'T': // Format the timestamp in - // hour:minute:sec:usec format. - { - ACE_TCHAR day_and_time[35]; - ACE_OS::strcpy (fp, ACE_TEXT ("s")); - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, - ACE::timestamp (day_and_time, sizeof day_and_time)); - else - this_len = ACE_OS::sprintf - (bp, format, ACE::timestamp (day_and_time, - sizeof day_and_time)); - ACE_UPDATE_COUNT (bspace, this_len); - break; - } - - case 't': // Format thread id. -#if defined (ACE_WIN32) - ACE_OS::strcpy (fp, ACE_TEXT ("u")); - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, - static_cast (ACE_Thread::self ())); - else - this_len = - ACE_OS::sprintf (bp, - format, - static_cast (ACE_Thread::self ())); -#elif defined (DIGITAL_UNIX) - ACE_OS::strcpy (fp, ACE_TEXT ("u")); - { - int id = -# if defined (ACE_HAS_THREADS) - pthread_getselfseq_np (); -# else - ACE_Thread::self (); -# endif /* ACE_HAS_THREADS */ - - if (can_check) - this_len = ACE_OS::snprintf (bp, bspace, format, id); - else - this_len = ACE_OS::sprintf (bp, format, id); - } -#else - ACE_hthread_t t_id; - ACE_Thread::self (t_id); - -# if defined (ACE_MVS) || defined (ACE_TANDEM_T1248_PTHREADS) - // MVS's pthread_t is a struct... yuck. So use the ACE 5.0 - // code for it. - ACE_OS::strcpy (fp, ACE_TEXT ("u")); - if (can_check) - this_len = ACE_OS::snprintf (bp, bspace, format, t_id); - else - this_len = ACE_OS::sprintf (bp, format, t_id); -# else - // Yes, this is an ugly C-style cast, but the correct - // C++ cast is different depending on whether the t_id - // is an integral type or a pointer type. FreeBSD uses - // a pointer type, but doesn't have a _np function to - // get an integral type, like the OSes above. - ACE_OS::strcpy (fp, ACE_TEXT ("lu")); - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, (unsigned long)t_id); - else - this_len = ACE_OS::sprintf - (bp, format, (unsigned long)t_id); -# endif /* ACE_MWS || ACE_TANDEM_T1248_PTHREADS */ - -#endif /* ACE_WIN32 */ - ACE_UPDATE_COUNT (bspace, this_len); - break; - - case 's': // String - { -#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - wchar_t *str = va_arg (argp, wchar_t *); - ACE_OS::strcpy (fp, ACE_TEXT ("ls")); -#else /* ACE_WIN32 && ACE_USES_WCHAR */ - ACE_TCHAR *str = va_arg (argp, ACE_TCHAR *); - ACE_OS::strcpy (fp, ACE_TEXT ("s")); -#endif /* ACE_WIN32 && ACE_USES_WCHAR */ - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, str ? str : ACE_TEXT ("(null)")); - else - this_len = ACE_OS::sprintf - (bp, format, str ? str : ACE_TEXT ("(null)")); - ACE_UPDATE_COUNT (bspace, this_len); - } - break; - - case 'C': // Char string, Unicode for Win32/WCHAR - { - ACE_TCHAR *cstr = va_arg (argp, ACE_TCHAR *); -#if defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_OS::strcpy (fp, ACE_TEXT ("S")); -#else /* ACE_WIN32 && ACE_USES_WCHAR */ - ACE_OS::strcpy (fp, ACE_TEXT ("s")); -#endif /* ACE_WIN32 && ACE_USES_WCHAR */ - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, cstr ? cstr : ACE_TEXT ("(null)")); - else - this_len = ACE_OS::sprintf - (bp, format, cstr ? cstr : ACE_TEXT ("(null)")); - ACE_UPDATE_COUNT (bspace, this_len); - } - break; - - case 'W': - { -#if defined (ACE_HAS_WCHAR) - wchar_t *wchar_str = va_arg (argp, wchar_t *); -# if defined (HPUX) - ACE_OS::strcpy (fp, ACE_TEXT ("S")); -# elif defined (ACE_WIN32) -# if defined (ACE_USES_WCHAR) - ACE_OS::strcpy (fp, ACE_TEXT ("s")); -# else /* ACE_USES_WCHAR */ - ACE_OS::strcpy (fp, ACE_TEXT ("S")); -# endif /* ACE_USES_WCHAR */ -# else - ACE_OS::strcpy (fp, ACE_TEXT ("ls")); -# endif /* HPUX */ - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, wchar_str ? wchar_str : ACE_TEXT_WIDE("(null)")); - else - this_len = ACE_OS::sprintf - (bp, format, wchar_str ? wchar_str : ACE_TEXT_WIDE("(null)")); -#endif /* ACE_HAS_WCHAR */ - ACE_UPDATE_COUNT (bspace, this_len); - } - break; - - case 'w': // Wide character -#if defined (ACE_WIN32) -# if defined (ACE_USES_WCHAR) - ACE_OS::strcpy (fp, ACE_TEXT ("c")); -# else /* ACE_USES_WCHAR */ - ACE_OS::strcpy (fp, ACE_TEXT ("C")); -# endif /* ACE_USES_WCHAR */ - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, va_arg (argp, int)); - else - this_len = ACE_OS::sprintf - (bp, format, va_arg (argp, int)); -#elif defined (ACE_USES_WCHAR) -# if defined (HPUX) - ACE_OS::strcpy (fp, ACE_TEXT ("C")); -# else - ACE_OS::strcpy (fp, ACE_TEXT ("lc")); -# endif /* HPUX */ - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, va_arg (argp, wint_t)); - else - this_len = ACE_OS::sprintf - (bp, format, va_arg (argp, wint_t)); -#else /* ACE_WIN32 */ - ACE_OS::strcpy (fp, ACE_TEXT ("u")); - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, va_arg (argp, int)); - else - this_len = ACE_OS::sprintf - (bp, format, va_arg (argp, int)); -#endif /* ACE_WIN32 */ - ACE_UPDATE_COUNT (bspace, this_len); - break; - - case 'z': // ACE_OS::WChar character - { - // On some platforms sizeof (wchar_t) can be 2 - // on the others 4 ... - wchar_t wtchar = - static_cast (va_arg (argp, int)); -#if defined (ACE_WIN32) -# if defined (ACE_USES_WCHAR) - ACE_OS::strcpy (fp, ACE_TEXT ("c")); -# else /* ACE_USES_WCHAR */ - ACE_OS::strcpy (fp, ACE_TEXT ("C")); -# endif /* ACE_USES_WCHAR */ -#elif defined (ACE_USES_WCHAR) -# if defined (HPUX) - ACE_OS::strcpy (fp, ACE_TEXT ("C")); -# else - ACE_OS::strcpy (fp, ACE_TEXT ("lc")); -# endif /* HPUX */ -#else /* ACE_WIN32 */ - ACE_OS::strcpy (fp, ACE_TEXT ("u")); -#endif /* ACE_WIN32 */ - if (can_check) - this_len = ACE_OS::snprintf (bp, bspace, format, wtchar); - else - this_len = ACE_OS::sprintf (bp, format, wtchar); - ACE_UPDATE_COUNT (bspace, this_len); - break; - } - - case 'Z': // ACE_OS::WChar character string - { - ACE_OS::WChar *wchar_str = va_arg (argp, ACE_OS::WChar*); - if (wchar_str == 0) - break; - - wchar_t *wchar_t_str = 0; - if (sizeof (ACE_OS::WChar) != sizeof (wchar_t)) - { - size_t len = ACE_OS::wslen (wchar_str) + 1; - ACE_NEW_NORETURN(wchar_t_str, wchar_t[len]); - if (wchar_t_str == 0) - break; - - for (size_t i = 0; i < len; ++i) - { - wchar_t_str[i] = wchar_str[i]; - } - } - - if (wchar_t_str == 0) - { - wchar_t_str = reinterpret_cast (wchar_str); - } -#if defined (ACE_WIN32) -# if defined (ACE_USES_WCHAR) - ACE_OS::strcpy (fp, ACE_TEXT ("s")); -# else /* ACE_USES_WCHAR */ - ACE_OS::strcpy (fp, ACE_TEXT ("S")); -# endif /* ACE_USES_WCHAR */ -#elif defined (ACE_HAS_WCHAR) -# if defined (HPUX) - ACE_OS::strcpy (fp, ACE_TEXT ("S")); -# else - ACE_OS::strcpy (fp, ACE_TEXT ("ls")); -# endif /* HPUX */ -#endif /* ACE_WIN32 / ACE_HAS_WCHAR */ - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, wchar_t_str); - else - this_len = ACE_OS::sprintf (bp, format, wchar_t_str); - if(sizeof(ACE_OS::WChar) != sizeof(wchar_t)) - { - delete [] wchar_t_str; - } - ACE_UPDATE_COUNT (bspace, this_len); - break; - } - - case 'c': -#if defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_OS::strcpy (fp, ACE_TEXT ("C")); -#else - ACE_OS::strcpy (fp, ACE_TEXT ("c")); -#endif /* ACE_WIN32 && ACE_USES_WCHAR */ - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, va_arg (argp, int)); - else - this_len = ACE_OS::sprintf - (bp, format, va_arg (argp, int)); - ACE_UPDATE_COUNT (bspace, this_len); - break; - - case 'd': case 'i': case 'o': - case 'u': case 'x': case 'X': - fp[0] = *format_str; - fp[1] = '\0'; - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, va_arg (argp, int)); - else - this_len = ACE_OS::sprintf - (bp, format, va_arg (argp, int)); - ACE_UPDATE_COUNT (bspace, this_len); - break; - - case 'F': case 'f': case 'e': case 'E': - case 'g': case 'G': - fp[0] = *format_str; - fp[1] = '\0'; - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, va_arg (argp, double)); - else - this_len = ACE_OS::sprintf - (bp, format, va_arg (argp, double)); - ACE_UPDATE_COUNT (bspace, this_len); - break; - - case 'Q': -#if defined (ACE_LACKS_LONGLONG_T) || defined (ACE_LACKS_UNSIGNEDLONGLONG_T) - { - // This relies on the ACE_U_LongLong storage layout. - ACE_UINT32 hi = va_arg (argp, ACE_UINT32); - ACE_UINT32 lo = va_arg (argp, ACE_UINT32); - if (hi > 0) - this_len = ACE_OS::sprintf (bp, - "0x%lx%0*lx", - hi, - 2 * sizeof lo, - lo); - else - this_len = ACE_OS::sprintf (bp, "0x%lx", lo); - } -#else /* ! ACE_LACKS_LONGLONG_T */ - { - const ACE_TCHAR *fmt = ACE_UINT64_FORMAT_SPECIFIER; - ACE_OS::strcpy (fp, &fmt[1]); // Skip leading % - if (can_check) - this_len = ACE_OS::snprintf (bp, bspace, - format, - va_arg (argp, ACE_UINT64)); - else - this_len = ACE_OS::sprintf (bp, - format, - va_arg (argp, ACE_UINT64)); - } -#endif /* ! ACE_LACKS_LONGLONG_T || ACE_LACKS_UNSIGNEDLONGLONG_T */ - ACE_UPDATE_COUNT (bspace, this_len); - break; - - case 'q': - #if defined (ACE_LACKS_LONGLONG_T) - // No implementation available yet, no ACE_INT64 emulation - // available yet - #else /* ! ACE_LACKS_LONGLONG_T */ - { - const ACE_TCHAR *fmt = ACE_INT64_FORMAT_SPECIFIER; - ACE_OS::strcpy (fp, &fmt[1]); // Skip leading % - if (can_check) - this_len = ACE_OS::snprintf (bp, bspace, - format, - va_arg (argp, ACE_INT64)); - else - this_len = ACE_OS::sprintf (bp, - format, - va_arg (argp, ACE_INT64)); - } - #endif /* ! ACE_LACKS_LONGLONG_T */ - ACE_UPDATE_COUNT (bspace, this_len); - break; - - case 'b': - { - const ACE_TCHAR *fmt = ACE_SSIZE_T_FORMAT_SPECIFIER; - ACE_OS::strcpy (fp, &fmt[1]); // Skip leading % - } - if (can_check) - this_len = ACE_OS::snprintf (bp, bspace, - format, - va_arg (argp, ssize_t)); - else - this_len = ACE_OS::sprintf (bp, - format, - va_arg (argp, ssize_t)); - ACE_UPDATE_COUNT (bspace, this_len); - break; - - case 'B': - { - const ACE_TCHAR *fmt = ACE_SIZE_T_FORMAT_SPECIFIER; - ACE_OS::strcpy (fp, &fmt[1]); // Skip leading % - } - if (can_check) - this_len = ACE_OS::snprintf (bp, bspace, - format, - va_arg (argp, size_t)); - else - this_len = ACE_OS::sprintf (bp, - format, - va_arg (argp, size_t)); - ACE_UPDATE_COUNT (bspace, this_len); - break; - - case ':': - { - // Assume a 32 bit time_t and change if needed. - const ACE_TCHAR *fmt = ACE_TEXT ("%d"); - if (sizeof (time_t) == 8) - fmt = ACE_INT64_FORMAT_SPECIFIER; - - ACE_OS::strcpy (fp, &fmt[1]); // Skip leading % - } - if (can_check) - this_len = ACE_OS::snprintf (bp, bspace, - format, - va_arg (argp, time_t)); - else - this_len = ACE_OS::sprintf (bp, - format, - va_arg (argp, time_t)); - ACE_UPDATE_COUNT (bspace, this_len); - break; - - case '@': - ACE_OS::strcpy (fp, ACE_TEXT ("p")); - if (can_check) - this_len = ACE_OS::snprintf - (bp, bspace, format, va_arg (argp, void*)); - else - this_len = ACE_OS::sprintf - (bp, format, va_arg (argp, void*)); - ACE_UPDATE_COUNT (bspace, this_len); - break; - - default: - // So, it's not a legit format specifier after all... - // Copy from the original % to where we are now, then - // continue with whatever comes next. - while (start_format != format_str && bspace > 0) - { - *bp++ = *start_format++; - --bspace; - } - if (bspace > 0) - { - *bp++ = *format_str; - --bspace; - } - break; - } - - // Bump to the next char in the caller's format_str - ++format_str; - } - - if (!skip_nul_locate) - while (*bp != '\0') // Locate end of bp. - ++bp; - } - } - - *bp = '\0'; // Terminate bp, but don't auto-increment this! - - ssize_t result = 0; - - // Check that memory was not corrupted, if it corrupted we can't log anything - // anymore because all our members could be corrupted. - if (bp >= (this->msg_ + ACE_MAXLOGMSGLEN+1)) - { - abort_prog = true; - ACE_OS::fprintf (stderr, - "The following logged message is too long!\n"); - } - else - { - // Copy the message from thread-specific storage into the transfer - // buffer (this can be optimized away by changing other code...). - log_record.msg_data (this->msg ()); - - // Write the to the appropriate location. - result = this->log (log_record, - abort_prog); - } - - if (abort_prog) - { - // Since we are now calling abort instead of exit, this value is - // not used. - ACE_UNUSED_ARG (exit_value); - - // *Always* print a message to stderr if we're aborting. We - // don't use verbose, however, to avoid recursive aborts if - // something is hosed. - log_record.print (ACE_Log_Msg::local_host_, 0, stderr); - ACE_OS::abort (); - } - - return result; -} - -#if !defined (ACE_WIN32) -/** - * @class ACE_Log_Msg_Sig_Guard - * - * @brief For use only by ACE_Log_Msg. - * - * Doesn't require the use of global variables or global - * functions in an application). - */ -class ACE_Log_Msg_Sig_Guard -{ -private: - ACE_Log_Msg_Sig_Guard (void); - ~ACE_Log_Msg_Sig_Guard (void); - - /// Original signal mask. - sigset_t omask_; - - friend ssize_t ACE_Log_Msg::log (ACE_Log_Record &log_record, - int suppress_stderr); -}; - -ACE_Log_Msg_Sig_Guard::ACE_Log_Msg_Sig_Guard (void) -{ -#if !defined (ACE_LACKS_UNIX_SIGNALS) - ACE_OS::sigemptyset (&this->omask_); - -# if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK) - ACE_OS::sigprocmask (SIG_BLOCK, - ACE_OS_Object_Manager::default_mask (), - &this->omask_); -# else - ACE_OS::thr_sigsetmask (SIG_BLOCK, - ACE_OS_Object_Manager::default_mask (), - &this->omask_); -# endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */ -#endif /* ACE_LACKS_UNIX_SIGNALS */ -} - -ACE_Log_Msg_Sig_Guard::~ACE_Log_Msg_Sig_Guard (void) -{ -#if !defined (ACE_LACKS_UNIX_SIGNALS) -# if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK) - ACE_OS::sigprocmask (SIG_SETMASK, - &this->omask_, - 0); -# else - ACE_OS::thr_sigsetmask (SIG_SETMASK, - &this->omask_, - 0); -# endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */ -#endif /* ! ACE_LACKS_UNIX_SIGNALS */ -} -#endif /* ! ACE_WIN32 */ - -ssize_t -ACE_Log_Msg::log (ACE_Log_Record &log_record, - int suppress_stderr) -{ - ssize_t result = 0; - - // Format the message and print it to stderr and/or ship it off to - // the log_client daemon, and/or print it to the ostream. Of - // course, only print the message if "SILENT" mode is disabled. - if (ACE_BIT_DISABLED (ACE_Log_Msg::flags_, - ACE_Log_Msg::SILENT)) - { - bool tracing = this->tracing_enabled (); - this->stop_tracing (); - -#if !defined (ACE_WIN32) - // Make this block signal-safe. - ACE_Log_Msg_Sig_Guard sb; -#endif /* !ACE_WIN32 */ - - // Do the callback, if needed, before acquiring the lock - // to avoid holding the lock during the callback so we don't - // have deadlock if the callback uses the logger. - if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, - ACE_Log_Msg::MSG_CALLBACK) - && this->msg_callback () != 0) - this->msg_callback ()->log (log_record); - - // Make sure that the lock is held during all this. - ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, - *ACE_Log_Msg_Manager::get_lock (), - -1)); - - if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, - ACE_Log_Msg::STDERR) - && !suppress_stderr) // This is taken care of by our caller. - log_record.print (ACE_Log_Msg::local_host_, - ACE_Log_Msg::flags_, - stderr); - - if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::CUSTOM) || - ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::SYSLOG) || - ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER)) - { - // Be sure that there is a message_queue_, with multiple threads. - ACE_MT (ACE_Log_Msg_Manager::init_backend ()); - } - - - if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER) || - ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::SYSLOG)) - { - result = - ACE_Log_Msg_Manager::log_backend_->log (log_record); - } - - if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::CUSTOM) && - ACE_Log_Msg_Manager::custom_backend_ != 0) - { - result = - ACE_Log_Msg_Manager::custom_backend_->log (log_record); - } - - - // This must come last, after the other two print operations - // (see the method for details). - if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, - ACE_Log_Msg::OSTREAM) - && this->msg_ostream () != 0) - log_record.print (ACE_Log_Msg::local_host_, - ACE_Log_Msg::flags_, -#if defined (ACE_LACKS_IOSTREAM_TOTALLY) - static_cast (this->msg_ostream ()) -#else /* ! ACE_LACKS_IOSTREAM_TOTALLY */ - *this->msg_ostream () -#endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */ - ); - - if (tracing) - this->start_tracing (); - } - - return result; -} - -// Calls log to do the actual print, but formats first. - -int -ACE_Log_Msg::log_hexdump (ACE_Log_Priority log_priority, - const char *buffer, - size_t size, - const ACE_TCHAR *text) -{ - // Only print the message if hasn't been reset to - // exclude this logging priority. - if (this->log_priority_enabled (log_priority) == 0) - return 0; - - ACE_TCHAR* buf = 0; - const size_t buf_sz = - ACE_Log_Record::MAXLOGMSGLEN - ACE_Log_Record::VERBOSE_LEN - 58; - ACE_NEW_RETURN (buf, ACE_TCHAR[buf_sz], -1); - - ACE_TCHAR *msg_buf = 0; - const size_t text_sz = text ? ACE_OS::strlen(text) : 0; - ACE_NEW_RETURN (msg_buf, - ACE_TCHAR[text_sz + 58], - -1); - - buf[0] = 0; // in case size = 0 - - const size_t len = ACE::format_hexdump - (buffer, size, buf, buf_sz / sizeof (ACE_TCHAR) - text_sz); - - int sz = 0; - - if (text) - sz = ACE_OS::sprintf (msg_buf, - ACE_TEXT ("%s - "), - text); - - sz += ACE_OS::sprintf (msg_buf + sz, - ACE_TEXT ("HEXDUMP ") - ACE_SIZE_T_FORMAT_SPECIFIER - ACE_TEXT (" bytes"), - size); - - if (len < size) - ACE_OS::sprintf (msg_buf + sz, - ACE_TEXT (" (showing first ") - ACE_SIZE_T_FORMAT_SPECIFIER - ACE_TEXT (" bytes)"), - len); - - // Now print out the formatted buffer. - this->log (log_priority, - ACE_TEXT ("%s\n%s"), - msg_buf, - buf); - - delete [] msg_buf; - delete [] buf; - return 0; -} - -void -ACE_Log_Msg::set (const char *filename, - int line, - int status, - int err, - int rs, - ACE_OSTREAM_TYPE *os, - ACE_Log_Msg_Callback *c) -{ - ACE_TRACE ("ACE_Log_Msg::set"); - this->file (filename); - this->linenum (line); - this->op_status (status); - this->errnum (err); - this->restart (rs); - this->msg_ostream (os); - this->msg_callback (c); -} - -void -ACE_Log_Msg::conditional_set (const char *filename, - int line, - int status, - int err) -{ - this->conditional_values_.is_set_ = true; - this->conditional_values_.file_ = filename; - this->conditional_values_.line_ = line; - this->conditional_values_.op_status_ = status; - this->conditional_values_.errnum_ = err; -} - -void -ACE_Log_Msg::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Log_Msg::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("status_ = %d\n"), this->status_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nerrnum_ = %d\n"), this->errnum_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nlinenum_ = %d\n"), this->linenum_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nfile_ = %C\n"), this->file_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmsg_ = %s\n"), this->msg_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nrestart_ = %d\n"), this->restart_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nostream_ = %@\n"), this->ostream_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmsg_callback_ = %@\n"), - this->msg_callback_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nprogram_name_ = %s\n"), - this->program_name_ ? this->program_name_ - : ACE_TEXT (""))); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nlocal_host_ = %s\n"), - this->local_host_ ? this->local_host_ - : ACE_TEXT (""))); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\npid_ = %d\n"), this->getpid ())); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nflags_ = 0x%x\n"), this->flags_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntrace_depth_ = %d\n"), - this->trace_depth_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntrace_active_ = %d\n"), - this->trace_active_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntracing_enabled_ = %d\n"), - this->tracing_enabled_)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\npriority_mask_ = 0x%x\n"), - this->priority_mask_)); - if (this->thr_desc_ != 0 && this->thr_desc_->state () != 0) - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthr_state_ = %d\n"), - this->thr_desc_->state ())); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmsg_off_ = %d\n"), this->msg_off_)); - - // Be sure that there is a message_queue_, with multiple threads. - ACE_MT (ACE_Log_Msg_Manager::init_backend ()); - - ACE_MT (ACE_Log_Msg_Manager::get_lock ()->dump ()); - // Synchronize output operations. - - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* ACE_HAS_DUMP */ -} - -void -ACE_Log_Msg::thr_desc (ACE_Thread_Descriptor *td) -{ - this->thr_desc_ = td; - - if (td != 0) - td->acquire_release (); -} - -#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) && defined(ACE_LEGACY_MODE) -ACE_SEH_EXCEPT_HANDLER -ACE_Log_Msg::seh_except_selector (void) -{ - return ACE_OS_Object_Manager::seh_except_selector (); -} - -ACE_SEH_EXCEPT_HANDLER -ACE_Log_Msg::seh_except_selector (ACE_SEH_EXCEPT_HANDLER n) -{ - return ACE_OS_Object_Manager::seh_except_selector (n); -} - -ACE_SEH_EXCEPT_HANDLER -ACE_Log_Msg::seh_except_handler (void) -{ - return ACE_OS_Object_Manager::seh_except_handler (); -} - -ACE_SEH_EXCEPT_HANDLER -ACE_Log_Msg::seh_except_handler (ACE_SEH_EXCEPT_HANDLER n) -{ - return ACE_OS_Object_Manager::seh_except_handler (n); -} -#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS && ACE_LEGACY_MODE */ - -ACE_Log_Msg_Backend * -ACE_Log_Msg::msg_backend (ACE_Log_Msg_Backend *b) -{ - ACE_TRACE ("ACE_Log_Msg::msg_backend"); - ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, - *ACE_Log_Msg_Manager::get_lock (), 0)); - - ACE_Log_Msg_Backend *tmp = ACE_Log_Msg_Manager::custom_backend_; - ACE_Log_Msg_Manager::custom_backend_ = b; - return tmp; -} - -ACE_Log_Msg_Backend * -ACE_Log_Msg::msg_backend (void) -{ - ACE_TRACE ("ACE_Log_Msg::msg_backend"); - ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, - *ACE_Log_Msg_Manager::get_lock (), 0)); - - return ACE_Log_Msg_Manager::custom_backend_; -} - -void -ACE_Log_Msg::msg_ostream (ACE_OSTREAM_TYPE *m, bool delete_ostream) -{ - if (this->ostream_ == m) - return; - - if (this->delete_ostream_) - { -#if defined (ACE_LACKS_IOSTREAM_TOTALLY) - ACE_OS::fclose (this->ostream_); -#else - delete this->ostream_; -#endif - } - - this->delete_ostream_ = delete_ostream; - this->ostream_ = m; -} - -void -ACE_Log_Msg::local_host (const ACE_TCHAR *s) -{ - if (s) - { - ACE_OS::free ((void *) ACE_Log_Msg::local_host_); - { - ACE_NO_HEAP_CHECK; - - ACE_ALLOCATOR (ACE_Log_Msg::local_host_, ACE_OS::strdup (s)); - } - } -} - -int -ACE_Log_Msg::log_priority_enabled (ACE_Log_Priority log_priority, - const char *, - ...) -{ - return this->log_priority_enabled (log_priority); -} - -#if defined (ACE_USES_WCHAR) -int -ACE_Log_Msg::log_priority_enabled (ACE_Log_Priority log_priority, - const wchar_t *, - ...) -{ - return this->log_priority_enabled (log_priority); -} -#endif /* ACE_USES_WCHAR */ - -// **************************************************************** - -void -ACE_Log_Msg::init_hook (ACE_OS_Log_Msg_Attributes &attributes -# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) - , ACE_SEH_EXCEPT_HANDLER selector - , ACE_SEH_EXCEPT_HANDLER handler -# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ - ) -{ -# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) - attributes.seh_except_selector_ = selector; - attributes.seh_except_handler_ = handler; -# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ - if (ACE_Log_Msg::exists ()) - { - ACE_Log_Msg *inherit_log = ACE_LOG_MSG; - attributes.ostream_ = inherit_log->msg_ostream (); - attributes.priority_mask_ = inherit_log->priority_mask (); - attributes.tracing_enabled_ = inherit_log->tracing_enabled (); - attributes.restart_ = inherit_log->restart (); - attributes.trace_depth_ = inherit_log->trace_depth (); - } -} - -void -ACE_Log_Msg::inherit_hook (ACE_OS_Thread_Descriptor *thr_desc, - ACE_OS_Log_Msg_Attributes &attributes) -{ -#if !defined (ACE_THREADS_DONT_INHERIT_LOG_MSG) && \ - !defined (ACE_HAS_MINIMAL_ACE_OS) - // Inherit the logging features if the parent thread has an - // . Note that all of the following operations occur - // within thread-specific storage. - ACE_Log_Msg *new_log = ACE_LOG_MSG; - - // Note that we do not inherit the callback because this might have - // been allocated off of the stack of the original thread, in which - // case all hell would break loose... - - if (attributes.ostream_) - { - new_log->msg_ostream (attributes.ostream_); - new_log->priority_mask (attributes.priority_mask_); - - if (attributes.tracing_enabled_) - new_log->start_tracing (); - - new_log->restart (attributes.restart_); - new_log->trace_depth (attributes.trace_depth_); - } - - // @@ Now the TSS Log_Msg has been created, cache my thread - // descriptor in. - - if (thr_desc != 0) - // This downcast is safe. We do it to avoid having to #include - // ace/Thread_Manager.h. - new_log->thr_desc (static_cast (thr_desc)); - // Block the thread from proceeding until - // thread manager has thread descriptor ready. -#endif /* ! ACE_THREADS_DONT_INHERIT_LOG_MSG && ! ACE_HAS_MINIMAL_ACE_OS */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Log_Msg.h b/ACE/ace/Log_Msg.h deleted file mode 100644 index 6084902bf30..00000000000 --- a/ACE/ace/Log_Msg.h +++ /dev/null @@ -1,746 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Log_Msg.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_LOG_MSG_H -#define ACE_LOG_MSG_H -#include /**/ "ace/pre.h" - -// This stuff must come first to avoid problems with circular -// headers... -// ... but ACE_NDEBUG and ACE_NLOGGING can come from the config.h file, so -// pull that one early. -#include /**/ "ace/config-all.h" -#include /**/ "ace/ACE_export.h" -#include "ace/Global_Macros.h" -#include "ace/Default_Constants.h" -#include "ace/Log_Priority.h" -#include "ace/os_include/os_limits.h" - -// The ACE_ASSERT macro used to be defined here, include ace/Assert.h -// for backwards compatibility. -#include "ace/Assert.h" - -#if defined (ACE_NLOGGING) -#define ACE_HEX_DUMP(X) do {} while (0) -#define ACE_RETURN(Y) do { return (Y); } while (0) -#define ACE_ERROR_RETURN(X, Y) return (Y) -#define ACE_ERROR_BREAK(X) { break; } -#define ACE_ERROR(X) do {} while (0) -#define ACE_DEBUG(X) do {} while (0) -#define ACE_ERROR_INIT(VALUE, FLAGS) -#else -#if !defined (ACE_HEX_DUMP) -#define ACE_HEX_DUMP(X) \ - do { \ - int __ace_error = ACE_Log_Msg::last_error_adapter (); \ - ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ - ace___->conditional_set (__FILE__, __LINE__, 0, __ace_error); \ - ace___->log_hexdump X; \ - } while (0) -#endif -#if !defined (ACE_RETURN) -#define ACE_RETURN(Y) \ - do { \ - int __ace_error = ACE_Log_Msg::last_error_adapter (); \ - ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ - ace___->set (__FILE__, __LINE__, Y, __ace_error, ace___->restart (), \ - ace___->msg_ostream (), ace___->msg_callback ()); \ - return Y; \ - } while (0) -#endif -#if !defined (ACE_ERROR_RETURN) -#define ACE_ERROR_RETURN(X, Y) \ - do { \ - int __ace_error = ACE_Log_Msg::last_error_adapter (); \ - ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ - ace___->conditional_set (__FILE__, __LINE__, Y, __ace_error); \ - ace___->log X; \ - return Y; \ - } while (0) -#endif -#if !defined (ACE_ERROR) -#define ACE_ERROR(X) \ - do { \ - int __ace_error = ACE_Log_Msg::last_error_adapter (); \ - ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ - ace___->conditional_set (__FILE__, __LINE__, -1, __ace_error); \ - ace___->log X; \ - } while (0) -#endif -#if !defined (ACE_DEBUG) -#define ACE_DEBUG(X) \ - do { \ - int __ace_error = ACE_Log_Msg::last_error_adapter (); \ - ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ - ace___->conditional_set (__FILE__, __LINE__, 0, __ace_error); \ - ace___->log X; \ - } while (0) -#endif -#if !defined (ACE_ERROR_INIT) -#define ACE_ERROR_INIT(VALUE, FLAGS) \ - do { \ - ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ - ace___->set_flags (FLAGS); ace___->op_status (VALUE); \ - } while (0) -#endif -#if !defined (ACE_ERROR_BREAK) -#define ACE_ERROR_BREAK(X) { ACE_ERROR (X); break; } -#endif -#endif /* ACE_NLOGGING */ - -#include "ace/OS_Log_Msg_Attributes.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -// These workarounds are necessary for nasty libraries or platforms -// that #define STDERR or THREAD (e.g. LynxOS). We simply #undef -// these macros as there is no way to save the macro definition using -// the pre-processor. See Bugzilla Bug #299 for more info. - -#if defined (STDERR) -# undef STDERR -#endif /* STDERR */ - -#if defined (THREAD) -# undef THREAD -#endif /* THREAD */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -class ACE_Log_Msg_Callback; -class ACE_Log_Msg_Backend; - -// **************************************************************** - -#define ACE_LOG_MSG ACE_Log_Msg::instance () - -// Forward declaration -class ACE_Thread_Descriptor; -class ACE_Log_Record; - -/** - * @class ACE_Log_Msg - * - * @brief Provides a variable length argument message logging - * abstraction. - * - * This class is very flexible since it allows formatted error - * messages to be printed in a thread-safe manner to various - * locations, such as stderr, cerr, a distributed logger, etc. The - * current message is also kept in a thread-specific storage location - * (threads spawned using ACE_Thread_Manager automatically get an - * ACE_Log_Msg object that inherits the spawning thread's settings), - * which can be used to communicate errors between framework methods - * and callers. A message is logged by the log() method, only if the - * message priority is currently enabled. Moreover, only the current - * log message is stored here -- it will be overwritten by the - * subsequent call to log(). - * - * The ACE_Log_Msg class uses two priority masks to control its - * logging behavior. The @c priority_mask_ object attribute is - * thread- specific and specifies the priority levels logged by the - * thread. The @c process_priority_mask_ class attribute is not - * thread-specific and specifies the priority levels that will be - * logged by all threads in the process. By default, all levels are - * disabled for @c priority_mask_ and all levels are enabled for @c - * process_priority_mask_ (i.e. the process-wide mask controls the - * settings, and each instance can expand on it if desired). Both - * priority masks can be modified using the priority_mask() method of - * this class. - */ -class ACE_Export ACE_Log_Msg -{ -public: - // Logger Flags. - enum - { - /// Write messages to stderr. - STDERR = 1, - /// Write messages to the local client logger deamon. - LOGGER = 2, - /// Write messages to the ostream * stored in thread-specific - /// storage. - OSTREAM = 4, - /// Write messages to the callback object. - MSG_CALLBACK = 8, - /// Display messages in a verbose manner. - VERBOSE = 16, - /// Display messages in a less verbose manner (i.e., only print - /// information that can change between calls). - VERBOSE_LITE = 32, - /// Do not print messages at all (just leave in thread-specific - /// storage for later inspection). - SILENT = 64, - /// Write messages to the system's event log. - SYSLOG = 128, - /// Write messages to the user provided backend - CUSTOM = 256 - }; - - // = Initialization and termination routines. - - /// Returns a pointer to the Singleton. - static ACE_Log_Msg *instance (void); - - /// Returns last error. - static int last_error_adapter (void); - - /// Returns non-null if an ACE_Log_Msg exists for the calling thread. - static int exists (void); - - /// Returns the current program name used for logging. - static const ACE_TCHAR * program_name (void); - - /// Clears the flag from the default priority mask used to - /// initialize ACE_Log_Msg instances. - static void disable_debug_messages (ACE_Log_Priority priority = LM_DEBUG); - - /// Sets the flag in the default priority mask used to initialize - /// ACE_Log_Msg instances. - static void enable_debug_messages (ACE_Log_Priority priority = LM_DEBUG); - - /// Initialize logger. - ACE_Log_Msg (void); - - /// cleanup logger. - ~ACE_Log_Msg (void); - - /// Initialize the ACE logging facility. - /** - * Initialize the ACE logging facility. Supplies the program name - * that is available to each logging message call. Default arguments - * set up logging to STDERR only. - * - * @param prog_name The name of the calling program. - * @param options_flags A bitwise-or of options flags used to set the - * initial behavior and logging sink(s). (see the - * enum above for the valid values). - * @param logger_key The name of ACE_FIFO rendezvous point where the - * local client logger daemon is listening for logging - * messages if the LOGGER bit is set in the @a flags - * argument. If the SYSLOG bit is set in @a flags, - * @a logger_key is the source/program name specified - * in the syslog facility (UNIX/Linux) or the Windows - * event log (Windows). In the SYSLOG case, if - * @a logger_key is 0, @a prog_name is used. - */ - int open (const ACE_TCHAR *prog_name, - u_long options_flags = ACE_Log_Msg::STDERR, - const ACE_TCHAR *logger_key = 0); - - // = Set/get the options flags. - - /** - * Enable the bits in the logger's options flags. - */ - void set_flags (u_long f); - - /** - * Disable the bits in the logger's options flags. - */ - void clr_flags (u_long f); - - /** - * Return the bits in the logger's options flags. - */ - u_long flags (void); - - /** @name Allow apps to acquire and release internal synchronization - * lock - * - * This lock is used internally by the ACE_Log_Msg - * implementation. By exporting the lock, applications can hold the - * lock atomically over a number of calls to ACE_Log_Msg. - */ - //@{ - - /// Acquire the internal lock. - int acquire (void); - - /// Release the internal lock. - int release (void); - //@} - - /// Call after doing a @c fork() to resynchronize the process id and - /// @c program_name_ variables. - void sync (const ACE_TCHAR *program_name); - - // = Set/get methods. Note that these are non-static and thus will - // be thread-specific. - - /// Set the result of the operation status (by convention, -1 means - /// error). - void op_status (int status); - - /// Get the result of the operation status (by convention, -1 means - /// error). - int op_status (void) const; - - /// Set the value of the errnum (by convention this corresponds to - /// errno). - void errnum (int); - - /// Get the value of the errnum (by convention this corresponds to - /// errno). - int errnum (void) const; - - /// Set the line number where an error occurred. - void linenum (int); - - /// Get the line number where an error occurred. - int linenum (void) const; - - /// Set the file name where an error occurred. - void file (const char *); - - /// Get the file name where an error occurred. - const char *file (void); - - /// Set the message that describes what type of error occurred. - void msg (const ACE_TCHAR *); - - /// Get the message that describes what type of error occurred. - const ACE_TCHAR *msg (void); - - /// Set the field that indicates whether interrupted calls should be - /// restarted. - void restart (int); - - /// Get the field that indicates whether interrupted calls should be - /// restarted. - int restart (void) const; - - // = Notice that the following two function is equivalent to - // "void msg_ostream (HANDLE)" and "HANDLE msg_ostream (void)" - // on Windows CE. There is no support on CE. - - /// Update the ostream without overwriting the delete_ostream_ flag. - void msg_ostream (ACE_OSTREAM_TYPE *); - - /** - * delete_stream == true, forces Log_Msg.h to delete the stream in - * its own ~dtor (assumes control of the stream) - * use only with proper ostream (eg: fstream), not (cout, cerr) - */ - void msg_ostream (ACE_OSTREAM_TYPE *, bool delete_ostream); - - /// Get the ostream that is used to print error messages. - ACE_OSTREAM_TYPE *msg_ostream (void) const; - - /** - * Set a new callback object and return the existing callback to - * allow "chaining". Note that ACE_Log_Msg_Callback objects are not - * inherited when spawning a new thread, so you'll need to reset - * them in each thread. - */ - ACE_Log_Msg_Callback *msg_callback (ACE_Log_Msg_Callback *c); - ACE_Log_Msg_Callback *msg_callback (void) const; - - /** - * Set a new backend object and return the existing backend to - * allow "chaining". Note that as opposed to ACE_Log_Msg_Callback, - * ACE_Log_Msg_Backend is a per-process entity. - * - * @note Be aware that because of the current architecture there is - * no guarantee that open (), reset () and close () will be called - * on a backend object. - * - */ - static ACE_Log_Msg_Backend *msg_backend (ACE_Log_Msg_Backend *b); - static ACE_Log_Msg_Backend *msg_backend (void); - - /// Nesting depth increment. - int inc (void); - - /// Nesting depth decrement. - int dec (void); - - /// Get trace depth. - int trace_depth (void) const; - - /// Set trace depth. - void trace_depth (int); - - /// Set trace active status. - bool trace_active (void) const; - - /// Get trace active status. - void trace_active (bool value); - - /// Get the TSS thread descriptor. - ACE_Thread_Descriptor *thr_desc (void) const; - - /** - * Set the TSS thread descriptor. This method will call - * td->acquire_release to block execution until this call - * return. - */ - void thr_desc (ACE_Thread_Descriptor *td); - -#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) && defined(ACE_LEGACY_MODE) - // These functions are disabled without ACE_LEGACY_MODE - // because the *semantics* have changed (the objects are no longer - // TSS). - /// Get TSS exception action. - /// @note The action is no longer TSS, they are global! - ACE_SEH_EXCEPT_HANDLER seh_except_selector (void); - - /// Set TSS exception action. - /// @note The action is no longer TSS, they are global! - ACE_SEH_EXCEPT_HANDLER seh_except_selector (ACE_SEH_EXCEPT_HANDLER); - - /// Get TSS exception handler. - /// @note The handler is no longer TSS, they are global! - ACE_SEH_EXCEPT_HANDLER seh_except_handler (void); - - /// Set TSS exception handler. - /// @note The handler is no longer TSS, they are global! - ACE_SEH_EXCEPT_HANDLER seh_except_handler (ACE_SEH_EXCEPT_HANDLER); -#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS && ACE_LEGACY_MODE */ - - /// Stop tracing status on a per-thread basis... - void stop_tracing (void); - - /// Start tracing status on a per-thread basis... - void start_tracing (void); - - /// Query tracing status on a per-thread basis... - bool tracing_enabled (void) const; - - typedef enum - { - PROCESS = 0, - THREAD = 1 - } MASK_TYPE; - - // = Get/set the priority mask. - /// Get the current ACE_Log_Priority mask. - u_long priority_mask (MASK_TYPE = THREAD); - - /// Set the ACE_Log_Priority mask, returns original mask. - u_long priority_mask (u_long, MASK_TYPE = THREAD); - - /// Return true if the requested priority is enabled. - int log_priority_enabled (ACE_Log_Priority log_priority); - - /// Return true if the requested priority is enabled. - int log_priority_enabled (ACE_Log_Priority log_priority, - const char *, - ...); - -#if defined (ACE_USES_WCHAR) - // We are not using ACE_TCHAR for this since ACE_HEX_DUMP - // doesn't take in a ACE_TCHAR. log_hexdump takes in a char - // string, so this must be able to take in a char string even - // when using ACE_USES_WCHAR. - /// Return true if the requested priority is enabled. - int log_priority_enabled (ACE_Log_Priority log_priority, - const wchar_t *, - ...); -#endif /* ACE_USES_WCHAR */ - - /// Optimize reading of the pid (avoids a system call if the value is - /// cached...). - pid_t getpid (void) const; - - /// Get the name of the local host. - const ACE_TCHAR *local_host (void) const; - - /// Set the name of the local host. - void local_host (const ACE_TCHAR *); - - /** - * Set the line number, file name, operational status, error number, - * restart flag, ostream, and the callback object. This combines - * all the other set methods into a single method. - */ - void set (const char *file, - int line, - int op_status = -1, - int errnum = 0, - int restart = 1, - ACE_OSTREAM_TYPE *os = 0, - ACE_Log_Msg_Callback *c = 0); - - /// These values are only actually set if the requested priority is - /// enabled. - void conditional_set (const char *file, - int line, - int op_status, - int errnum); - - /** - * Format a message to the thread-safe ACE logging mechanism. Valid - * options (prefixed by '%', as in printf format strings) include: - * - 'A': print an ACE_timer_t value (which could be either double - * or ACE_UINT32.) - * - 'a': abort the program at this point abruptly. - * - 'b': print a ssize_t value - * - 'B': print a size_t value - * - 'c': print a character - * - 'C': print a character string - * - 'i', 'd': print a decimal number - * - 'I': indent according to nesting depth (obtained from - * ACE_Trace::get_nesting_indent()). - * - 'e', 'E', 'f', 'F', 'g', 'G': print a double - * - 'l': print line number where an error occurred. - * - 'M': print the name of the priority of the message. - * - 'm': return the message corresponding to errno value, e.g., as - * done by strerror() - * - 'N': print file name where the error occurred. - * - 'n': print the name of the program (or "" if not set) - * - 'o': print as an octal number - * - 'P': print out the current process id - * - 'p': print out the appropriate errno message from sys_errlist, - * e.g., as done by perror() - * - 'Q': print out the uint64 number - * - 'q': print out the int64 number - * - '@': print a void* pointer (in hexadecimal) - * - 'r': call the function pointed to by the corresponding argument - * - 'R': print return status - * - 'S': print out the appropriate _sys_siglist entry corresponding - * to var-argument. - * - 's': print out a character string - * - 'T': print timestamp in hour:minute:sec:usec format. - * - 'D': print timestamp as Weekday Month day year hour:minute:sec.usec - * - 't': print thread id (1 if single-threaded) - * - 'u': print as unsigned int - * - 'w': prints a wide character - * - 'W': print a wide character string - * - 'x': print as a hex number - * - 'X': print as a hex number - * - 'z': print an ACE_OS::WChar character - * - 'Z': print an ACE_OS::WChar character string - * - ':': print a time_t value as an integral number - * - '%': print out a single percent sign, '%' - */ - ssize_t log (ACE_Log_Priority priority, const ACE_TCHAR *format, ...); - -#if defined (ACE_HAS_WCHAR) - ssize_t log (ACE_Log_Priority priority, const ACE_ANTI_TCHAR *format, ...); -#endif /* ACE_HAS_WCHAR */ - - /** - * An alternative logging mechanism that makes it possible to - * integrate variable argument lists from other logging mechanisms - * into the ACE mechanism. - */ - ssize_t log (const ACE_TCHAR *format, - ACE_Log_Priority priority, - va_list argp); - - /// Log a custom built log record to the currently enabled logging - /// sinks. - ssize_t log (ACE_Log_Record &log_record, - int suppress_stderr = 0); - - /** - * Method to log hex dump. This is useful for debugging. Calls - * log() to do the actual print, but formats first to make the chars - * printable. - */ - int log_hexdump (ACE_Log_Priority log_priority, - const char *buffer, - size_t size, - const ACE_TCHAR *text = 0); - - static void init_hook (ACE_OS_Log_Msg_Attributes &attributes -# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) - , ACE_SEH_EXCEPT_HANDLER selector = 0 - , ACE_SEH_EXCEPT_HANDLER handler = 0 -# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ - /** - * Init hook, create a Log_Msg_Attribute object, initialize its - * attributes from the TSS Log_Msg and save the object in the - * @a attributes argument - */ - ); - - /** - * Inherit hook, the @a attributes field is a ACE_OS_Log_Msg_Attributes - * object, invoke the inherit_log_msg() method on it, then destroy - * it and set the @a attribute argument to 0. - */ - static void inherit_hook (ACE_OS_Thread_Descriptor *thr_desc, - ACE_OS_Log_Msg_Attributes &attributes); - - /// Dump the state of an object. - void dump (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - /// Status of operation (-1 means failure, >= 0 means success). - int status_; - - /// Type of error that occurred (see ). - int errnum_; - - /// Line number where the error occurred. - int linenum_; - - /// File where the error occurred. - char file_[MAXPATHLEN + 1]; - - /// The log message, which resides in thread-specific storage. Note - /// that only the current log message is stored here -- it will be - /// overwritten by the subsequent call to log(). - ACE_TCHAR* msg_; // Add one for NUL-terminator. - - /// Indicates whether we should restart system calls that are - /// interrupted. - int restart_; - - /// The ostream where logging messages can be written. - ACE_OSTREAM_TYPE *ostream_; - - /// The callback object. - ACE_Log_Msg_Callback *msg_callback_; - - /// Depth of the nesting for printing traces. - int trace_depth_; - - /// Are we already within an ACE_Trace constructor call? - bool trace_active_; - - /// Are we allowing tracing in this thread? - bool tracing_enabled_; - - /// Are we deleting this ostream? - bool delete_ostream_; - - /** - * If we're running in the context of an ACE_Thread_Manager this - * will point to the thread descriptor adapter which holds the - * thread descriptor of the thread. This can be used to repidly - * access all thread data kept in ACE_Thread_Descriptor. - */ - ACE_Thread_Descriptor *thr_desc_; - - /** - * Keeps track of all the per-thread ACE_Log_Priority values that - * are currently enabled. Default is for all logging priorities to - * be disabled. - */ - u_long priority_mask_; - - /// Always timestamp? - int timestamp_; - - // = The following fields are *not* kept in thread-specific storage. - - // We only want one instance for the entire process! - - /** - * Keeps track of all the per-process ACE_Log_Priority values that - * are currently enabled. Default is for all logging priorities to - * be enabled. - */ - static u_long process_priority_mask_; - - /// Records the program name. - static const ACE_TCHAR *program_name_; - - /// Name of the local host (used when printing messages). - static const ACE_TCHAR *local_host_; - - /// Process id of the current process. - static pid_t pid_; - - /// Options flags used to hold the logger flag options, e.g., - /// STDERR, LOGGER, OSTREAM, MSG_CALLBACK, etc. - static u_long flags_; - - /// Offset of msg_[]. - static ptrdiff_t msg_off_; - - /** - * Number of existing ACE_Log_Msg instances; when 0, delete program/host - * names - */ - static int instance_count_; - - /** - * Priority mask to use for each new instance - */ - static u_long default_priority_mask_; - - /// Anonymous struct since there will only be one instance. This - /// struct keeps information stored away in case we actually end up - /// calling log() if the log priority is correct. - struct - { - bool is_set_; - const char *file_; - int line_; - int op_status_; - int errnum_; - } conditional_values_; - -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) - static int key_created_; -#endif /* ACE_MT_SAFE */ - - /// For cleanup, at program termination. - static void close (void); - - /// Decouple the OS layer from the ACE_Log_Msg layer. - static void sync_hook (const ACE_TCHAR *prg_name); - - /// Return the TSS singleton thread descriptor - static ACE_OS_Thread_Descriptor *thr_desc_hook (void); - - //friend void ACE_OS::cleanup_tss (const u_int); - - // = Disallow these operations. - ACE_Log_Msg &operator= (const ACE_Log_Msg &); - ACE_Log_Msg (const ACE_Log_Msg &); -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) -# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \ - defined (ACE_HAS_TSS_EMULATION) -/* static */ -# if defined (ACE_HAS_THR_C_DEST) -# define LOCAL_EXTERN_PREFIX extern "C" -# else -# define LOCAL_EXTERN_PREFIX -# endif /* ACE_HAS_THR_C_DEST */ - -#if (defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1) -# define ACE_TSS_CLEANUP_NAME ACE_PREPROC_CONCATENATE(ACE_,ACE_PREPROC_CONCATENATE(ACE_VERSIONED_NAMESPACE_NAME, _TSS_cleanup)) -#else -# define ACE_TSS_CLEANUP_NAME ACE_TSS_cleanup -#endif /* ACE_HAS_VERSIONED_NAMESPACE == 1 */ - - -LOCAL_EXTERN_PREFIX -void -ACE_TSS_CLEANUP_NAME (void *ptr); -# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */ -#endif /* ACE_MT_SAFE */ - -#if defined(ACE_LEGACY_MODE) -#include "ace/Log_Msg_Callback.h" -#endif /* ACE_LEGACY_MODE */ - -#if defined (__ACE_INLINE__) -#include "ace/Log_Msg.inl" -#endif /* __ACE_INLINE__ */ - -#include /**/ "ace/post.h" -#endif /* ACE_LOG_MSG_H */ diff --git a/ACE/ace/Log_Msg.inl b/ACE/ace/Log_Msg.inl deleted file mode 100644 index 677a6856d8f..00000000000 --- a/ACE/ace/Log_Msg.inl +++ /dev/null @@ -1,235 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_unistd.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE -u_long -ACE_Log_Msg::priority_mask (MASK_TYPE mask_type) -{ - return mask_type == THREAD - ? this->priority_mask_ - : ACE_Log_Msg::process_priority_mask_; -} - -ACE_INLINE -int -ACE_Log_Msg::log_priority_enabled (ACE_Log_Priority log_priority) -{ - return ACE_BIT_ENABLED (this->priority_mask_ | - ACE_Log_Msg::process_priority_mask_, - log_priority); -} - -ACE_INLINE -void -ACE_Log_Msg::op_status (int status) -{ - this->status_ = status; -} - -ACE_INLINE -int -ACE_Log_Msg::op_status (void) const -{ - return this->status_; -} - -ACE_INLINE -void -ACE_Log_Msg::restart (int r) -{ - this->restart_ = r; -} - -ACE_INLINE -int -ACE_Log_Msg::restart (void) const -{ - return this->restart_; -} - -ACE_INLINE -int -ACE_Log_Msg::errnum (void) const -{ - return this->errnum_; -} - -ACE_INLINE -void -ACE_Log_Msg::errnum (int e) -{ - this->errnum_ = e; -} - -ACE_INLINE -int -ACE_Log_Msg::linenum (void) const -{ - return this->linenum_; -} - -ACE_INLINE -void -ACE_Log_Msg::linenum (int l) -{ - this->linenum_ = l; -} - -ACE_INLINE -int -ACE_Log_Msg::inc (void) -{ - return this->trace_depth_++; -} - -ACE_INLINE -int -ACE_Log_Msg::dec (void) -{ - return this->trace_depth_ == 0 ? 0 : --this->trace_depth_; -} - -ACE_INLINE -int -ACE_Log_Msg::trace_depth (void) const -{ - return this->trace_depth_; -} - -ACE_INLINE -void -ACE_Log_Msg::trace_depth (int depth) -{ - this->trace_depth_ = depth; -} - -ACE_INLINE -bool -ACE_Log_Msg::trace_active (void) const -{ - return this->trace_active_; -} - -ACE_INLINE -void -ACE_Log_Msg::trace_active (bool value) -{ - this->trace_active_ = value; -} - -ACE_INLINE -ACE_Thread_Descriptor * -ACE_Log_Msg::thr_desc (void) const -{ - return this->thr_desc_; -} - -/// Enable the tracing facility on a per-thread basis. -ACE_INLINE -void -ACE_Log_Msg::start_tracing (void) -{ - this->tracing_enabled_ = true; -} - -/// Disable the tracing facility on a per-thread basis. -ACE_INLINE -void -ACE_Log_Msg::stop_tracing (void) -{ - this->tracing_enabled_ = false; -} - -ACE_INLINE -bool -ACE_Log_Msg::tracing_enabled (void) const -{ - return this->tracing_enabled_; -} - -ACE_INLINE -const char * -ACE_Log_Msg::file (void) -{ - return this->file_; -} - -ACE_INLINE -void -ACE_Log_Msg::file (const char *s) -{ - ACE_OS::strsncpy (this->file_, s, sizeof this->file_); -} - -ACE_INLINE -const ACE_TCHAR * -ACE_Log_Msg::msg (void) -{ - return this->msg_ + ACE_Log_Msg::msg_off_; -} - -ACE_INLINE -void -ACE_Log_Msg::msg (const ACE_TCHAR *m) -{ - ACE_OS::strsncpy (this->msg_, m, - ((ACE_MAXLOGMSGLEN+1) / sizeof (ACE_TCHAR))); -} - -ACE_INLINE -ACE_Log_Msg_Callback * -ACE_Log_Msg::msg_callback (void) const -{ - return this->msg_callback_; -} - -ACE_INLINE -ACE_Log_Msg_Callback * -ACE_Log_Msg::msg_callback (ACE_Log_Msg_Callback *c) -{ - ACE_Log_Msg_Callback *old = this->msg_callback_; - this->msg_callback_ = c; - return old; -} - -ACE_INLINE -ACE_OSTREAM_TYPE * -ACE_Log_Msg::msg_ostream (void) const -{ - return this->ostream_; -} - -ACE_INLINE -void -ACE_Log_Msg::msg_ostream (ACE_OSTREAM_TYPE *m) -{ - this->ostream_ = m; -} - -ACE_INLINE -const ACE_TCHAR * -ACE_Log_Msg::local_host (void) const -{ - return ACE_Log_Msg::local_host_; -} - -ACE_INLINE -pid_t -ACE_Log_Msg::getpid (void) const -{ - if (ACE_Log_Msg::pid_ == -2) - ACE_Log_Msg::pid_ = ACE_OS::getpid (); - - return ACE_Log_Msg::pid_; -} - - - -ACE_END_VERSIONED_NAMESPACE_DECL - diff --git a/ACE/ace/Log_Msg_Backend.cpp b/ACE/ace/Log_Msg_Backend.cpp deleted file mode 100644 index de9b9c22b7b..00000000000 --- a/ACE/ace/Log_Msg_Backend.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// $Id$ - -#include "ace/Log_Msg_Backend.h" - -ACE_RCSID(ace, Log_Msg_Backend, "$Id$") - - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_Log_Msg_Backend::~ACE_Log_Msg_Backend (void) -{ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Log_Msg_Backend.h b/ACE/ace/Log_Msg_Backend.h deleted file mode 100644 index b98465987db..00000000000 --- a/ACE/ace/Log_Msg_Backend.h +++ /dev/null @@ -1,88 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Log_Msg_Backend.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - - -#ifndef ACE_LOG_MSG_BACKEND_H -#define ACE_LOG_MSG_BACKEND_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/os_include/sys/os_types.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -class ACE_Log_Record; - -/** - * @class ACE_Log_Msg_Backend - * - * @brief Defines the interface for ACE_Log_Msg back end processing. - * - * The ACE_Log_Msg class uses ACE_Log_Msg_Backend as the target interface - * for back end log record procesing. In addition to the classes ACE - * derives from this (ACE_Log_Msg_NT_Event_Log, ACE_Log_Msg_UNIX_Syslog, and - * ACE_Log_Msg_IPC) users can derive classes from ACE_Log_Msg_Backend for - * use as a custom logger back end. - */ -class ACE_Export ACE_Log_Msg_Backend -{ -public: - /// No-op virtual destructor. - virtual ~ACE_Log_Msg_Backend (void); - - /** - * Open the back end object. Perform any actions needed to prepare - * the object for later logging operations. - * - * @param logger_key The character string passed to ACE_Log_Msg::open(). - * If the @c LOGGER logging destination is not being - * used, any string can be passed through to the back end. - * - * @retval 0 for success. - * @retval -1 for failure. - */ - virtual int open (const ACE_TCHAR *logger_key) = 0; - - /** - * Reset the backend. If ACE_Log_Msg is reopened during execution, this - * hook will be called. This method should perform any needed cleanup - * activity (similar to close()) because this object won't be reopened - * if the new open call does not specify use of this back end being reset. - * - * @retval Currently ignored, but to be safe, return 0 for success; - * -1 for failure. - */ - virtual int reset (void) = 0; - - /// Close the backend completely. - virtual int close (void) = 0; - - /** - * Process a log record. - * - * @param log_record The ACE_Log_Record to process. - * - * @retval -1 for failure; else it is customarily the number of bytes - * processed, but can also be 0 to signify success. - */ - virtual ssize_t log (ACE_Log_Record &log_record) = 0; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#include /**/ "ace/post.h" -#endif /* ACE_LOG_MSG_BACKEND_H */ diff --git a/ACE/ace/Log_Msg_Callback.cpp b/ACE/ace/Log_Msg_Callback.cpp deleted file mode 100644 index 2fcf5206dd1..00000000000 --- a/ACE/ace/Log_Msg_Callback.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// $Id$ - -#include "ace/Log_Msg_Callback.h" - -ACE_RCSID(ace, Log_Msg_Callback, "$Id$") - - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_Log_Msg_Callback::~ACE_Log_Msg_Callback (void) -{ -} -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Log_Msg_Callback.h b/ACE/ace/Log_Msg_Callback.h deleted file mode 100644 index ecd8641dbb3..00000000000 --- a/ACE/ace/Log_Msg_Callback.h +++ /dev/null @@ -1,69 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Log_Msg_Callback.h - * - * $Id$ - * - * @author Douglas C. Schmidt - */ -//============================================================================= - -#ifndef ACE_LOG_MSG_CALLBACK_H -#define ACE_LOG_MSG_CALLBACK_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/ACE_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -class ACE_Log_Record; - -/** - * @class ACE_Log_Msg_Callback - * - * @brief An interface class used to get logging callbacks. - * - * Users who are interested in getting the logging messages - * directly, can subclass this interface and override the log() - * method. They must then register their subclass with the - * Log_Msg class and make sure that they turn on the - * ACE_Log_Msg::MSG_CALLBACK flag. - * - * Your routine is called with an instance of - * ACE_Log_Record. From this class, you can get the log - * message, the verbose log message, message type, message - * priority, and so on. - * - * Remember that there is one Log_Msg object per thread. - * Therefore, you may need to register your callback object with - * many ACE_Log_Msg objects (and have the correct - * synchronization in the method) or have a separate - * callback object per Log_Msg object. Moreover, - * are not inherited when a new thread - * is spawned because it might have been allocated off of the - * stack of the original thread, in which case all hell would - * break loose... Therefore, you'll need to reset these in each - * new thread. - */ -class ACE_Export ACE_Log_Msg_Callback -{ -public: - /// No-op virtual destructor. - virtual ~ACE_Log_Msg_Callback (void); - - /// Callback routine. This is called when we want to log a message. - /// Since this routine is pure virtual, it must be overwritten by the - /// subclass. - virtual void log (ACE_Log_Record &log_record) = 0; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#include /**/ "ace/post.h" -#endif /* ACE_LOG_MSG_CALLBACK_H */ diff --git a/ACE/ace/Log_Msg_IPC.cpp b/ACE/ace/Log_Msg_IPC.cpp deleted file mode 100644 index 82411a3cf92..00000000000 --- a/ACE/ace/Log_Msg_IPC.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// $Id$ - -#include "ace/Log_Msg_IPC.h" -#include "ace/Log_Record.h" -#include "ace/CDR_Stream.h" -#include "ace/Truncate.h" - -ACE_RCSID(ace, Log_Msg_IPC, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_Log_Msg_IPC::ACE_Log_Msg_IPC (void) -{ -} - -ACE_Log_Msg_IPC::~ACE_Log_Msg_IPC (void) -{ - (void) this->close (); -} - -int -ACE_Log_Msg_IPC::open (const ACE_TCHAR *logger_key) -{ - ACE_LOG_MSG_IPC_CONNECTOR con; - return con.connect (this->message_queue_, - ACE_LOG_MSG_IPC_ADDR (logger_key)); -} - -int -ACE_Log_Msg_IPC::reset (void) -{ - if (this->message_queue_.get_handle () != ACE_INVALID_HANDLE) - { - // If we don't do this, handles aren't reused on Win32 and the - // server eventually crashes! - return this->close (); - } - return 0; -} - -int -ACE_Log_Msg_IPC::close (void) -{ - return this->message_queue_.close (); -} - -ssize_t -ACE_Log_Msg_IPC::log (ACE_Log_Record &log_record) -{ - // Serialize the log record using a CDR stream, allocate enough - // space for the complete . - size_t const max_payload_size = - 4 // type - + 4 // pid - + 12 // timestamp - + 4 // process id - + 4 // data length -#if defined (ACE_USES_WCHAR) - + (log_record.msg_data_len () * ACE_OutputCDR::wchar_maxbytes()) // message -#else - + log_record.msg_data_len () // message -#endif - + ACE_CDR::MAX_ALIGNMENT; // padding; - - // Insert contents of into payload stream. - ACE_OutputCDR payload (max_payload_size); - payload << log_record; - - // Get the number of bytes used by the CDR stream. If it becomes desireable - // to support payloads more than 4GB, this field will need to be changed - // to a 64-bit value. - ACE_CDR::ULong length = - ACE_Utils::truncate_cast (payload.total_length ()); - - // Send a header so the receiver can determine the byte order and - // size of the incoming CDR stream. - ACE_OutputCDR header (ACE_CDR::MAX_ALIGNMENT + 8); - header << ACE_OutputCDR::from_boolean (ACE_CDR_BYTE_ORDER); - - // Store the size of the payload that follows - header << ACE_CDR::ULong (length); - - // Use an iovec to send both buffer and payload simultaneously. - iovec iov[2]; - iov[0].iov_base = header.begin ()->rd_ptr (); - iov[0].iov_len = 8; - iov[1].iov_base = payload.begin ()->rd_ptr (); - iov[1].iov_len = length; - -#if defined (ACE_HAS_STREAM_PIPES) - // Use the API if supported to ensure correct message - // queueing according to priority. - - ACE_Str_Buf header_msg (static_cast (header.begin ()->rd_ptr ()), - static_cast (8)); - - ACE_Str_Buf payload_msg (static_cast (payload.begin ()->rd_ptr ()), - static_cast (length)); - - return this->message_queue_.send (&header_msg, - &payload_msg, - static_cast (log_record.priority ()), - MSG_BAND); -#else - // We're running over sockets, so send header and payload - // efficiently using "gather-write". - return this->message_queue_.sendv_n (iov, 2); -#endif /* ACE_HAS_STREAM_PIPES */ -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Log_Msg_IPC.h b/ACE/ace/Log_Msg_IPC.h deleted file mode 100644 index 8b39b9ec551..00000000000 --- a/ACE/ace/Log_Msg_IPC.h +++ /dev/null @@ -1,79 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Log_Msg_IPC.h - * - * $Id$ - * - * @author Carlos O'Ryan - */ -//============================================================================= - -#ifndef ACE_LOG_MSG_LOGGER_H -#define ACE_LOG_MSG_LOGGER_H -#include /**/ "ace/pre.h" - -#include "ace/Log_Msg_Backend.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -// IPC conduit between sender and client daemon. This should be -// included in the ACE_Log_Msg class, but due to "order of include" -// problems it can't be... -#if defined (ACE_HAS_STREAM_PIPES) -# include "ace/SPIPE_Connector.h" -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -typedef ACE_SPIPE_Stream ACE_LOG_MSG_IPC_STREAM; -typedef ACE_SPIPE_Connector ACE_LOG_MSG_IPC_CONNECTOR; -typedef ACE_SPIPE_Addr ACE_LOG_MSG_IPC_ADDR; -ACE_END_VERSIONED_NAMESPACE_DECL -#else -# include "ace/SOCK_Connector.h" -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -typedef ACE_SOCK_Stream ACE_LOG_MSG_IPC_STREAM; -typedef ACE_SOCK_Connector ACE_LOG_MSG_IPC_CONNECTOR; -typedef ACE_INET_Addr ACE_LOG_MSG_IPC_ADDR; -ACE_END_VERSIONED_NAMESPACE_DECL -#endif /* ACE_HAS_STREAM_PIPES */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/// Defines the interfaces for ACE_Log_Msg backend. -/** - * Implement an ACE_Log_Msg_Backend that logs to a remote logging - * process. - */ -class ACE_Export ACE_Log_Msg_IPC : public ACE_Log_Msg_Backend -{ -public: - /// Constructor - ACE_Log_Msg_IPC (void); - - /// Destructor - virtual ~ACE_Log_Msg_IPC (void); - - /// Open a new connection - virtual int open (const ACE_TCHAR *logger_key); - - /** - * Reset the backend. When changing the logging destination the - * backend may need to properly disconnect from the remote logging - * daemon and reclaim some local resources. But we try to reduce - * the number of local allocations/deallocations. - */ - virtual int reset (void); - - virtual int close (void); - virtual ssize_t log (ACE_Log_Record &log_record); - -private: - ACE_LOG_MSG_IPC_STREAM message_queue_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#include /**/ "ace/post.h" -#endif /* ACE_LOG_MSG_H */ diff --git a/ACE/ace/Log_Msg_NT_Event_Log.cpp b/ACE/ace/Log_Msg_NT_Event_Log.cpp deleted file mode 100644 index e22170c01dc..00000000000 --- a/ACE/ace/Log_Msg_NT_Event_Log.cpp +++ /dev/null @@ -1,162 +0,0 @@ -// $Id$ - -#include "ace/config-all.h" - -#if defined (ACE_HAS_LOG_MSG_NT_EVENT_LOG) - -#include "ace/Log_Msg_NT_Event_Log.h" -#include "ace/Log_Msg.h" -#include "ace/Log_Record.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_string.h" - -ACE_RCSID(ace, Log_Msg_NT_Event_Log, "$Id$") - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_Log_Msg_NT_Event_Log::ACE_Log_Msg_NT_Event_Log (void) - : evlog_handle_(0) -{ -} - -ACE_Log_Msg_NT_Event_Log::~ACE_Log_Msg_NT_Event_Log (void) -{ - this->close (); -} - -int -ACE_Log_Msg_NT_Event_Log::open (const ACE_TCHAR *logger_key) -{ - // ACE's "resource module" contains the message resource required - // for event logging. - ACE_TCHAR msg_file [MAXPATHLEN]; - - if (!ACE_TEXT_GetModuleFileName (ACE_OS::get_win32_resource_module (), - msg_file, - MAXPATHLEN)) - return -1; - DWORD msg_file_length = - static_cast ((ACE_OS::strlen (msg_file) + 1) * sizeof (ACE_TCHAR)); - - // If a logger_key has been supplied then we use that as the event - // source name, otherwise we default to the program name. - const ACE_TCHAR *event_source_name = logger_key ? logger_key : ACE_Log_Msg::program_name (); - - // Information is stored in the registry at a location based on the - // program name. - ACE_TCHAR reg_key [MAXPATHLEN]; - ACE_OS::strcpy (reg_key, - ACE_TEXT ("SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\")); - size_t reg_key_length = ACE_OS::strlen(reg_key); - ACE_OS::strncat (reg_key, - event_source_name, - MAXPATHLEN - reg_key_length); - - // Add the event source to the registry. Note that if this fails it - // is not fatal. The application will still be able to write entries - // to the event log, they just won't be formatted correctly. - HKEY hkey; - ACE_TEXT_RegCreateKey (HKEY_LOCAL_MACHINE, - reg_key, - &hkey); - DWORD flags = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE; - ACE_TEXT_RegSetValueEx (hkey, - ACE_TEXT ("TypesSupported"), - 0, - REG_DWORD, - (LPBYTE) &flags, - sizeof (DWORD)); - ACE_TEXT_RegSetValueEx (hkey, - ACE_TEXT ("EventMessageFile"), - 0, - REG_SZ, - (LPBYTE) msg_file, - msg_file_length); - RegCloseKey (hkey); - - // Obtain a handle to the event source. - this->evlog_handle_ = ACE_TEXT_RegisterEventSource (0, - event_source_name); - return this->evlog_handle_ ? 0 : -1; -} - -int -ACE_Log_Msg_NT_Event_Log::reset (void) -{ - return this->close (); -} - -int -ACE_Log_Msg_NT_Event_Log::close (void) -{ - if (this->evlog_handle_ == 0 - || DeregisterEventSource (this->evlog_handle_)) - { - this->evlog_handle_ = 0; - return 0; - } - else - return -1; -} - -ssize_t -ACE_Log_Msg_NT_Event_Log::log (ACE_Log_Record &log_record) -{ - // Make a copy of the log text and replace any newlines with - // CR-LF. Newline characters on their own do not appear correctly in - // the event viewer. We allow for a doubling in the size of the msg - // data for the worst case of all newlines. - const ACE_TCHAR* src_msg_data = log_record.msg_data (); - ACE_TCHAR msg_data [ACE_Log_Record::MAXLOGMSGLEN * 2]; - - for (size_t i = 0, j = 0; - i < log_record.msg_data_len (); - ++i) - { - if (src_msg_data[i] == '\n') - { - msg_data[j++] = '\r'; - msg_data[j++] = '\n'; - } - else - msg_data[j++] = src_msg_data[i]; - } - - // Map the ACE log record type to an event log type. - WORD event_type; - switch (log_record.type ()) - { - case LM_STARTUP: - case LM_SHUTDOWN: - case LM_TRACE: - case LM_DEBUG: - case LM_INFO: - event_type = EVENTLOG_INFORMATION_TYPE; - break; - case LM_NOTICE: - case LM_WARNING: - event_type = EVENTLOG_WARNING_TYPE; - break; - case LM_ERROR: - case LM_CRITICAL: - case LM_ALERT: - case LM_EMERGENCY: - default: - event_type = EVENTLOG_ERROR_TYPE; - break; - } - - // Send the log message to the system event log. - const ACE_TCHAR* msgs [1]; - msgs[0] = msg_data; - - if (ACE_TEXT_ReportEvent (this->evlog_handle_, - event_type, 0, 0, 0, 1, 0, msgs, 0) == 0) - return -1; - else - return 0; -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_LOG_MSG_NT_EVENT_LOG */ diff --git a/ACE/ace/Log_Msg_NT_Event_Log.h b/ACE/ace/Log_Msg_NT_Event_Log.h deleted file mode 100644 index 4bca6adaa20..00000000000 --- a/ACE/ace/Log_Msg_NT_Event_Log.h +++ /dev/null @@ -1,72 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Log_Msg_NT_Event_Log.h - * - * $Id$ - * - * @author Christopher Kohlhoff - */ -//============================================================================= - -#ifndef ACE_LOG_MSG_NT_EVENT_LOG_H -#define ACE_LOG_MSG_NT_EVENT_LOG_H -#include /**/ "ace/pre.h" - -#include /**/ "ace/config-all.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined ACE_HAS_LOG_MSG_NT_EVENT_LOG - -#include "ace/Log_Msg_Backend.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * @class ACE_Log_Msg_NT_Event_Log - * - * @brief Implements an ACE_Log_Msg_Backend that logs to the WinNT system - * event log. - */ -class ACE_Export ACE_Log_Msg_NT_Event_Log : public ACE_Log_Msg_Backend -{ -public: - /// Constructor - ACE_Log_Msg_NT_Event_Log (void); - - /// Destructor - virtual ~ACE_Log_Msg_NT_Event_Log (void); - - /// Open a new event log. - /** - * Initialize the event logging facility. - * @param logger_key The name of the calling program. This name is - * used in the Source field of the event log. If - * it is 0 (no name), the application name as - * returned from ACE_Log_Msg::program_name() is used. - */ - virtual int open (const ACE_TCHAR *logger_key); - - /// Reset the backend. - virtual int reset (void); - - /// Close the backend completely. - virtual int close (void); - - /// This is called when we want to log a message. - virtual ssize_t log (ACE_Log_Record &log_record); - -private: - HANDLE evlog_handle_; -}; - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_HAS_LOG_MSG_NT_EVENT_LOG */ - -#include /**/ "ace/post.h" -#endif /* ACE_LOG_MSG_NT_EVENT_LOG_H */ diff --git a/ACE/ace/Log_Msg_UNIX_Syslog.cpp b/ACE/ace/Log_Msg_UNIX_Syslog.cpp deleted file mode 100644 index dba78bcd571..00000000000 --- a/ACE/ace/Log_Msg_UNIX_Syslog.cpp +++ /dev/null @@ -1,207 +0,0 @@ -// $Id$ - -#include "ace/config-all.h" - -#if !defined (ACE_LACKS_UNIX_SYSLOG) - -#include "ace/ACE.h" -#include "ace/Log_Msg.h" -#include "ace/Log_Msg_UNIX_Syslog.h" -#include "ace/Log_Record.h" -#include "ace/OS_NS_string.h" -#include "ace/os_include/os_syslog.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -// NOTE: -// The ACE_Log_Msg_UNIX_Syslog class can use the openlog(), -// setlogmask(), syslog() and closelog() routines in a thread safe -// manner (versus using openlog_r(), et. al.), as the ACE_Log_Msg -// class uses the lock provided by its local ACE_Log_Msg_Manager -// class when calling the methods of the backend classes. As a -// result, logging semantics with respect to the UNIX syslog -// facility, will be the same for all threads in a process. This -// should not be too limiting, as the ACE_Log_Msg class itself can -// be used to control thread specific logging behavior. - -ACE_Log_Msg_UNIX_Syslog::ACE_Log_Msg_UNIX_Syslog (void) -{ -} - -ACE_Log_Msg_UNIX_Syslog::~ACE_Log_Msg_UNIX_Syslog (void) -{ - (void) this->close (); -} - -int -ACE_Log_Msg_UNIX_Syslog::open (const ACE_TCHAR * logger_key) -{ - if (logger_key == 0) - logger_key = ACE_Log_Msg::program_name (); - - // Initialize the UNIX syslog facility. Default the syslog log - // options LOG_CONS and LOG_PID to be set. There really should be a - // logging strategy option to control the syslog log options, - // however, we'll take the easy way out for now. -#if defined (ACE_USES_WCHAR) - openlog (ACE_TEXT_ALWAYS_CHAR (logger_key), - LOG_CONS|LOG_PID, - ACE_DEFAULT_SYSLOG_FACILITY); -#else - openlog (const_cast (logger_key), - LOG_CONS|LOG_PID, - ACE_DEFAULT_SYSLOG_FACILITY); -#endif /* ACE_USES_WCHAR */ - - // Enable logging of all syslog priorities. If logging of all - // priorities is not desired, use the ACE_Log_Msg::priority_mask() - // method to control the log output sent to the syslog daemon via - // the log() method, or use the system's syslog.conf file to select - // desired level of information. - -#if !defined (ACE_LACKS_SETLOGMASK) - (void) setlogmask (LOG_UPTO (LOG_DEBUG)); -#endif /* ACE_LACKS_SETLOGMASK */ - - return 0; -} - -int -ACE_Log_Msg_UNIX_Syslog::reset (void) -{ - return this->close (); -} - -int -ACE_Log_Msg_UNIX_Syslog::close (void) -{ - closelog(); - return 0; -} - -ssize_t -ACE_Log_Msg_UNIX_Syslog::log (ACE_Log_Record &log_record) -{ - int syslog_priority = this->convert_log_priority (log_record.type ()); - u_long flags = ACE_LOG_MSG->flags (); - - // The UNIX syslog() facility does not support multi-line messages. - // Break up the message data into separate lines and send each line - // to the syslog daemon. - - ACE_TCHAR message[ACE_Log_Record::MAXVERBOSELOGMSGLEN]; - ACE_OS::strcpy (message, log_record.msg_data ()); - ACE_TCHAR *strtokp = 0; - - for (ACE_TCHAR *line = ACE_OS::strtok_r (message, - ACE_TEXT ("\n"), - &strtokp); - line != 0; - line = ACE_OS::strtok_r (0, - ACE_TEXT ("\n"), - &strtokp)) - { - // Format the message line. Note that the processing for - // VERBOSE is the same as for VERBOSE_LITE, since syslog() - // already provides us with the hostname and PID. However, the - // timestamp is duplicated (albeit a shortened version) to - // provide a timestamp with greater precision than that provided - // by syslog(). - if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::VERBOSE) - || ACE_BIT_ENABLED (flags, ACE_Log_Msg::VERBOSE_LITE)) - { - ACE_TCHAR date_and_time[35]; - if (0 == ACE::timestamp (date_and_time, sizeof (date_and_time), 1)) - ACE_OS::strcpy (date_and_time, ACE_TEXT ("