VAObject.h 2.48 KB
Newer Older
Jonas Stienen's avatar
Jonas Stienen committed
1
/*
2
 *  --------------------------------------------------------------------------------------------
Jonas Stienen's avatar
Jonas Stienen committed
3
 *
4 5 6
 *    VVV        VVV A           Virtual Acoustics (VA) | http://www.virtualacoustics.org
 *     VVV      VVV AAA          Licensed under the Apache License, Version 2.0
 *      VVV    VVV   AAA
7
 *       VVV  VVV     AAA        Copyright 2015-2019
8 9
 *        VVVVVV       AAA       Institute of Technical Acoustics (ITA)
 *         VVVV         AAA      RWTH Aachen University
Jonas Stienen's avatar
Jonas Stienen committed
10
 *
11
 *  --------------------------------------------------------------------------------------------
Jonas Stienen's avatar
Jonas Stienen committed
12
 */
13

14 15
#ifndef IW_VABASE_OBJECT
#define IW_VABASE_OBJECT
Jonas Stienen's avatar
Jonas Stienen committed
16 17

#include <VABaseDefinitions.h>
18
#include <VABase.h>
Jonas Stienen's avatar
Jonas Stienen committed
19 20 21 22
#include <VAStruct.h>

//! Base class for objects with identity and message interface
/**
23 24 25 26 27
  * In VA, anything can be an object and can be called via the module call interface during runtime.
  * These calls are usually not thread-safe.
  */
class VABASE_API CVAObject
{
Jonas Stienen's avatar
Jonas Stienen committed
28 29 30 31
public:
	//! Default constructor
	CVAObject();

32 33 34 35
	//! Initialization constructor
	/**
	  * @param[in] pszName Character type name initialization
	  */
36
	CVAObject( const char* pszName );
37 38 39 40 41
	
	//! Initialization constructor
	/**
	  * @param[in] sName String type name initialization
	  */
42
	CVAObject( const std::string& sName );
Jonas Stienen's avatar
Jonas Stienen committed
43 44 45 46 47

	//! Destructor
	virtual ~CVAObject();

	//! Returns the ID of the object
48 49 50
	/**
	  * @return Object identifier integer
	  */
Jonas Stienen's avatar
Jonas Stienen committed
51 52 53
	int GetObjectID() const;

	//! Returns the name of the object
54 55 56
	/**
	  * @return Object name
	  */
Jonas Stienen's avatar
Jonas Stienen committed
57 58 59
	std::string GetObjectName() const;

	//! Returns information on the object
60 61 62
	/**
	  * @return Object info
	  */
Jonas Stienen's avatar
Jonas Stienen committed
63 64 65 66
	virtual CVAObjectInfo GetObjectInfo() const;

	//! Call the object with a message and capture return message
	/**
67 68
	  * @param[in] oArgs Object call arguments as CVAStruct
	  * @return Object call return value as CVAStruct
69 70
	  */
	virtual CVAStruct CallObject( const CVAStruct& oArgs ) = 0;
Jonas Stienen's avatar
Jonas Stienen committed
71 72 73

protected:
	// Important: An object may not change its name after it is registered
74 75 76 77
	/**
	  * @param[in] sName Name of new object
	  * @note This may only be called from an object registry
	  */
78
	void SetObjectName( const std::string& sName );
Jonas Stienen's avatar
Jonas Stienen committed
79 80

private:
81 82
	int m_iObjectID; //!< Object identifier
	std::string m_sObjectName; //!< Object name (should not be changed during runtime)
Jonas Stienen's avatar
Jonas Stienen committed
83

84 85 86 87 88 89
	//! Object identifier (integer) setter 
	/**
	  * @param[in] iID Object identifier number
	  * @note This may only be called from an object registry
	  */
 	void SetObjectID( const int iID );
Jonas Stienen's avatar
Jonas Stienen committed
90 91 92 93

	friend class CVAObjectRegistry;
};

94
#endif // IW_VABASE_OBJECT