torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Cloning.cpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 #include "torc/generic/Cloning.hpp"
17 
18 namespace torc {
19 namespace generic {
20 
21 void copyParams(const Instance& inOriginal, const InstanceSharedPtr& outCloned,
22  const ObjectFactorySharedPtr& inFactory) {
23 
24  ParameterMapSharedPtr params = inOriginal.getParameters();
25  ParameterMapSharedPtr clonedParams = outCloned->getParameters();
26  ParameterContext origContext = inOriginal.getParameterContext();
27  ParameterContext clonedContext = outCloned->getParameterContext();
28  std::map<std::string, ParameterSharedPtr> overriddenParams;
29  params->getOverriddenParameters(origContext, overriddenParams);
30  for(std::map<std::string, ParameterSharedPtr>::iterator it = overriddenParams.begin();
31  it != overriddenParams.end(); ++it) {
32  ParameterSharedPtr clonedParam = clone((*it).second, inFactory);
33  clonedParams->set(clonedContext, (*it).first, clonedParam);
34  }
35 }
36 
37 } //namespace generic
38 } //namespace torc
boost::shared_ptr< Instance > InstanceSharedPtr
Represents an instantiation of a cell view in the view of another cell.
virtual ParameterContext getParameterContext() const
boost::shared_ptr< Parameter > ParameterSharedPtr
boost::shared_ptr< ObjectFactory > ObjectFactorySharedPtr
boost::shared_ptr< _Tp > clone(const boost::shared_ptr< _Tp > &inPointer, const ObjectFactorySharedPtr &inFactory)
Definition: Cloning.hpp:63
virtual ParameterMapSharedPtr getParameters() const
void copyParams(const Instance &inOriginal, const InstanceSharedPtr &outCloned, const ObjectFactorySharedPtr &inFactory)
Definition: Cloning.cpp:21
boost::shared_ptr< ParameterMap > ParameterMapSharedPtr