model_impl.h
Go to the documentation of this file.
00001 /******************************************************************************
00002  *   Copyright (C) 2013-2014 by Alexander Rykovanov                        *
00003  *   rykovanov.as@gmail.com                                                   *
00004  *                                                                            *
00005  *   This library is free software; you can redistribute it and/or modify     *
00006  *   it under the terms of the GNU Lesser General Public License as           *
00007  *   published by the Free Software Foundation; version 3 of the License.     *
00008  *                                                                            *
00009  *   This library is distributed in the hope that it will be useful,          *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00012  *   GNU Lesser General Public License for more details.                      *
00013  *                                                                            *
00014  *   You should have received a copy of the GNU Lesser General Public License *
00015  *   along with this library; if not, write to the                            *
00016  *   Free Software Foundation, Inc.,                                          *
00017  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                *
00018  ******************************************************************************/
00019 
00020 #pragma once
00021 
00022 #include <opc/ua/model.h>
00023 
00024 namespace OpcUa
00025 {
00026   namespace Model
00027   {
00028     template <typename T>
00029     std::vector<T> Browse(const NodeId& node, NodeClass nodeClassMask, Services::SharedPtr services)
00030     {
00031       BrowseDescription desc;
00032       desc.Direction = BrowseDirection::Forward;
00033       desc.IncludeSubtypes = true;
00034       desc.NodeClasses =   nodeClassMask;
00035       desc.ReferenceTypeId = ObjectId::HierarchicalReferences;
00036       desc.NodeToBrowse = node;
00037       desc.ResultMask = BrowseResultMask::None;
00038 
00039       NodesQuery query;
00040       query.NodesToBrowse.push_back(desc);
00041       ViewServices::SharedPtr views = services->Views();
00042       std::vector<BrowseResult> results = views->Browse(query);
00043 
00044       std::vector<T> objects;
00045       std::for_each(results[0].Referencies.begin(), results[0].Referencies.end(), [&node, &services, &objects](const ReferenceDescription& ref){
00046         objects.push_back(T(ref.TargetNodeId, services));
00047       });
00048 
00049       return objects;
00050     }
00051   }
00052 }


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Sat Jun 8 2019 18:24:56