本文整理汇总了C++中Program::GetDevice方法的典型用法代码示例。如果您正苦于以下问题:C++ Program::GetDevice方法的具体用法?C++ Program::GetDevice怎么用?C++ Program::GetDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Program
的用法示例。
在下文中一共展示了Program::GetDevice方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseProgram
Program* UpcbJsonParser::ParseProgram( string json )
{
size_t idIndex;
size_t programDescrIndex;
size_t devicesIndex;
size_t nameIndex;
size_t powerwireIndex;
size_t wiresIndex;
size_t devTypeIndex;
size_t devPropsIndex;
size_t start, end;
size_t startIndex = 0;
size_t startFrom = 0;
size_t bracketIndex = 0;
size_t keyIndex;
size_t valueIndex;
size_t typeIndex;
string id;
string programDescription;
string devices;
string name;
string powerWire;
string wires;
string deviceType;
string deviceProperties;
string cpId;
string propertyKey;
string propertyValue;
string propertyType;
idIndex = json.find( JsonParameters::Id );
programDescrIndex = json.find( JsonParameters::ProgramDescription );
devicesIndex = json.find( JsonParameters::Devices );
nameIndex = json.find( JsonParameters::Name );
powerwireIndex = json.find( JsonParameters::PowerWire );
wiresIndex = json.find( JsonParameters::Wires );
start = idIndex + JsonParameters::Id.size() + 2; //":
end = programDescrIndex - 2;
id = json.substr( start, end - start );
start = programDescrIndex + JsonParameters::ProgramDescription.size() + 3; //":"
end = devicesIndex - 3;
programDescription = json.substr( start, end - start );
start = devicesIndex + JsonParameters::Devices.size() + 3; //":[
end = nameIndex - 3;
devices = json.substr( start, end - start );
start = nameIndex + JsonParameters::Name.size() + 3; //":"
end = powerwireIndex - 3;
name = json.substr( start, end - start );
start = powerwireIndex + JsonParameters::PowerWire.size() + 3;
end = wiresIndex - 3;
powerWire = json.substr( start, end - start );
start = wiresIndex + JsonParameters::Wires.size() + 3;
end = json.size() - 2;
wires = json.substr( start, end - start );
#ifndef PROFILE
Program* program = new Program( atoi( id.c_str() ), name, programDescription );
#else
Program* program = NULL;
#endif
BaseDevice* device;
ConnectionPoint* connPoint;
// Resolve Devices:
while ( true )
{
idIndex = devices.find( JsonParameters::Id, startIndex );
if ( idIndex == string::npos)
break;
devTypeIndex = devices.find( JsonParameters::DeviceType, startIndex );
devPropsIndex = devices.find( JsonParameters::DeviceProperties, startIndex );
start = idIndex + JsonParameters::Id.size() + 2;
end = devTypeIndex - 2;
id = devices.substr( start, end - start );
start = devTypeIndex + JsonParameters::DeviceType.size() + 3;
end = devPropsIndex - 3;
deviceType = devices.substr( start, end - start );
#ifndef PROFILE
device = DeviceManager::Instance()->GetDevice( deviceType.c_str() );
if( device == NULL )
{
// LOG !
return NULL;
}
device->SetId( atoi( id.c_str() ) );
program->AddDevice( device );
#endif
//.........这里部分代码省略.........
示例2: 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;
}