📄 service_type_repository.cpp
字号:
else
mask = 1;
}
void
TAO_Service_Type_Repository::
unmask_type (const char *name
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
CosTrading::IllegalServiceType,
CosTrading::UnknownServiceType,
CosTradingRepos::ServiceTypeRepository::NotMasked))
{
if (TAO_Trader_Base::is_valid_identifier_name (name) == 0)
ACE_THROW (CosTrading::IllegalServiceType (name));
ACE_WRITE_GUARD_THROW_EX (ACE_Lock, ace_mon, *this->lock_, CORBA::INTERNAL ());
// Make sure the type exists.
TAO_String_Hash_Key type_name (name);
Service_Type_Map::ENTRY *type_entry = 0;
if (this->type_map_.find (type_name,
type_entry) != -1)
ACE_THROW (CosTrading::UnknownServiceType (name));
// Make sure the type is masked.
CORBA::Boolean &mask = type_entry->int_id_->type_struct_.masked;
if (mask == 0)
ACE_THROW (CosTradingRepos::ServiceTypeRepository::NotMasked (name));
else
mask = 0;
}
void
TAO_Service_Type_Repository::
fully_describe_type_i (const CosTradingRepos::ServiceTypeRepository::TypeStruct &type_struct,
CosTradingRepos::ServiceTypeRepository::PropStructSeq &props,
CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq &super_types)
{
TAO_String_Queue service_type_queue;
this->collect_inheritance_hierarchy (type_struct,
service_type_queue);
// Count the total number of properties.
CORBA::ULong num_props = 0;
CORBA::ULong num_types = ACE_static_cast (CORBA::ULong,
service_type_queue.size ());
TAO_String_Queue::ITERATOR iterator (service_type_queue);
for (;
iterator.done () == 0;
iterator.advance ())
{
char **next_type_name = 0;
Service_Type_Map::ENTRY *type_entry = 0;
iterator.next (next_type_name);
TAO_String_Hash_Key hash_key (ACE_const_cast (const char *,
*next_type_name));
this->type_map_.find (hash_key,
type_entry);
CosTradingRepos::ServiceTypeRepository::TypeStruct &tstruct =
type_entry->int_id_->type_struct_;
num_props += tstruct.props.length ();
}
num_props += type_struct.props.length ();
props.length (num_props);
super_types.length (num_types);
// Copy in all properties.
int i = 0;
CORBA::ULong prop_index = 0;
CORBA::ULong type_index = 0;
for (i = type_struct.props.length () - 1;
i >= 0;
i--)
props[prop_index++] = type_struct.props[i];
for (iterator.first ();
iterator.done () == 0;
iterator.advance ())
{
char **next_type_name = 0;
Service_Type_Map::ENTRY *type_entry = 0;
iterator.next (next_type_name);
TAO_String_Hash_Key hash_key (ACE_const_cast (const char *,
*next_type_name));
this->type_map_.find (hash_key,
type_entry);
// Should never be zero.
if (type_entry != 0)
{
CosTradingRepos::ServiceTypeRepository::TypeStruct& tstruct =
type_entry->int_id_->type_struct_;
for (i = tstruct.props.length () - 1;
i >= 0;
i--)
props[prop_index++] = tstruct.props[i];
super_types[type_index++] = hash_key.in ();
}
}
}
void
TAO_Service_Type_Repository::
collect_inheritance_hierarchy (const CosTradingRepos::ServiceTypeRepository::TypeStruct &type_struct,
TAO_String_Queue &target)
{
// Recurse for each super_type
for (int i = type_struct.super_types.length () - 1;
i >= 0;
i--)
{
Service_Type_Map::ENTRY *next_type_entry = 0;
TAO_String_Hash_Key next_type_name (type_struct.super_types[i]);
if (this->type_map_.find (next_type_name, next_type_entry) != -1)
{
CosTradingRepos::ServiceTypeRepository::TypeStruct &next_type_struct =
next_type_entry->int_id_->type_struct_;
const char *type_name =
type_struct.super_types[i];
target.enqueue_tail (ACE_const_cast (char *,
type_name));
this->collect_inheritance_hierarchy (next_type_struct,
target);
}
}
}
void
TAO_Service_Type_Repository::
validate_properties (Prop_Map &prop_map,
const CosTradingRepos::ServiceTypeRepository::PropStructSeq &props
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CosTrading::IllegalPropertyName,
CosTrading::DuplicatePropertyName))
{
for (CORBA::ULong i = 0;
i < props.length ();
i++)
{
const char *n = props[i].name;
if (TAO_Trader_Base::is_valid_identifier_name (n) == 0)
ACE_THROW (CosTrading::IllegalPropertyName (n));
else
{
TAO_String_Hash_Key prop_name (n);
CosTradingRepos::ServiceTypeRepository::PropStruct *prop_val =
ACE_const_cast (CosTradingRepos::ServiceTypeRepository::PropStruct *,
&props[i]);
if (prop_map.bind (prop_name,
prop_val) == 1)
ACE_THROW (CosTrading::DuplicatePropertyName (n));
}
}
}
void
TAO_Service_Type_Repository::
validate_supertypes (Service_Type_Map &super_map,
const CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq &super_types
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CosTrading::IllegalServiceType,
CosTrading::UnknownServiceType,
CosTradingRepos::ServiceTypeRepository::DuplicateServiceTypeName))
{
for (CORBA::ULong i = 0;
i < super_types.length ();
i++)
{
const char *type =
super_types[i];
if (TAO_Trader_Base::is_valid_identifier_name (type) == 0)
ACE_THROW (CosTrading::IllegalServiceType (type));
else
{
TAO_String_Hash_Key hash_type (type);
Service_Type_Map::ENTRY *type_entry = 0;
if (this->type_map_.find (hash_type,
type_entry) == -1)
ACE_THROW (CosTrading::UnknownServiceType (type));
else
{
if (super_map.bind (hash_type,
type_entry->int_id_) == 1)
ACE_THROW (CosTradingRepos::ServiceTypeRepository::DuplicateServiceTypeName (type));
}
}
}
}
void
TAO_Service_Type_Repository::
validate_inheritance (Prop_Map &prop_map,
const CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq &super_types
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CosTradingRepos::ServiceTypeRepository::ValueTypeRedefinition))
{
CORBA::ULong num_super_types = super_types.length ();
for (CORBA::ULong i = 0;
i < num_super_types;
i++)
{
Service_Type_Map::ENTRY *super_type_entry = 0;
TAO_String_Hash_Key super_type (super_types[i]);
CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq place_holder;
CosTradingRepos::ServiceTypeRepository::PropStructSeq super_props;
this->type_map_.find (super_type, super_type_entry);
// Super_type_entry should never be zero.
if (super_type_entry != 0)
this->fully_describe_type_i (super_type_entry->int_id_->type_struct_,
super_props,
place_holder);
else
continue;
CORBA::ULong num_props = super_props.length ();
for (CORBA::ULong j = 0;
j < num_props;
j++)
{
Prop_Map::ENTRY *existing_prop = 0;
TAO_String_Hash_Key prop_name (super_props[j].name);
if (prop_map.bind (prop_name,
&super_props[j],
existing_prop) == 1)
{
// If already there, check that it is compatible with
// properties of other types. Value Types have to be the
// same.
const CosTradingRepos::ServiceTypeRepository::PropStruct &property_in_map =
*existing_prop->int_id_;
CORBA::TypeCode_ptr prop_type = property_in_map.value_type.in ();
int compare = 0;
ACE_TRY
{
compare =
super_props[j].value_type->equal (prop_type
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
ACE_CATCHANY
{
ACE_TRY_THROW (CosTradingRepos::ServiceTypeRepository::ValueTypeRedefinition
(super_props[j].name,
super_props[j],
property_in_map.name,
property_in_map));
}
ACE_ENDTRY;
ACE_CHECK;
if (compare == 0
|| super_props[j].mode > property_in_map.mode)
ACE_THROW (CosTradingRepos::ServiceTypeRepository::ValueTypeRedefinition
(super_props[j].name,
super_props[j],
property_in_map.name,
property_in_map));
}
}
}
}
void
TAO_Service_Type_Repository::
update_type_map (const char *name,
const char *if_name,
const CosTradingRepos::ServiceTypeRepository::PropStructSeq &props,
const CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq &super_types,
Prop_Map &,
Service_Type_Map &super_map)
{
// Update entries for all supertypes to include this type as a
// subtype. we can use the super_types_map we have constructed.
for (Service_Type_Map_Iterator super_map_iterator (super_map);
super_map_iterator.done () == 0;
super_map_iterator++)
{
Type_Info *super_type_info =
(*super_map_iterator).int_id_;
super_type_info->has_subtypes_ = 0;
}
// All parameters are valid, create an entry for this service type
// in the this->type_map_.
Type_Info *type = 0;
ACE_NEW (type,
Type_Info);
type->type_struct_.props = props;
type->type_struct_.if_name = if_name;
type->type_struct_.super_types = super_types;
type->type_struct_.incarnation = this->incarnation_;
type->type_struct_.masked = 0;
type->has_subtypes_ = 0;
// Move the prop struct sequences and super type names from the in
// params to the internal storage.
/*
CORBA::ULong pslength = props.length ();
CosTradingRepos::ServiceTypeRepository::PropStructSeq* pstructs =
ACE_const_cast (CosTradingRepos::ServiceTypeRepository::PropStructSeq*,
&props);
CosTradingRepos::ServiceTypeRepository::PropStruct* psbuf =
pstructs->get_buffer (1);
type->type_struct_.props.replace (pslength,
pslength,
psbuf,
1);
*/
TAO_String_Hash_Key type_name (name);
this->type_map_.bind (type_name, type);
}
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class ACE_Hash_Map_Entry<TAO_String_Hash_Key, CosTradingRepos::ServiceTypeRepository::PropStruct*>;
template class ACE_Hash_Map_Manager_Ex<TAO_String_Hash_Key, CosTradingRepos::ServiceTypeRepository::PropStruct*, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex>;
template class ACE_Hash_Map_Iterator_Ex<TAO_String_Hash_Key, CosTradingRepos::ServiceTypeRepository::PropStruct*, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex>;
template class ACE_Hash_Map_Iterator_Base_Ex<TAO_String_Hash_Key, CosTradingRepos::ServiceTypeRepository::PropStruct*, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex>;
template class ACE_Hash_Map_Reverse_Iterator_Ex<TAO_String_Hash_Key, CosTradingRepos::ServiceTypeRepository::PropStruct*, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex>;
template class ACE_Hash_Map_Entry<TAO_String_Hash_Key, TAO_Service_Type_Repository::Type_Info*>;
template class ACE_Hash_Map_Manager_Ex<TAO_String_Hash_Key, TAO_Service_Type_Repository::Type_Info*, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex>;
template class ACE_Hash_Map_Iterator_Ex<TAO_String_Hash_Key, TAO_Service_Type_Repository::Type_Info*, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex>;
template class ACE_Hash_Map_Iterator_Base_Ex<TAO_String_Hash_Key, TAO_Service_Type_Repository::Type_Info*, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex>;
template class ACE_Hash_Map_Reverse_Iterator_Ex<TAO_String_Hash_Key, TAO_Service_Type_Repository::Type_Info*, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
#pragma instantiate ACE_Hash_Map_Entry<TAO_String_Hash_Key, CosTradingRepos::ServiceTypeRepository::PropStruct*>
#pragma instantiate ACE_Hash_Map_Manager_Ex<TAO_String_Hash_Key, CosTradingRepos::ServiceTypeRepository::PropStruct*, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex>
#pragma instantiate ACE_Hash_Map_Iterator_Ex<TAO_String_Hash_Key, CosTradingRepos::ServiceTypeRepository::PropStruct*, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex>
#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<TAO_String_Hash_Key, CosTradingRepos::ServiceTypeRepository::PropStruct*, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex>
#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<TAO_String_Hash_Key, CosTradingRepos::ServiceTypeRepository::PropStruct*, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex>
#pragma instantiate ACE_Hash_Map_Entry<TAO_String_Hash_Key, TAO_Service_Type_Repository::Type_Info*>
#pragma instantiate ACE_Hash_Map_Manager_Ex<TAO_String_Hash_Key, TAO_Service_Type_Repository::Type_Info*, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex>
#pragma instantiate ACE_Hash_Map_Iterator_Ex<TAO_String_Hash_Key, TAO_Service_Type_Repository::Type_Info*, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex>
#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<TAO_String_Hash_Key, TAO_Service_Type_Repository::Type_Info*, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex>
#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<TAO_String_Hash_Key, TAO_Service_Type_Repository::Type_Info*, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -