00001 #include "stdafx.h" 00002 00003 #include "BON.h" 00004 #include "BONImpl.h" 00005 00006 #include "ConnectionRep.h" 00007 #include "logger.h" 00008 #include "ModelRep.h" 00009 #include "CodeGen.h" 00010 00011 #include "globals.h" 00012 extern Globals global_vars; 00013 00014 00015 ConnectionRep::ConnectionRep( BON::FCO& ptr, BON::FCO& resp_ptr) 00016 : FCO( ptr, resp_ptr) 00017 { 00018 m_jointList.clear(); 00019 } 00020 00021 00022 ConnectionRep::~ConnectionRep() 00023 { 00024 m_jointList.clear(); 00025 } 00026 00027 00028 void ConnectionRep::addJoint( ConnJoint & joint) 00029 { 00030 m_jointList.push_back( joint); 00031 } 00032 00033 00034 void ConnectionRep::appendJointElements( const ConnJoint & old_joint) 00035 { 00036 ConnJoint joint( old_joint); // create a copy of the old joint 00037 joint.setConnectionPtr( this); // set the new container connection 00038 00039 if (m_jointList.empty()) 00040 m_jointList.push_back( joint); 00041 else // with some constraint, but still copying 00042 m_jointList.push_back( joint); 00043 } 00044 00045 00046 void ConnectionRep::inherit() 00047 { 00048 ModelRepPtrList models = this->modelsIAmPartOfFinal(); 00049 00050 // interface inheritance 00051 ModelRepPtrList_Iterator mod_it = models.begin(); 00052 // for all models i am part of 00053 for( ; mod_it != models.end(); ++mod_it ) 00054 { 00055 ModelRep* mod_ptr = *mod_it; 00056 00057 // for all connJoints it has 00058 std::list<ConnJoint>::iterator joint_it = m_jointList.begin(); 00059 for( ; joint_it != m_jointList.end(); ++joint_it ) 00060 { 00061 joint_it->intInherit( mod_ptr); // creates map containing src and dst roles 00062 } 00063 } 00064 00065 // implementation inheritance 00066 // not needed since the inheritance provides the needed functionality 00067 } 00068 00069 00070 std::string ConnectionRep::doDump() 00071 { 00072 std::string h_file, c_file; 00073 00074 dumpPre( h_file, c_file); 00075 00076 dumpFCO( h_file, c_file); 00077 00078 if ( !m_connMethods.empty()) 00079 h_file += CodeGen::indent(1) + "//\n" + CodeGen::indent(1) + "// connectionEnd getters\n"; 00080 00081 MethodLexicographicSort lex; 00082 std::sort( m_connMethods.begin(), m_connMethods.end(), lex); 00083 00084 std::vector<Method>::iterator i = m_connMethods.begin(); 00085 for( ; i != m_connMethods.end(); ++i) 00086 { 00087 h_file += i->getHeader() + "\n"; 00088 c_file += i->getSource() + ""; 00089 } 00090 00091 h_file += hideAndExpose(); 00092 00093 dumpPost( h_file, c_file); 00094 00095 sendOutH( h_file);//DMP_H( h_file); 00096 sendOutS( c_file);//DMP_S( c_file); 00097 00098 return ""; 00099 } 00100 00101 00102 bool ConnectionRep::checkConnectionTargets() 00103 { 00104 bool res = true; 00105 std::list<ConnJoint>::iterator joint_it = m_jointList.begin(); 00106 for( ; joint_it != m_jointList.end(); ++joint_it ) 00107 { 00108 res = res && joint_it->checkElements( getName()); 00109 } 00110 return res; 00111 } 00112 00113 00114 bool ConnectionRep::calcLCD() 00115 { 00116 std::list<ConnJoint>::iterator joint_it = m_jointList.begin(); 00117 for( ; joint_it != m_jointList.end(); ++joint_it ) 00118 joint_it->calcLCD(); 00119 00120 return true; 00121 } 00122 00123 bool ConnectionRep::createEndGetters() 00124 { 00125 std::list<ConnJoint>::iterator joint_it = m_jointList.begin(); 00126 for( ; joint_it != m_jointList.end(); ++joint_it ) 00127 { 00128 joint_it->createLinkGetters(); 00129 joint_it->createSrcDstGetters(); 00130 joint_it->createEndGetters(); 00131 } 00132 return true; 00133 } 00134