/** * @file XTPCalendarResourcesManager.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ #if !defined(_XTPCALENDAR_RESOURCES_MANAGER_H_) # define _XTPCALENDAR_RESOURCES_MANAGER_H_ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPCalendarResourcesManager; class CCalendarResourcesDlg; class CXTPCalendarResource; /** @cond */ XTP_DEFINE_SMART_PTR_INTERNAL(CXTPCalendarResource) /** @endcond */ /** * @brief * This class is a wrapper for CXTPCalendarResource class. * It is needed for easier processing in scope of CXTPCalendarResourcesManager. */ class _XTP_EXT_CLASS CXTPCalendarResourceDescription : public CXTPCmdTarget { /** @cond */ DECLARE_DYNAMIC(CXTPCalendarResourceDescription) /** @endcond */ public: /** * @brief * Default object constructor. */ CXTPCalendarResourceDescription(); BOOL m_bEnabled; /**< This flag indicates is resource enabled.*/ BOOL m_bGenerateName; /**< This flag indicates that resource name should be generated from the schedule(s) name(s).*/ CXTPCalendarResourcePtr m_ptrResource; /**< A smart pointer to the resource object.*/ protected: # ifdef _XTP_ACTIVEX DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPCalendarResourceDescription) LPDISPATCH OleGetResource(); void OleSetResource(LPDISPATCH pDispResource); # endif }; /** * @brief * This class is used as a helper to manage calendar resources (and schedules) * data configurations. */ class _XTP_EXT_CLASS CXTPCalendarResourcesManager : public CXTPCmdTarget { /** @cond */ DECLARE_DYNCREATE(CXTPCalendarResourcesManager) /** @endcond */ public: /** * @brief * Default object constructor. */ CXTPCalendarResourcesManager(); /** * @brief * Default object destructor. */ virtual ~CXTPCalendarResourcesManager(); /** * @brief * This enum specifies data provider flags. */ enum XTPEnumCalendarDataProviderFlags { xtpCalendarDPFUnknown = 0, /**< Zero value flag*/ xtpCalendarDPF_CreateIfNotExists = 0x001, /**< Call Create method of data provider if Open method returns FALSE.*/ xtpCalendarDPF_SaveOnDestroy = 0x010, /**< Call Save method of data provider on Resources Manager destroy.*/ xtpCalendarDPF_CloseOnDestroy = 0x020, /**< Call Close method of data provider on Resources Manager destroy.*/ }; /** * @brief * Adds a new data provider to the data providers collection using a * specified Calendar connection string. * * @param pcszConnectionString A text Calendar connection string. * @param eDPFlags Additional flags to control data provider creation/Opening and * destruction/Closing. * * @return TRUE if operation is successful, FALSE otherwise. * * @see SetDataProvider * @see XTPEnumCalendarDataProviderFlags * @see CXTPCalendarControl::CreateDataProvider * @see CXTPCalendarData overview */ BOOL AddDataProvider(LPCTSTR pcszConnectionString, int eDPFlags = xtpCalendarDPF_CreateIfNotExists); /** * @brief * Set a new data provider to data providers collection using * specified Calendar connection string. * * @param nIndex Index of the data provider in the collection. * @param pcszConnectionString A text Calendar connection string. * @param eDPFlags Additional flags to control data provider creation/Opening and * destruction/Closing. * * @return TRUE if operation is successful, FALSE otherwise. * * @see * AddDataProvider, XTPEnumCalendarDataProviderFlags, * CXTPCalendarControl::CreateDataProvider, CXTPCalendarData overview. */ BOOL SetDataProvider(int nIndex, LPCTSTR pcszConnectionString, int eDPFlags = xtpCalendarDPF_CreateIfNotExists); /** * @brief * Retrieve data providers count in the collection. * * @return Data providers count. * * @see GetDataProvider * @see AddDataProvider * @see SetDataProvider * @see RemoveDataProvider */ int GetDataProvidersCount() const; /** * @brief * Retrieve data provider at specified index. * * @param nIndex Zero-based data provider index in the collection. * * @return Data provider at specified index. * * @see GetDataProvidersCount * @see AddDataProvider * @see SetDataProvider * @see RemoveDataProvider */ CXTPCalendarData* GetDataProvider(int nIndex) const; /** * @brief * Remove data provider at specified index. * * @param nIndex Zero-based data provider index in the collection. * * @see GetDataProvidersCount * @see GetDataProvider * @see AddDataProvider * @see SetDataProvider */ void RemoveDataProvider(int nIndex); /** * @brief * Call this method to find a data provider by a connection string. * * @param pcszConnectionString A text Calendar connection string. * @param pnIndex A pointer to receive data provider index in the collection. * * @return Pointer to a data provider with specified connection string if such * presents in the collection, NULL otherwise. * * @see GetDataProvider_ConnStr */ CXTPCalendarData* GetDataProvider(LPCTSTR pcszConnectionString, int* pnIndex = NULL) const; /** * @brief * Retrieve a text Calendar connection string for data provider at * specified index. * * @param nIndex Zero-based data provider index in the collection. * * @return A text Calendar connection string. * * @see GetDataProvider */ CString GetDataProvider_ConnStr(int nIndex) const; /** * @brief * Adds a new data resource to the calendar resources collection. * * @param pcszName Resource name string. * @param bEnabled Is resource enabled. * * @return TRUE if operation is successful, FALSE otherwise. * * @see GetResourcesCount * @see GetResource * @see RemoveResource * @see MoveResource */ BOOL AddResource(LPCTSTR pcszName, BOOL bEnabled); /** * @brief * Retrieve the calendar data resources count for the collection. * * @return Calendar data resources count for the collection. * * @see AddResource * @see GetResourcesCount * @see RemoveResource * @see MoveResource */ int GetResourcesCount() const; /** * @brief * Retrieve resource at specified index. * * @param nIndex Zero-based resource index in the collection. * * @return Calendar resource at specified index. * * @see AddResource * @see GetResourcesCount * @see RemoveResource * @see MoveResource */ CXTPCalendarResourceDescription* GetResource(int nIndex) const; /** * @brief * Remove resource at specified index. * * @param nIndex Zero-based resource index in the collection. * * @see AddResource * @see GetResourcesCount * @see GetResource * @see MoveResource */ void RemoveResource(int nIndex); /** * @brief * Move resource to a new position in the collection. * * @param nIndex Current zero-based resource index in the collection. * @param nNewIndex A new index to move resource to. * * @see AddResource * @see GetResourcesCount * @see GetResource * @see RemoveResource */ void MoveResource(int nIndex, int nNewIndex); /** * @brief * This method reads data providers and resources configuration from or * writes data providers and resources configuration to storage. * * @param pPX A CXTPPropExchange object to serialize to or from. * * @see SaveCfg * @see LoadCfg */ void DoExchangeCfg(CXTPPropExchange* pPX); /** * @brief * This method writes data providers and resources configuration to * a specified file. * * @param pcszFile A file name to store configuration. * * @return TRUE if operation is successful, FALSE otherwise. * * @see LoadCfg * @see DoExchangeCfg */ BOOL SaveCfg(LPCTSTR pcszFile); /** * @brief * This method loads data providers and resources configuration from * a specified file. * * @param pcszFile A file name to load configuration. * * @return TRUE if operation is successful, FALSE otherwise. * * @see SaveCfg * @see DoExchangeCfg */ BOOL LoadCfg(LPCTSTR pcszFile); /** * @brief * Set the active configuration (enabled resources) to calendar control. * * @param pCalendar A pointer to calendar control. * * @see CXTPCalendarControl::SetResources */ void ApplyToCalendar(CXTPCalendarControl* pCalendar); /** * @brief * Remove all resources and all data providers. * * @details * Data providers will be saved and closed if this was specified for them. * * @see XTPEnumCalendarDataProviderFlags */ void RemoveAll(); protected: CXTPCalendarPtrCollectionT m_arDataProviders; /**< Data providers collection.*/ CXTPCalendarPtrCollectionT m_arResources; /**< Resources collection.*/ /** * @brief * This method saves data providers and resources configuration to * storage. * * @param pPX A CXTPPropExchange object to serialize to. * * @see _Load * @see LoadCfg * @see SaveCfg * @see DoExchangeCfg */ void _Save(CXTPPropExchange* pPX); /** * @brief * This method loads data providers and resources configuration from * storage. * * @param pPX A CXTPPropExchange object to serialize from. * * @see _Save * @see LoadCfg * @see SaveCfg * @see DoExchangeCfg */ void _Load(CXTPPropExchange* pPX); /** * @brief * This method is called to Save and Close data provider if these * actions were specified in AddDataProvider or SetDataProvider * methods. * * @param pData A pointer to data provider object. * * @see AddDataProvider * @see SetDataProvider * @see XTPEnumCalendarDataProviderFlags. */ void _SaveCloseDPifNeed(CXTPCalendarData* pData); protected: # ifdef _XTP_ACTIVEX DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPCalendarResourcesManager) DECLARE_OLECREATE_EX(CXTPCalendarResourcesManager) LPDISPATCH OleGetDataProvider(long nIndex); LPDISPATCH OleGetDataProvider2(LPCTSTR pcszConnectionString); long OleGetDataProviderIndex(LPCTSTR pcszConnectionString); BSTR OleGetDataProviderConnStr(long nIndex); LPDISPATCH OleGetResource(long nIndex); void OleDoExchangeCfg(LPDISPATCH pDispPropExchange); void OleApplyToCalendar(LPDISPATCH pDispCalendar); # endif }; # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // !defined(_XTPCALENDAR_RESOURCES_MANAGER_H_)