STDMETHODIMP COPCBrowserImpl::ShowBranches() { // Clear out the list ClearNames(); // Get the Branch names IEnumString* pEnumString = NULL; HRESULT hr = m_pOPCBrowser->BrowseOPCItemIDs(OPC_BRANCH, m_filter, m_dataType, m_accessRights, &pEnumString); if( SUCCEEDED(hr) ) { // Enumerate all the names, saving them in the list LPWSTR pName[NEXT_COUNT]; ULONG count = 0; do { hr = pEnumString->Next(NEXT_COUNT, &pName[0], &count); for( ULONG index=0; index<count; index++ ) { m_names.push_back( new CComBSTR( pName[index] ) ); CoTaskMemFree( pName[index] ); } } while( hr == S_OK ); pEnumString->Release(); } return hr; }
///////////////////////////////////////////////////////////////////// // OPCBrowser::MoveDown method STDMETHODIMP COPCBrowserImpl::MoveDown( BSTR Branch) { // Clear out the list ClearNames(); HRESULT hr = m_pOPCBrowser->ChangeBrowsePosition( OPC_BROWSE_DOWN, Branch ); return hr; }
///////////////////////////////////////////////////////////////////// // OPCBrowser::MoveUp method STDMETHODIMP COPCBrowserImpl::MoveUp() { // Clear out the list ClearNames(); HRESULT hr = m_pOPCBrowser->ChangeBrowsePosition( OPC_BROWSE_UP, empty ); return hr; }
bool ClassHeaderGenerator::ProcessElementDef( const TiXmlElement* field ) { const char* name = field->Attribute("name"); if( name == NULL ) { _log( COMMON__ERROR, "<element> at line %d is missing the name attribute, skipping.", field->Row() ); return false; } const TiXmlElement* main = field->FirstChildElement(); if( main->NextSiblingElement() != NULL ) { _log( COMMON__ERROR, "<element> at line %d contains more than one root element. skipping.", field->Row() ); return false; } const char* encode_type = GetEncodeType( main ); fprintf( mOutputFile, "class %s\n" "{\n" "public:\n" " %s();\n" " %s( const %s& oth );\n" " ~%s();\n" "\n" " void Dump( LogType type, const char* pfx = \"\" ) const;\n" "\n" " bool Decode( PyRep* packet );\n" " bool Decode( PyRep** packet );\n" " bool Decode( %s** packet );\n" " %s* Encode() const;\n" "\n" " %s& operator=( const %s& oth );\n" "\n", name, name, name, name, name, encode_type, encode_type, name, name ); if( !ParseElement( main ) ) return false; fprintf( mOutputFile, "};\n" "\n" ); ClearNames(); return true; }
///////////////////////////////////////////////////////////////////// // OPCBrowser::MoveToRoot method STDMETHODIMP COPCBrowserImpl::MoveToRoot() { // Clear out the list ClearNames(); HRESULT hr = S_OK; for( int i=0; i<50 && SUCCEEDED(hr); i++ ) hr = m_pOPCBrowser->ChangeBrowsePosition( OPC_BROWSE_UP, empty ); return S_OK; }
STDMETHODIMP COPCBrowserImpl::ShowLeafs( VARIANT Flat) { // Clear out the list ClearNames(); // Get the Leaf names IEnumString* pEnumString = NULL; HRESULT hr = S_OK; if ((Flat.vt==VT_BOOL) && (Flat.boolVal)) { hr = m_pOPCBrowser->BrowseOPCItemIDs(OPC_FLAT, m_filter, m_dataType, m_accessRights, &pEnumString); } else { hr = m_pOPCBrowser->BrowseOPCItemIDs(OPC_LEAF, m_filter, m_dataType, m_accessRights, &pEnumString); } if( SUCCEEDED(hr) ) { // Enumerate all the names, saving them in the list LPWSTR pName[NEXT_COUNT]; ULONG count = 0; do { hr = pEnumString->Next(NEXT_COUNT, &pName[0], &count); for( ULONG index=0; index<count; index++ ) { m_names.push_back( new CComBSTR( pName[index] ) ); CoTaskMemFree( pName[index] ); } } while( hr == S_OK ); pEnumString->Release(); } return hr; }
///////////////////////////////////////////////////////////////////// // OPCBrowser::MoveTo method STDMETHODIMP COPCBrowserImpl::MoveTo( SAFEARRAY ** ppBranches ) { if(*ppBranches == NULL) return E_INVALIDARG; // Clear out the list ClearNames(); HRESULT hr = S_OK; LONG lBound=0; LONG uBound=0; // ServerHandles hr = SafeArrayGetLBound(*ppBranches, 1, &lBound); if( FAILED(hr) ) return hr; hr = SafeArrayGetUBound(*ppBranches, 1, &uBound); if( FAILED(hr) ) return hr; hr = MoveToRoot(); if( FAILED(hr) ) return hr; for( LONG index=lBound; index<=uBound; index++ ) { BSTR Branch; hr = SafeArrayGetElement(*ppBranches, &index, &Branch); if( FAILED(hr) ) return hr; if(*Branch != 0 ) { hr = m_pOPCBrowser->ChangeBrowsePosition( OPC_BROWSE_DOWN, Branch ); SysFreeString( Branch ); if( FAILED(hr) ) return hr; } } return hr; }
COPCBrowserImpl::~COPCBrowserImpl() { ClearNames(); }