cppDataPipeline 0.3.0
C++ Implementation of the FAIR Data Pipeline API
Loading...
Searching...
No Matches
api_object.hxx
1#ifndef __FDP_APIOBJECT_HXX__
2#define __FDP_APIOBJECT_HXX__
3
4#include <string>
5#include <cstddef>
6#include <json/value.h>
7
8#include "fdp/utilities/logging.hxx"
9
10namespace FairDataPipeline {
15 class ApiObject {
16 private:
17 Json::Value obj_;
18
19 protected:
20 ApiObject();
21
22 public:
23
24 typedef std::shared_ptr< ApiObject > sptr;
25
26 static sptr from_json( const Json::Value& j );
27
28 //static copy( const ApiObject& src );
29
36 static ApiObject::sptr construct( void );
37
38
39 int add( const std::string& key, int value );
40 int add( const std::string& key, float value );
41 int add( const std::string& key, double value );
42 int add( const std::string& key, const std::string& value );
43 int add( const std::string& key, const ApiObject& value );
44
45 int remove( const std::string& key );
52 int get_id() const ;
59 static int get_id_from_string(std::string url);
60
61 std::string get_type() const ;
67 std::string get_uri() const;
68
75 std::string get_value_as_string( const std::string& key) const;
76
83 int get_value_as_int( const std::string& key) const;
84
90 std::string get_first_component() const;
91
98 bool is_empty();
99 };
100
101}
102#endif
Class for API objects.
Definition: api_object.hxx:15
static ApiObject::sptr construct(void)
Construct a new Api Object object.
Definition: api_object.cxx:17
int get_value_as_int(const std::string &key) const
Get the value of a given key as int object.
Definition: api_object.cxx:96
std::string get_value_as_string(const std::string &key) const
Get the value of a given key as string object.
Definition: api_object.cxx:93
int get_id() const
Get the object id from the uri.
Definition: api_object.cxx:65
std::string get_uri() const
Get the object uri.
Definition: api_object.cxx:89
bool is_empty()
Check to see if the object is empty.
Definition: api_object.cxx:100
std::string get_first_component() const
Get the first component of the object.
Definition: api_object.cxx:107
static int get_id_from_string(std::string url)
Get the object type from the uri.
Definition: api_object.cxx:69
std::string get_type() const
Returns the object type from the object uri_ (table)
Definition: api_object.cxx:81