X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fftacmp%2Fnic_def.h;h=08f6667742728d7ce4f46e6eff2b002c07e946e9;hb=f1754ecea2eab7bd0a302042ac82eb11667b166c;hp=9d7139cd9639b66dd7baacfc431bde47c42d7e72;hpb=07495effe193ca3f73c3bf0ce417068f9ac9dcdd;p=com%2Fgs-lite.git diff --git a/src/ftacmp/nic_def.h b/src/ftacmp/nic_def.h index 9d7139c..08f6667 100644 --- a/src/ftacmp/nic_def.h +++ b/src/ftacmp/nic_def.h @@ -1,84 +1,84 @@ -/* ------------------------------------------------ -Copyright 2014 AT&T Intellectual Property - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ------------------------------------------- */ -#ifndef _FTA_NIC_DEF_H_INCLUDED__ -#define _FTA_NIC_DEF_H_INCLUDED__ - -#include -#include -#include - -class nic_property{ -public: - std::vector opta; // option args - std::vector optv; // val of option args - std::vector typea; // legal types - std::vector opba; // legal binary ops - std::vector opua; // legal unary ops - std::vector fieldsa; // illegal fields - std::vector funca; // legal functions - - nic_property(){}; - - bool legal_type(std::string t); - bool legal_unary_op(std::string t); - bool legal_binary_op(std::string t); - bool illegal_field(std::string t); - bool option_exists(std::string t); - std::string option_value(std::string t); -}; - - -nic_property *load_nic_property(std::string dir, std::string name); - - -class nic_prop_db{ -public: - std::string dir; - std::map ndb; - - nic_prop_db(std::string d){dir=d;}; - - - nic_property *get_nic_property(std::string nics, int &err_no){ - if(ndb.count(nics)) - return ndb[nics]; - nic_property *ret = load_nic_property(dir, nics); - if(ret) - ndb[nics] = ret; - return ret; - }; - - - std::string get_nic_prop_val(std::string nics, std::string prop,int &err_no){ - nic_property *nicp = this->get_nic_property(nics, err_no); - if(!nicp){ - fprintf(stderr,"ERROR cannot load nic properties %s for nic type %s in get_nic_prop_val\n",nics.c_str(), prop.c_str()); - exit(1); - } - if(nicp->option_exists(prop)){ - return nicp->option_value("Return"); - }else{ - return ""; - } - - } -}; - - -void NicParser_setfileinput(FILE *f); - - - -#endif +/* ------------------------------------------------ +Copyright 2014 AT&T Intellectual Property + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ------------------------------------------- */ +#ifndef _FTA_NIC_DEF_H_INCLUDED__ +#define _FTA_NIC_DEF_H_INCLUDED__ + +#include +#include +#include + +class nic_property{ +public: + std::vector opta; // option args + std::vector optv; // val of option args + std::vector typea; // legal types + std::vector opba; // legal binary ops + std::vector opua; // legal unary ops + std::vector fieldsa; // illegal fields + std::vector funca; // legal functions + + nic_property(){}; + + bool legal_type(std::string t); + bool legal_unary_op(std::string t); + bool legal_binary_op(std::string t); + bool illegal_field(std::string t); + bool option_exists(std::string t); + std::string option_value(std::string t); +}; + + +nic_property *load_nic_property(std::string dir, std::string name); + + +class nic_prop_db{ +public: + std::string dir; + std::map ndb; + + nic_prop_db(std::string d){dir=d;}; + + + nic_property *get_nic_property(std::string nics, int &err_no){ + if(ndb.count(nics)) + return ndb[nics]; + nic_property *ret = load_nic_property(dir, nics); + if(ret) + ndb[nics] = ret; + return ret; + }; + + + std::string get_nic_prop_val(std::string nics, std::string prop,int &err_no){ + nic_property *nicp = this->get_nic_property(nics, err_no); + if(!nicp){ + fprintf(stderr,"ERROR cannot load nic properties %s for nic type %s in get_nic_prop_val\n",nics.c_str(), prop.c_str()); + exit(1); + } + if(nicp->option_exists(prop)){ + return nicp->option_value("Return"); + }else{ + return ""; + } + + } +}; + + +void NicParser_setfileinput(FILE *f); + + + +#endif