File:  [parser3project] / parser3 / src / doc / ClassExample2.dox
Revision 1.4.36.1: download - view: text, annotated - select for diffs - revision graph
Mon Mar 29 07:25:52 2004 UTC (22 years, 8 months ago) by paf
Branches: release_3_1_2
Diff to: branchpoint 1.4: preferred, unified
translated to english

/**	@page ClassExample2  Sample of creating simple class (with fields only)

To create the class of your own, which does not contain methods [like 'env', see VEnv],
one need to create a derivate from Value, where override Value::type,
and also Value::get_element and/or Value::put_element.

File pa_vexample2.h in types/ directory:
@code
#define EXAMPLE2_CLASS_NAME "example2"

/// env class
class VExample2 : public Value {
public: // Value
	
	const char *type() const { return "example2"; }

	/// VEnv: field
	Value *get_element(const String& aname) {
		// device information
		double temperature=25;
		return NEW VDouble(temperature);
	}

public: // usage

	VExample2(Pool& apool) : Value(apool) {
	}

};
@endcode

Register your class in Request::classes(), by adding it to Request constructor [in pa_request.C file]:

@code
	/// methodless
	// example2 class
	classes().put(*NEW String(pool(), EXAMPLE2_CLASS_NAME), &example2);
@endcode

User could then read temperature like:
@verbatim
$example2:test
@endverbatim

*/

E-mail: