00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "torc/generic/om/DumpRestoreConfig.hpp"
00017
00018 #ifndef HAVE_CONFIG_H
00019 #include "torc/generic/config.h"
00020 #endif
00021
00022
00023 #include <boost/bind.hpp>
00024 #include <boost/mem_fn.hpp>
00025 #ifdef GENOM_SERIALIZATION
00026 #include <boost/archive/binary_iarchive.hpp>
00027 #include <boost/archive/binary_oarchive.hpp>
00028 #include <boost/serialization/base_object.hpp>
00029 #include <boost/serialization/export.hpp>
00030 #endif //GENOM_SERIALIZATION
00031
00032 #include "torc/generic/om/InstanceArray.hpp"
00033
00034 #ifdef GENOM_SERIALIZATION
00035 BOOST_CLASS_EXPORT( torc::generic::InstanceArray )
00036 #endif //GENOM_SERIALIZATION
00037
00038 namespace torc {
00039
00040 namespace generic {
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 InstanceArraySharedPtr
00056 InstanceArray::Factory::newInstanceArrayPtr( const std::string &inName,
00057 const ViewSharedPtr &inViewPtr,
00058 const ViewSharedPtr &inMaster,
00059 const size_t &inSize,
00060 const ChildFactorySharedPtr &inFactory,
00061 const std::string &inOriginalName ) throw(Error) {
00062 try
00063 {
00064 std::vector<size_t> limits;
00065 limits.push_back( inSize );
00066 return newInstanceArrayPtr( inName, inViewPtr, inMaster, limits, inFactory, inOriginalName );
00067 }
00068 catch( Error &e )
00069 {
00070 e.setCurrentLocation(
00071 __FUNCTION__, __FILE__, __LINE__ );
00072 throw;
00073 }
00074 }
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 InstanceArraySharedPtr
00090 InstanceArray::Factory::newInstanceArrayPtr( const std::string &inName,
00091 const ViewSharedPtr &inViewPtr,
00092 const ViewSharedPtr &inMaster,
00093 const std::vector<size_t> &inLimits,
00094 const ChildFactorySharedPtr &inFactory,
00095 const std::string &inOriginalName ) throw(Error) {
00096 try
00097 {
00098 InstanceArraySharedPtr newInstanceArray;
00099 create( newInstanceArray );
00100 newInstanceArray->setName(inName);
00101
00102 newInstanceArray->constructChildren( inFactory, inLimits);
00103 newInstanceArray->bindToMasterView( inMaster );
00104 newInstanceArray->setOriginalName( inOriginalName );
00105 inViewPtr->addInstance( newInstanceArray );
00106 return newInstanceArray;
00107 }
00108 catch( Error &e )
00109 {
00110 e.setCurrentLocation(
00111 __FUNCTION__, __FILE__, __LINE__ );
00112 throw;
00113 }
00114 }
00115 void
00116 InstanceArray::accept(BaseVisitor & inoutVisitor) throw(Error) {
00117 try
00118 {
00119 runVisitor( *this, inoutVisitor );
00120 }
00121 catch( Error &e )
00122 {
00123 e.setCurrentLocation(
00124 __FUNCTION__, __FILE__, __LINE__ );
00125 throw;
00126 }
00127 }
00128
00129 void
00130 InstanceArray::setParent(
00131 const ViewSharedPtr &inParent ) throw() {
00132 ParentedObject<View>::setParent( inParent );
00133 BaseVectorType::List children;
00134 getCreatedChildren( children );
00135 std::for_each( children.begin(), children.end(),
00136 boost::bind( boost::mem_fn(
00137 &Instance::setParent), _1, getParent() ));
00138 }
00139
00140 void
00141 InstanceArray::bindToMasterView(
00142 const ViewSharedPtr &inMaster,
00143 bool inMapPortReferences ) throw(Error) {
00144 typedef std::vector< InstanceSharedPtr >
00145 Children;
00146 Children children;
00147 getChildren( children );
00148 Children::iterator child = children.begin();
00149 Children::iterator cEnd = children.end();
00150 for( ; child != cEnd; ++child )
00151 {
00152 try
00153 {
00154 (*child)->bindToMasterView( inMaster );
00155 }
00156 catch( Error &e )
00157 {
00158 e.setCurrentLocation(
00159 __FUNCTION__, __FILE__, __LINE__ );
00160 throw;
00161 }
00162 }
00163 Instance::bindToMasterView( inMaster, false );
00164 }
00165
00166 void
00167 InstanceArray::addPortReference(
00168 const PortReferenceSharedPtr & inPortRef) throw(Error) {
00169
00170 }
00171
00172 PortReferenceSharedPtr
00173 InstanceArray::findPortReference(
00174 const std::string &inName) throw(Error) {
00175
00176 return PortReferenceSharedPtr();
00177 }
00178
00179 void
00180 InstanceArray::removePortReference(
00181 const std::string &inName) throw(Error) {
00182
00183 }
00184
00185 void
00186 InstanceArray::getPortReferences(
00187 std::vector< PortReferenceSharedPtr > &outPortRefs
00188 ) const throw() {
00189 return;
00190 }
00191
00192
00193 void
00194 InstanceArray::setPortReferences(
00195 const std::vector< PortReferenceSharedPtr > &inSource
00196 ) throw( Error ) {
00197
00198 }
00199
00200
00201
00202
00203 void InstanceArray::flatten() throw(Error) {
00204
00205 }
00206
00207 void
00208 InstanceArray::onChildCreate( const boost::shared_ptr<BaseVectorType::ChildType> &inCreatedChild
00209 ) const throw(Error) {
00210 inCreatedChild->setName( getName() );
00211 }
00212
00213 InstanceArray::InstanceArray()
00214 :Instance(),
00215 Vector<Instance, InstanceArrayMember,
00216 InstanceArrayMember::Factory, false>() {
00217 }
00218
00219 InstanceArray::~InstanceArray() throw() {
00220 }
00221
00222 #ifdef GENOM_SERIALIZATION
00223 template<class Archive> void
00224 InstanceArray::serialize( Archive &ar, unsigned int ) {
00225 ar & boost::serialization::base_object<Instance>( *this );
00226 ar & boost::serialization::base_object< BaseVectorType >( *this );
00227 }
00228
00229
00230 template void
00231 InstanceArray::serialize<boost::archive::binary_iarchive>(
00232 boost::archive::binary_iarchive & ar, const unsigned int);
00233
00234 template void
00235 InstanceArray::serialize<boost::archive::binary_oarchive>(
00236 boost::archive::binary_oarchive & ar, const unsigned int);
00237
00238 #endif //GENOM_SERIALIZATION
00239
00240
00241 }
00242
00243 }