00001 //############################################################################################################################################### 00002 // 00003 // Meta and Builder Object Network V2.0 for GME 00004 // Common.cpp 00005 // 00006 //############################################################################################################################################### 00007 00008 /* 00009 Copyright (c) Vanderbilt University, 2000-2004 00010 ALL RIGHTS RESERVED 00011 00012 Vanderbilt University disclaims all warranties with regard to this 00013 software, including all implied warranties of merchantability 00014 and fitness. In no event shall Vanderbilt University be liable for 00015 any special, indirect or consequential damages or any damages 00016 whatsoever resulting from loss of use, data or profits, whether 00017 in an action of contract, negligence or other tortious action, 00018 arising out of or in connection with the use or performance of 00019 this software. 00020 */ 00021 00022 #pragma warning( disable : 4786 ) 00023 00024 #include "stdafx.h" 00025 #include "Common.h" 00026 00027 //############################################################################################################################################### 00028 // 00029 // E N U M E R A T I O N : MON::ObjectEventType 00030 // 00031 //############################################################################################################################################### 00032 00033 MON::ObjectEventType& operator ++ ( MON::ObjectEventType& eType, int ) 00034 { 00035 switch ( eType ) { 00036 case MON::OET_None : return eType = MON::OET_ObjectCreated; 00037 case MON::OET_ObjectCreated : return eType = MON::OET_ObjectDestroyed; 00038 case MON::OET_ObjectDestroyed : return eType = MON::OET_ObjectMoved; 00039 case MON::OET_ObjectMoved : return eType = MON::OET_AttributeChanged; 00040 case MON::OET_AttributeChanged : return eType = MON::OET_RegistryChanged; 00041 case MON::OET_RegistryChanged : return eType = MON::OET_RelationChanged; 00042 case MON::OET_RelationChanged : return eType = MON::OET_PropertyChanged; 00043 case MON::OET_PropertyChanged : return eType = MON::OET_ChildAdded; 00044 case MON::OET_ChildAdded : return eType = MON::OET_ChildLost; 00045 case MON::OET_ChildLost : return eType = MON::OET_ObjectReferenced; 00046 case MON::OET_ObjectReferenced : return eType = MON::OET_ObjectReleased; 00047 case MON::OET_ObjectReleased : return eType = MON::OET_ObjectIncluded; 00048 case MON::OET_ObjectIncluded : return eType = MON::OET_ObjectExcluded; 00049 case MON::OET_ObjectExcluded : return eType = MON::OET_ObjectConnected; 00050 case MON::OET_ObjectConnected : return eType = MON::OET_ObjectDisconnected; 00051 case MON::OET_ObjectDisconnected : return eType = MON::OET_DescendantCreated; 00052 case MON::OET_DescendantCreated : return eType = MON::OET_ModelClosed; 00053 case MON::OET_ModelClosed : return eType = MON::OET_All; 00054 case MON::OET_All : return eType = MON::OET_None; 00055 } 00056 return eType = MON::OET_None; 00057 } 00058 00059 MON::ObjectEventType& operator ++ ( MON::ObjectEventType& eType ) 00060 { 00061 return eType++; 00062 } 00063 00064 bool isAll( const std::set<MON::ObjectEventType>& setEvents ) 00065 { 00066 if ( setEvents.find( MON::OET_All ) != setEvents.end() ) 00067 return true; 00068 00069 for ( MON::ObjectEventType eType = MON::OET_ObjectCreated; eType != MON::OET_All ; eType++ ) 00070 if ( setEvents.find( eType ) == setEvents.end() ) 00071 return false; 00072 return true; 00073 } 00074 00075 bool isNone( const std::set<MON::ObjectEventType>& setEvents ) 00076 { 00077 if ( setEvents.find( MON::OET_None ) != setEvents.end() ) 00078 return true; 00079 00080 for ( MON::ObjectEventType eType = MON::OET_None ; eType != MON::OET_All ; eType++ ) 00081 if ( setEvents.find( eType ) != setEvents.end() ) 00082 return false; 00083 return true; 00084 } 00085 00086 std::string toString( const MON::ObjectEventType& eType ) 00087 { 00088 switch ( eType ) { 00089 case MON::OET_None : return "None"; 00090 case MON::OET_ObjectCreated : return "ObjectCreated"; 00091 case MON::OET_ObjectDestroyed : return "ObjectDestroyed"; 00092 case MON::OET_ObjectMoved : return "ObjectMoved"; 00093 case MON::OET_AttributeChanged : return "AttributeChanged"; 00094 case MON::OET_RegistryChanged : return "RegistryChanged"; 00095 case MON::OET_RelationChanged : return "RelationChanged"; 00096 case MON::OET_PropertyChanged : return "PropertyChanged"; 00097 case MON::OET_ChildAdded : return "ChildAdded"; 00098 case MON::OET_ChildLost : return "ChildLost"; 00099 case MON::OET_ObjectReferenced : return "ObjectReferenced"; 00100 case MON::OET_ObjectReleased : return "ObjectReleased"; 00101 case MON::OET_ObjectIncluded : return "ObjectIncluded"; 00102 case MON::OET_ObjectExcluded : return "ObjectExcluded"; 00103 case MON::OET_ObjectConnected : return "ObjectConnected"; 00104 case MON::OET_ObjectDisconnected : return "ObjectDisconnected"; 00105 case MON::OET_DescendantCreated : return "DescendantCreated"; 00106 case MON::OET_ModelClosed : return "ModelClosed"; 00107 case MON::OET_All : return "All"; 00108 } 00109 return "None"; 00110 } 00111 00112 MON::ObjectEventTypes copy( const std::set<MON::ObjectEventType>& setEvents ) 00113 { 00114 MON::ObjectEventTypes ulEvents = 0; 00115 for ( MON::ObjectEventType eType = MON::OET_None ; eType != MON::OET_All ; eType++ ) 00116 if ( setEvents.find( eType ) != setEvents.end() ) 00117 ulEvents |= eType; 00118 return ulEvents; 00119 } 00120 00121 std::set<MON::ObjectEventType> copy( MON::ObjectEventTypes ulEvents ) 00122 { 00123 std::set<MON::ObjectEventType> setEvents; 00124 for ( MON::ObjectEventType eType = MON::OET_None ; eType != MON::OET_All ; eType++ ) 00125 if ( ulEvents & eType ) 00126 setEvents.insert( eType ); 00127 return setEvents; 00128 } 00129 00130 std::string toString( MON::ObjectType eType, bool bWithNameSpace ) 00131 { 00132 std::string str; 00133 switch ( eType ) { 00134 case MON::OT_Model : str = "Model"; break; 00135 case MON::OT_Atom : str = "Atom"; break; 00136 case MON::OT_Reference : str = "Reference"; break; 00137 case MON::OT_Connection : str = "Connection"; break; 00138 case MON::OT_Set : str = "Set"; break; 00139 case MON::OT_Folder : str = "Folder"; break; 00140 case MON::OT_Aspect : str = "Aspect"; break; 00141 case MON::OT_Role : str = "Containment"; break; 00142 case MON::OT_Attribute : str = "Attribute"; break; 00143 case MON::OT_Part : str = "ContainmentPart"; break; 00144 default : return "Null"; 00145 } 00146 return ( bWithNameSpace ) ? "MON::" + str : str; 00147 } 00148 00149 std::string toString( BON::ObjectType eType, bool bWithNameSpace ) 00150 { 00151 std::string str; 00152 switch ( eType ) { 00153 case BON::OT_Model : str = "Model"; break; 00154 case BON::OT_Atom : str = "Atom"; break; 00155 case BON::OT_Reference : str = "Reference"; break; 00156 case BON::OT_Connection : str = "Connection"; break; 00157 case BON::OT_Set : str = "Set"; break; 00158 case BON::OT_Folder : str = "Folder"; break; 00159 default : return "Null"; 00160 } 00161 return ( bWithNameSpace ) ? "BON::" + str : str; 00162 }