2021-05-27 10:59:22 -04:00
|
|
|
/*
|
|
|
|
component.h
|
|
|
|
|
|
|
|
Copyright (c) 2021 Kevin Matz (kevin.matz@gmail.com)
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
SOFTWARE.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2022-11-28 14:18:21 -05:00
|
|
|
#include "uuid.h"
|
2021-06-19 20:27:11 -04:00
|
|
|
#include <string>
|
2021-05-27 10:59:22 -04:00
|
|
|
|
2022-11-15 11:32:29 -05:00
|
|
|
/**
|
|
|
|
* @brief @cite ACN Architecture for Control Networks
|
|
|
|
*/
|
2021-05-27 10:59:22 -04:00
|
|
|
namespace ACN {
|
|
|
|
|
2021-07-30 09:11:32 -04:00
|
|
|
/**
|
2022-11-15 11:32:29 -05:00
|
|
|
* @brief The process, program or application corresponding to a single ACN endpoint.
|
|
|
|
*
|
2021-07-30 09:26:21 -04:00
|
|
|
* All messages in ACN are sent and received by a component.
|
2022-11-15 11:32:29 -05:00
|
|
|
* See @cite ACN [Arch] for a more complete definition.
|
2021-07-30 09:26:21 -04:00
|
|
|
*
|
2022-11-15 11:32:29 -05:00
|
|
|
* @cite epi19 **EPI 19: ACN Discovery on IP Networks**
|
|
|
|
*
|
|
|
|
* (3) Component Name Strings
|
|
|
|
* Each component shall maintain two text identifier strings intended to
|
|
|
|
* indicate the function of the component in human readable terms for
|
|
|
|
* browsing purposes.
|
2021-07-30 09:11:32 -04:00
|
|
|
*/
|
2021-05-27 10:59:22 -04:00
|
|
|
class Component {
|
|
|
|
public:
|
2021-08-25 17:20:33 -04:00
|
|
|
/**
|
|
|
|
* @brief Component
|
2022-11-19 15:43:02 -05:00
|
|
|
* @param cid
|
|
|
|
* @param fctn
|
2021-08-25 17:20:33 -04:00
|
|
|
*/
|
2022-12-10 11:07:13 -05:00
|
|
|
explicit Component(UUID::uuid cid = UUID::uuid(), std::string fctn = "OpenLCP ACN Component")
|
2022-11-19 15:43:02 -05:00
|
|
|
: cid_(cid)
|
|
|
|
, fctn_(fctn)
|
2021-08-02 10:10:55 -04:00
|
|
|
, uacn_(std::string())
|
2021-06-19 20:27:11 -04:00
|
|
|
{};
|
2021-05-27 10:59:22 -04:00
|
|
|
|
2021-08-25 17:20:33 -04:00
|
|
|
/**
|
2022-11-15 11:32:29 -05:00
|
|
|
* @brief Component Identifier
|
|
|
|
* @return the CID
|
|
|
|
*
|
|
|
|
* @cite ACN 1.2.3: In ACN each distinct endpoint transmitting and receiving ACN data is called a
|
|
|
|
* Component and all ACN communications take place between components. Each ACN component has a
|
|
|
|
* component identifier or CID which is unique not just within the system but across the whole
|
|
|
|
* world and does not change with time.
|
2021-08-25 17:20:33 -04:00
|
|
|
*/
|
2022-12-04 12:06:16 -05:00
|
|
|
const UUID::uuid cid() const { return cid_; }
|
2022-11-15 11:32:29 -05:00
|
|
|
|
2021-08-25 17:20:33 -04:00
|
|
|
/**
|
2022-11-15 11:32:29 -05:00
|
|
|
* @brief @cite epi19 3.1 Fixed Component Type Name (FCTN)
|
|
|
|
* @return the FCTN
|
|
|
|
*
|
|
|
|
* Shall be a UTF-8 string that is assigned during manufacture.
|
2021-08-25 17:20:33 -04:00
|
|
|
*/
|
2021-06-19 20:27:11 -04:00
|
|
|
const std::string fixedName() const { return fctn_; }
|
2021-08-25 17:20:33 -04:00
|
|
|
/**
|
2022-11-15 11:32:29 -05:00
|
|
|
* @brief @cite epi19 3.2 User Assigned Component Name (UACN)
|
|
|
|
* @return the UACN
|
|
|
|
*
|
|
|
|
* Shall be a UTF-8 string that may be assigned by the user.
|
2021-08-25 17:20:33 -04:00
|
|
|
*/
|
2022-12-04 12:06:16 -05:00
|
|
|
const std::string userName() const { return uacn_; }
|
2021-08-25 17:20:33 -04:00
|
|
|
/**
|
2022-11-15 11:32:29 -05:00
|
|
|
* @brief Component Name, either User Asigned or Fixed.
|
|
|
|
* @return a name
|
2021-08-25 17:20:33 -04:00
|
|
|
*/
|
2022-12-04 12:06:16 -05:00
|
|
|
const std::string name() const { return uacn_.empty() ? fctn_ : uacn_; }
|
2021-08-25 17:20:33 -04:00
|
|
|
/**
|
2022-11-15 11:32:29 -05:00
|
|
|
* @brief Set the User Asigned Component Name (UACN).
|
|
|
|
* @param s UACN Name string
|
|
|
|
*
|
|
|
|
* If not an empty string, will be prefered over the FCTN.
|
2021-08-25 17:20:33 -04:00
|
|
|
*/
|
2022-11-24 11:35:25 -05:00
|
|
|
virtual void assignUserName(const std::string s) { uacn_ = s; }
|
2021-05-27 10:59:22 -04:00
|
|
|
|
2021-07-30 09:31:16 -04:00
|
|
|
private:
|
|
|
|
const UUID::uuid cid_;
|
2022-11-19 15:43:02 -05:00
|
|
|
const std::string fctn_; //!< Fixed Component Type Name (FCTN)
|
|
|
|
std::string uacn_; //!< User Assigned Component Name (UACN)
|
2021-05-27 10:59:22 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
}; // ACN
|