本文整理汇总了C++中Wire::Attach方法的典型用法代码示例。如果您正苦于以下问题:C++ Wire::Attach方法的具体用法?C++ Wire::Attach怎么用?C++ Wire::Attach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wire
的用法示例。
在下文中一共展示了Wire::Attach方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Clone
Wire* Wire::Clone()
{
Wire* clone = new Wire();
list<ConnectionPoint *>::iterator it;
for( it = this->connectionPoints->begin(); it != this->connectionPoints->end(); it++ )
{
ConnectionPoint* cp = (*it)->Clone();
clone->Attach( cp );
}
return clone;
}
示例2: ParseProgram
//.........这里部分代码省略.........
device->SetId( atoi( id.c_str() ) );
program->AddDevice( device );
#endif
start = devPropsIndex + JsonParameters::DeviceProperties.size() + 2;
end = devices.find( ']', devPropsIndex ) + 1;
deviceProperties = devices.substr( start, end - start );
startFrom = 0;
startIndex = end + 1;
while( true )
{
bracketIndex = deviceProperties.find( '}', startFrom );
if( bracketIndex == string::npos )
break;
keyIndex = deviceProperties.find( JsonParameters::DevicePropertyKey, startFrom );
valueIndex = deviceProperties.find( JsonParameters::DevicePropertyValue, startFrom );
typeIndex = deviceProperties.find( JsonParameters::DevicePropertyType, startFrom );
start = keyIndex + JsonParameters::DevicePropertyKey.size() + 3; // ":"
end = valueIndex - 3;
propertyKey = deviceProperties.substr( start, end - start );
start = valueIndex + JsonParameters::DevicePropertyValue.size() + 3;
end = typeIndex - 3;
propertyValue = deviceProperties.substr( start, end - start );
start = typeIndex + JsonParameters::DevicePropertyType.size() + 3;
end = bracketIndex - 1;
propertyType = deviceProperties.substr( start, end - start );
string * valueString = new string(propertyValue);
DeviceParameter* prop = new DeviceParameter( propertyKey, propertyType, propertyValue );
#ifndef PROFILE
device->AddCustomProperty( prop );
device->SetParameter(propertyKey, (void *)valueString);
#endif
startFrom = bracketIndex + 1;
}
}
//Resolve the Power wire
int cpArrayIndex;
string connPoints;
int cpIdIndex, deviceIdIndex;
string cpElement;
//Resolve Wires
startIndex = 0;
while ( true )
{
startFrom = 0;
cpArrayIndex = wires.find( JsonParameters::ConnectionPoints, startIndex );
if ( cpArrayIndex == string::npos )
break;
startIndex = cpArrayIndex + 1;
start = cpArrayIndex + JsonParameters::ConnectionPoints.size() + 3;
end = wires.find( ']', startIndex );
connPoints = wires.substr( start, end - start );
#ifndef PROFILE
Wire* wire = new Wire();
#endif
while ( true )
{
bracketIndex = connPoints.find( '}', startFrom );
if ( bracketIndex == string::npos )
break;
cpElement = connPoints.substr( startFrom, bracketIndex - startFrom );
startFrom = bracketIndex + 1;
cpIdIndex = cpElement.find( JsonParameters::ConnectionPointId );
deviceIdIndex = cpElement.find( JsonParameters::DeviceId );
start = cpIdIndex + JsonParameters::ConnectionPointId.size() + 2;
end = deviceIdIndex - 2;
cpId = cpElement.substr( start, end - start );
start = deviceIdIndex + JsonParameters::DeviceId.size() + 2;
end = cpElement.size();
id = cpElement.substr( start, end - start );
#ifndef PROFILE
device = program->GetDevice( atoi( id.c_str() ) );
connPoint = device->GetConnectionPoint( atoi( cpId.c_str() ) );
wire->Attach( connPoint );
#endif
}
#ifndef PROFILE
program->Wires()->push_back( wire );
#endif
}
return program;
}
示例3: CreateFromDescriptor
Program* ProgramManager::CreateFromDescriptor( ProgramDescriptor* descriptor )
{
int id;
string name;
string description;
DescriptorsUtil::GetIntProperty( descriptor->Properties, "Id", &id );
DescriptorsUtil::GetStringProperty( descriptor->Properties, "Name", &name );
DescriptorsUtil::GetStringProperty( descriptor->Properties, "Description",
&description );
Program* program = new Program( id, name, description );
string deviceType;
// ------ Initialize Devices:
list<DeviceDescriptor>::iterator deviceIt;
for ( deviceIt = descriptor->Devices.begin(); deviceIt
!= descriptor->Devices.end(); deviceIt++ )
{
BaseDevice* device = DeviceManager::Instance()->CreateFromDescriptor(
*deviceIt );
if( device == NULL )
return NULL;
program->AddDevice( device );
}
// ------- Initialize Wires:
list<WireDescriptor>::iterator wireIt;
list<WireConnectionPointDescriptor>::iterator cpIt; //connectionPointsIt
for ( wireIt = descriptor->Wires.begin(); wireIt != descriptor->Wires.end(); wireIt++ )
{
Wire* wire = new Wire();
for ( cpIt = ( *wireIt ).WireConnectionPoints.begin(); cpIt
!= ( *wireIt ).WireConnectionPoints.end(); cpIt++ )
{
BaseDevice* device = program->GetDevice(
( *cpIt ).DeviceDescriptorId );
ConnectionPoint* cp = device->GetConnectionPoint(
( *cpIt ).ConnectionPointDescriptorId );
wire->Attach( cp );
}
program->AddWire( wire );
}
// ------ Initialize the program's Power Wire:
list<WireConnectionPointDescriptor>* stratupPoints =
&descriptor->PowerWire.WireConnectionPoints;
for ( cpIt = stratupPoints->begin(); cpIt != stratupPoints->end(); cpIt++ )
{
int* startUpValue = new int( 1 );
BaseDevice* device = program->GetDevice( ( *cpIt ).DeviceDescriptorId );
ConnectionPoint* cp = device->GetConnectionPoint(
( *cpIt ).ConnectionPointDescriptorId );
InConnectionPoint* inConnectionPoint = (InConnectionPoint*) cp;
inConnectionPoint->SetValue( startUpValue );
program->PowerWire()->Attach( inConnectionPoint );
}
return program;
}