Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

370 lines
13 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright(C) 2000 Microsoft Corporation all rights reserved.
  4. //
  5. // Module: Objects.H
  6. //
  7. // Project: Windows 2000 IAS
  8. //
  9. // Description: Declaration of the CObjects class
  10. //
  11. // Author: tperraut
  12. //
  13. // Revision 02/24/2000 created
  14. //
  15. //////////////////////////////////////////////////////////////////////////////
  16. #ifndef _OBJECT_H_3A179338_CF1E_4932_8663_9F6AE0F03AA5
  17. #define _OBJECT_H_3A179338_CF1E_4932_8663_9F6AE0F03AA5
  18. #if _MSC_VER > 1000
  19. #pragma once
  20. #endif // _MSC_VER > 1000
  21. #include "nocopy.h"
  22. #include "basecommand.h"
  23. class CObjects : private NonCopyable
  24. {
  25. public:
  26. //////////////////////////////////////////////////////////////////////////
  27. // Constructor
  28. //////////////////////////////////////////////////////////////////////////
  29. explicit CObjects(CSession& CurrentSession);
  30. //////////////////////////////////////////////////////////////////////////
  31. // Destructor
  32. //////////////////////////////////////////////////////////////////////////
  33. virtual ~CObjects() throw();
  34. //////////////////////////////////////////////////////////////////////////
  35. // GetObject
  36. //////////////////////////////////////////////////////////////////////////
  37. HRESULT GetObject(_bstr_t& Name, LONG& Identity, LONG Parent);
  38. //////////////////////////////////////////////////////////////////////////
  39. // GetNextObject
  40. //////////////////////////////////////////////////////////////////////////
  41. HRESULT GetNextObject(
  42. _bstr_t& Name,
  43. LONG& Identity,
  44. LONG Parent,
  45. LONG Index
  46. ) throw();
  47. //////////////////////////////////////////////////////////////////////////
  48. // WalkPath
  49. //////////////////////////////////////////////////////////////////////////
  50. void WalkPath(LPCWSTR Path, LONG& Identity, LONG Parent = 1);
  51. //////////////////////////////////////////////////////////////////////////
  52. // GetObjectIdentity
  53. //////////////////////////////////////////////////////////////////////////
  54. HRESULT GetObjectIdentity(
  55. _bstr_t& Name,
  56. LONG& Parent,
  57. LONG Identity
  58. ) throw();
  59. //////////////////////////////////////////////////////////////////////////
  60. // GetObjectNameParent
  61. //////////////////////////////////////////////////////////////////////////
  62. HRESULT GetObjectNameParent(
  63. const _bstr_t& Name,
  64. LONG Parent,
  65. LONG& Identity
  66. ) throw();
  67. //////////////////////////////////////////////////////////////////////////
  68. // DeleteObject
  69. //////////////////////////////////////////////////////////////////////////
  70. HRESULT DeleteObject(LONG Identity);
  71. //////////////////////////////////////////////////////////////////////////
  72. // InsertObject
  73. //////////////////////////////////////////////////////////////////////////
  74. BOOL InsertObject(
  75. const _bstr_t& Name,
  76. LONG Parent,
  77. LONG& Identity
  78. );
  79. private:
  80. //////////////////////////////////////////////////////////////////////////
  81. // OBJECTS COMMAND CLASSES START
  82. //////////////////////////////////////////////////////////////////////////
  83. struct CBaseObjectConst
  84. {
  85. static const int NAME_SIZE = 256;
  86. };
  87. //////////////////////////////////////////////////////////////////////////
  88. // class CObjectsAccSelectParent
  89. //////////////////////////////////////////////////////////////////////////
  90. class CObjectsAccSelectParent : public CBaseObjectConst
  91. {
  92. protected:
  93. LONG m_Identity;
  94. WCHAR m_Name[NAME_SIZE];
  95. LONG m_Parent;
  96. BEGIN_COLUMN_MAP(CObjectsAccSelectParent)
  97. COLUMN_ENTRY(1, m_Identity)
  98. COLUMN_ENTRY(2, m_Name)
  99. COLUMN_ENTRY(3, m_Parent)
  100. END_COLUMN_MAP()
  101. WCHAR m_NameParam[NAME_SIZE];
  102. LONG m_ParentParam;
  103. BEGIN_PARAM_MAP(CObjectsAccSelectParent)
  104. COLUMN_ENTRY(1, m_ParentParam)
  105. END_PARAM_MAP()
  106. DEFINE_COMMAND(CObjectsAccSelectParent, L" \
  107. SELECT * \
  108. FROM Objects \
  109. WHERE Parent = ?");
  110. };
  111. //////////////////////////////////////////////////////////////////////////
  112. // class CObjectsCommandGet
  113. //////////////////////////////////////////////////////////////////////////
  114. class CObjectsCommandGet :
  115. public CBaseCommand<CAccessor<CObjectsAccSelectParent> >
  116. {
  117. public:
  118. explicit CObjectsCommandGet(CSession& CurrentSession);
  119. //////////////////////////////////////////////////////////////////////
  120. // GetObject
  121. //////////////////////////////////////////////////////////////////////
  122. HRESULT GetObject(_bstr_t& Name, LONG& Identity, LONG Parent);
  123. //////////////////////////////////////////////////////////////////////
  124. // GetObject overloaded
  125. //////////////////////////////////////////////////////////////////////
  126. HRESULT GetObject(
  127. _bstr_t& Name,
  128. LONG& Identity,
  129. LONG Parent,
  130. LONG Index);
  131. };
  132. //////////////////////////////////////////////////////////////////////////
  133. // class CObjectsAccSelectIdentity
  134. //////////////////////////////////////////////////////////////////////////
  135. class CObjectsAccSelectIdentity : public CBaseObjectConst
  136. {
  137. protected:
  138. LONG m_Identity;
  139. WCHAR m_Name[NAME_SIZE];
  140. LONG m_Parent;
  141. BEGIN_COLUMN_MAP(CObjectsAccSelectIdentity)
  142. COLUMN_ENTRY(1, m_Identity)
  143. COLUMN_ENTRY(2, m_Name)
  144. COLUMN_ENTRY(3, m_Parent)
  145. END_COLUMN_MAP()
  146. LONG m_IdentityParam;
  147. BEGIN_PARAM_MAP(CObjectsAccSelectIdentity)
  148. COLUMN_ENTRY(1, m_IdentityParam)
  149. END_PARAM_MAP()
  150. DEFINE_COMMAND(CObjectsAccSelectIdentity, L" \
  151. SELECT * \
  152. FROM Objects \
  153. WHERE Identity = ?");
  154. };
  155. //////////////////////////////////////////////////////////////////////////
  156. // class CObjectsCommandIdentity
  157. //////////////////////////////////////////////////////////////////////////
  158. class CObjectsCommandIdentity :
  159. public CBaseCommand<CAccessor<CObjectsAccSelectIdentity> >
  160. {
  161. public:
  162. explicit CObjectsCommandIdentity(CSession& CurrentSession);
  163. //////////////////////////////////////////////////////////////////////
  164. // GetObjectIdentity
  165. //////////////////////////////////////////////////////////////////////
  166. HRESULT GetObjectIdentity(
  167. _bstr_t& Name,
  168. LONG& Parent,
  169. LONG Identity
  170. );
  171. };
  172. //////////////////////////////////////////////////////////////////////////
  173. // class CObjectsAccSelectNameParent
  174. //////////////////////////////////////////////////////////////////////////
  175. class CObjectsAccSelectNameParent : public CBaseObjectConst
  176. {
  177. protected:
  178. LONG m_Identity;
  179. WCHAR m_Name[NAME_SIZE];
  180. LONG m_Parent;
  181. BEGIN_COLUMN_MAP(CObjectsAccSelectNameParent)
  182. COLUMN_ENTRY(1, m_Identity)
  183. COLUMN_ENTRY(2, m_Name)
  184. COLUMN_ENTRY(3, m_Parent)
  185. END_COLUMN_MAP()
  186. WCHAR m_NameParam[NAME_SIZE];
  187. LONG m_ParentParam;
  188. BEGIN_PARAM_MAP(CObjectsAccSelectNameParent)
  189. COLUMN_ENTRY(1, m_NameParam)
  190. COLUMN_ENTRY(2, m_ParentParam)
  191. END_PARAM_MAP()
  192. DEFINE_COMMAND(CObjectsAccSelectNameParent, L" \
  193. SELECT * \
  194. FROM Objects \
  195. WHERE Name = ? AND Parent = ?");
  196. };
  197. //////////////////////////////////////////////////////////////////////////
  198. // class CObjectsCommandNameParent
  199. //////////////////////////////////////////////////////////////////////////
  200. class CObjectsCommandNameParent :
  201. public CBaseCommand<CAccessor<CObjectsAccSelectNameParent> >
  202. {
  203. public:
  204. explicit CObjectsCommandNameParent(CSession& CurrentSession);
  205. //////////////////////////////////////////////////////////////////////
  206. // GetObjectNameParent
  207. //
  208. // works on CObjectsAccSelectNameParent
  209. //////////////////////////////////////////////////////////////////////
  210. HRESULT GetObjectNameParent(
  211. const _bstr_t& Name,
  212. LONG Parent,
  213. LONG& Identity
  214. );
  215. };
  216. //////////////////////////////////////////////////////////////////////////
  217. // class CObjectsCommandPath
  218. //////////////////////////////////////////////////////////////////////////
  219. class CObjectsCommandPath :
  220. public CBaseCommand<CAccessor<CObjectsAccSelectNameParent> >
  221. {
  222. public:
  223. explicit CObjectsCommandPath(CSession& CurrentSession);
  224. //////////////////////////////////////////////////////////////////////
  225. // WalkPath
  226. //////////////////////////////////////////////////////////////////////
  227. void WalkPath(LPCWSTR Path, LONG& Identity, LONG Parent = 1);
  228. };
  229. //////////////////////////////////////////////////////////////////////////
  230. // class CObjectsAccDelete
  231. //////////////////////////////////////////////////////////////////////////
  232. class CObjectsAccDelete : public CBaseObjectConst
  233. {
  234. protected:
  235. LONG m_IdentityParam;
  236. BEGIN_PARAM_MAP(CObjectsAccDelete)
  237. COLUMN_ENTRY(1, m_IdentityParam)
  238. END_PARAM_MAP()
  239. DEFINE_COMMAND(CObjectsAccDelete, L" \
  240. DELETE \
  241. FROM Objects \
  242. WHERE Identity = ?");
  243. };
  244. //////////////////////////////////////////////////////////////////////////
  245. // class CObjectsCommandDelete
  246. //////////////////////////////////////////////////////////////////////////
  247. class CObjectsCommandDelete :
  248. public CBaseCommand<CAccessor<CObjectsAccDelete> >
  249. {
  250. public:
  251. explicit CObjectsCommandDelete(CSession& CurrentSession);
  252. //////////////////////////////////////////////////////////////////////
  253. // DeleteObject
  254. //
  255. // works on CObjectsAccDelete
  256. //////////////////////////////////////////////////////////////////////
  257. HRESULT DeleteObject(LONG Identity);
  258. };
  259. //////////////////////////////////////////////////////////////////////////
  260. // class CObjectsAccInsert
  261. //////////////////////////////////////////////////////////////////////////
  262. class CObjectsAccInsert : public CBaseObjectConst
  263. {
  264. protected:
  265. // You may wish to call this function if you are inserting a record
  266. // and wish to
  267. // initialize all the fields, if you are not going to explicitly
  268. // set all of them.
  269. void ClearRecord()
  270. {
  271. memset(this, 0, sizeof(*this));
  272. }
  273. WCHAR m_NameParam[NAME_SIZE];
  274. LONG m_ParentParam;
  275. BEGIN_PARAM_MAP(CObjectsAccInsert)
  276. COLUMN_ENTRY(1, m_NameParam)
  277. COLUMN_ENTRY(2, m_ParentParam)
  278. END_PARAM_MAP()
  279. DEFINE_COMMAND(CObjectsAccInsert, L" \
  280. INSERT INTO Objects \
  281. (Name, Parent) \
  282. VALUES (?, ?)");
  283. };
  284. //////////////////////////////////////////////////////////////////////////
  285. // class CObjectsCommandInsert
  286. //////////////////////////////////////////////////////////////////////////
  287. class CObjectsCommandInsert :
  288. public CBaseCommand<CAccessor<CObjectsAccInsert> >
  289. {
  290. public:
  291. explicit CObjectsCommandInsert(CSession& CurrentSession);
  292. //////////////////////////////////////////////////////////////////////
  293. // InsertObject
  294. //
  295. // works on CObjectsAccInsert
  296. //////////////////////////////////////////////////////////////////////
  297. BOOL InsertObject(
  298. const _bstr_t& Name,
  299. LONG Parent,
  300. LONG& Identity
  301. );
  302. private:
  303. CSession& m_Session;
  304. };
  305. CObjectsCommandPath m_ObjectsCommandPath;
  306. CObjectsCommandIdentity m_ObjectsCommandIdentity;
  307. CObjectsCommandDelete m_ObjectsCommandDelete;
  308. CObjectsCommandNameParent m_ObjectsCommandNameParent;
  309. CObjectsCommandGet m_ObjectsCommandGet;
  310. CObjectsCommandInsert m_ObjectsCommandInsert;
  311. };
  312. #endif // _OBJECT_H_3A179338_CF1E_4932_8663_9F6AE0F03AA5