📄 offer_exporter.cpp
字号:
for (CORBA::ULong i = 0; i < length; i++)
{
this->register_->modify (offer_id_seq[i],
del_list,
modify_list
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
}
}
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "TAO_Offer_Exporter::modify_offers");
ACE_RE_THROW;
}
ACE_ENDTRY;
}
void
TAO_Offer_Exporter::
withdraw_offers_using_constraints (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
CosTrading::IllegalServiceType,
CosTrading::UnknownServiceType,
CosTrading::IllegalConstraint,
CosTrading::Register::NoMatchingOffers))
{
ACE_DEBUG ((LM_DEBUG, "*** TAO_Offer_Exporter::Withdrawing with constraint.\n"));
const char* constraint =
"(not exist Description) and (Location == 'MODIFIED') and (exist Name)";
if (this->verbose_)
ACE_DEBUG ((LM_DEBUG, "Constraint: %s\n", constraint));
ACE_TRY
{
this->register_->
withdraw_using_constraint (TT_Info::INTERFACE_NAMES[TT_Info::PLOTTER],
constraint
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
this->register_->
withdraw_using_constraint (TT_Info::INTERFACE_NAMES[TT_Info::PRINTER],
constraint
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
this->register_->
withdraw_using_constraint (TT_Info::INTERFACE_NAMES[TT_Info::FILESYSTEM],
constraint
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
"TAO_Offer_Exporter::withdraw_using_constraint");
ACE_RE_THROW;
}
ACE_ENDTRY;
}
CosTrading::OfferIdSeq*
TAO_Offer_Exporter::grab_offerids (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
CosTrading::NotImplemented))
{
if (this->verbose_)
ACE_DEBUG ((LM_DEBUG, "TAO_Offer_Exporter::Grabbing all offer ids.\n"));
CosTrading::OfferIdSeq *offer_id_seq;
ACE_TRY
{
CORBA::ULong length = NUM_OFFERS;
CosTrading::OfferIdIterator_ptr offer_id_iter;
this->admin_->list_offers (NUM_OFFERS,
CosTrading::OfferIdSeq_out (offer_id_seq),
CosTrading::OfferIdIterator_out (offer_id_iter)
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
if ((! CORBA::is_nil (offer_id_iter)) && offer_id_seq != 0)
{
CORBA::Boolean any_left = 0;
CosTrading::OfferIdSeq *id_seq;
CosTrading::OfferIdIterator_var offer_id_iter_var (offer_id_iter);
do
{
any_left =
offer_id_iter->next_n (length,
CosTrading::OfferIdSeq_out (id_seq)
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
int offers = id_seq->length ();
int old_length = offer_id_seq->length ();
offer_id_seq->length (old_length + offers);
for (int i = 0; i < offers; i++)
(*offer_id_seq)[i + old_length] = (*id_seq)[i];
delete id_seq;
}
while (any_left);
offer_id_iter->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
}
if (this->verbose_)
{
ACE_DEBUG ((LM_DEBUG, "The following offer ids are registered:\n"));
for (int len = offer_id_seq->length (), j = 0; j < len; j++)
ACE_DEBUG ((LM_DEBUG, "Offer Id: %s\n", (const char *)(*offer_id_seq)[j]));
}
}
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
"TAO_Offer_Exporter::grab_offerids");
ACE_RE_THROW;
}
ACE_ENDTRY;
// @@ redundant.
// ACE_CHECK_RETURN (offer_id_seq);
return offer_id_seq;
}
void
TAO_Offer_Exporter::create_offers (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
{
const int QUEUE_SIZE = 4;
int counter = 0, i = 0;
char name[BUFSIZ];
char description[BUFSIZ];
CORBA::Any extra_info;
TAO_Trader_Test::StringSeq string_seq (QUEUE_SIZE);
TAO_Trader_Test::ULongSeq ulong_seq (QUEUE_SIZE);
CosTradingDynamic::DynamicProp* dp_user_queue;
CosTradingDynamic::DynamicProp* dp_file_queue;
CosTradingDynamic::DynamicProp* dp_space_left;
ACE_INET_Addr addr ((u_short) 0);
const char* hostname = addr.get_host_name ();
// Initialize plotters
string_seq.length (QUEUE_SIZE);
ulong_seq.length (QUEUE_SIZE);
for (i = 0; i < NUM_OFFERS; i++)
{
ACE_OS::sprintf (name, "Plotter #%d", i);
ACE_OS::sprintf (description,
"%s is a plotter. It plots stuff.",
name);
for (int j = 0; j < QUEUE_SIZE; j++, counter = (counter + 1) % NUM_OFFERS)
{
string_seq[j] = TT_Info::USERS [counter];
ulong_seq[j] = counter * 10000;
}
TAO_Dynamic_Property* user_queue =
new TAO_Simple_Dynamic_Property<TAO_Trader_Test::StringSeq> (string_seq);
TAO_Dynamic_Property* file_sizes =
new TAO_Simple_Dynamic_Property<TAO_Trader_Test::ULongSeq> (ulong_seq);
this->clean_up_.enqueue_head (user_queue);
this->clean_up_.enqueue_head (file_sizes);
dp_user_queue = user_queue->construct_dynamic_prop
(TT_Info::PLOTTER_PROPERTY_NAMES[TT_Info::PLOTTER_USER_QUEUE],
TAO_Trader_Test::_tc_StringSeq,
extra_info);
dp_file_queue = file_sizes->construct_dynamic_prop
(TT_Info::PLOTTER_PROPERTY_NAMES[TT_Info::PLOTTER_FILE_SIZES_PENDING],
TAO_Trader_Test::_tc_ULongSeq,
extra_info);
this->props_plotters_[i].length (11);
this->props_plotters_[i][0].name = TT_Info::REMOTE_IO_PROPERTY_NAMES[TT_Info::NAME];
this->props_plotters_[i][0].value <<= name;
this->props_plotters_[i][1].name = TT_Info::REMOTE_IO_PROPERTY_NAMES[TT_Info::LOCATION];
this->props_plotters_[i][1].value <<= TT_Info::LOCATIONS[i];
this->props_plotters_[i][2].name = TT_Info::REMOTE_IO_PROPERTY_NAMES[TT_Info::DESCRIPTION];
this->props_plotters_[i][2].value <<= description;
this->props_plotters_[i][3].name = TT_Info::REMOTE_IO_PROPERTY_NAMES[TT_Info::HOST_NAME];
this->props_plotters_[i][3].value <<= hostname;
this->props_plotters_[i][4].name = TT_Info::REMOTE_IO_PROPERTY_NAMES[TT_Info::TRADER_NAME];
this->props_plotters_[i][4].value <<= "Default";
this->props_plotters_[i][5].name = TT_Info::PLOTTER_PROPERTY_NAMES[TT_Info::PLOTTER_NUM_COLORS];
this->props_plotters_[i][5].value <<= (CORBA::Long)(i * 2);
this->props_plotters_[i][6].name = TT_Info::PLOTTER_PROPERTY_NAMES[TT_Info::PLOTTER_AUTO_LOADING];
this->props_plotters_[i][6].value <<= CORBA::Any::from_boolean ((CORBA::Boolean) (i % 2));
this->props_plotters_[i][7].name = TT_Info::PLOTTER_PROPERTY_NAMES[TT_Info::PLOTTER_COST_PER_PAGE];
this->props_plotters_[i][7].value <<= (CORBA::Float) i;
this->props_plotters_[i][8].name = TT_Info::PLOTTER_PROPERTY_NAMES[TT_Info::PLOTTER_MODEL_NUMBER];
this->props_plotters_[i][8].value <<= TT_Info::MODEL_NUMBERS[i];
this->props_plotters_[i][9].name = TT_Info::PLOTTER_PROPERTY_NAMES[TT_Info::PLOTTER_USER_QUEUE];
this->props_plotters_[i][9].value <<= dp_user_queue;
this->props_plotters_[i][10].name = TT_Info::PLOTTER_PROPERTY_NAMES[TT_Info::PLOTTER_FILE_SIZES_PENDING];
this->props_plotters_[i][10].value <<= dp_file_queue;
}
// Initialize printers
for (i = 0; i < NUM_OFFERS; i++)
{
ACE_OS::sprintf (name, "Printer #%d", i);
ACE_OS::sprintf (description,
"%s is a printer. It prints stuff.",
name);
for (int j = 0; j < QUEUE_SIZE; j++, counter = (counter + 1) % NUM_OFFERS)
{
string_seq[j] = TT_Info::USERS [counter];
ulong_seq[j] = counter * 10000;
}
TAO_Dynamic_Property* user_queue =
new TAO_Simple_Dynamic_Property<TAO_Trader_Test::StringSeq> (string_seq);
TAO_Dynamic_Property* file_sizes =
new TAO_Simple_Dynamic_Property<TAO_Trader_Test::ULongSeq> (ulong_seq);
this->clean_up_.enqueue_head (user_queue);
this->clean_up_.enqueue_head (file_sizes);
dp_user_queue = user_queue->construct_dynamic_prop
(TT_Info::PRINTER_PROPERTY_NAMES[TT_Info::PLOTTER_USER_QUEUE],
TAO_Trader_Test::_tc_StringSeq,
extra_info);
dp_file_queue = file_sizes->construct_dynamic_prop
(TT_Info::PRINTER_PROPERTY_NAMES[TT_Info::PLOTTER_FILE_SIZES_PENDING],
TAO_Trader_Test::_tc_ULongSeq,
extra_info);
this->props_printers_[i].length (12);
this->props_printers_[i][0].name = TT_Info::REMOTE_IO_PROPERTY_NAMES[TT_Info::NAME];
this->props_printers_[i][0].value <<= name;
this->props_printers_[i][1].name = TT_Info::REMOTE_IO_PROPERTY_NAMES[TT_Info::LOCATION];
this->props_printers_[i][1].value <<= TT_Info::LOCATIONS[i];
this->props_printers_[i][2].name = TT_Info::REMOTE_IO_PROPERTY_NAMES[TT_Info::DESCRIPTION];
this->props_printers_[i][2].value <<= description;
this->props_printers_[i][3].name = TT_Info::REMOTE_IO_PROPERTY_NAMES[TT_Info::HOST_NAME];
this->props_printers_[i][3].value <<= hostname;
this->props_printers_[i][4].name = TT_Info::REMOTE_IO_PROPERTY_NAMES[TT_Info::TRADER_NAME];
this->props_printers_[i][4].value <<= "Default";
this->props_printers_[i][5].name = TT_Info::PRINTER_PROPERTY_NAMES[TT_Info::PRINTER_COLOR];
this->props_printers_[i][5].value <<= CORBA::Any::from_boolean ((CORBA::Boolean) (i % 2));
this->props_printers_[i][6].name = TT_Info::PRINTER_PROPERTY_NAMES[TT_Info::PRINTER_DOUBLE_SIDED];
this->props_printers_[i][6].value <<= CORBA::Any::from_boolean ((CORBA::Boolean) ((i + 1) % 2));
this->props_printers_[i][7].name = TT_Info::PRINTER_PROPERTY_NAMES[TT_Info::PRINTER_COST_PER_PAGE];
this->props_printers_[i][7].value <<= (CORBA::Float) i;
this->props_printers_[i][8].name = TT_Info::PRINTER_PROPERTY_NAMES[TT_Info::PRINTER_MODEL_NUMBER];
this->props_printers_[i][8].value <<= TT_Info::MODEL_NUMBERS[i];
this->props_printers_[i][9].name = TT_Info::PRINTER_PROPERTY_NAMES[TT_Info::PRINTER_PAGES_PER_SEC];
this->props_printers_[i][9].value <<= (CORBA::UShort) i;
this->props_printers_[i][10].name = TT_Info::PRINTER_PROPERTY_NAMES[TT_Info::PRINTER_USER_QUEUE];
this->props_printers_[i][10].value <<= dp_user_queue;
this->props_printers_[i][11].name = TT_Info::PRINTER_PROPERTY_NAMES[TT_Info::PRINTER_FILE_SIZES_PENDING];
this->props_printers_[i][11].value <<= dp_file_queue;
}
// Initialize FileSystem
for (i = 0; i < NUM_OFFERS; i++)
{
ACE_OS::sprintf (name, "File System #%d", i);
ACE_OS::sprintf (description,
"%s is a File System. It stores stuff.",
name);
TAO_Dynamic_Property* space_left =
new TAO_Simple_Dynamic_Property<CORBA::ULong> (i * 4434343);
this->clean_up_.enqueue_head (space_left);
dp_space_left = space_left->construct_dynamic_prop
(TT_Info::FILESYSTEM_PROPERTY_NAMES[TT_Info::SPACE_REMAINING],
CORBA::_tc_ulong,
extra_info);
this->props_fs_[i].length (8);
this->props_fs_[i][0].name = TT_Info::REMOTE_IO_PROPERTY_NAMES[TT_Info::NAME];
this->props_fs_[i][0].value <<= name;
this->props_fs_[i][1].name = TT_Info::REMOTE_IO_PROPERTY_NAMES[TT_Info::LOCATION];
this->props_fs_[i][1].value <<= TT_Info::LOCATIONS[i];
this->props_fs_[i][2].name = TT_Info::REMOTE_IO_PROPERTY_NAMES[TT_Info::DESCRIPTION];
this->props_fs_[i][2].value <<= description;
this->props_fs_[i][3].name = TT_Info::REMOTE_IO_PROPERTY_NAMES[TT_Info::HOST_NAME];
this->props_fs_[i][3].value <<= hostname;
this->props_fs_[i][4].name = TT_Info::REMOTE_IO_PROPERTY_NAMES[TT_Info::TRADER_NAME];
this->props_fs_[i][4].value <<= "Default";
this->props_fs_[i][5].name = TT_Info::FILESYSTEM_PROPERTY_NAMES[TT_Info::DISK_SIZE];
this->props_fs_[i][5].value <<= (CORBA::ULong) (i * 2000000);
this->props_fs_[i][6].name = TT_Info::FILESYSTEM_PROPERTY_NAMES[TT_Info::PERMISSION_LEVEL];
this->props_fs_[i][6].value <<= (CORBA::UShort) (i + 1);
this->props_fs_[i][7].name = TT_Info::FILESYSTEM_PROPERTY_NAMES[TT_Info::SPACE_REMAINING];
this->props_fs_[i][7].value <<= dp_space_left;
}
}
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class ACE_Node<TAO_Dynamic_Property*>;
template class ACE_Unbounded_Queue<TAO_Dynamic_Property*>;
template class ACE_Unbounded_Queue_Iterator<TAO_Dynamic_Property*>;
template class TAO_Simple_Dynamic_Property<TAO_Trader_Test::StringSeq>;
template class TAO_Simple_Dynamic_Property<TAO_Trader_Test::ULongSeq>;
template class TAO_Simple_Dynamic_Property<CORBA::ULong>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
#pragma instantiate ACE_Node<TAO_Dynamic_Property*>
#pragma instantiate ACE_Unbounded_Queue<TAO_Dynamic_Property*>
#pragma instantiate ACE_Unbounded_Queue_Iterator<TAO_Dynamic_Property*>
#pragma instantiate TAO_Simple_Dynamic_Property<TAO_Trader_Test::StringSeq>
#pragma instantiate TAO_Simple_Dynamic_Property<TAO_Trader_Test::ULongSeq>
#pragma instantiate TAO_Simple_Dynamic_Property<CORBA::ULong>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -