TResultShapeCreatorWrap.h
Go to the documentation of this file.
1 #pragma once
2 
3 
4 // ACF includes
5 #include <iview/IShapeFactory.h>
6 #include <iview/IColorSchema.h>
7 
8 
9 namespace iqtinsp
10 {
11 
12 
13 template <class Base>
14 class TResultShapeCreatorWrap: public Base
15 {
16 public:
17  typedef Base BaseClass;
18 
19  I_BEGIN_BASE_COMPONENT(TResultShapeCreatorWrap);
20  I_ASSIGN(m_okColorSchemeCompPtr, "OkColorSchema", "Color schema used for ok shapes", false, "OkColorSchema");
21  I_ASSIGN(m_warningColorSchemeCompPtr, "WarningColorSchema", "Color schema used for warning shapes", false, "WarningColorSchema");
22  I_ASSIGN(m_errorColorSchemeCompPtr, "ErrorColorSchema", "Color schema used for error shapes", false, "ErrorColorSchema");
23  I_END_COMPONENT;
24 
29  const iview::IShapeFactory* shapeFactoryPtr,
30  const istd::IChangeable* objectPtr,
31  const istd::IInformationProvider* infoPtr,
32  bool connectToModel = true) const;
33 private:
34  I_REF(iview::IColorSchema, m_okColorSchemeCompPtr);
35  I_REF(iview::IColorSchema, m_warningColorSchemeCompPtr);
36  I_REF(iview::IColorSchema, m_errorColorSchemeCompPtr);
37 };
38 
39 
40 // public methods
41 template <class Base>
43  const iview::IShapeFactory* shapeFactoryPtr,
44  const istd::IChangeable* objectPtr,
45  const istd::IInformationProvider* infoPtr,
46  bool connectToModel) const
47 {
48  if (shapeFactoryPtr != NULL){
49  iview::IShape* shapePtr = shapeFactoryPtr->CreateShape(objectPtr, connectToModel);
50  if (shapePtr == NULL){
51  return NULL;
52  }
53 
54  if (infoPtr == NULL){
55  return shapePtr;
56  }
57 
58  int category = infoPtr->GetInformationCategory();
59 
60  const iview::IColorSchema* userColorSchemaPtr = shapePtr->GetUserColorSchema();
61 
62  switch (category){
63  case istd::IInformationProvider::IC_ERROR:
64  case istd::IInformationProvider::IC_CRITICAL:
65  if ((userColorSchemaPtr == NULL) && m_errorColorSchemeCompPtr.IsValid()){
66  shapePtr->SetUserColorSchema(m_errorColorSchemeCompPtr.GetPtr());
67  }
68  break;
69 
70  case istd::IInformationProvider::IC_WARNING:
71  if ((userColorSchemaPtr == NULL) && m_warningColorSchemeCompPtr.IsValid()){
72  shapePtr->SetUserColorSchema(m_warningColorSchemeCompPtr.GetPtr());
73  }
74  break;
75 
76  case istd::IInformationProvider::IC_INFO:
77  case istd::IInformationProvider::IC_NONE:
78  if ((userColorSchemaPtr == NULL) && m_okColorSchemeCompPtr.IsValid()){
79  shapePtr->SetUserColorSchema(m_okColorSchemeCompPtr.GetPtr());
80  }
81  break;
82 
83  default:;
84  }
85 
86  return shapePtr;
87  }
88 
89  return NULL;
90 }
91 
92 
93 } // namespace iqtinsp
94 
95 
virtual InformationCategory GetInformationCategory() const =0
#define NULL
virtual IShape * CreateShape(const istd::IChangeable *objectPtr, bool connectToModel=false) const =0
virtual iview::IShape * CreateResultShape(const iview::IShapeFactory *shapeFactoryPtr, const istd::IChangeable *objectPtr, const istd::IInformationProvider *infoPtr, bool connectToModel=true) const
Create a shape for the result object and corresponding status information.

© 2007-2017 Witold Gantzke and Kirill Lepskiy