本文整理汇总了C++中PropertyBag::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertyBag::getType方法的具体用法?C++ PropertyBag::getType怎么用?C++ PropertyBag::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyBag
的用法示例。
在下文中一共展示了PropertyBag::getType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: composeProperty
bool composeProperty(const PropertyBag& bag, WeightedSample<T>& weightedSample)
{
//log(Debug) << "composeProperty of WeightedSample " << endlog();
std::string tname = detail::DataSourceTypeInfo<T>::getType();
if ( bag.getType() == std::string("WeightedSample") ) {
// Get values of sample
Property<PropertyBag>* el_bag = bag.getProperty<PropertyBag>("WeightedSampleValue");
if(el_bag==NULL){
// Works for properties in WeightedSample
PropertyBase* element = bag.getItem( 0 );
//log(Debug)<<element->getName()<<", "<< element->getDescription()<<endlog();
Property<T> my_property_t (element->getName(),element->getDescription());
if(my_property_t.getType()!=element->getType())
{
log(Error)<< "Type of "<< element->getName() << " does not match type of WeightedSample"<< "OR "<<"Could not read WeightedSample Value "<<endlog();
return false;
}
else{
my_property_t.getTypeInfo()->composeType(element->getDataSource(),my_property_t.getDataSource());
weightedSample.ValueSet( my_property_t.get());
}
}
else{
// Works for propertybags in WeightedSample
const std::string el_bagType = el_bag->getType();
Property<T > el_p(el_bag->getName(),el_bag->getDescription());
if(!(el_p.getDataSource()->composeType(el_bag->getDataSource()))){
log(Error)<<"Could not compose WeightedSampleValue "<<endlog();
return false;
}
if(el_p.ready()){
weightedSample.ValueSet( el_p.get());
}else{
log(Error)<<"Property of WeightedSampleValue was not ready for use"<<endlog();
return false;
}
}
// Get weight of sample
Property<double>* weightProp = bag.getProperty<double>("WeightedSampleWeight");
if(!weightProp)
{
log(Error)<< "Error reading weight of WeightedSample"<<endlog();
return false;
}
else{
weightedSample.WeightSet( weightProp->get());
}
}
else {
Logger::log() << Logger::Error << "Composing Property< WeightedSample<T> > :"
<< " type mismatch, got type '"<< bag.getType()
<< "', expected type "<<tname<<"."<<Logger::endl;
return false;
}
return true;
};
示例2: composeTypeImpl
/**
* Specialize to resize \a result given the size of \a source.
*/
virtual bool composeTypeImpl(const PropertyBag& bag, typename internal::AssignableDataSource<T>::reference_t result) const
{
if ( bag.getType() == "Matrix" ) {
unsigned int rows = bag.size();
unsigned int cols = 0;
// Get values
for (unsigned int i = 1; i <= rows ; i++) {
std::stringstream out;
out << i;
Property<PropertyBag>* row_bag = bag.getProperty<PropertyBag>(out.str());
if(row_bag==NULL){
log(Error)<<"Could not read row "<<i<<endlog();
return false;
}
Property<RowVector> row_p(row_bag->getName(),row_bag->getDescription());
if(!(row_p.getDataSource()->composeType(row_bag->getDataSource()))){
log(Error)<<"Could not decompose row "<<i<<endlog();
return false;
}
if(row_p.ready()){
if(i==1){
cols = row_p.get().size();
result.resize(rows,cols);
} else
if(row_p.get().size()!=cols){
log(Error)<<"Row "<<i+1<<" size does not match matrix columns"<<endlog();
return false;
}
for ( unsigned int j=1; j <= row_p.get().size() ; j++){
result(i,j)=row_p.get()(j);
}
}else{
log(Error)<<"Property of Row "<<i<<"was not ready for use"<<endlog();
return false;
}
}
}else {
log(Error) << "Composing Property< Matrix > :"
<< " type mismatch, got type '"<< bag.getType()
<< "', expected type "<<"Matrix."<<endlog();
return false;
}
return true;
}
示例3: composeTypeImpl
/**
* Implementation that updates result with the matching parts in source
* Relies on the fact that getMember returns a C++ reference to each part of \a result, which is then updated
* with a property found in source.
*/
virtual bool composeTypeImpl(const PropertyBag& source, typename internal::AssignableDataSource<T>::reference_t result) const {
// The default implementation decomposes result and refreshes it with source.
TypeInfoRepository::shared_ptr tir = Types();
internal::ReferenceDataSource<T> rds(result);
rds.ref(); // prevent dealloc.
PropertyBag decomp;
// only try refreshProperties if decomp's type is equal to source type.
// update vs refresh: since it is intentional that the decomposition leads to references to parts of result,
// only refreshProperties() is meaningful (ie we have a one-to-one mapping). In case of sequences, this would
// of course not match, so this is struct specific.
return typeDecomposition( &rds, decomp, false) && ( tir->type(decomp.getType()) == tir->type(source.getType()) ) && refreshProperties(decomp, source);
}
示例4: composeTemplateProperty
bool composeTemplateProperty(const PropertyBag& bag, T& result)
{
TypeInfoRepository::shared_ptr tir = Types();
if ( tir->type( bag.getType()) == tir->getTypeInfo< T >() ) {
Property< typename T::value_type>* comp;
int dimension = bag.size();
result.resize( dimension );
// Get values
int size_correction = 0;
for (int i = 0; i < dimension ; i++) {
base::PropertyBase* element = bag.getItem( i );
comp = dynamic_cast< Property< typename T::value_type>* >( element );
if ( comp == 0 ) {
// detect LEGACY element:
if ( element->getName() == "Size" ) {
// oops, our result vector will be one smaller.
size_correction += 1;
continue;
}
Logger::log() << Logger::Error << "Aborting composition of Property< T > "
<< ": Exptected data element "<< i << " to be of type " << internal::DataSourceTypeInfo< typename T::value_type>::getTypeName()
<<" got type " << element->getType()
<<Logger::endl;
return false;
}
result[ i - size_correction ] = comp->get();
}
result.resize( dimension - size_correction );
}
else {
Logger::log() << Logger::Error << "Composing Property< T > :"
<< " type mismatch, got type '"<< bag.getType()
<< "', expected 'vector<" << internal::DataSourceTypeInfo< typename T::value_type>::getTypeName() <<">'."<<Logger::endl;
return false;
}
return true;
}