fw4spl
fwAtomsFilter/src/fwAtomsFilter/functions.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 
8 #include "fwAtomsFilter/functions.hpp"
9 
10 #include <fwActivities/registry/Activities.hpp>
11 
12 #include <fwAtoms/Object.hpp>
13 #include <fwAtoms/Object.hxx>
14 #include <fwAtoms/String.hpp>
15 
16 #include <fwAtomsPatch/helper/functions.hpp>
17 
18 #include <fwData/registry/detail.hpp>
19 
20 #include <algorithm>
21 #include <string>
22 
23 namespace fwAtomsFilter
24 {
25 
26 bool isSeriesKnown(const SPTR(::fwAtoms::Object)& series)
27 {
28  bool isKnown = false;
29 
30  namespace reg = ::fwActivities::registry;
31  reg::Activities::sptr registry = reg::Activities::getDefault();
32  const std::vector< reg::ActivityInfo >& infos = registry->getInfos();
33 
34  const std::string& classname = ::fwAtomsPatch::helper::getClassname(series);
35 
36  SPTR(::fwData::registry::Type) objectRegistry = ::fwData::registry::get();
37  ::fwData::registry::Type::KeyVectorType keys = objectRegistry->getFactoryKeys();
38  ::fwData::registry::Type::KeyVectorType::iterator itKey = std::find(keys.begin(), keys.end(), classname);
39 
40  if(itKey != keys.end())
41  {
42  if(classname == "::fwMedData::ActivitySeries")
43  {
44  // Check if activity config id is known
45  ::fwAtoms::String::sptr asId = series->getAttribute< ::fwAtoms::String >("activity_config_id");
46 
47  for(reg::ActivityInfo info : infos)
48  {
49  if(info.id == asId->getString())
50  {
51  isKnown = true;
52  break;
53  }
54  }
55  }
56  else
57  {
58  isKnown = true;
59  }
60  }
61 
62  return isKnown;
63 }
64 
65 } // namespace fwAtomsFilter
66 
#define SPTR(_cls_)
Contains fwAtomsFilter::registry details.
FWATOMSFILTER_API bool isSeriesKnown(const std::shared_ptr< ::fwAtoms::Object > &series)
Returns true if given atom matches a defined fwMedData::Series implementations.
FWATOMS_API Base::sptr getAttribute(const std::string &key) const
Returns requested attribute if exists, empty sptr else.
Class represented a fwData::Object.
FactoryRegistry is a class used to store factories and create instance object with these factories...
Class represented a String.