📄 base_instancecollection.h
字号:
/*
Copyright (c) 2008, Intel Corporation.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*///==============================================================================// base_InstanceCollection.h////==============================================================================#ifndef _BASE_INSTANCECOLLECTION_H#define _BASE_INSTANCECOLLECTION_H#include <vector>#include "inc/framework/base_Object.h"#include "inc/framework/base_Event.h"#include "inc/framework/base_Exception.h"using namespace std;class ServerClassObject;class ServerInstanceCollection;class ServerInstanceObject;struct MonitorParm{ vector<ServerInstanceObject*>* m_pObjects; ServerInstanceCollection* m_this;};// This is a enumeration objectclass ServerInstanceCollection : public ServerObject{public: ServerInstanceCollection( CLog &theLog, const IntelMobileString sType, ServerClassObject *pParentClass = NULL ); //ServerInstanceCollection( const IntelMobileString sType, ServerClassObject *pParentClass = NULL ); virtual ~ServerInstanceCollection(); virtual bool Current( ServerInstanceObject** pCurrent, int iCurrentIndex, long iChangedIndex ); virtual bool Next( ServerInstanceObject** pNext, int* iCurrentIndex, long iChangedIndex ); virtual bool HasNext( int iCurrentIndex, long iChangedIndex ); virtual void Reset( long* iChangedIndex ); // not for CurrentIndex, returns the current "Changed" index // Must create own because each does specific things with each InstanceObject vector. virtual int Add( ServerInstanceObject* _Instance ); // Virtual because each collection has its own vector virtual int Remove( ServerInstanceObject* _Instance ); // Virtual because each collection has its own vector void Modify( ServerEvent::EventType eType ); // Used to tell collection that something has changed, will navigate up all levels calling Modify() on those appropriately // inlines inline void SetParentClass( ServerClassObject *pParentClass ) { __cParentClass = pParentClass; } virtual int GetCount() const { return static_cast<int>(__pObjects.size()); } // Gets count of this collection only, no sub collections of associated class // Only used from server sideprotected: virtual ServerInstanceObject* CurrentImpl( int iCurrentIndex ); bool HasChanged( long iChangedIndex ) const; // internal check to see if structure has been modified from previous call of ServerInstanceCollection int GetSubClassCount() const; // Gets collection of sub collections of parent class only int GetTotalCount() const; // Gets the total count of it and all sub classes GetTotalCount() = GetSubClassCount() + GetCount() bool HasNextImpl( int iCurrentIndex, long iChangedIndex ) const; bool IsContained( ServerInstanceObject** pObject, int iCurrentIndex ); //==============================================================================// These might be taken out, depends on Threshold implementation taking over// this functionality.// For automatic event signaling for property change events bool CreateMonitoringThread( const unsigned int iTheta ); void DestroyMonitoringThread(); static DWORD WINAPI MonitoringThread( /*in*/ LPVOID param);//==============================================================================protected: long __lChangedIndex; ServerClassObject* __cParentClass; // needed so that we can navigate up for Modify() function. HANDLE __hMonitoringThread; DWORD __dwMonitoringThreadId; vector<ServerInstanceObject*> __pObjects; // No copies allowed!};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -