#include <i_collection_impl.h>


Definition at line 24 of file i_collection_impl.h.
Public Member Functions | |
| i_Collection_i () | |
| CORBA::Any * | NextBatch (CORBA::Boolean &a_more) |
Protected Member Functions | |
| virtual | ~i_Collection_i () |
| virtual void | PrepareNextBatch (CORBA::Any &a_batch, bool &a_more) |
| This is an example of function PrepareNextBatch to demonstrate how the inherited classes prepare data batches. | |
| UInt32_t | AllocateInBatch (UInt32_t a_bytes) |
Private Attributes | |
| log_CLASSID_m | |
| UInt32_t | m_freeInBatch |
| const UInt32_t | m_maxBatchSize |
| i_Collection_i::i_Collection_i | ( | ) |
Definition at line 34 of file i_collection_impl.cpp.
References log_FUNC_m.
00035 : m_freeInBatch(0), 00036 m_maxBatchSize (cfg_MEGABYTE) { 00037 00038 log_FUNC_m(i_Collection_i); 00039 00040 }
| i_Collection_i::~i_Collection_i | ( | ) | [protected, virtual] |
Definition at line 42 of file i_collection_impl.cpp.
References log_FUNC_m.
00042 { 00043 log_FUNC_m(~i_Collection_i); 00044 }
| CORBA::Any * i_Collection_i::NextBatch | ( | CORBA::Boolean & | a_more | ) |
Definition at line 46 of file i_collection_impl.cpp.
References dbg_DETAIL, ipc_CATCH_IVD_THROW_CORBA_m, log_DBG_m, log_FUNC_m, m_freeInBatch, m_maxBatchSize, and PrepareNextBatch().
00046 { 00047 00048 log_FUNC_m(NextBatch); 00049 00050 try { 00051 CORBA::Any_var retAny(new CORBA::Any); 00052 00053 m_freeInBatch = m_maxBatchSize; 00054 00055 PrepareNextBatch(retAny, a_more); 00056 00057 log_DBG_m(dbg_DETAIL, "Batch size: " << m_maxBatchSize - m_freeInBatch); 00058 00059 return retAny._retn(); 00060 } 00061 ipc_CATCH_IVD_THROW_CORBA_m; 00062 00063 }

| void i_Collection_i::PrepareNextBatch | ( | CORBA::Any & | a_batch, | |
| bool & | a_more | |||
| ) | [protected, virtual] |
This is an example of function PrepareNextBatch to demonstrate how the inherited classes prepare data batches.
Base class calls this function to prepare each of the batches (sequence of some type of data).
Inherited classes must keep track of the current position in the data that it is sending as a collection.
There is no rule how the data must be prepared: it can be copied from some other sequence, vector; it can be generated on-the-fly or read from a file/database...
| a_batch | Container for the batch. | |
| a_more | Is there more after this batch? Must be set to false for the last batch. |
Definition at line 92 of file i_collection_impl.cpp.
References AllocateInBatch(), dbg_NORM, len, log_DBG_m, log_FUNC_m, and str.
Referenced by NextBatch().
00092 { 00093 log_FUNC_m(PrepareNextBatch); 00094 00095 // == General for all implementations == 00096 // Batch container of the type that will be used by the CORBA client 00097 // It must be allocated on heap. 00098 // Inherited classes will use different sequence type. 00099 i_StringList_t_var strSeq(new i_StringList_t); 00100 00101 // == Implementation specific == 00102 // Preparation of data. Use AllocateInBatch for each elemnt 00103 // that is added to the sequence to prevent creating too big batches. 00104 // AllocateInBatch returns 0 if there is not enough space in the batch 00105 // to store the next record. 00106 strSeq->length(100000); 00107 const char* str ("ABCDEFGHIJKLMNOPQRSTUVZ0123456789"); 00108 size_t len = strlen(str) + 1; 00109 00110 for (CORBA::ULong i(0); i < 100000; ++i) { 00111 00112 // Use AllocateInBatch to find out whether there is 00113 // more room in the batch 00114 if (AllocateInBatch(len) != 0) { 00115 strSeq[i] = CORBA::string_dup(str); 00116 } 00117 else { 00118 break; 00119 } 00120 } 00121 00122 log_DBG_m(dbg_NORM, "Batch size: " << strSeq->length()); 00123 00124 // == General for all implementations == 00125 // Assign prepared sequence to CORBA::Any 00126 a_batch <<= strSeq._retn(); 00127 00128 // == Implementation specific == 00129 // Simple condition for end of data 00130 static Int32_t count(20); 00131 --count; 00132 00133 if (count < 1) { 00134 a_more=false; 00135 } 00136 else { 00137 a_more=true; 00138 } 00139 }


Definition at line 65 of file i_collection_impl.cpp.
References m_freeInBatch.
Referenced by PrepareNextBatch().
00065 { 00066 if (m_freeInBatch > a_bytes) { 00067 m_freeInBatch -= a_bytes; 00068 return a_bytes; 00069 } 00070 else { 00071 return 0; 00072 } 00073 }

i_Collection_i::log_CLASSID_m [private] |
UInt32_t i_Collection_i::m_freeInBatch [private] |
Definition at line 45 of file i_collection_impl.h.
Referenced by AllocateInBatch(), and NextBatch().
const UInt32_t i_Collection_i::m_maxBatchSize [private] |
1.5.6