source: branches/work_311/output/URLLink.h @ 536

Revision 536, 3.2 KB checked in by jls17, 5 years ago (diff)
  • added new constructor to URLLink class to create links from CARServerObject-instances with a specific link-caption
  • replaced the function call in ARInside.cpp with the new URLLink class constructor
  • removed the GetURL function from the CARField class
Line 
1//Copyright (C) 2014 John Luthgers | jls17
2//
3//This file is part of ARInside.
4//
5//    ARInside is free software: you can redistribute it and/or modify
6//    it under the terms of the GNU General Public License as published by
7//    the Free Software Foundation, version 2 of the License.
8//
9//    ARInside is distributed in the hope that it will be useful,
10//    but WITHOUT ANY WARRANTY; without even the implied warranty of
11//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12//    GNU General Public License for more details.
13//
14//    You should have received a copy of the GNU General Public License
15//    along with ARInside.  If not, see <http://www.gnu.org/licenses/>.
16
17#pragma once
18
19class CARServerObject;
20class CPageParams;
21
22#include "ImageTag.h"
23
24namespace OUTPUT
25{
26        class URLLink
27        {
28        public:
29                enum LinkTargetMode {
30                        TARGET_MODE_SELF = 0,
31                        TARGET_MODE_PARENT = 1,
32                        TARGET_MODE_TOP = 2,
33                        TARGET_MODE_BLANK = 3,
34                };
35
36                URLLink(const std::string &caption, const CPageParams &linkToPage, const OUTPUT::ImageTag &image, int rootLevel, bool validate = true, LinkTargetMode target = TARGET_MODE_SELF);
37                URLLink(const std::string &caption, const CPageParams &linkToPage, const OUTPUT::ImageTag &image, int rootLevel, LinkTargetMode target);
38                URLLink(const std::string &caption, const CPageParams &linkToPage, const OUTPUT::ImageTag::ImageEnum imageId, int rootLevel);
39                URLLink(const std::string &caption, const CPageParams &linkToPage, int rootLevel);
40                URLLink(const std::string &caption, unsigned int page, OUTPUT::ImageTag::ImageEnum imageId, int rootLevel);
41                URLLink(const std::string &caption, unsigned int page, int rootLevel);
42                URLLink(const CARServerObject &workflowObject, int rootLevel, bool showImage = true);
43                URLLink(const std::string &caption, const CARServerObject &workflowObject, int rootLevel, bool showImage = true);
44
45                std::ostream& ToStream(std::ostream &strm) const;
46                operator std::string () const;
47        protected:
48                URLLink() {};
49        private:
50                std::string link;
51
52        protected:
53                void Init(const std::string &caption, const CPageParams &linkToPage, const OUTPUT::ImageTag &image, int rootLevel, bool validate, OUTPUT::URLLink::LinkTargetMode target);
54                void InitObj(const std::string &caption, const CARServerObject &workflowObject, int rootLevel, bool showImage);
55                void InitDirect(const std::string &linkHTML);
56                static void AddCaption(std::ostream &strm, const std::string &caption, bool validate);
57        };
58
59        class CheckedURLLink : public URLLink
60        {
61        public:
62                CheckedURLLink(const CARServerObject &workflowObject, const std::string &alternateHTML, int rootLevel, bool showImage = true);
63        };
64
65        class DirectURLLink : public URLLink
66        {
67        public:
68                enum DirectLinkEnum
69                {
70                        CreateTop,
71                        LinkToTop
72                };
73                DirectURLLink(DirectLinkEnum directLinkType, int rootLevel);
74
75        private:
76                void InitLinkEnum(const std::string &caption, const OUTPUT::ImageTag::ImageEnum imageId, const std::string &href, int rootLevel);
77        };
78
79        std::ostream& operator<<(std::ostream &stream, const OUTPUT::URLLink &link);
80        std::ostream& operator<<(std::ostream &stream, const OUTPUT::DirectURLLink::DirectLinkEnum link);
81        std::ostream& operator<<(std::ostream &stream, const OUTPUT::DirectURLLink &link);
82};
Note: See TracBrowser for help on using the repository browser.