• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

spl/data/Command.h

00001 /*
00002  *   This file is part of the Standard Portable Library (SPL).
00003  *
00004  *   SPL is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   SPL is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with SPL.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 #ifndef _command_h
00018 #define _command_h
00019 
00020 #include <spl/types.h>
00021 #include <spl/Debug.h>
00022 
00023 #include <spl/data/CommandParameter.h>
00024 #include <spl/Exception.h>
00025 #include <spl/collection/Hashtable.h>
00026 #include <spl/Memory.h>
00027 #include <spl/data/RecordSet.h>
00028 #include <spl/RefCountPtr.h>
00029 #include <spl/String.h>
00030 #include <spl/Variant.h>
00031 #include <spl/collection/Vector.h>
00032 
00039 class Command;
00040 typedef RefCountPtr<Command> CommandPtr;
00041 
00046 class Command : public IMemoryValidate
00047 {
00048 protected:
00049         String m_cmdtxt;
00050         Hashtable<String, CommandParameterPtr> m_prmIdx;
00051         Vector<CommandParameterPtr> m_prm;
00052 
00053 public:
00054         Command();
00055         Command(const Command& cmd);
00056         Command(const String& cmdtxt);
00057         virtual ~Command();
00058 
00059         Command& operator =(const Command& cmd);
00060 
00061         virtual void Clear();
00062 
00063         inline String CommandTextGet() { return m_cmdtxt; };
00064         virtual void CommandTextSet(const String& txt);
00065 
00066         virtual CommandParameterPtr CreateParameter(const String& name, int type, int direction, int len);
00067         virtual CommandParameterPtr CreateParameter(const String& name, int type, int direction);
00068         virtual CommandParameterPtr CreateParameter(const String& name, const String& value);
00069         virtual CommandParameterPtr CreateParameter(const String& name, int32 value);
00070         virtual CommandParameterPtr CreateParameter(const String& name, int8 value);
00071         virtual CommandParameterPtr CreateParameter(const String& name, float32 value);
00072         virtual CommandParameterPtr CreateParameter(const String& name, float64 value);
00073 
00074         virtual CommandParameterPtr GetParameter(const String& name) const;
00075         inline CommandParameterPtr GetParameter(int idx) const
00076         { 
00077                 return  m_prm.ElementAt(idx); 
00078         }
00079 
00080         inline int ParameterCount() const 
00081         { 
00082                 return m_prm.Count(); 
00083         }
00084 
00085         virtual void Prepare();
00086         virtual int ExecuteNonQuery();
00087         virtual RecordSetPtr ExecuteQuery();
00088 
00089 #if defined(DEBUG)
00090         virtual void CheckMem() const;
00091         virtual void ValidateMem() const;
00092 #endif
00093 };
00094 
00097 #endif