본문 바로가기

Native/C++

EventQueue

[code]#include <list>

class CSmartPoint
{
    // This function is auto_ptr(STL) same.
};

class CCDEventData
    : public CSmartPoint
{
public:
    virtual void Processing();
    virtual void SetData();
};

class CCDWidgetImageData
    : public CCDEventData
{
public:
    virtual void Processing()
    {
        std::string szID    = "OtherID";
        std::string szValue = "OtherValue";
    }

    void SetData()
    {
        
    }
};

//
// WidgetImage class type definition
//
typedef CSmartPointer<CCDWidgetImageData*, CCDWidgetImageData&> CCDWidgetImageDataT;[/code]

[code]
class CCDEvent
    : public CCDSingleToneEx<CCDEvent, CSmartPoint>
{
protected:
    std::list<CCDEventData*> _arrEventQueue;

public:
    void PushEvent(CCDEventData* pEventData)
    {
        _arrEventQueue.push_back(pEventData);
    }

    CCDEventData* PopEvent()
    {
        return _arrEventQueue.pop_front();
    }

    size_t GetCount()
    {
        return _arrEventQueue.size();
    }
};[/code]
[code]
//
// Event message type?
//
enum eMyType
{
    eType1,
    eType2
};[/code]
[code]
void main()
{
    CCDEvent objEvent;

    int nValue = 0;

    nValue = OtherFunction();

    //
    // Event loop
    //
    switch(argv)
    {
    case eType1:
        {
            CCDWidgetImageDataT pWidgetImageData(new CCDWidgetImageData);
            objEvent.PushEvent(pWidgetImageData);
        }
        break;

    case eType2;
        break;
    }
}[/code]

[code]
//
// This is callback function
//
void main2()
{
    CCDEvent* pEvent = CCDEvent::getInstance();

    while (true)
    {
        if (pEvent->GetCount())
        {
            CCDEventData* pData = pEvent->PopEvent();
            pData->Processing();
        }
    }
}[/code]

간단히 생각해봐서 지금에 Source 문제점을 보안한? 이벤트 큐 처리 클래스 만든시간 약 10분 정도라서 -ㅅ- 역시나 날림으로~ ㅎ

'Native > C++' 카테고리의 다른 글

STLport  (0) 2013.10.02
boost install  (0) 2013.10.02
DLOPEN  (0) 2013.10.02
singletone  (0) 2013.10.02
virtual int memberFunc() = 0; 에서 = 0 에 의미  (0) 2013.10.02