Ignition Fuel_tools

API Reference

4.4.0
ModelIdentifier.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef IGNITION_FUEL_TOOLS_MODELIDENTIFIER_HH_
19 #define IGNITION_FUEL_TOOLS_MODELIDENTIFIER_HH_
20 
21 #include <cstdint>
22 #include <ctime>
23 #include <memory>
24 #include <string>
25 #include <vector>
26 
28 
29 #ifdef _WIN32
30 // Disable warning C4251 which is triggered by
31 // std::unique_ptr
32 #pragma warning(push)
33 #pragma warning(disable: 4251)
34 #endif
35 
36 namespace ignition
37 {
38  namespace fuel_tools
39  {
41  class ModelIdentifierPrivate;
42  class ServerConfig;
43 
45  class IGNITION_FUEL_TOOLS_VISIBLE ModelIdentifier
46  {
48  public: ModelIdentifier();
49 
52  public: ModelIdentifier(const ModelIdentifier &_orig);
53 
55  public: ~ModelIdentifier();
56 
60  public: ModelIdentifier &operator=(const ModelIdentifier &_orig);
61 
65  public: bool operator==(const ModelIdentifier &_rhs) const;
66 
69  public: std::string Name() const;
70 
73  public: std::string Owner() const;
74 
77  public: ServerConfig &Server() const;
78 
82  public: std::string UniqueName() const;
83 
87  public: bool SetName(const std::string &_name);
88 
92  public: bool SetOwner(const std::string &_name);
93 
97  public: bool SetServer(const ServerConfig &_server);
98 
101  public: std::string Description() const;
102 
105  public: unsigned int FileSize() const;
106 
109  public: std::time_t UploadDate() const;
110 
113  public: std::time_t ModifyDate() const;
114 
117  public: uint32_t LikeCount() const;
118 
121  public: uint32_t DownloadCount() const;
122 
125  public: std::string LicenseName() const;
126 
129  public: std::string LicenseUrl() const;
130 
133  public: std::string LicenseImageUrl() const;
134 
138 
142  public: bool Private() const;
143 
147  public: void SetPrivate(bool _private) const;
148 
152  public: bool SetDescription(const std::string &_desc);
153 
157  public: bool SetFileSize(const unsigned int _filesize);
158 
162  public: bool SetUploadDate(const std::time_t &_date);
163 
166  public: bool SetModifyDate(const std::time_t &_date);
167 
171  public: bool SetLikeCount(const uint32_t _likes);
172 
176  public: bool SetDownloadCount(const uint32_t _downloads);
177 
181  public: bool SetLicenseName(const std::string &_name);
182 
186  public: bool SetLicenseUrl(const std::string &_url);
187 
191  public: bool SetLicenseImageUrl(const std::string &_url);
192 
196  public: bool SetTags(const std::vector<std::string> &_tags);
197 
203  public: unsigned int Version() const;
204 
210  public: std::string VersionStr() const;
211 
218  public: bool SetVersion(const unsigned int _version);
219 
226  public: bool SetVersionStr(const std::string &_version);
227 
228  // /// \brief returns a SHA 2 256 hash of the model
229  // /// \remarks fulfills versioning requirement
230  // public: std::array<std::uint8_t, 32> SHA_256() const;
231 
232  // /// \brief Sets the SHA 2 256 hash of the model
233  // /// \param[in] _hash a 256 bit SHA 2 hash
234  // /// \returns true if successful
235  // public: bool SHA_256(const std::array<std::uint8_t, 32> &_hash);
236 
241  public: std::string AsString(const std::string &_prefix = "") const;
242 
247  public: std::string AsPrettyString(const std::string &_prefix = "") const;
248 
251  };
252  }
253 }
254 
255 #ifdef _MSC_VER
256 #pragma warning(pop)
257 #endif
258 
259 #endif
Defines how to identify a model.
Definition: ModelIdentifier.hh:46
std::string AsPrettyString(const std::string &_prefix="") const
Returns all the available model information as a string using colors for better human parsing.
std::string Description() const
Returns the description of the model.
bool SetLicenseImageUrl(const std::string &_url)
Set the license image URL of the model.
bool Private() const
Returns the privacy setting of the model.
uint32_t LikeCount() const
Returns the number of "likes" for the model.
std::string Name() const
Returns just the last part of the model name.
bool SetName(const std::string &_name)
set the name of the model.
bool SetOwner(const std::string &_name)
Set the owner of the model.
bool SetVersionStr(const std::string &_version)
Set the model's version. Versions are integers counting from 1 or "tip" for the latest version.
std::string AsString(const std::string &_prefix="") const
Returns all the model information as a string. Convenient for debugging.
std::string UniqueName() const
Returns a unique name for the model.
ServerConfig & Server() const
Returns server information to retrieve model from.
bool SetLicenseUrl(const std::string &_url)
Set the license URL of the model.
bool SetTags(const std::vector< std::string > &_tags)
Set the list of tags of the model.
std::string LicenseImageUrl() const
Returns the license image URL.
bool SetDescription(const std::string &_desc)
Set the description of the model.
std::time_t ModifyDate() const
Returns the modify date of the model.
std::string VersionStr() const
Returns the model's version as a string. Versions are integers counting from 1. The strings "tip" or ...
unsigned int Version() const
Returns the model's version as a number. Versions are integers counting from 1. Version zero means th...
void SetPrivate(bool _private) const
Set the privacy setting of the model.
std::time_t UploadDate() const
Returns the upload date of the model.
std::string Owner() const
Returns owner to attribute model to.
bool SetUploadDate(const std::time_t &_date)
Set the upload date.
std::string LicenseName() const
Returns the license name.
bool SetLikeCount(const uint32_t _likes)
Set the number of "likes" of the model.
ModelIdentifier(const ModelIdentifier &_orig)
Copy Constructor.
bool SetModifyDate(const std::time_t &_date)
Set the modify date.
uint32_t DownloadCount() const
Returns the number of downloads for the model.
bool SetServer(const ServerConfig &_server)
Set the server from which this model comes.
bool SetFileSize(const unsigned int _filesize)
Set the file size of the model in bytes.
std::string LicenseUrl() const
Returns the license URL.
ModelIdentifier & operator=(const ModelIdentifier &_orig)
Assignment operator.
bool operator==(const ModelIdentifier &_rhs) const
Equality operator.
bool SetDownloadCount(const uint32_t _downloads)
Set the number of downloads of the model.
bool SetLicenseName(const std::string &_name)
Set the license name of the model.
bool SetVersion(const unsigned int _version)
Set the model's version. Versions are integers counting from 1.
std::vector< std::string > Tags() const
Returns the collection of tags.
unsigned int FileSize() const
Returns the file size of the model in bytes.
Describes options needed for a server.
Definition: ClientConfig.hh:48