Hurricane VLSI Database


List of all members | Public Member Functions
Hurricane::JsonObject Class Referenceabstract

Support for JSON export. More...

Inherited by Hurricane::Cell::SlavedsRelation::JsonProperty, Hurricane::Cell::SlavedsRelation::JsonPropertyRef, Hurricane::Cell::UniquifyRelation::JsonProperty, Hurricane::Cell::UniquifyRelation::JsonPropertyRef, Hurricane::JsonBaseArray< T >, Hurricane::JsonBox, Hurricane::JsonDBo, Hurricane::JsonDummy, Hurricane::JsonEntityRef, Hurricane::JsonKey, Hurricane::JsonOccurrence, Hurricane::JsonPlugRef, Hurricane::JsonPoint, Hurricane::JsonTransformation, and Hurricane::StandardPrivateProperty< Value, JsonState >::JsonProperty.

Public Member Functions

 JsonObject (unsigned long flags)
 
virtual bool isDummy () const
 
virtual std::string getTypeName () const =0
 
std::string getStackName () const
 
bool check (JsonStack &, std::string fname) const
 
bool has (const std::string &key) const
 
void add (const std::string &key, std::type_index tid)
 
void remove (const std::string &key)
 
template<typename T >
get (JsonStack &, const std::string &key) const
 
template<typename T >
T * jget (JsonStack &) const
 
void copyAttrs (const JsonObject *, bool reset=false)
 
void clear ()
 
std::string getName () const
 
void setName (const std::string &)
 
template<typename T >
getObject () const
 
template<typename T >
void setObject (T)
 
bool isBound () const
 
virtual JsonObjectclone (unsigned long flags) const =0
 
virtual void toData (JsonStack &)
 
unsigned int presetId (JsonStack &)
 
template<typename T >
void update (JsonStack &, T)
 
JsonObjectsetFlags (unsigned long mask)
 
JsonObjectresetFlags (unsigned long mask)
 
bool issetFlags (unsigned long mask) const
 

Detailed Description

Support for JSON export.

Constructor & Destructor Documentation

◆ JsonObject()

Hurricane::JsonObject::JsonObject ( unsigned long  flags)
Parameters
flagsFlags sets by derived classes.

Base object to be used by all JSON parsers. Provides helpers functions. Store three separated lists of requirements/attributes needes to build the object.

  • stackeds : thoses are not attributes of the current object, but other objects that are expected to be already in the stack. They are needed to build the current object. Their key must start with a '.' character.
  • attributes : the simple attributes of the object. Their key must start with a '_'.
  • collections : any container, collection or whatever set of other objects part of the current object. Their key must start with a '+' character.

For adding a requirement/attribute, see JsonObject::add().

Member Function Documentation

◆ isDummy()

bool Hurricane::JsonObject::isDummy ( ) const
virtual

Returns: true if the concrete object is of type JsonDummy, false otherwise.

◆ getTypeName()

string Hurricane::JsonObject::getTypeName ( ) const
pure virtual

Returns: The typename of the concrete object, that is, the value of the @typename key of the JSON object.

◆ getStackName()

std::string Hurricane::JsonObject::getStackName ( ) const
inline

Returns: The key with which the DataBase object will be pushed on the parser stack.

If the current object is associated to an attribute (that is, a key in JSON), then the name attribute of the JsonObject should have been set, and it will be returned here.

If the name attribute has not been set (for example, because we are in an array). Then the typename (JsonObject::getTypeName()), prefixed by a '.' character will be returned.

If the JsonObject is, for instance, a JsonBox (typename: "Box") :

  • If name is set to "_abutmentBox", the box will be stacked with that key.
  • If name is not set, then the key will be ".Box".

Referenced by update().

◆ check()

bool Hurricane::JsonObject::check ( JsonStack ,
std::string  fname 
) const
Parameters
stackWhere the objects already parsed are stored.
fnameThe function name on behalf of which the check is performed.
Returns
true if the check is successful.

Check that the stack actually contains all the objects (i.e. attributes) needed to build the current object. The list of attributes is built using the JsonObject::add() function. If an attribute is missing, a warning is issued, but the parser will try to continue.

◆ has()

bool Hurricane::JsonObject::has ( const std::string &  key) const
Parameters
keyThe key name to search for.
Returns
true if the object possess such a key.

◆ add()

void Hurricane::JsonObject::add ( const std::string &  key,
std::type_index  tid 
)
Parameters
keyThe requirement/attribute to add.
tidThe type index of the attribute.

Adds a new requirement or attribute to the object. The first character of the key tells which kind it is:

  • '.' : a requirement (not part of the object) that must be present in the stack.
  • '_' : a simple attribute of the object.
  • '+' : belongs to a collection or container.

A more detailed description could be found in JsonObject::JsonObject().

◆ remove()

void Hurricane::JsonObject::remove ( const std::string &  key)
Parameters
keyThe key of the requirement/attribute to remove.

Removes an attribute from the current object.

◆ get()

