lgrRuntimeCommandFactory.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 ** Copyright (c) 1992-2010 VT MAK
00003 ** All rights reserved.
00004 ******************************************************************************/
00005 
00009 
00010 #ifndef lgrRuntimeCommandFactory_H_
00011 #define lgrRuntimeCommandFactory_H_
00012 
00013 #include "lgrCore.h"
00014 #include "lgrCommand.h"
00015 
00016 #include "collectors.h"
00017 
00018 #include <map>
00019 #include <list>
00020 
00021 class DtString;
00022 
00023 namespace MAKLogger
00024 {
00025 
00027    typedef std::pair<DtString,DtString>     DtNamedTypedParameter;
00028 
00030    typedef std::list<DtNamedTypedParameter> DtParameterList;
00031 
00032    //Define a command Unique Id as its type and id
00033    typedef std::pair<DtLgrCommandType,DtLgrCommandId> DtLgrCommandUniqueId;
00034 
00036    typedef std::pair<DtString,DtParameterList> DtCommandAttributes;
00037    typedef std::pair<DtLgrCommandUniqueId,DtCommandAttributes> DtCommandDefinitionPair;
00038 
00041    class DT_DLL_LGRCORE DtCommandDefinition
00042    {
00043    public:
00044       DtCommandDefinition(DtLgrCommandType,DtLgrCommandId,DtString,
00045          bool commandLine = true);
00046 
00047       DtLgrCommandType type() const;
00048       DtLgrCommandId id() const;
00049 
00050       void setUniqueId(DtLgrCommandType,DtLgrCommandId);
00051       DtLgrCommandUniqueId uniqueId() const;
00052 
00053       void setName(const DtString&);
00054       DtString name() const;
00055 
00056       DtParameterList& parameters();
00057       const DtParameterList& parameters() const;
00058 
00059       bool accessViaCommandLine() const;
00060 
00061    protected:
00062       bool myAccessViaCommandLine;
00063       DtCommandDefinitionPair myDefinition;
00064    };
00065 
00068    class DT_DLL_LGRCORE DtRuntimeCommandFactory
00069    {
00070    public:
00074 
00075       DtRuntimeCommandFactory();
00076       virtual ~DtRuntimeCommandFactory();
00077 
00079       virtual void commandNames(DtCollector<DtString> names);
00080 
00082       virtual void commandParams(DtLgrCommandType,DtLgrCommandId,
00083          DtParameterList& outParams);
00084 
00086       virtual DtString* commandName(DtLgrCommandType,DtLgrCommandId);
00087 
00089       DtLgrCommandType commandType(const DtString& name);
00090 
00092       virtual DtLgrCommandId commandId(const DtString&);
00093 
00103       virtual DtCommand generateCommand(DtLgrCommandType type,
00104          DtLgrCommandId id,const DtParameterList& nameValuePairs);
00105 
00106       DtAnyValue* deserializeParameter(const DtString& type,const DtString& value) const;
00107 
00108       DtAnyValue* deserializeParameterList(const DtString& type,const std::vector<DtString>& values) const;
00109 
00111       void registerCommand(const DtCommandDefinition&);
00112 
00114       void unregisterCommand(const DtCommandDefinition&);
00115 
00117       static bool isListType(const DtString&);
00118 
00120       static DtString listItemType(const DtString listType);
00121 
00125       static DtString baseType(const DtString typeAlias);
00126 
00127       static DtString stringType();
00128       static DtString intType();
00129       static DtString int64Type();
00130       static DtString floatType();
00131       static DtString doubleType();
00132       static DtString boolType();
00133       static DtString timeType();
00134       static DtString stringListType();
00135       static DtString voidPtrType();
00136       static DtString base64Type();
00137 
00138    protected:
00139 
00140       virtual bool isStringType(const DtString& type) const;
00141       virtual bool isIntType(const DtString& type) const;
00142       virtual bool isInt64Type(const DtString& type) const;
00143       virtual bool isFloatType(const DtString& type) const;
00144       virtual bool isDoubleType(const DtString& type) const;
00145       virtual bool isBoolType(const DtString& type) const;
00146       virtual bool isTimeType(const DtString& type) const;
00147       virtual bool isStringListType(const DtString& type) const;      
00148       virtual bool isVoidPtrType(const DtString& type) const;
00149       virtual bool isBase64Type(const DtString& type) const;
00150 
00151       typedef std::map<DtLgrCommandUniqueId,DtParameterList> DtCommandParamMap;
00152       typedef std::map<DtLgrCommandUniqueId,DtString>        DtCommandIdMap;
00153       typedef std::map<DtString,DtLgrCommandUniqueId>  DtCommandNameMap;
00154 
00156       DtCommandNameMap myCommandNameMap;
00157 
00159       DtCommandIdMap   myCommandIdMap;
00160 
00162       DtCommandParamMap myCommandParamMap;
00163 
00164    };
00165 
00166 }
00167 
00168 #endif

Document ID: Generated on Tue Oct 11 19:41:03 EDT 2011 from SVN revision 107422
Copyright © 2005-2011 VT MÄK Inc. All Rights Reserved (www.mak.com)