#ifndef _PROMOTE_H_ #define _PROMOTE_H_ #include // for NULL #include #include "SDDAS_types.h" #include "pro_defs.h" // defines for others to use class Entry; class CServer; class TimeObj; class MirrorDatabase; typedef enum {OFF, ON} XFileStatusType; const int MAX_PROMOTE = 1000; class Promote { public : Promote (const char * = NULL, SDDAS_BOOL = sFalse); virtual ~Promote (); void SetBTime (SDDAS_INT, SDDAS_INT, SDDAS_LONG); // year, day, msec of day void SetBTime (SDDAS_INT, SDDAS_INT, SDDAS_INT, SDDAS_INT, SDDAS_INT, SDDAS_LONG = 0); // year, day, hour, min, sec, msec void SetETime (SDDAS_INT, SDDAS_INT, SDDAS_LONG); // year, day, msec of day void SetETime (SDDAS_INT, SDDAS_INT, SDDAS_INT, SDDAS_INT, SDDAS_INT, SDDAS_LONG = 0); // year, day, hour, min, sec, msec void AddSource (SDDAS_ULONG); void AddSource (char *, char *, char *, char *, char *); SDDAS_INT BuildDBIntersectionList (int, FileStatusType, int = 1000); SDDAS_INT BuildDBList (int, FileStatusType, int = 1000); SDDAS_BOOL PromoteList (); SDDAS_BOOL DemoteAllData (SDDAS_BOOL = sFalse); SDDAS_BOOL PromoteMeta (); void SetXStatus (XFileStatusType); void SetAutoPromoteMeta (SDDAS_BOOL); Entry *GetEntry (unsigned int); const unsigned int GetEntryListSize () { return _entryList.size (); } const char *GetErrorMessage () {return _error_msg;} bool GetMetaDataExists () {return _haveMeta == DB_GOOD;} protected : typedef enum {DB_GOOD, DB_NO_DATA, DB_ERROR} DBPromoteStatus; // status from MySQL promote std::vector _entryList; // list of entries to promote std::vector _ServerUsed; // which Server to use // (parallel array w/_entryList) char _error_msg [256]; std::vector _data_sources; // the data keys for promoting std::vector _Server; // Servers to use for promotion TimeObj *_btime; // beginning time TimeObj *_etime; // ending time void InitializePromoStatus (int); void WritePipeMessage (char *); void ClosePromoStatus (); SDDAS_BOOL PromoteSingleEntry (int, Entry *, int); SDDAS_BOOL PromoteMetaForSource (SDDAS_ULONG, int); DBPromoteStatus PromoteMetaForSource_MYSQL (char *, SDDAS_ULONG = 0, char * = NULL, char * = NULL, char * = NULL, char * = NULL, char * = NULL); SDDAS_BOOL PromoteMetaForSource_EXTERNAL (char *, SDDAS_ULONG); int Process (char *, ...); private : char *_app_name; // the application name requesting the data XFileStatusType _XStatus; // Whether or not to show an X Status window int _src_in_use; // which source we are using (index into _data_sources) int _PipeFD; // pipe file descriptor (XStatus pipe) SDDAS_BOOL _autoPromoteMeta; // should we promote meta automatically or not // default to true - always promote meta SDDAS_BOOL _forcePromote; // should we force the data to promote automatically or not // default to false - ask before promoting DBPromoteStatus _haveMeta; // does meta data exist for this list of promotes? SDDAS_INT SwRI_BuildDBList (int, FileStatusType, int = 1000); SDDAS_INT SQL_BuildDBList (int, FileStatusType, int = 1000); MirrorDatabase *_mirror; #ifndef SwRI_DB typedef void *(queryProcType) (Promote *, char *, int); static void *IntersectionQueryCallback (Promote *, char *, int); static void *RegularQueryCallback (Promote *, char *, int); void *IntersectionQuery (char *, int); void *RegularQuery (char *, int); unsigned int MakeList (int, FileStatusType, int, queryProcType); #endif #if defined (SwRI_DB) || defined (ALL_DB) void GetField (int, const char *, void *); void FillInfoFromDB (int, char *&, TimeObj &, TimeObj &); SDDAS_BOOL FindEntry (int, int); SDDAS_BOOL OpenDatabase (const char *, SDDAS_INT *, SDDAS_INT *); void CloseDatabase (int, int); unsigned int MakeList (int, int, int, FileStatusType, int); #endif void SetupDefaultServers (unsigned int); void StartPromoStatus (); SDDAS_BOOL AutoGetMeta (SDDAS_ULONG); SDDAS_BOOL PromoteHDI (Entry *, char *); }; #endif