template<typename T >
T Hurricane::JsonObject::get ( JsonStack stack,
const std::string &  key 
) const
inline
Parameters
stackThe object stack of the parser.
keyThe key of the requested object.
Returns
The first object associated with key, starting from the top of the stack.

Retrieve requirements or attributes from the parser stack.

  • If no element with a corresponding key is found, an empty element of type T is returned (by calling the default T constructor).
  • If an element matching the key is found, but it's type do not match T, an exception from any_cast<> will be thrown.

References Hurricane::JsonStack::as(), and Hurricane::JsonStack::rhas().

◆ jget()

template<typename T >
T * Hurricane::JsonObject::jget ( JsonStack stack) const
inline
Parameters
stackThe parser stack. Returns: the first JsonObject that can be cast into type T*.

Search the JsonObject stack, from the top, the first object that can be cast into type T*. Base classes can be used here, as the dynamic_cast<> operator is used to perform the casts.

This function always return a pointer (never a value).

References Hurricane::JsonStack::jobjects().

◆ copyAttrs()

void Hurricane::JsonObject::copyAttrs ( const JsonObject other,
bool  reset = false 
)
inline
Parameters
otherThe object from which to copy attributes.
resetWhether to keep or erase the original attributes of the object.

Copy the attributes from other into the current object. Only the attributes are copied. Neither the requirements, nor the collections. By default, the attributes are added to the existing one of the object, but if reset is true, the original ones will be suppresseds.

◆ clear()

void Hurricane::JsonObject::clear ( )
inline

Removes all requirements/attributes/collections of the object. Also unbind it from any generated DataBase object.

◆ getName()

std::string Hurricane::JsonObject::getName ( ) const
inline

Returns: The name of the whole object as attribute.

During the parsing of the JSON structure, excepted when in an array, an object is associated with a key. This is the string returned by this function. It is called getName() instead of getKey() to avoid confusing with the attributes keys.

◆ setName()

void Hurricane::JsonObject::setName ( const std::string &  )
inline
Parameters
nameSet the key associated to this object.

See JsonObject::getName() for the meaning of the name (key).

◆ getObject()

template<typename T >
T Hurricane::JsonObject::getObject
inline

Returns: The associated DataBase object.

Once all the attributes have been gathered, the creation of the DataBase object is triggered by calling JsonObject::toData(). We keep track of that DataBase object by storing it (or a pointer to it) in an boost::any field of the JsonObject.

◆ setObject()

template<typename T >
void Hurricane::JsonObject::setObject ( t)
inline
Parameters
TThe DataBase object.

Associate the constructed DataBase object T to the JSON object (for later access).

◆ isBound()

bool Hurricane::JsonObject::isBound ( ) const
inline

Returns: true if a DataBase object is associated to the JSON object (see JsonObject::setObject()).

◆ clone()

JsonObject * Hurricane::JsonObject::clone ( unsigned long  flags) const
pure virtual

Returns: a new empty object of the same dynamic type as the source one.

This is not a true clone operation in the sense that the datas of the original object are not copied. The cloning is about the type, and is the result of a call to the new operator.

\Important This method must be overloaded in each concrete derived class.

◆ toData()

void Hurricane::JsonObject::toData ( JsonStack stack)
virtual
Parameters
Theparser object stack.

\Important This method must be overloaded in each concrete derived class.

Creates the DataBase object. The requirements and attributes must be on top of the stack, they are popped, the DataBase object is created from them and the result is then pushed back.

◆ presetId()

unsigned int Hurricane::JsonObject::presetId ( JsonStack stack)
Parameters
stackThe parser object stack. Returns: the next id that has been set.

\Remark This is a helper for JsonStack::toData().

In blob mode, the DataBase must be restored as is, including the ids of all the Entities (see Entity). This function read from the stack the _id attribute and sets it so that the next Entity created will use it.

◆ update()

template<typename T >
void Hurricane::JsonObject::update ( JsonStack stack,
hobject 
)
inline
Parameters
stackparser object stack.
hobjectthe newly created DataBase object.

\Remark This is a helper for JsonStack::toData().

Pop the attributes from the stack. Push the newly created object and bind it to the JsonObject.

References getStackName(), Hurricane::JsonStack::pop_back(), and Hurricane::JsonStack::push_back().

◆ setFlags()

JsonObject * Hurricane::JsonObject::setFlags ( unsigned long  mask)
inline
Parameters
maskFlag(s) to be raised.
Returns
The current object.

◆ resetFlags()

JsonObject * Hurricane::JsonObject::resetFlags ( unsigned long  mask)
inline
Parameters
maskFlag(s) to be lowered.
Returns
The current object.

◆ issetFlags()

bool Hurricane::JsonObject::issetFlags ( unsigned long  mask) const
inline
Parameters
maskThe combination of flags to be checked.
Returns
true if all the flags given in mask are sets.

The documentation for this class was generated from the following files:


Generated by doxygen 1.9.1 on Thu Aug 11 2022 Return to top of page
Hurricane VLSI Database Copyright © 2000-2020 Bull S.A. All rights reserved