本文整理汇总了C++中pvstructure::shared_pointer::get方法的典型用法代码示例。如果您正苦于以下问题:C++ shared_pointer::get方法的具体用法?C++ shared_pointer::get怎么用?C++ shared_pointer::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pvstructure::shared_pointer
的用法示例。
在下文中一共展示了shared_pointer::get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printValue
void printValue(std::string const & channelName, PVStructure::shared_pointer const & pv)
{
if (mode == ValueOnlyMode)
{
PVField::shared_pointer value = pv->getSubField("value");
if (value.get() == 0)
{
std::cerr << "no 'value' field" << std::endl;
//std::cout << channelName << std::endl << *(pv.get()) << std::endl << std::endl;
pvutil_ostream myos(std::cout.rdbuf());
myos << channelName << std::endl << *(pv.get()) << std::endl << std::endl;
}
else
{
Type valueType = value->getField()->getType();
if (valueType != scalar && valueType != scalarArray)
{
// switch to structure mode, unless it's T-type
if (valueType == structure && isTType(static_pointer_cast<PVStructure>(value)))
{
std::cout << std::setw(30) << std::left << channelName;
std::cout << fieldSeparator;
formatTType(std::cout, static_pointer_cast<PVStructure>(value));
std::cout << std::endl;
}
else
{
//std::cout << channelName << std::endl << *(pv.get()) << std::endl << std::endl;
pvutil_ostream myos(std::cout.rdbuf());
myos << channelName << std::endl << *(pv.get()) << std::endl << std::endl;
}
}
else
{
if (fieldSeparator == ' ' && value->getField()->getType() == scalar)
std::cout << std::setw(30) << std::left << channelName;
else
std::cout << channelName;
std::cout << fieldSeparator;
terse(std::cout, value) << std::endl;
}
}
}
else if (mode == TerseMode)
terseStructure(std::cout, pv) << std::endl;
else
{
//std::cout << channelName << std::endl << *(pv.get()) << std::endl << std::endl;
pvutil_ostream myos(std::cout.rdbuf());
myos << channelName << std::endl << *(pv.get()) << std::endl << std::endl;
}
}
示例2: main
int main (int argc, char *argv[])
{
int opt; // getopt() current option
std::string testFile;
setvbuf(stdout,NULL,_IOLBF,BUFSIZ); // Set stdout to line buffering
while ((opt = getopt(argc, argv, ":hr:w:i:c:s:l:f:v")) != -1) {
switch (opt) {
case 'h': // Print usage
usage();
return 0;
case 'w': // Set PVA timeout value
if((epicsScanDouble(optarg, &timeOut)) != 1)
{
fprintf(stderr, "'%s' is not a valid timeout value "
"- ignored. ('cainfo -h' for help.)\n", optarg);
timeOut = DEFAULT_TIMEOUT;
}
break;
case 'r': // pvRequest string
request = optarg;
break;
case 'i': // iterations
iterations = atoi(optarg);
break;
case 'c': // channels
channels = atoi(optarg);
break;
case 's': // arraySize
arraySize = atoi(optarg);
break;
case 'l': // runs
runs = atoi(optarg);
break;
case 'f': // testFile
testFile = optarg;
break;
case 'v': // testFile
verbose = true;
break;
case '?':
fprintf(stderr,
"Unrecognized option: '-%c'. ('testGetPerformance -h' for help.)\n",
optopt);
return 1;
case ':':
fprintf(stderr,
"Option '-%c' requires an argument. ('testGetPerformance -h' for help.)\n",
optopt);
return 1;
default :
usage();
return 1;
}
}
// typedef enum {logLevelInfo, logLevelDebug, logLevelError, errlogFatal} errlogSevEnum;
SET_LOG_LEVEL(logLevelError);
pvRequest = CreateRequest::create()->createRequest(request);
if (pvRequest.get() == 0) {
printf("failed to parse request string\n");
return 1;
}
ClientFactory::start();
provider = ChannelProviderRegistry::clients()->getProvider("pva");
if (!testFile.empty())
{
ifstream ifs(testFile.c_str(), ifstream::in);
if (ifs.good())
{
string line;
while (true)
{
getline(ifs, line);
if (ifs.good())
{
// ignore lines that starts (no trimming) with '#'
if (line.find('#') != 0)
{
// <c> <s> <i> <l>
if (sscanf(line.c_str(), "%d %d %d %d", &channels, &arraySize, &iterations, &runs) == 4)
{
//printf("%d %d %d %d\n", channels, arraySize, iterations, runs);
runTest();
// wait a bit for a next test
epicsThreadSleep(1.0);
}
else
{
fprintf(stderr,
"Failed to parse line '%s', ignoring...\n",
line.c_str());
}
}
}
//.........这里部分代码省略.........