00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef TECPLOT_TOOLBOX_STYLEVALUE_H
00012 #define TECPLOT_TOOLBOX_STYLEVALUE_H
00013
00014 #if defined MSWIN
00015 #pragma once
00016 #endif
00017
00018 #include <string>
00019 #include "tptoolbox.h"
00020 #include "ArgList.h"
00021 #include "StringList.h"
00022 #include "Set.h"
00023
00024
00025
00026
00027
00028 #define STYLEVALUE_NO_OFFSET BAD_SET_VALUE
00029 #define STYLEVALUE_NO_ASSIGNOP AssignOp_Invalid
00030 #define STYLEVALUE_MAX_PARAMETERS 7
00031
00032 namespace tecplot
00033 {
00034 namespace toolbox
00035 {
00036
00136 class TPTOOLBOX_DLLAPI StyleValue
00137 {
00138 public:
00158 StyleValue(const char* P1 = NULL,
00159 const char* P2 = NULL,
00160 const char* P3 = NULL,
00161 const char* P4 = NULL,
00162 const char* P5 = NULL,
00163 const char* P6 = NULL,
00164 const char* P7 = NULL);
00165
00187 StyleValue(UniqueID_t pageOrFrameUniqueID,
00188 const char* P1 = NULL,
00189 const char* P2 = NULL,
00190 const char* P3 = NULL,
00191 const char* P4 = NULL,
00192 const char* P5 = NULL,
00193 const char* P6 = NULL,
00194 const char* P7 = NULL);
00195
00204 StyleValue(const StringList& paramList);
00205
00217 StyleValue(UniqueID_t pageOrFrameUniqueID,
00218 const StringList& paramList);
00219
00220 StyleValue(const StyleValue& other);
00221 virtual ~StyleValue();
00222
00226 inline const StringList& getParamList() const
00227 {
00228 return m_params;
00229 }
00230
00241 static bool returnCodeOk(SetValueReturnCode_e SVRC);
00242
00252 static bool returnCodeOk(GetValueReturnCode_e GVRC);
00253
00292 template <typename T>
00293 SetValueReturnCode_e set(T value,
00294 const char* aP1 = NULL,
00295 const char* aP2 = NULL,
00296 const char* aP3 = NULL,
00297 const char* aP4 = NULL,
00298 const char* aP5 = NULL,
00299 const char* aP6 = NULL,
00300 const char* aP7 = NULL) const
00301 {
00302 StringList extraParams(aP1, aP2, aP3, aP4, aP5, aP6, aP7, NULL);
00303 return setValue(value,
00304 extraParams,
00305 NULL,
00306 STYLEVALUE_NO_OFFSET,
00307 STYLEVALUE_NO_OFFSET,
00308 STYLEVALUE_NO_ASSIGNOP);
00309 }
00310
00352 template <typename T>
00353 SetValueReturnCode_e set(T value,
00354 LgIndex_t offset1,
00355 const char* aP1 = NULL,
00356 const char* aP2 = NULL,
00357 const char* aP3 = NULL,
00358 const char* aP4 = NULL,
00359 const char* aP5 = NULL,
00360 const char* aP6 = NULL,
00361 const char* aP7 = NULL) const
00362 {
00363 StringList extraParams(aP1, aP2, aP3, aP4, aP5, aP6, aP7, NULL);
00364 return setValue(value,
00365 extraParams,
00366 NULL,
00367 offset1,
00368 STYLEVALUE_NO_OFFSET,
00369 STYLEVALUE_NO_ASSIGNOP);
00370 }
00371
00421 template <typename T>
00422 SetValueReturnCode_e set(T value,
00423 AssignOp_e assignOp,
00424 const char* aP1 = NULL,
00425 const char* aP2 = NULL,
00426 const char* aP3 = NULL,
00427 const char* aP4 = NULL,
00428 const char* aP5 = NULL,
00429 const char* aP6 = NULL,
00430 const char* aP7 = NULL) const
00431 {
00432 StringList extraParams(aP1, aP2, aP3, aP4, aP5, aP6, aP7, NULL);
00433 return setValue(value,
00434 extraParams,
00435 NULL,
00436 STYLEVALUE_NO_OFFSET,
00437 STYLEVALUE_NO_OFFSET,
00438 assignOp);
00439 }
00440
00484 template <typename T>
00485 SetValueReturnCode_e set(T value,
00486 LgIndex_t offset1,
00487 AssignOp_e assignOp,
00488 const char* aP1 = NULL,
00489 const char* aP2 = NULL,
00490 const char* aP3 = NULL,
00491 const char* aP4 = NULL,
00492 const char* aP5 = NULL,
00493 const char* aP6 = NULL,
00494 const char* aP7 = NULL) const
00495 {
00496 StringList extraParams(aP1, aP2, aP3, aP4, aP5, aP6, aP7, NULL);
00497 return setValue(value,
00498 extraParams,
00499 NULL,
00500 offset1,
00501 STYLEVALUE_NO_OFFSET,
00502 assignOp);
00503 }
00504
00544 template <typename T>
00545 SetValueReturnCode_e set(T value,
00546 LgIndex_t offset1,
00547 LgIndex_t offset2,
00548 const char* aP1 = NULL,
00549 const char* aP2 = NULL,
00550 const char* aP3 = NULL,
00551 const char* aP4 = NULL,
00552 const char* aP5 = NULL,
00553 const char* aP6 = NULL,
00554 const char* aP7 = NULL) const
00555 {
00556 StringList extraParams(aP1, aP2, aP3, aP4, aP5, aP6, aP7, NULL);
00557 return setValue(value,
00558 extraParams,
00559 NULL,
00560 offset1,
00561 offset2,
00562 STYLEVALUE_NO_ASSIGNOP);
00563 }
00564
00612 template <typename T>
00613 SetValueReturnCode_e set(T value,
00614 LgIndex_t offset1,
00615 LgIndex_t offset2,
00616 AssignOp_e assignOp,
00617 const char* aP1 = NULL,
00618 const char* aP2 = NULL,
00619 const char* aP3 = NULL,
00620 const char* aP4 = NULL,
00621 const char* aP5 = NULL,
00622 const char* aP6 = NULL,
00623 const char* aP7 = NULL) const
00624 {
00625 StringList extraParams(aP1, aP2, aP3, aP4, aP5, aP6, aP7, NULL);
00626 return setValue(value,
00627 extraParams,
00628 NULL,
00629 offset1,
00630 offset2,
00631 assignOp);
00632 }
00633
00681 template <typename T>
00682 SetValueReturnCode_e set(T value,
00683 const Set& objectSet,
00684 const char* aP1 = NULL,
00685 const char* aP2 = NULL,
00686 const char* aP3 = NULL,
00687 const char* aP4 = NULL,
00688 const char* aP5 = NULL,
00689 const char* aP6 = NULL,
00690 const char* aP7 = NULL) const
00691 {
00692 StringList extraParams(aP1, aP2, aP3, aP4, aP5, aP6, aP7, NULL);
00693 return setValue(value,
00694 extraParams,
00695 &objectSet,
00696 STYLEVALUE_NO_OFFSET,
00697 STYLEVALUE_NO_OFFSET,
00698 STYLEVALUE_NO_ASSIGNOP);
00699 }
00700
00752 template <typename T>
00753 SetValueReturnCode_e set(T value,
00754 const Set& objectSet,
00755 AssignOp_e assignOp,
00756 const char* aP1 = NULL,
00757 const char* aP2 = NULL,
00758 const char* aP3 = NULL,
00759 const char* aP4 = NULL,
00760 const char* aP5 = NULL,
00761 const char* aP6 = NULL,
00762 const char* aP7 = NULL) const
00763 {
00764 StringList extraParams(aP1, aP2, aP3, aP4, aP5, aP6, aP7, NULL);
00765 return setValue(value,
00766 extraParams,
00767 &objectSet,
00768 STYLEVALUE_NO_OFFSET,
00769 STYLEVALUE_NO_OFFSET,
00770 assignOp);
00771 }
00772
00773
00814 template <typename T>
00815 GetValueReturnCode_e get(T* value,
00816 const char* aP1 = NULL,
00817 const char* aP2 = NULL,
00818 const char* aP3 = NULL,
00819 const char* aP4 = NULL,
00820 const char* aP5 = NULL,
00821 const char* aP6 = NULL,
00822 const char* aP7 = NULL) const
00823 {
00824 StringList extraParams(aP1, aP2, aP3, aP4, aP5, aP6, aP7, NULL);
00825 return getValue(value,
00826 STYLEVALUE_NO_OFFSET,
00827 STYLEVALUE_NO_OFFSET,
00828 extraParams);
00829 }
00830
00875 template <typename T>
00876 GetValueReturnCode_e get(T* value,
00877 LgIndex_t offset1,
00878 const char* aP1 = NULL,
00879 const char* aP2 = NULL,
00880 const char* aP3 = NULL,
00881 const char* aP4 = NULL,
00882 const char* aP5 = NULL,
00883 const char* aP6 = NULL,
00884 const char* aP7 = NULL) const
00885 {
00886 StringList extraParams(aP1, aP2, aP3, aP4, aP5, aP6, aP7, NULL);
00887 return getValue(value,
00888 offset1,
00889 STYLEVALUE_NO_OFFSET,
00890 extraParams);
00891 }
00892
00929 template <typename T>
00930 GetValueReturnCode_e get(T* value,
00931 LgIndex_t offset1,
00932 LgIndex_t offset2,
00933 const char* aP1 = NULL,
00934 const char* aP2 = NULL,
00935 const char* aP3 = NULL,
00936 const char* aP4 = NULL,
00937 const char* aP5 = NULL,
00938 const char* aP6 = NULL,
00939 const char* aP7 = NULL) const
00940 {
00941 StringList extraParams(aP1, aP2, aP3, aP4, aP5, aP6, aP7, NULL);
00942 return getValue(value,
00943 offset1,
00944 offset2,
00945 extraParams);
00946 }
00947
00948 #if 0
00949
00950
00951
00952 static const LgIndex_t NO_OFFSET = BAD_SET_VALUE;
00953 static const AssignOp_e NO_ASSIGNOP = AssignOp_Invalid;
00954 static const int MAX_PARAMETERS = 7;
00955 #endif
00956
00957 protected:
00959
00961
00981 virtual SetValueReturnCode_e styleSetLowLevel(const ArgList& argList) const;
00982
00983 template <typename T>
00984 SetValueReturnCode_e setFinalValue(T value,
00985 ArgList& argList) const
00986 {
00987 REQUIRE("value can be any value");
00988 REQUIRE("no way to check argList");
00989 argList.appendArbParam(SV_IVALUE, (ArbParam_t)value);
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017 argList.appendDouble(SV_DVALUE, (double)((ArbParam_t)value));
01018 return styleSetLowLevel(argList);
01019 }
01020
01021 SetValueReturnCode_e setFinalValue(bool value,
01022 ArgList& argList) const;
01023 SetValueReturnCode_e setFinalValue(double value,
01024 ArgList& argList) const;
01025 SetValueReturnCode_e setFinalValue(const Set_pa value,
01026 ArgList& argList) const;
01027 SetValueReturnCode_e setFinalValue(const Set& value,
01028 ArgList& argList) const;
01029 SetValueReturnCode_e setFinalValue(const char* value,
01030 ArgList& argList) const;
01031 SetValueReturnCode_e setFinalValue(const std::string& value,
01032 ArgList& argList) const;
01033
01034 template <typename T>
01035 SetValueReturnCode_e setValue(const T& value,
01036 const StringList& extraParams,
01037 const Set* objectSet,
01038 LgIndex_t offset1,
01039 LgIndex_t offset2,
01040 AssignOp_e assignOp) const
01041 {
01042 REQUIRE("valid can be any value");
01043 REQUIRE(extraParams.size() >= 0);
01044 REQUIRE(VALID_REF_OR_NULL(objectSet));
01045 REQUIRE(offset1 >= 1 || offset1 == STYLEVALUE_NO_OFFSET);
01046 REQUIRE(offset2 >= 1 || offset2 == STYLEVALUE_NO_OFFSET);
01047 REQUIRE(VALID_ENUM(assignOp, AssignOp_e) || assignOp == STYLEVALUE_NO_ASSIGNOP);
01048
01049 REQUIRE(IMPLICATION(VALID_REF(objectSet), offset1 == STYLEVALUE_NO_OFFSET));
01050 REQUIRE(IMPLICATION(offset1 >= 1, objectSet == NULL));
01051
01052 StringList finalParams(m_params);
01053 finalParams.append(extraParams);
01054
01055 ArgList argList;
01056 setupSetValueArgList(finalParams,
01057 objectSet,
01058 offset1,
01059 offset2,
01060 assignOp,
01061 argList);
01062 return setFinalValue(value, argList);
01063 }
01064
01065
01067
01069
01087 virtual GetValueReturnCode_e styleGetLowLevel(const ArgList& argList) const;
01088
01089 template <typename T>
01090 GetValueReturnCode_e getFinalValue(T* value,
01091 ArgList& argList) const
01092 {
01093 REQUIRE(VALID_REF(value));
01094 REQUIRE("no way to check argList");
01095
01096 ArbParam_t arbValue = 0;
01097 argList.appendArbParamPtr(SV_IVALUE, &arbValue);
01098 GetValueReturnCode_e GVRC = styleGetLowLevel(argList);
01099 if (returnCodeOk(GVRC))
01100 *value = (T)arbValue;
01101
01102 ENSURE(VALID_ENUM(GVRC, GetValueReturnCode_e));
01103 return GVRC;
01104 }
01105
01106 GetValueReturnCode_e getFinalValue(bool* value,
01107 ArgList& argList) const;
01108 GetValueReturnCode_e getFinalValue(double* value,
01109 ArgList& argList) const;
01110 GetValueReturnCode_e getFinalValue(std::string* value,
01111 ArgList& argList) const;
01112 GetValueReturnCode_e getFinalValue(char** value,
01113 ArgList& argList) const;
01114 GetValueReturnCode_e getFinalValue(Set* value,
01115 ArgList& argList) const;
01116 GetValueReturnCode_e getFinalValue(Set_pa* value,
01117 ArgList& argList) const;
01118
01119 template <typename T>
01120 GetValueReturnCode_e getValue(T* value,
01121 LgIndex_t offset1,
01122 LgIndex_t offset2,
01123 const StringList& extraParams) const
01124 {
01125 REQUIRE(VALID_REF(value));
01126 REQUIRE(offset1 >= 1 || offset1 == STYLEVALUE_NO_OFFSET);
01127 REQUIRE(offset2 >= 1 || offset2 == STYLEVALUE_NO_OFFSET);
01128 REQUIRE(extraParams.size() >= 0);
01129
01130 StringList finalParams(m_params);
01131 finalParams.append(extraParams);
01132
01133 ArgList argList;
01134 setupGetValueArgList(finalParams,
01135 offset1,
01136 offset2,
01137 argList);
01138 return getFinalValue(value, argList);
01139 }
01140
01142
01144 const char *getPValueString(int depth) const;
01145
01146 void validateParamList(StringList& stringList) const;
01147 void setupPValueArgList(const StringList& parameters,
01148 ArgList& argList) const;
01149 void setupSetValueArgList(const StringList& parameters,
01150 const Set* objectSet,
01151 LgIndex_t offset1,
01152 LgIndex_t offset2,
01153 AssignOp_e assignOp,
01154 ArgList& argList) const;
01155
01156 void setupGetValueArgList(const StringList& parameters,
01157 LgIndex_t offset1,
01158 LgIndex_t offset2,
01159 ArgList& argList) const;
01160
01161 private:
01162 UniqueID_t m_pageOrFrameUniqueID;
01163 StringList m_params;
01164
01168 StyleValue& operator = (const StyleValue&);
01169 };
01170
01171 }
01172 }
01173
01174 #endif