00001 #include "stdafx.h" 00002 00003 #include "RootFolder.h" 00004 #include "Broker.h" 00005 #include "Any.h" 00006 00007 #include "algorithm" 00008 extern int ind; 00009 00010 00011 void RootFolder::addRootElement( FCO * ptr) 00012 { 00013 m_fcoList.push_back( ptr); 00014 } 00015 00016 00017 bool RootFolder::isInRoot( FCO * ptr) const 00018 { 00019 FCO_ConstIterator fco_it = std::find( m_fcoList.begin(), m_fcoList.end(), ptr); 00020 return fco_it != m_fcoList.end(); 00021 } 00022 00023 00024 bool RootFolder::isEmpty() const 00025 { 00026 return m_fcoList.empty() && m_subFolderList.empty(); 00027 } 00028 00029 00030 void RootFolder::addSubFolder( FolderRep *ptr) 00031 { 00032 m_subFolderList.push_back( ptr); 00033 } 00034 00035 00036 std::string RootFolder::headDump() 00037 { 00038 ++ind; 00039 std::string mmm = indStr() + "<folder name = \"RootFolder\" metaref = \"" + Broker::ROOTFOLDER_METAREF_STR + "\" "; 00040 00041 AnyLexicographicSort lex; 00042 std::sort( m_subFolderList.begin(), m_subFolderList.end(), lex); 00043 SubFolder_ConstIterator it_f = m_subFolderList.begin(); 00044 if ( it_f != m_subFolderList.end()) 00045 { 00046 mmm +=" subfolders = \""; 00047 bool first = true; 00048 while( it_f != m_subFolderList.end()) 00049 { 00050 if (!first) mmm += " "; 00051 mmm += (*it_f)->getName(); 00052 first = false; 00053 ++it_f; 00054 } 00055 mmm +="\""; 00056 } 00057 00058 std::sort( m_fcoList.begin(), m_fcoList.end(), lex); 00059 00060 if ( !m_fcoList.empty()) 00061 { 00062 std::string nnn; 00063 bool first = true; 00064 FCO_ConstIterator it = m_fcoList.begin(); 00065 while ( it != m_fcoList.end()) 00066 { 00067 if ((*it)->isFCO() && !(*it)->isAbstract()) 00068 { 00069 if ( !first) nnn += " "; 00070 nnn += (*it)->getName(); 00071 first = false; 00072 } 00073 ++it; 00074 } 00075 00076 if ( !nnn.empty()) 00077 mmm += " rootobjects = \"" + nnn + "\""; 00078 } 00079 mmm += " >\n"; 00080 return mmm; 00081 } 00082 00083 00084 std::string RootFolder::tailDump() 00085 { 00086 --ind; 00087 std::string mmm; 00088 mmm = indStr() + "</folder>\n"; 00089 00090 return mmm; 00091 }